@xopcai/xopc 0.0.329 → 0.0.330

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 (257) 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/{agent-avatar-dicebear-Bs1qnnhD.js → agent-avatar-dicebear-BDG0hI-J.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-ArM6Sm9S.js +1 -0
  5. package/dist/gateway/static/root/assets/agent-plugin-dialog-BX_Bhre1.js +1 -0
  6. package/dist/gateway/static/root/assets/agents-BiQqpMw0.js +70 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-BrIji9B5.js → app-management-settings-panel-DgttzUCG.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-Uts-MQ7K.js → appearance-settings-CHpyWV8Z.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-BhfYQcm8.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-_EzRfBuI.js → archive-plugin-B7Q7Oeo7.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CHg7_XFl.js → attachment-load-BYwqQ8qN.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-CGMErk_w.js → automations-page-CsvAtTNd.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-DMH_1Ped.js +7 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-D3WB-tVn.js → binary-plugins-DdgWCI-M.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-Cm1W-14I.js → block-editor-DyOagNnn.js} +53 -53
  16. package/dist/gateway/static/root/assets/{browser-automation-inputs-VnvK-GQP.js → browser-automation-inputs-CwF8OQFN.js} +1 -1
  17. package/dist/gateway/static/root/assets/browser-automations-page-D_EQjiiu.js +3 -0
  18. package/dist/gateway/static/root/assets/browser-settings-page-BE6691Jz.js +3 -0
  19. package/dist/gateway/static/root/assets/capabilities-page-MweWNrC1.js +2 -0
  20. package/dist/gateway/static/root/assets/capabilities-settings-panel-CdSWkh89.js +8 -0
  21. package/dist/gateway/static/root/assets/{capability-header-actions-C3chJDQu.js → capability-header-actions-C5F2GNE9.js} +1 -1
  22. package/dist/gateway/static/root/assets/channels-NGfwR3He.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-ClbmjCL2.js → chat-terminal-dock-C6tl9Rfw.js} +2 -2
  24. package/dist/gateway/static/root/assets/{computer-settings-page-BfZaf516.js → computer-settings-page-C0MsVw4l.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-F-fYNIx8.js → connector-service-page-DsF60pPs.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-BE8NdQcR.js +2 -0
  27. package/dist/gateway/static/root/assets/date-picker-CELKKqYN.js +1 -0
  28. package/dist/gateway/static/root/assets/{dependency-picker-B_z3zihW.js → dependency-picker-BcEwCnI5.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-C1TZzKS3.js → desktop-pet-Ww7Gm8-x.js} +1 -1
  30. package/dist/gateway/static/root/assets/desktop-pet-settings-D-dbAxGu.js +1 -0
  31. package/dist/gateway/static/root/assets/device-pairing-wizard-DsYY6szg.js +1 -0
  32. package/dist/gateway/static/root/assets/{directory-picker-path-field-BfxaNwMB.js → directory-picker-path-field-CVmuCRyO.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-debug-page-Bs8_FYCm.js → extension-debug-page-UUHNJj-d.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-DH5vFbBw.js → extension-page-BvL452mX.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-hGKovxxC.js → extension-settings-page-CrNnUSOs.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-BYMrbKZE.js → gateway-config-swr-DMm1vU51.js} +1 -1
  37. package/dist/gateway/static/root/assets/gateway-settings-DrHhtZqv.js +1 -0
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-DMqYXHAn.js → gateway-startup-retry-Ck6tj6yE.js} +1 -1
  39. package/dist/gateway/static/root/assets/home-page-YgI6jfGA.js +1 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-D1sQGaJz.js → image-generation-api-BOh6j0BF.js} +1 -1
  41. package/dist/gateway/static/root/assets/imports-page-BuqdzA7h.js +1 -0
  42. package/dist/gateway/static/root/assets/index-DJmO2VAY.css +1 -0
  43. package/dist/gateway/static/root/assets/index-vCIBfJp7.js +121 -0
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CMitbles.js → keyboard-shortcuts-settings-D9L7IdUg.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-DO8uUtos.js +1 -0
  46. package/dist/gateway/static/root/assets/local-apps-page-BEvyufm7.js +1 -0
  47. package/dist/gateway/static/root/assets/locale-store-DAOwT3Zp.js +1 -0
  48. package/dist/gateway/static/root/assets/logs-page-Jev1m9sS.js +2 -0
  49. package/dist/gateway/static/root/assets/management-settings-41i7B1RO.js +1 -0
  50. package/dist/gateway/static/root/assets/{markdown-view-DXubGEic.js → markdown-view-nL4xzvI8.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-DLJrmU9J.js → media-plugins-dHbcqMan.js} +1 -1
  52. package/dist/gateway/static/root/assets/{messages-D0G_sZvA.js → messages-BZbt9x1y.js} +3 -3
  53. package/dist/gateway/static/root/assets/note-detail-panel-DonP0E6Q.js +5 -0
  54. package/dist/gateway/static/root/assets/notes-page-CYHMeVKo.js +8 -0
  55. package/dist/gateway/static/root/assets/{page-context-capture-button-C3JiQEKD.js → page-context-capture-button-BKsMcPOy.js} +1 -1
  56. package/dist/gateway/static/root/assets/{preview-open-alternatives-buk_gdip.js → preview-open-alternatives-Du18QgWc.js} +1 -1
  57. package/dist/gateway/static/root/assets/{product-open-page-DwEEO0Ak.js → product-open-page-IY1QL6s0.js} +1 -1
  58. package/dist/gateway/static/root/assets/project-detail-page-Bpw9mxfV.js +1 -0
  59. package/dist/gateway/static/root/assets/projects-page-BdYbDNUn.js +1 -0
  60. package/dist/gateway/static/root/assets/{registry-api-tx8XCHOs.js → registry-api-DCFXWBOt.js} +1 -1
  61. package/dist/gateway/static/root/assets/remote-access-hub-CLhbz3TF.js +1 -0
  62. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-De7HmmBu.js → runtime-tools-settings-panel-CuTFmXyj.js} +2 -2
  63. package/dist/gateway/static/root/assets/scenes-page-XwK2IEmr.js +2 -0
  64. package/dist/gateway/static/root/assets/{schema-form-DPMEuj5D.js → schema-form-qWQii8IU.js} +1 -1
  65. package/dist/gateway/static/root/assets/sessions-page-4-QoiDES.js +1 -0
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-BggQVM1y.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-DM0D-BQ_.js → settings-form-section-B0ZBr0L9.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-page-CWS9yOH3.js → settings-page-DpII4NO3.js} +1 -1
  69. package/dist/gateway/static/root/assets/setup-status-panel-HPpC7EE0.js +1 -0
  70. package/dist/gateway/static/root/assets/{share-preview-page-CcRi2yGy.js → share-preview-page-B2CGYZHc.js} +1 -1
  71. package/dist/gateway/static/root/assets/shares-settings-DhVCRYGP.js +1 -0
  72. package/dist/gateway/static/root/assets/skill-api-_ddww47C.js +1 -0
  73. package/dist/gateway/static/root/assets/skill-reload-api-XPZkWJJe.js +1 -0
  74. package/dist/gateway/static/root/assets/skills-page-uF7DkJMC.js +2 -0
  75. package/dist/gateway/static/root/assets/system-settings-panel-25ABVt7H.js +1 -0
  76. package/dist/gateway/static/root/assets/task-detail-page-gepxhO4j.js +1 -0
  77. package/dist/gateway/static/root/assets/tunnel-api-CwQGBI_4.js +1 -0
  78. package/dist/gateway/static/root/assets/{use-autosave-ZTHe1zCM.js → use-autosave-CL3wytbs.js} +1 -1
  79. package/dist/gateway/static/root/assets/user-model-page-DldQW9Wh.js +2 -0
  80. package/dist/gateway/static/root/assets/{voice-api-key-field-C8Kpkct-.js → voice-api-key-field-zjAzQrx4.js} +1 -1
  81. package/dist/gateway/static/root/assets/{voice-config-api-BvzxINUk.js → voice-config-api-DvzQ-128.js} +1 -1
  82. package/dist/gateway/static/root/assets/{work-discovery-overlay-ClB6T-dm.js → work-discovery-overlay-MaPPjWwl.js} +1 -1
  83. package/dist/gateway/static/root/assets/workflow-run-setup-panel-C3dQN1fE.js +3 -0
  84. package/dist/gateway/static/root/assets/workflows-page-B9lnTU3U.js +6 -0
  85. package/dist/gateway/static/root/index.html +8 -14
  86. package/dist/package.js +1 -1
  87. package/dist/src/agent/agent-manager.d.ts +1 -0
  88. package/dist/src/agent/agent-manager.js +19 -4
  89. package/dist/src/agent/background-review/run-background-review.js +1 -1
  90. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  91. package/dist/src/agent/capabilities/definitions.d.ts +3 -2
  92. package/dist/src/agent/capabilities/definitions.js +3 -2
  93. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  94. package/dist/src/agent/image/tool-model-config.js +1 -1
  95. package/dist/src/agent/orchestration/llm-turn-retry.js +2 -15
  96. package/dist/src/agent/service.d.ts +1 -0
  97. package/dist/src/agent/service.js +5 -2
  98. package/dist/src/agent/tasks/task-judge-service.js +1 -1
  99. package/dist/src/agent/tools/factory.js +3 -2
  100. package/dist/src/agent/tools/index.d.ts +1 -0
  101. package/dist/src/agent/tools/index.js +2 -1
  102. package/dist/src/agent/tools/workflow-manage-tool.d.ts +2 -0
  103. package/dist/src/agent/tools/workflow-manage-tool.js +225 -0
  104. package/dist/src/agent/tools/xopc-use-tool.js +1 -1
  105. package/dist/src/agent-catalog/capabilities.js +2 -2
  106. package/dist/src/auth/credentials.js +1 -1
  107. package/dist/src/auth/oauth-provider-lock.js +1 -1
  108. package/dist/src/auth/sync-provider-auth.js +1 -1
  109. package/dist/src/automations/capabilities/drafts.js +1 -1
  110. package/dist/src/automations/draft/automation-draft-service.js +13 -4
  111. package/dist/src/bootstrap/application-state.js +1 -1
  112. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  113. package/dist/src/capabilities/runtime/product.js +1 -1
  114. package/dist/src/chat-commands/agent-edit.js +1 -1
  115. package/dist/src/chat-commands/builtins/config.js +1 -1
  116. package/dist/src/chat-previews/service.js +1 -2
  117. package/dist/src/cli/commands/agent.js +1 -1
  118. package/dist/src/cli/commands/agents.js +1 -1
  119. package/dist/src/cli/commands/models.js +1 -1
  120. package/dist/src/cli/commands/onboard/model.js +2 -2
  121. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  122. package/dist/src/config/index.js +4 -4
  123. package/dist/src/config/loader.js +2 -2
  124. package/dist/src/config/models-json.js +1 -1
  125. package/dist/src/config/schema.js +1 -1
  126. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  127. package/dist/src/extensions/bundled-extension-activation.d.ts +3 -1
  128. package/dist/src/extensions/bundled-extension-activation.js +5 -8
  129. package/dist/src/gateway/agents-admin.js +2 -2
  130. package/dist/src/gateway/file-path-classifier.js +1 -1
  131. package/dist/src/gateway/gateway-workflow-host.types.d.ts +1 -0
  132. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  133. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +27 -5
  134. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  135. package/dist/src/gateway/hono/routes/notes.js +2 -2
  136. package/dist/src/gateway/hono/routes/projects.js +2 -2
  137. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  138. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  139. package/dist/src/gateway/hono/routes/workflows.js +1 -23
  140. package/dist/src/gateway/image-generation-setup.js +2 -2
  141. package/dist/src/gateway/lock.js +1 -1
  142. package/dist/src/gateway/service/config-coordinator.d.ts +4 -4
  143. package/dist/src/gateway/service/config-coordinator.js +6 -6
  144. package/dist/src/gateway/service/marketplace-service.js +8 -6
  145. package/dist/src/gateway/service.d.ts +1 -1
  146. package/dist/src/gateway/service.js +14 -14
  147. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  148. package/dist/src/home-intelligence/generator.js +7 -6
  149. package/dist/src/home-intelligence/host.js +1 -1
  150. package/dist/src/local-apps/service.js +1 -1
  151. package/dist/src/providers/model-catalog-persistence.js +1 -1
  152. package/dist/src/providers/model-response.d.ts +2 -0
  153. package/dist/src/providers/model-response.js +24 -1
  154. package/dist/src/tasks/capabilities/read.js +2 -2
  155. package/dist/src/tui/backends/embedded-backend.js +6 -3
  156. package/dist/src/tui/tui-commands.js +2 -2
  157. package/dist/src/tui/tui-startup-resources.js +1 -1
  158. package/dist/src/tui/tui.js +3 -3
  159. package/dist/src/voice/platform-streams.js +15 -7
  160. package/dist/src/voice/realtime/agentEngine.js +19 -3
  161. package/dist/src/voice/realtime/pcmFrameBuffer.js +2 -1
  162. package/dist/src/voice/realtime/persona-context.js +1 -1
  163. package/dist/src/voice/realtime/playback-echo.js +16 -1
  164. package/dist/src/workflows/authoring/index.d.ts +1 -0
  165. package/dist/src/workflows/authoring/index.js +2 -1
  166. package/dist/src/workflows/authoring/workflow-draft-defaults.d.ts +3 -0
  167. package/dist/src/workflows/authoring/workflow-draft-defaults.js +63 -0
  168. package/dist/src/workflows/domain/index.js +1 -1
  169. package/dist/src/workflows/engine/workflow-engine.js +1 -1
  170. package/dist/src/workflows/index.js +2 -2
  171. package/dist/src/workflows/service/workflow-run-service.d.ts +1 -1
  172. package/dist/src/workflows/service/workflow-run-service.js +34 -11
  173. package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
  174. package/package.json +4 -4
  175. package/skills/engineering/workflow-authoring/SKILL.md +32 -0
  176. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHJyAT7t.js +0 -1
  177. package/dist/gateway/static/root/assets/agent-plugin-dialog-DLKj_iIh.js +0 -1
  178. package/dist/gateway/static/root/assets/agents-SXZ5O0g4.js +0 -70
  179. package/dist/gateway/static/root/assets/apps-page-DcclVdxW.js +0 -1
  180. package/dist/gateway/static/root/assets/automations-workspace-Cc4yqiF6.js +0 -7
  181. package/dist/gateway/static/root/assets/box-DvYoGszj.js +0 -1
  182. package/dist/gateway/static/root/assets/braces-Cfmtagno.js +0 -1
  183. package/dist/gateway/static/root/assets/browser-automations-page-CZYCvSSU.js +0 -3
  184. package/dist/gateway/static/root/assets/browser-settings-page-DDz9PE6m.js +0 -3
  185. package/dist/gateway/static/root/assets/calendar-clock-D-quYVPe.js +0 -1
  186. package/dist/gateway/static/root/assets/capabilities-page-DH3aDk53.js +0 -2
  187. package/dist/gateway/static/root/assets/capabilities-settings-panel-C8jMZAJl.js +0 -8
  188. package/dist/gateway/static/root/assets/capability-discover-page-CgGvsf3t.js +0 -1
  189. package/dist/gateway/static/root/assets/channels-CuVS_KsY.js +0 -1
  190. package/dist/gateway/static/root/assets/chevron-left-DqFhpbvK.js +0 -1
  191. package/dist/gateway/static/root/assets/clock-3-DnrAnuyZ.js +0 -1
  192. package/dist/gateway/static/root/assets/connectors-page-B4SLpvSL.js +0 -2
  193. package/dist/gateway/static/root/assets/date-picker-DXQTsUJn.js +0 -1
  194. package/dist/gateway/static/root/assets/desktop-pet-settings-B5JGIfqn.js +0 -1
  195. package/dist/gateway/static/root/assets/device-pairing-wizard-DFYK_Ywf.js +0 -1
  196. package/dist/gateway/static/root/assets/extension-marketplace-api-DqV4YRYs.js +0 -1
  197. package/dist/gateway/static/root/assets/gateway-settings-BIsiP-JI.js +0 -1
  198. package/dist/gateway/static/root/assets/gauge-C78eD2BA.js +0 -1
  199. package/dist/gateway/static/root/assets/git-branch-Dh9uxTot.js +0 -1
  200. package/dist/gateway/static/root/assets/home-page-CoBivEvx.js +0 -1
  201. package/dist/gateway/static/root/assets/image-Cwyalflz.js +0 -1
  202. package/dist/gateway/static/root/assets/imports-page-rssb4rjP.js +0 -1
  203. package/dist/gateway/static/root/assets/inbox-DNoSz682.js +0 -1
  204. package/dist/gateway/static/root/assets/index-C4QN4gCi.css +0 -1
  205. package/dist/gateway/static/root/assets/index-Cr4SINLG.js +0 -121
  206. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
  207. package/dist/gateway/static/root/assets/layout-grid-CEVZdVFU.js +0 -1
  208. package/dist/gateway/static/root/assets/list-BBGUdmkF.js +0 -1
  209. package/dist/gateway/static/root/assets/local-app-workbench-page-Di82Oacm.js +0 -1
  210. package/dist/gateway/static/root/assets/local-apps-page-CCvA9d9L.js +0 -1
  211. package/dist/gateway/static/root/assets/locale-store-BSkKhYkc.js +0 -1
  212. package/dist/gateway/static/root/assets/lock-keyhole-DEK5kH0u.js +0 -1
  213. package/dist/gateway/static/root/assets/logs-page-BK8ol1q0.js +0 -2
  214. package/dist/gateway/static/root/assets/management-settings-CebXkEtB.js +0 -1
  215. package/dist/gateway/static/root/assets/message-circle-Badhj-4D.js +0 -1
  216. package/dist/gateway/static/root/assets/message-square-fVE7Ghj1.js +0 -1
  217. package/dist/gateway/static/root/assets/models-hub-cache-B0EUPwTv.js +0 -1
  218. package/dist/gateway/static/root/assets/network-BUQLY1BV.js +0 -1
  219. package/dist/gateway/static/root/assets/note-detail-panel-xsKDIJdK.js +0 -5
  220. package/dist/gateway/static/root/assets/notes-page-BFm7XnWH.js +0 -8
  221. package/dist/gateway/static/root/assets/paperclip-f1HujQY1.js +0 -1
  222. package/dist/gateway/static/root/assets/power-ZI-pBczI.js +0 -1
  223. package/dist/gateway/static/root/assets/project-detail-page-CRQGCRSU.js +0 -1
  224. package/dist/gateway/static/root/assets/projects-page-DcqylysA.js +0 -1
  225. package/dist/gateway/static/root/assets/remote-access-hub-Cq5MaiRW.js +0 -1
  226. package/dist/gateway/static/root/assets/scenes-page-GXJ-b3dO.js +0 -2
  227. package/dist/gateway/static/root/assets/server-BlHCBjiE.js +0 -1
  228. package/dist/gateway/static/root/assets/sessions-page-C6FwYIRA.js +0 -1
  229. package/dist/gateway/static/root/assets/settings-advanced-gate-BEyQiZs0.js +0 -1
  230. package/dist/gateway/static/root/assets/setup-status-panel-BhGKiTPf.js +0 -1
  231. package/dist/gateway/static/root/assets/shares-settings-DNmcCBfX.js +0 -1
  232. package/dist/gateway/static/root/assets/skill-api-BCAV_F1P.js +0 -1
  233. package/dist/gateway/static/root/assets/skill-card-icon-BrrpZ3Mw.js +0 -1
  234. package/dist/gateway/static/root/assets/skill-reload-api-BEV2WXGk.js +0 -1
  235. package/dist/gateway/static/root/assets/skills-page-C8zOGpKw.js +0 -2
  236. package/dist/gateway/static/root/assets/star-BUWJqJ5c.js +0 -1
  237. package/dist/gateway/static/root/assets/stethoscope-DRqTAtjD.js +0 -1
  238. package/dist/gateway/static/root/assets/store-SzD1Jvgm.js +0 -1
  239. package/dist/gateway/static/root/assets/system-settings-panel-C_lajq9u.js +0 -1
  240. package/dist/gateway/static/root/assets/task-detail-page-Dk8Bmlhw.js +0 -1
  241. package/dist/gateway/static/root/assets/tunnel-api-CYvKiE_f.js +0 -1
  242. package/dist/gateway/static/root/assets/upload-rrb46c3c.js +0 -1
  243. package/dist/gateway/static/root/assets/user-model-page-C_SPNZbP.js +0 -2
  244. package/dist/gateway/static/root/assets/user-round-C9jxPhMR.js +0 -1
  245. package/dist/gateway/static/root/assets/wand-sparkles-DWuJz5ya.js +0 -1
  246. package/dist/gateway/static/root/assets/workflow-run-setup-panel-X0Cyh2AR.js +0 -3
  247. package/dist/gateway/static/root/assets/workflows-page-BrL6dzf0.js +0 -6
  248. package/dist/src/workflows/draft/index.d.ts +0 -3
  249. package/dist/src/workflows/draft/index.js +0 -3
  250. package/dist/src/workflows/draft/workflow-draft-prompt.d.ts +0 -22
  251. package/dist/src/workflows/draft/workflow-draft-prompt.js +0 -54
  252. package/dist/src/workflows/draft/workflow-draft-service.d.ts +0 -12
  253. package/dist/src/workflows/draft/workflow-draft-service.js +0 -125
  254. package/dist/src/workflows/draft/workflow-draft-validator.d.ts +0 -4
  255. package/dist/src/workflows/draft/workflow-draft-validator.js +0 -123
  256. package/dist/src/workflows/draft/workflow-draft.types.d.ts +0 -44
  257. package/dist/src/workflows/draft/workflow-draft.types.js +0 -1
@@ -1,121 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/sessions-page-C6FwYIRA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/dist-BGTk37IG.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/chunk-KS7C4IRE-BMYIfy9x.js","assets/preload-helper-zJ_50EbN.js","assets/vendor-swr-BIWyz7Rc.js","assets/createLucideIcon-DPHK1VkS.js","assets/popover-select-DcsFzD_i.js","assets/check-DUBLcKHA.js","assets/dist-3h6cXXhT.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/cn-JdwAhgNB.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-BTQUDoJ2.js","assets/download-Dk-ZjtO6.js","assets/folder-open-CyzJ19I9.js","assets/layout-grid-CEVZdVFU.js","assets/message-square-fVE7Ghj1.js","assets/minimize-2-DtOGrlpo.js","assets/plus-Q2yW6OE7.js","assets/search-DA7gz22f.js","assets/x-B_N4OPjy.js","assets/locale-store-BSkKhYkc.js","assets/messages-D0G_sZvA.js","assets/use-autosave-ZTHe1zCM.js","assets/loader-circle-CifKLtgG.js","assets/button-CS04eWY9.js","assets/registry-api-tx8XCHOs.js","assets/gateway-startup-retry-DMqYXHAn.js","assets/gateway-config-swr-BYMrbKZE.js","assets/settings-advanced-gate-BEyQiZs0.js","assets/settings-form-section-DM0D-BQ_.js","assets/pencil-DmIY3Oa-.js","assets/settings-page-layout-X1x-2Cp9.js","assets/external-link-DjqjBmc3.js","assets/automations-page-CGMErk_w.js","assets/automations-workspace-Cc4yqiF6.js","assets/markdown-view-DXubGEic.js","assets/app-link-C6gA5Nck.js","assets/product-delivery-bv3z8Xkh.js","assets/schemas-88fK3zzl.js","assets/local-apps-Bpja8nC6.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-DSjfHfaW.css","assets/calendar-clock-D-quYVPe.js","assets/circle-check-C23XjkUj.js","assets/clock-3-DnrAnuyZ.js","assets/ellipsis-0k4rZLoy.js","assets/git-branch-Dh9uxTot.js","assets/message-circle-Badhj-4D.js","assets/workflow-run-setup-panel-X0Cyh2AR.js","assets/eye-CABVeTq0.js","assets/browser-automation-inputs-VnvK-GQP.js","assets/scenes-page-GXJ-b3dO.js","assets/inbox-DNoSz682.js","assets/page-context-capture-button-C3JiQEKD.js","assets/browser-automations-page-CZYCvSSU.js","assets/home-page-CoBivEvx.js","assets/paperclip-f1HujQY1.js","assets/tab-completion-input-D64VNmiA.js","assets/task-detail-page-Dk8Bmlhw.js","assets/tasks-CDR_RVbQ.js","assets/date-picker-DXQTsUJn.js","assets/chevron-left-DqFhpbvK.js","assets/dependency-picker-B_z3zihW.js","assets/dist-Che_jiQF.js","assets/link-2-D_ZKYUW7.js","assets/projects-page-DcqylysA.js","assets/project-detail-page-CRQGCRSU.js","assets/style-TIDOdKy0.js","assets/with-selector-aYPsXwdl.js","assets/style-DLioOiRN.css","assets/note-detail-panel-xsKDIJdK.js","assets/copy-Dv6d4Dvw.js","assets/note-image-lightbox-1qg2v-9j.js","assets/image-Cwyalflz.js","assets/lock-keyhole-DEK5kH0u.js","assets/message-square-plus-XP0tGdlV.js","assets/store-SzD1Jvgm.js","assets/upload-rrb46c3c.js","assets/user-round-C9jxPhMR.js","assets/directory-picker-path-field-BfxaNwMB.js","assets/skill-api-BCAV_F1P.js","assets/skill-reload-api-BEV2WXGk.js","assets/skill-card-icon-BrrpZ3Mw.js","assets/notes-page-BFm7XnWH.js","assets/star-BUWJqJ5c.js","assets/workflows-page-BrL6dzf0.js","assets/vendor-codemirror-DFxP3B9T.js","assets/braces-Cfmtagno.js","assets/list-BBGUdmkF.js","assets/wand-sparkles-DWuJz5ya.js","assets/code-editor-CXIH8jQw.js","assets/tab-completion-input.utils-BP3NH_du.js","assets/capabilities-page-DH3aDk53.js","assets/capability-header-actions-C3chJDQu.js","assets/user-model-page-C_SPNZbP.js","assets/logs-page-BK8ol1q0.js","assets/gauge-C78eD2BA.js","assets/settings-page-CWS9yOH3.js","assets/browser-settings-page-DDz9PE6m.js","assets/settings-loading-skeleton-CAmWMaOT.js","assets/computer-settings-page-BfZaf516.js","assets/globe-DSSGFWFn.js","assets/extension-page-DH5vFbBw.js","assets/extension-settings-page-hGKovxxC.js","assets/schema-form-DPMEuj5D.js","assets/voice-api-key-field-C8Kpkct-.js","assets/voice-config-api-BvzxINUk.js","assets/extension-debug-page-Bs8_FYCm.js","assets/share-preview-page-CcRi2yGy.js","assets/local-apps-page-CCvA9d9L.js","assets/box-DvYoGszj.js","assets/local-app-workbench-page-Di82Oacm.js","assets/power-ZI-pBczI.js","assets/product-open-page-DwEEO0Ak.js","assets/work-discovery-overlay-ClB6T-dm.js","assets/setup-status-panel-BhGKiTPf.js","assets/stethoscope-DRqTAtjD.js","assets/electron-env-Dit0bHgy.js","assets/is-masked-secret-DOkL5b_X.js","assets/appearance-settings-Uts-MQ7K.js","assets/keyboard-shortcuts-settings-CMitbles.js","assets/system-settings-panel-C_lajq9u.js","assets/desktop-pet-settings-B5JGIfqn.js","assets/desktop-pet-sprite-DTqXSpqf.js","assets/app-management-settings-panel-BrIji9B5.js","assets/capabilities-settings-panel-C8jMZAJl.js","assets/image-generation-api-D1sQGaJz.js","assets/models-hub-cache-B0EUPwTv.js","assets/gateway-settings-BIsiP-JI.js","assets/network-BUQLY1BV.js","assets/rotate-cw-LIg3Am9S.js","assets/runtime-tools-settings-panel-De7HmmBu.js","assets/remote-access-hub-Cq5MaiRW.js","assets/server-BlHCBjiE.js","assets/tunnel-api-CYvKiE_f.js","assets/shares-settings-DNmcCBfX.js","assets/agent-defaults-settings-panel-DHJyAT7t.js","assets/management-settings-CebXkEtB.js","assets/device-pairing-wizard-DFYK_Ywf.js","assets/browser-BLJWD7WI.js","assets/attachment-process-heavy-Db4nTY5N.js","assets/pdf-runtime-DU_sMPjG.js","assets/source-workspace-editor-DunRD1gY.js","assets/languages-BFe8nIOO.js","assets/binary-plugins-D3WB-tVn.js","assets/use-blob-object-url-D4BFuzZB.js","assets/preview-open-alternatives-buk_gdip.js","assets/media-plugins-DLJrmU9J.js","assets/archive-plugin-_EzRfBuI.js","assets/jszip.min-DT31yWkU.js","assets/agent-avatar-dicebear-Bs1qnnhD.js","assets/chat-terminal-dock-ClbmjCL2.js","assets/chat-terminal-dock-uQUnjRtf.css","assets/imports-page-rssb4rjP.js","assets/connector-service-page-F-fYNIx8.js","assets/desktop-pet-C1TZzKS3.js"])))=>i.map(i=>d[i]);
2
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,i as r,n as i,r as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./preload-helper-zJ_50EbN.js";import{a as c,f as l,g as u,h as d,i as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as x}from"./createLucideIcon-DPHK1VkS.js";import{t as S}from"./check-DUBLcKHA.js";import{a as C,c as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./popover-select-DcsFzD_i.js";import{t as j}from"./circle-check-C23XjkUj.js";import{t as M}from"./clock-3-DnrAnuyZ.js";import{t as N}from"./copy-Dv6d4Dvw.js";import{t as P}from"./download-Dk-ZjtO6.js";import{t as F}from"./ellipsis-0k4rZLoy.js";import{t as I}from"./external-link-DjqjBmc3.js";import{t as L}from"./eye-CABVeTq0.js";import{_ as R,a as z,c as B,g as V,h as H,i as U,l as W,n as G,o as ee,p as te,r as ne,s as re,t as ie,u as ae}from"./markdown-view-DXubGEic.js";import{t as oe}from"./folder-open-CyzJ19I9.js";import{t as se}from"./git-branch-Dh9uxTot.js";import{t as ce}from"./globe-DSSGFWFn.js";import{t as le}from"./link-2-D_ZKYUW7.js";import{t as ue}from"./loader-circle-CifKLtgG.js";import{t as de}from"./message-circle-Badhj-4D.js";import{t as fe}from"./message-square-plus-XP0tGdlV.js";import{t as pe}from"./message-square-fVE7Ghj1.js";import{t as me}from"./minimize-2-DtOGrlpo.js";import{t as he}from"./pencil-DmIY3Oa-.js";import{t as ge}from"./plus-Q2yW6OE7.js";import{t as _e}from"./rotate-cw-LIg3Am9S.js";import{t as ve}from"./search-DA7gz22f.js";import{t as ye}from"./x-B_N4OPjy.js";import{n as be,t as xe}from"./messages-D0G_sZvA.js";import{t as K}from"./cn-JdwAhgNB.js";import{a as q,c as Se,d as Ce,i as we,l as Te,n as Ee,o as De,p as Oe,r as J,s as ke,t as Ae,u as je}from"./locale-store-BSkKhYkc.js";import{a as Me,d as Ne,f as Pe,g as Fe,h as Ie,i as Le,l as Re,m as ze,n as Be,o as Ve,p as He,r as Ue,s as We,t as Ge,u as Ke}from"./es2015-DBLcMg5B.js";import{i as qe,n as Je}from"./dist-CxGUk8J-.js";import{a as Ye,c as Xe,i as Ze,n as Qe,o as $e,r as et,s as tt,t as nt}from"./dist-BGTk37IG.js";import{_ as rt,a as it,d as at,f as ot,g as st,h as ct,i as lt,l as ut,m as dt,p as Y,r as ft,s as pt,t as mt,u as ht,v as gt}from"./schemas-88fK3zzl.js";import{n as _t,t as vt}from"./turn-outcome-D0SnyZ3Z.js";import{a as yt,c as bt,g as xt,h as St,l as Ct,m as wt,p as Tt,r as Et,t as Dt}from"./tasks-CDR_RVbQ.js";import{i as Ot,n as kt,o as At,s as jt,t as Mt}from"./product-delivery-bv3z8Xkh.js";import{a as Nt}from"./local-apps-Bpja8nC6.js";import{n as Pt,t as Ft}from"./conversation-identity-Cw0n9uzK.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,s as Vt,t as Ht}from"./capabilities-sAZT4brT.js";import{t as Ut}from"./tool-activity-BtJkgjFf.js";import{i as Wt,n as Gt,r as Kt,t as qt}from"./files-BK6enEvD.js";import{r as Jt,t as Yt}from"./copy-to-clipboard-HOJ79TWv.js";import{a as Xt,i as Zt,n as Qt,o as $t,t as en}from"./vendor-swr-BIWyz7Rc.js";import{t as X}from"./button-CS04eWY9.js";import{a as tn,i as nn,n as rn,r as an,t as on}from"./gateway-config-swr-BYMrbKZE.js";import{t as sn}from"./middleware-Pd0e8Igk.js";import{n as cn,t as ln}from"./is-masked-secret-DOkL5b_X.js";import{a as un,i as dn,n as fn,r as pn,t as mn}from"./dist-CI_fqRk-.js";import{a as hn,i as gn,n as _n,o as vn,r as yn,s as bn}from"./dist-3h6cXXhT.js";import{t as xn}from"./skeleton-BwbyijEw.js";import{i as Sn,n as Cn,o as wn,r as Tn,t as En}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as Dn,r as On,t as kn}from"./settings-shell-layer-context-BTQUDoJ2.js";import{n as An}from"./electron-env-Dit0bHgy.js";import{t as jn}from"./gateway-startup-retry-DMqYXHAn.js";import{a as Mn,i as Nn,n as Pn,r as Fn,t as In}from"./dist-Che_jiQF.js";import{n as Ln,r as Rn,t as zn}from"./registry-api-tx8XCHOs.js";import{i as Bn,n as Vn}from"./models-hub-cache-B0EUPwTv.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Z=e(n(),1),Hn=e(r(),1);function Un(e){return Z.createElement(c,{flushSync:Hn.flushSync,...e})}h();var Wn=x(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Gn=x(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),Kn=x(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),qn=x(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Jn=x(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Yn=x(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Xn=x(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Zn=x(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),Qn=x(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),$n=x(`book-open-text`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M16 12h2`,key:`7q9ll5`}],[`path`,{d:`M16 8h2`,key:`msurwy`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}],[`path`,{d:`M6 12h2`,key:`32wvfc`}],[`path`,{d:`M6 8h2`,key:`30oboj`}]]),er=x(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),tr=x(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),nr=x(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),rr=x(`briefcase-business`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,key:`1ksdt3`}],[`path`,{d:`M22 13a18.15 18.15 0 0 1-20 0`,key:`12hx5q`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),ir=x(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),ar=x(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),or=x(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),sr=x(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),cr=x(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),lr=x(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ur=x(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),dr=x(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),fr=x(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),pr=x(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),mr=x(`circle-dot-dashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),hr=x(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),gr=x(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),_r=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),vr=x(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),yr=x(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),br=x(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),xr=x(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Sr=x(`clipboard-check`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`m9 14 2 2 4-4`,key:`df797q`}]]),Cr=x(`clipboard-copy`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2`,key:`4jdomd`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v4`,key:`3hqy98`}],[`path`,{d:`M21 14H11`,key:`1bme5i`}],[`path`,{d:`m15 10-4 4 4 4`,key:`5dvupr`}]]),wr=x(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),Tr=x(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Er=x(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Dr=x(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Or=x(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),kr=x(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ar=x(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),jr=x(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),Mr=x(`file-chart-column-increasing`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M12 18v-4`,key:`q1q25u`}],[`path`,{d:`M16 18v-6`,key:`15y0np`}]]),Nr=x(`file-clock`,[[`path`,{d:`M16 22h2a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v2.85`,key:`ryk6xj`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 14v2.2l1.6 1`,key:`6m4bie`}],[`circle`,{cx:`8`,cy:`16`,r:`6`,key:`10v15b`}]]),Pr=x(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),Fr=x(`file-headphone`,[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]]),Ir=x(`file-play`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z`,key:`1tzo1f`}]]),Lr=x(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Rr=x(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),zr=x(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Br=x(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Vr=x(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),Hr=x(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Ur=x(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),Wr=x(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Gr=x(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),Kr=x(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),qr=x(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Jr=x(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Yr=x(`heart`,[[`path`,{d:`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`,key:`mvr1a0`}]]),Xr=x(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),Zr=x(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Qr=x(`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`}]]),$r=x(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ei=x(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),ti=x(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),ni=x(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),ri=x(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),ii=x(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),ai=x(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),oi=x(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),si=x(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),ci=x(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),li=x(`message-circle-more`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),ui=x(`message-square-share`,[[`path`,{d:`M12 3H4a2 2 0 0 0-2 2v16.286a.71.71 0 0 0 1.212.502l2.202-2.202A2 2 0 0 1 6.828 19H20a2 2 0 0 0 2-2v-4`,key:`11da1y`}],[`path`,{d:`M16 3h6v6`,key:`1bx56c`}],[`path`,{d:`m16 9 6-6`,key:`m4dnic`}]]),di=x(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),fi=x(`message-square-warning`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]),pi=x(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),mi=x(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),hi=x(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),gi=x(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),_i=x(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]),vi=x(`monitor-up`,[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]),yi=x(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),bi=x(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),xi=x(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Si=x(`notebook-text`,[[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`path`,{d:`M9.5 8h5`,key:`11mslq`}],[`path`,{d:`M9.5 12H16`,key:`ktog6x`}],[`path`,{d:`M9.5 16H14`,key:`p1seyn`}]]),Ci=x(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),wi=x(`package-plus`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`M16 17h6`,key:`1ook5g`}],[`path`,{d:`M19 14v6`,key:`1ckrd5`}],[`path`,{d:`M21 10.535V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.675-.955`,key:`28k6lz`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Ti=x(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Ei=x(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),Di=x(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Oi=x(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),ki=x(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),Ai=x(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),ji=x(`paw-print`,[[`circle`,{cx:`11`,cy:`4`,r:`2`,key:`vol9p0`}],[`circle`,{cx:`18`,cy:`8`,r:`2`,key:`17gozi`}],[`circle`,{cx:`20`,cy:`16`,r:`2`,key:`1v9bxh`}],[`path`,{d:`M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z`,key:`1ydw1z`}]]),Mi=x(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 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 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 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 .244.473`,key:`10hv5p`}]]),Ni=x(`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`}]]),Pi=x(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Fi=x(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),Ii=x(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Li=x(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Ri=x(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),zi=x(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Bi=x(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Vi=x(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Hi=x(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Ui=x(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Wi=x(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),Gi=x(`search-check`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),Ki=x(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),qi=x(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ji=x(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Yi=x(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),Xi=x(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Zi=x(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Qi=x(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),$i=x(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ea=x(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),ta=x(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),na=x(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),ra=x(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ia=x(`step-forward`,[[`path`,{d:`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`1ystz2`}],[`path`,{d:`M3 4v16`,key:`1ph11n`}]]),aa=x(`step-back`,[[`path`,{d:`M13.971 4.285A2 2 0 0 1 17 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`19qhus`}],[`path`,{d:`M21 20V4`,key:`cb8qj8`}]]),oa=x(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),sa=x(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),ca=x(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),la=x(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),ua=x(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),da=x(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),fa=x(`timer-off`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7`,key:`10he05`}],[`path`,{d:`M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2`,key:`15f7sh`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M12 12v-2`,key:`fwoke6`}]]),pa=x(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),ma=x(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ha=x(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),ga=x(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),_a=x(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),va=x(`wallet`,[[`path`,{d:`M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1`,key:`18etb6`}],[`path`,{d:`M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4`,key:`xoc0q4`}]]),ya=x(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ba=x(`wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]),xa=x(`workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]),Sa=x(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Ca=x(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),wa=a(),Q=i(),Ta=[{id:`work-overview`,domain:`work`,path:`/`},{id:`work-projects`,domain:`work`,path:`/projects`},{id:`work-notes`,domain:`work`,path:`/notes`}],Ea=[{id:`automation-activity`,domain:`automation`,path:`/automations?view=activity`},{id:`automation-scenes`,domain:`automation`,path:`/scenes`},{id:`automation-triggers`,domain:`automation`,path:`/automations`},{id:`automation-workflows`,domain:`automation`,path:`/workflows`},{id:`automation-browser`,domain:`automation`,path:`/browser-automations`}],Da=[`discover`,`agents`,`skills`,`connectors`,`channels`,`extensions`],Oa=Da.map(e=>({id:`capabilities-${e}`,domain:`capabilities`,path:`/capabilities/${e}`}));function ka(e){return`/capabilities/${e}`}var Aa=[{id:`work`,path:`/`,sections:Ta},{id:`automation`,path:`/automations?view=activity`,sections:Ea},{id:`capabilities`,path:`/capabilities/discover`,sections:Oa},{id:`apps`,path:`/local-apps`,sections:[{id:`apps-library`,domain:`apps`,path:`/local-apps`}]}];function ja(e,t){return e===t||e.startsWith(`${t}/`)}function Ma(e){return e===`/`||ja(e,`/chat`)||ja(e,`/tasks`)||ja(e,`/projects`)||ja(e,`/notes`)?`work`:ja(e,`/automations`)||ja(e,`/scenes`)||ja(e,`/workflows`)||ja(e,`/browser-automations`)?`automation`:ja(e,`/capabilities`)||ja(e,`/extensions`)?`capabilities`:ja(e,`/local-apps`)||ja(e,`/open`)?`apps`:null}function Na(e,t=``){if(e===`/`)return`work-overview`;if(ja(e,`/projects`))return`work-projects`;if(ja(e,`/notes`))return`work-notes`;if(ja(e,`/automations`))return new URLSearchParams(t).get(`view`)===`activity`?`automation-activity`:`automation-triggers`;if(ja(e,`/scenes`))return`automation-scenes`;if(ja(e,`/workflows`))return`automation-workflows`;if(ja(e,`/browser-automations`))return`automation-browser`;if(ja(e,`/extensions`))return`capabilities-extensions`;if(ja(e,`/local-apps`)||ja(e,`/open`))return`apps-library`;if(ja(e,`/capabilities`)){let t=`capabilities-${e.split(`/`)[2]||`discover`}`;return Oa.some(e=>e.id===t)?t:`capabilities-discover`}return null}function Pa(e){return Aa.find(t=>t.id===e)}function Fa(e){if(ja(e,`/chat`)||ja(e,`/tasks`))return!1;let t=Ma(e);return t===`work`||t===`automation`||t===`capabilities`}var $=o(),Ia={work:rr,automation:Ca,capabilities:ri,apps:nr};function La(){let e=(0,Q.c)(10),{pathname:t}=b(),n=Ee(Ra),r;e[0]===n?r=e[1]:(r=xe(n),e[0]=n,e[1]=r);let i=r.productNavigation,a;e[2]===t?a=e[3]:(a=Ma(t),e[2]=t,e[3]=a);let o=a,s=i.primaryAria,c;e[4]!==o||e[5]!==i.domains?(c=Aa.map(e=>{let t=Ia[e.id],n=e.id===o;return(0,$.jsxs)(y,{to:e.path,"aria-current":n?`page`:void 0,className:K(`flex min-h-14 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,n?`text-accent-fg`:`text-fg-muted`),children:[(0,$.jsx)(t,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`max-w-full truncate`,children:i.domains[e.id]})]},e.id)}),e[4]=o,e[5]=i.domains,e[6]=c):c=e[6];let l;return e[7]!==i.primaryAria||e[8]!==c?(l=(0,$.jsx)(`nav`,{"aria-label":s,className:`flex shrink-0 border-t border-edge-subtle bg-surface-panel pb-[env(safe-area-inset-bottom)] md:hidden`,children:c}),e[7]=i.primaryAria,e[8]=c,e[9]=l):l=e[9],l}function Ra(e){return e.language}var za=ht({id:Y(),name:Y(),status:Y(),description:Y().optional(),brief:Y().optional(),updatedAt:ut()}),Ba=ht({dependencyTaskId:Y(),dependentTaskId:Y()}),Va=ht({id:Y(),title:Y(),phase:St,resolution:xt.optional(),operationalState:wt,priority:bt,dueAt:ut().optional(),acceptanceCriteriaCount:ut().int().nonnegative(),latestVerification:mt([`passed`,`failed`,`unverified`]).optional(),nextCheckAt:ut().int().nonnegative().optional(),attention:ft(Tt).default([]),blockedBy:ft(yt).default([]),allowedCommands:ft(Y()),updatedAt:ut()});ht({health:mt([`healthy`,`attention`,`idle`,`empty`]),summary:Y(),recommendedAction:Y().optional(),counts:ht({ready:ut().int().nonnegative(),moving:ut().int().nonnegative(),waiting:ut().int().nonnegative(),needsUser:ut().int().nonnegative(),done:ut().int().nonnegative()}),updatedAt:ut().int().nonnegative()});var Ha=ht({project:za,tasks:ft(Va),dependencyEdges:ft(Ba),blockers:ft(ht({id:Y(),taskId:Y(),kind:Y(),title:Y(),detail:Y().optional(),href:Y().optional(),updatedAt:ut().optional()})),running:ft(ht({runId:Y(),definitionId:Y(),status:Y(),createdAt:ut()})),recentResults:ft(ht({taskId:Y(),taskTitle:Y(),receipt:Ct})),digest:ht({health:mt([`healthy`,`attention`,`idle`,`empty`]),summary:Y(),recommendedAction:Y().optional()})}),Ua=mt([`active`,`idle`,`archived`,`pinned`]),Wa=ht({agentId:Y().optional(),source:Y().optional(),accountId:Y().optional(),peerKind:Y().optional(),peerId:Y().optional(),threadId:Y().optional(),scopeId:Y().optional()}).passthrough();ht({agentId:Y().optional(),projectId:Y().optional(),key:Y(),transcriptId:Pt.optional(),name:Y().optional(),title:Y().optional(),displayName:Y().optional(),messageCount:ut(),updatedAt:Y(),sourceChannel:Y().optional(),status:Ua.optional(),routing:Wa.optional()}).passthrough();var Ga=ht({items:ft(st()),total:ut(),limit:ut(),offset:ut(),hasMore:lt()}),Ka=ht({role:Y(),content:st(),timestamp:ct([Y(),ut()]).optional()}).passthrough(),qa=ht({key:Y(),messages:ft(Ka)}).passthrough(),Ja=ht({session:qa}),Ya=ht({session:ht({key:Y(),transcriptId:Pt.optional(),messages:ft(Ka),name:Y().optional(),status:Ua.optional(),sourceChannel:Y().optional(),sourceChatId:Y().optional(),projectId:Y().optional(),customData:at(Y(),st()).optional(),routing:Wa.optional()}).passthrough(),pagination:ht({total:ut(),limit:ut(),offset:ut(),hasMore:lt(),before:Y().optional(),nextBeforeCursor:Y().optional()}).passthrough()}).passthrough();ht({session:ht({key:Y(),transcriptId:Pt.optional(),projectId:Y().optional(),routing:Wa.optional()}).passthrough()}).passthrough();var Xa=ht({ok:pt(!0),conversationId:rt(),rowCount:ut().int().nonnegative(),lastTurnId:Y().min(1),session:qa}).passthrough(),Za=ht({ok:lt().optional(),payload:ht({active:lt(),runId:Y().optional()}).passthrough().optional()}).passthrough(),Qa=ht({ok:lt().optional(),error:Y().optional()}).passthrough(),$a=Qa.extend({renamed:lt().optional()}),eo=Qa.extend({reset:lt().optional(),transcriptId:Pt.optional(),previousTranscriptId:Y().optional(),session:st().optional()}),to=ht({totalSessions:ut(),activeSessions:ut(),archivedSessions:ut(),pinnedSessions:ut(),totalMessages:ut(),totalTokens:ut(),oldestSession:Y().optional(),newestSession:Y().optional(),byChannel:at(Y(),ut())}).passthrough();ht({ok:lt(),payload:ht({conversationId:rt(),transcriptId:Pt,session:st()}).passthrough().optional(),error:Y().optional()}).passthrough();var no=ht({ok:pt(!0),projects:ht({items:ft(ht({project:st(),sessions:ft(st()),sessionTotal:ut(),sessionHasMore:lt()}).passthrough()),total:ut(),limit:ut(),offset:ut(),hasMore:lt()}),inbox:Ga,pinned:ft(st()).default([]),layouts:at(Y(),ht({itemIds:ft(Y()),revision:ut().int().nonnegative()})).default({})}).passthrough();function ro(e){return Ja.parse(e)}function io(e){return Ya.parse(e)}function ao(e){return Xa.parse(e)}function oo(e){return Za.parse(e)}function so(e){return Qa.parse(e)}function co(e){return $a.parse(e)}function lo(e){return eo.parse(e)}function uo(e){return to.parse(e)}function fo(e){return no.parse(e)}function po(e){let t=oo(e).payload,n=typeof t?.runId==`string`?t.runId.trim():``;return!t?.active||!n?{active:!1}:{active:!0,runId:n}}function mo(e){let t=new URLSearchParams;if(!e)return``;e.status&&t.set(`status`,e.status),e.search&&t.set(`search`,e.search),e.channel&&t.set(`channel`,e.channel),e.sources?.length&&t.set(`sources`,e.sources.join(`,`)),e.purposes?.length&&t.set(`purposes`,e.purposes.join(`,`)),e.activity&&t.set(`activity`,e.activity),e.agentId&&t.set(`agentId`,e.agentId),e.excludeArchived&&t.set(`excludeArchived`,`true`),e.projectId&&t.set(`projectId`,e.projectId),e.unassigned&&t.set(`unassigned`,`true`),e.updatedAfter!=null&&t.set(`updatedAfter`,String(e.updatedAfter)),e.includePinned&&t.set(`includePinned`,`true`),e.includeConversationId&&t.set(`includeConversationId`,e.includeConversationId),e.sessionTypes?.length&&t.set(`types`,e.sessionTypes.join(`,`)),e.sortBy&&t.set(`sortBy`,e.sortBy),e.sortOrder&&t.set(`sortOrder`,e.sortOrder),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString();return n?`?${n}`:``}function ho(e,t){let n=[];t?.includeTranscript&&n.push(`transcript`),t?.includeTranscriptRows&&n.push(`transcriptRows`);let r=n.length?`?include=${n.join(`,`)}`:``;return`/api/sessions/${encodeURIComponent(e)}${r}`}function go(e){return`/api/sessions/${encodeURIComponent(e)}/fork-at-turn`}function _o(e,t){let n=new URLSearchParams;n.set(`limit`,String(t?.limit??50));let r=t?.before?.trim();return r?n.set(`before`,r):t?.offset!=null&&n.set(`offset`,String(t.offset)),`/api/sessions/${encodeURIComponent(e)}/history?${n.toString()}`}function vo(e){return`/api/sessions/${encodeURIComponent(e)}/run`}function yo(){return`/api/sessions/stats`}function bo(e){let t=new URLSearchParams;e?.projectLimit!=null&&t.set(`projectLimit`,String(e.projectLimit)),e?.projectOffset!=null&&t.set(`projectOffset`,String(e.projectOffset)),e?.sessionPreviewLimit!=null&&t.set(`sessionPreviewLimit`,String(e.sessionPreviewLimit)),e?.inboxLimit!=null&&t.set(`inboxLimit`,String(e.inboxLimit)),e?.inboxOffset!=null&&t.set(`inboxOffset`,String(e.inboxOffset)),e?.staleDays!=null&&t.set(`staleDays`,String(e.staleDays)),e?.includeConversationId&&t.set(`includeConversationId`,e.includeConversationId);let n=t.toString();return`/api/sidebar/chat-list${n?`?${n}`:``}`}function xo(e){return`/api/sidebar/layouts/${encodeURIComponent(e)}`}function So(e,t){let n=encodeURIComponent(e);return t===`delete`?`/api/sessions/${n}`:`/api/sessions/${n}/${t}`}function Co(e){return e?JSON.stringify({status:e.status,search:e.search,channel:e.channel,sources:e.sources,purposes:e.purposes,activity:e.activity,agentId:e.agentId,excludeArchived:e.excludeArchived,projectId:e.projectId,unassigned:e.unassigned,updatedAfter:e.updatedAfter,includePinned:e.includePinned,includeConversationId:e.includeConversationId,sessionTypes:e.sessionTypes,sortBy:e.sortBy,sortOrder:e.sortOrder,limit:e.limit,offset:e.offset}):`default`}var wo={workbench:[`webchat`,`web`,`ui`,`webui`,`gateway`],browser:[`browser_extension`],terminal:[`cli`,`tui`],telegram:[`telegram`],wechat:[`wechat`,`weixin`],feishu:[`feishu`,`lark`],api:[`api`,`mcp`],automation:[`automation`,`cron`],system:[`heartbeat`,`system`]},To=[...Object.keys(wo),`other`],Eo=[`chat`,`automation`,`workflow`,`subagent`,`system`],Do=ht({sources:ft(mt(To)).max(To.length).optional(),purposes:ft(mt(Eo)).max(Eo.length).optional(),activity:mt([`manual`,`automatic`]).optional(),agentId:Y().trim().min(1).max(128).optional(),excludeArchived:lt().optional()});function Oo(e){let t=e.sourceChannel.trim().toLowerCase(),n=e.customData??{},r=`other`;for(let[e,n]of Object.entries(wo))n.includes(t)&&(r=e);n.createdSurface===`browser_extension`&&(r=`browser`),(n.origin===`automation`||n.triggerSource===`automation`||e.sessionType===`cron`)&&(r=`automation`),e.sessionType===`heartbeat`&&(r=`system`);let i=r===`system`?`system`:e.sessionType===`workflow-subagent`?`subagent`:e.sessionType===`workflow-run`?`workflow`:r===`automation`?`automation`:`chat`;return{source:r,purpose:i,automatic:r===`automation`||r===`system`}}var ko=[0,500,1500],Ao=1e4;function jo(e){let t=[e.content,e.thinking??null,e.attachments??null,e.contextRefs??null,e.browserContexts??null];e.appContext!==void 0&&t.push(e.appContext);let n=JSON.stringify(t),r=2166136261,i=5381;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);r^=t,r=Math.imul(r,16777619),i=Math.imul(i,33)^t}return`${n.length.toString(36)}:${(r>>>0).toString(36)}:${(i>>>0).toString(36)}`}function Mo(e){return e===408||e===429||e>=500}var No={main:`general`,coder:`coding`,writer:`writing`,researcher:`research`,"data-analyst":`data`,creative:`creative`};function Po(e,t){if(e)return e.replace(/\{\{(\w+)}}/g,(e,n)=>t[n]?.trim()??``).replace(/[ \t]{2,}/g,` `).trim()}function Fo(e,t){return{headline:Po(e.headline,t)??e.headline,tagline:Po(e.tagline,t)??e.tagline,contextLabel:Po(e.contextLabel,t),categories:e.categories.map(e=>({...e,title:Po(e.title,t)??e.title,description:Po(e.description,t)??e.description,scenarios:e.scenarios.map((n,r)=>({id:n.id??`${e.id}:${r}`,prompt:Po(n.prompt,t)??n.prompt}))}))}}function Io(e){let t=e?.id.trim().toLowerCase()??``;if(No[t])return No[t];let n=[e?.id,e?.name,e?.description,e?.role,...e?.responsibilities??[],...e?.skills??[]].filter(Boolean).join(` `).toLowerCase();return/\b(code|coder|coding|developer|engineer|debug|refactor|test|review|software)\b|编程|代码|开发|工程|调试|测试|审查|重构|软件/.test(n)?`coding`:/\b(write|writer|writing|draft|edit|rewrite|copy|content|translate)\b|写作|文案|编辑|改写|翻译|内容|撰写/.test(n)?`writing`:/\b(research|researcher|search|source|fact|synthesis|investigate|investigation)\b|调研|研究|搜索|检索|核查|资料|事实|来源|综合/.test(n)?`research`:/\b(data|analysis|analyst|csv|sql|metric|visuali[sz]ation|report)\b|数据|分析|报表|指标|可视化|统计/.test(n)?`data`:/\b(creative|design|visual|image|story|brainstorm|ideation)\b|创意|设计|视觉|图像|故事|头脑风暴|构思/.test(n)?`creative`:`general`}function Lo(e){switch(e.kind){case`codingProject`:case`generalProject`:return e.projectName;case`note`:return e.title;case`workingDirectory`:case`codingWorkspace`:return e.path;case`task`:return e.taskTitle;case`file`:return e.fileName;case`workflow`:return e.workflowName;default:return``}}function Ro(e,t,n,r){if(r&&n)return Po(t.reasons.agent,{agentName:n})??t.reasons.general;switch(e.kind){case`codingProject`:case`generalProject`:return Po(t.reasons.project,{projectName:e.projectName})??t.reasons.general;case`note`:return Po(t.reasons.note,{noteTitle:e.title})??t.reasons.general;case`workingDirectory`:case`codingWorkspace`:return Po(t.reasons.directory,{path:e.path})??t.reasons.general;case`task`:case`file`:case`workflow`:return t.reasons.general;default:return n?Po(t.reasons.agent,{agentName:n})??t.reasons.general:t.reasons.general}}function zo(e,t,n){let r=``,i=``,a={};if(e.kind===`codingProject`&&e.workspaceRoot?.trim()&&(r=`understand-codebase`,i=n.contextPrompts.codingWorkspace,a={projectName:e.projectName,workspaceRoot:e.workspaceRoot}),(e.kind===`codingProject`||e.kind===`generalProject`)&&e.blockedReason?.trim()?(r=e.kind===`codingProject`?`review-debug`:`project-status`,i=n.contextPrompts.projectBlocked,a={projectName:e.projectName,blockedReason:e.blockedReason}):(e.kind===`codingProject`||e.kind===`generalProject`)&&e.recentFailure?.trim()?(r=e.kind===`codingProject`?`review-debug`:`project-status`,i=n.contextPrompts.projectFailure,a={projectName:e.projectName,recentFailure:e.recentFailure}):(e.kind===`codingProject`||e.kind===`generalProject`)&&e.recommendedAction?.trim()&&(r=e.kind===`codingProject`?`implement-feature`:`project-next-step`,i=n.contextPrompts.projectNextAction,a={projectName:e.projectName,nextAction:e.recommendedAction}),e.kind===`task`&&(a={taskTitle:e.taskTitle},e.attentionSummary?.trim()?(r=`task-clarify`,i=n.contextPrompts.taskAttention,a.attentionSummary=e.attentionSummary):e.recentFailure?.trim()?(r=`task-recover`,i=n.contextPrompts.taskFailure,a.recentFailure=e.recentFailure):e.phase===`review`||e.operationalState===`verifying`?(r=`task-verify`,i=n.contextPrompts.taskReview):e.phase===`closed`?(r=`task-verify`,i=n.contextPrompts.taskClosed):e.nextAction?.trim()&&(r=`task-next-step`,i=n.contextPrompts.taskNextAction,a.nextAction=e.nextAction)),e.kind===`file`&&(r=`file-edit`,i=n.contextPrompts.fileStart,a={fileName:e.fileName}),e.kind===`workflow`&&(a={workflowName:e.workflowName},e.recentFailure?.trim()?(r=`workflow-recover`,i=n.contextPrompts.workflowFailure,a.recentFailure=e.recentFailure):e.nextAction?.trim()&&(r=`workflow-next-step`,i=n.contextPrompts.workflowNextAction,a.nextAction=e.nextAction)),!r||!i)return null;let o=t.find(e=>e.id===r);return o?{id:`context:${r}`,categoryId:r,category:o,icon:o.icon,title:o.title,prompt:Po(i,a)??i,reason:``,score:300}:null}function Bo(e,t){switch(e.kind){case`codingProject`:return t===`understand-codebase`?45:t===`implement-feature`?30:20;case`codingWorkspace`:return t===`directory-understand`?45:t===`directory-entry`?30:20;case`generalProject`:return t===`project-next-step`?40:25;case`note`:return t===`note-summarize`?40:25;case`workingDirectory`:return t===`directory-understand`?40:25;case`task`:return e.attentionSummary?t===`task-clarify`?60:20:e.recentFailure?t===`task-recover`?60:20:e.phase===`review`||e.phase===`closed`?t===`task-verify`?55:20:t===`task-next-step`?45:25;case`file`:return t===`file-edit`?45:25;case`workflow`:return e.recentFailure?t===`workflow-recover`?50:20:e.status===`succeeded`?t===`workflow-review`?45:20:t===`workflow-next-step`?40:20;default:return 0}}function Vo(e,t,n,r,i){let a=e.flatMap((e,i)=>e.scenarios.map((a,o)=>{let s=a.id??`${e.id}:${o}`,c=Math.min(35,Math.max(0,r[s]??0)),l=e.id===n?t.kind===`empty`?55:20:0;return{id:s,categoryId:e.id,category:e,icon:e.icon,title:e.title,prompt:a.prompt,reason:``,score:100-i*8-o+Bo(t,e.id)+l+c}})),o=zo(t,e,i);o&&a.push(o);let s=new Set;return a.sort((e,t)=>t.score-e.score).filter(e=>{let t=e.prompt.trim().toLocaleLowerCase();return!t||s.has(t)?!1:(s.add(t),!0)})}function Ho(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t}function Uo(e,t){return Math.max(0,...e.scenarios.map((n,r)=>t[n.id??`${e.id}:${r}`]??0))}function Wo(e,t,n,r){let i=Fo({headline:``,tagline:``,categories:e.exploreCards},{}).categories.map(e=>({...e,scope:`explore`}));if(i.length===0)throw Error(`Welcome spotlight requires at least one exploration card`);let a=Ho(n)%i.length;if(r>0)return i[(a+r)%i.length]??i[0];let o=i.map((e,n)=>({card:e,index:n,score:Uo(e,t)})).sort((e,t)=>t.score-e.score||Math.abs(e.index-a)-Math.abs(t.index-a))[0];return o&&o.score>0?o.card:i[a]??i[0]}function Go(e){return e.kind===`codingProject`||e.kind===`codingWorkspace`}function Ko(e){return e.kind===`empty`||e.kind===`note`||e.kind===`workingDirectory`||e.kind===`codingWorkspace`}function qo(e,t,n,r={}){let i,a={};switch(e.kind){case`codingProject`:i=t.codingProject,a.projectName=e.projectName,a.workspaceRoot=e.workspaceRoot;break;case`codingWorkspace`:i=t.codingWorkspace,a.path=e.path;break;case`generalProject`:i=t.generalProject,a.projectName=e.projectName;break;case`note`:i=t.note,a.noteTitle=e.title;break;case`workingDirectory`:i=t.workingDirectory,a.path=e.path;break;case`task`:i=t.task,a.taskTitle=e.taskTitle;break;case`file`:i=t.file,a.fileName=e.fileName;break;case`workflow`:i=t.workflow,a.workflowName=e.workflowName;break;default:i=t.empty;break}let o=Fo(i,a),s=Io(n),c=n?.name?.trim()||n?.id.trim()||``,l=Lo(e)||t.contextFallbackTitle,u=null,d=[...o.categories];if(s!==`general`&&!Go(e)&&(s!==`coding`||e.kind===`empty`)){let e=t.agentCards[s];if(e){let[t]=Fo({headline:o.headline,tagline:o.tagline,categories:[e]},{agentName:c,contextTitle:l}).categories;t&&!d.some(e=>e.id===t.id)&&(d.push(t),u=t.id)}}let f=Vo(d,e,u,r.affinity??{},t),p=f[0];if(!p)throw Error(`Welcome spotlight requires at least one suggestion`);let m=Ro(e,t,c,p.categoryId===u),h=d.map(e=>!p.id.startsWith(`context:`)||e.id!==p.categoryId?e:{...e,scenarios:[{id:p.id,prompt:p.prompt},...e.scenarios.filter(e=>e.prompt!==p.prompt)]}),g=new Map;for(let e of f)g.set(e.categoryId,Math.max(g.get(e.categoryId)??0,e.score));let _=(e.kind===`empty`?h.filter(e=>e.id!==`research`):h).filter(e=>e.scenarios.length>0).sort((e,t)=>(g.get(t.id)??0)-(g.get(e.id)??0)).slice(0,Ko(e)?2:3).map(e=>({...e,scope:`context`})),v=Ko(e)?Wo(t,r.affinity??{},r.explorationSeed??`default`,Math.max(0,r.explorationOffset??0)):null,y=r.contextStatus??`ready`;return{...o,contextKind:e.kind,tagline:c&&s!==`general`?Po(t.agentTagline,{agentName:c})??o.tagline:o.tagline,contextStatus:y,statusLabel:y===`loading`?t.contextLoading:y===`degraded`?t.contextFallback:void 0,retryLabel:t.retryContext,refreshExplorationLabel:t.refreshExplorationLabel,otherSuggestionsLabel:t.otherSuggestionsLabel,primaryRecommendation:{id:p.id,categoryId:p.categoryId,icon:p.icon,title:p.title,prompt:p.prompt,reason:m},categories:v?[..._,v]:_}}var Jo=/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s*/u,Yo=[`user-profile`,`active-focuses`,`collaboration-contract`,`user-context`];function Xo(e,t){let n=`<${t}>`;if(!e.startsWith(n))return null;let r=`</${t}>`,i=e.indexOf(r,n.length);return i<0?null:e.slice(i+r.length).trimStart()}function Zo(e){return Jo.test(e)||e.startsWith(`<source_contexts>`)||Yo.some(t=>e.startsWith(`<${t}>`))}function Qo(e){if(!e.includes(`<source_contexts>`))return e;let t=e.replace(/^\s*<source_contexts>[\s\S]*?<\/source_contexts>\s*/u,``).trimStart();return t.match(/^<user_message>\r?\n([\s\S]*)\r?\n<\/user_message>\s*$/u)?.[1]??t}function $o(e){let t=e,n=Xo(t.trimStart(),`xopc_task_execution`);n!==null&&Zo(n)&&(t=n),t=Qo(t);let r=t,i=!1;for(t=t.trimStart();;){let e=Yo.find(e=>t.startsWith(`<${e}>`));if(!e)break;let n=Xo(t,e);if(n===null){t=r,i=!1;break}t=n,i=!0}return i&&!Jo.test(t)&&(t=r),t.replace(Jo,``)}function es(e){return!e.includes(`[media attached:`)&&!e.includes(`xopc-media-uri:`)?e:e.replace(/\s*\[media attached:[^\]]+\]\s*\r?\nxopc-media-uri:[^\r\n]+\r?\n\s*xopc-media-path:[^\r\n]+(?:\r?\n\s*Use the read_media tool[^\r\n]*)?/g,``).replace(/\s*\[media attached:[^\]]+\]\s*/g,` `).replace(/\s*xopc-media-uri:[^\r\n]+/g,``).replace(/\s*xopc-media-path:[^\r\n]+/g,``).replace(/\s*Use the read_media tool[^\r\n]*/g,``).replace(/\n{3,}/g,`
3
-
4
- `).trim()}var ts=`@xopc-ref:`,ns=`[A-Za-z0-9_-]{1,64}`,rs=RegExp(`${ts}(${ns})`,`g`);function is(e){if(!RegExp(`^${ns}$`).test(e))throw Error(`Invalid context reference id`);return`${ts}${e}`}function as(){return new RegExp(rs.source,`g`)}function os(e){let t=[],n=as(),r=0,i;for(;(i=n.exec(e))!==null;)i.index>r&&t.push({type:`text`,text:e.slice(r,i.index)}),t.push({type:`context_ref`,refId:i[1]??``}),r=i.index+i[0].length;return t.length===0?null:(r<e.length&&t.push({type:`text`,text:e.slice(r)}),{version:1,parts:t})}function ss(e){return e.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])}function cs(e,t){return e.parts.map(e=>{if(e.type===`text`)return e.text;let n=t(e.refId)?.trim();return n?`@${n}`:``}).join(``)}function ls(e){return e.parts.map(e=>e.type===`text`?e.text:is(e.refId)).join(``)}function us(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.version!==1||!Array.isArray(t.parts)?!1:t.parts.every(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.type===`text`?typeof t.text==`string`:t.type===`context_ref`&&typeof t.refId==`string`&&RegExp(`^${ns}$`).test(t.refId)})}function ds(e){return e?.trim()||void 0}function fs(e){return ds(e)?.toLowerCase()}function ps(){return{kind:`none`}}function ms(e){let t=ds(e);return t?{kind:`project`,projectId:t}:ps()}function hs(){return{version:1,modelByAgent:{},executionModeByProject:{},lastChatScope:ps()}}function gs(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind===`none`)return ps();if(t.kind!==`project`||typeof t.projectId!=`string`)return null;let n=ds(t.projectId);return n?{kind:`project`,projectId:n}:null}function _s(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){let e=fs(n);if(!e||!r||typeof r!=`object`)continue;let i=r,a=typeof i.modelRef==`string`?ds(i.modelRef):void 0;if(!a)continue;let o=typeof i.thinkingLevel==`string`?ds(i.thinkingLevel):void 0;t[e]={modelRef:a,...o?{thinkingLevel:o}:{},...i.thinkingByModel&&typeof i.thinkingByModel==`object`?{thinkingByModel:Object.fromEntries(Object.entries(i.thinkingByModel).filter(e=>typeof e[1]==`string`))}:{}}}return t}function vs(e){return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{let n=ds(e);return n&&(t===`local_checkout`||t===`managed_worktree`)?[[n,t]]:[]}))}function ys(e){let t=hs();if(!e||typeof e!=`object`||Array.isArray(e))return t;let n=e;if(n.version!==1)return t;let r=typeof n.selectedAgentId==`string`?fs(n.selectedAgentId):void 0;return{version:1,...r?{selectedAgentId:r}:{},modelByAgent:_s(n.modelByAgent),executionModeByProject:vs(n.executionModeByProject),lastChatScope:gs(n.lastChatScope)??ps()}}function bs(e,t){let n=fs(t),{selectedAgentId:r,...i}=e;return n?{...i,selectedAgentId:n}:i}function xs(e,t,n){let r=fs(t);if(!r)return e;let i={...e.modelByAgent},a=n?ds(n.modelRef):void 0;if(!n||!a)delete i[r];else{let e=ds(n.thinkingLevel),t={...i[r]?.thinkingByModel,...i[r]?.thinkingLevel?{[i[r].modelRef]:i[r].thinkingLevel}:{},...e?{[a]:e}:{}};i[r]={modelRef:a,...e?{thinkingLevel:e}:{},...Object.keys(t).length?{thinkingByModel:t}:{}}}return{...e,modelByAgent:i}}function Ss(e,t){let n=ds(t);return{...e,lastChatScope:n?{kind:`project`,projectId:n}:ps()}}function Cs(e,t){let n=fs(t);return n?e.modelByAgent[n]:void 0}function ws(e,t,n){let r=ds(t);if(!r)return e;let i={...e.executionModeByProject};return n===`local_checkout`||n===`managed_worktree`?i[r]=n:delete i[r],{...e,executionModeByProject:i}}function Ts(e,t){let n=ds(t);return n?e.executionModeByProject[n]:void 0}function Es(e,t){return e.kind===`project`?ms(e.projectId):e.kind===`none`?ps():e.kind===`inherit-current`?ms(t.currentSession?.projectId??``):t.lastChatScope?.kind===`project`?ms(t.lastChatScope.projectId):ps()}function Ds(e,t){let n=Es(e.project,t),r=fs(e.agentId)??(e.project.kind===`inherit-current`?fs(t.currentSession?.agentId):void 0)??fs(t.projectDefaultAgentId)??fs(t.selectedAgentId)??fs(t.defaultAgentId)??`main`;return{origin:e.origin,agentId:r,projectId:n.kind===`project`?n.projectId:null,forceNew:e.forceNew===!0,temporary:e.temporary===!0}}function Os(e,t){return[ds(e)??`default`,fs(t.agentId)??`main`,ds(t.projectId)??`none`].join(`:`)}var ks=it(`kind`,[ht({kind:pt(`scene_result`),activationId:Y().min(1),presentationId:Y().min(1)}),ht({kind:pt(`scene_digest`),digestId:Y().min(1)}),ht({kind:pt(`chat`),conversationId:Y().min(1)}),ht({kind:pt(`task`),taskId:Y().min(1)}),ht({kind:pt(`home`)}),ht({kind:pt(`automation_run`),automationId:Y().min(1),runId:Y().min(1)}),ht({kind:pt(`work_discovery`),runId:Y().min(1),conversationId:Y().min(1)})]),As=mt([`scene.result`,`scene.digest`,`chat.completed`,`chat.failed`,`task.needs_input`,`task.blocked`,`task.failed`,`task.completed`,`automation.completed`,`automation.failed`,`work_discovery.completed`,`work_discovery.failed`,`home.opportunity`]),js=ht({en:Y().min(1).max(500),zh:Y().min(1).max(500)}),Ms=ht({schemaVersion:pt(1),id:Y().min(1).max(160),type:As,target:ks,priority:mt([`normal`,`high`]),title:js,body:js.optional(),payload:at(Y(),st()),createdAt:ut().int().nonnegative()});function Ns(e,t){return{...e,localizedTitle:e.title[t],...e.body?{localizedBody:e.body[t]}:{}}}function Ps(e,t){switch(e.kind){case`scene_result`:return`/scenes/${encodeURIComponent(e.activationId)}?result=${encodeURIComponent(e.presentationId)}`;case`scene_digest`:return`/scenes/inbox?digest=${encodeURIComponent(e.digestId)}`;case`chat`:return`/chat/${encodeURIComponent(e.conversationId)}`;case`task`:return`/tasks/${encodeURIComponent(e.taskId)}`;case`home`:return`/`;case`automation_run`:return t===`mobile`?`/automation/runs/${encodeURIComponent(e.runId)}`:`/automations?automation=${encodeURIComponent(e.automationId)}&run=${encodeURIComponent(e.runId)}`;case`work_discovery`:return t===`web`?`/user-model?workDiscovery=review&run=${encodeURIComponent(e.runId)}`:`/chat/${encodeURIComponent(e.conversationId)}`}}function Fs(e,t,n){for(let r of[n,t])if(e.options.includes(r))return r;return e.initialValue}var Is=7200*1e3,Ls=1024*1024*1024,Rs=8*1024*1024,zs=ot({id:mt([`xopc.notes.get`,`xopc.notes.list`,`xopc.tasks.get`,`xopc.tasks.list`,`xopc.notes.create`,`xopc.notes.update`,`xopc.notes.append`]),majorVersion:ut().int().positive(),descriptorDigest:Y().regex(/^[a-f0-9]{64}$/)});ft(zs).max(7).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate capability binding`);function Bs(e){return e===`zh`?{newWork:`交给 xopc`,dialogTitle:`现在想完成什么?`,dialogDescription:`发送后会进入新对话。xopc 会直接回答或开始处理;需要持续推进时,再转为任务。`,intentLabel:`告诉 xopc 你要做什么`,intentPlaceholder:`例如:整理这周的会议记录,提炼待办并给出下周优先级`,intentSuggestion:`整理这周的会议记录,提炼待办并给出下周优先级`,submit:`进入对话并开始`,projectLabel:`归属项目`,monitoringLabel:`跟进策略`,monitoringModes:{observe:`仅观察`,ask_before_action:`行动前询问`,auto_low_risk:`自动执行低风险操作`},existingProject:`已有项目`,newProject:`新项目`,needsAttention:`需要你处理`,waitingStatus:`当前等待`,runAttention:`运行异常`,running:`xopc 正在处理`,continue:`继续推进`,recent:`最近对话`,evidenceCount:`项证据`,remainingCount:`项待继续`,projects:`长期项目`,emptyRunning:`当前没有正在处理的对话`,emptyContinue:`还没有需要继续推进的事项`,openChat:`打开对话`,whyNow:`为什么现在`,impact:`影响`,workDone:`AI 已完成`,recommendation:`建议`,policyReason:`处理依据`,proposedAction:`拟执行动作`,actionStates:{not_authorized:`仅建议,未获自动执行授权`,approval_required:`等待你批准`,pending:`等待执行`,executing:`正在执行`,completed:`已自动执行`,rejected:`已拒绝`,failed:`执行失败`},judgmentReasons:`判断依据`,rejectedAlternatives:`未选方案`,uncertainty:`不确定性`,snooze:`明天再看`,dismiss:`忽略`,feedbackPlaceholder:`告诉 AI:以后遇到这类情况应该怎样判断…`,applyFeedback:`调整后续判断`,evidence:`证据引用`,useful:`有帮助`,notUseful:`没帮助`,taskStatuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`},taskProgress:{title:`xopc 已接手`,open:`查看结果`,decide:`查看并决定`,evidence:`项已验证依据`,statuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`}},detailStatuses:{captured:`尚未安排`,ready:`等待开始`,queued:`已进入队列`,running:`正在执行`,verifying:`正在验证`,waiting:`等待条件`,blocked:`被阻塞`,needsUser:`需要你处理`,review:`等待验收`,completed:`已完成`,ended:`已结束`,paused:`已暂停`},detailStatusDescriptions:{captured:`任务已记录,但尚未进入执行队列。安排后,xopc 会开始推进。`,ready:`任务已经准备好,可以交给 xopc 开始执行。`,queued:`任务已进入执行队列,xopc 将在资源可用时开始。`,running:`xopc 正在推进这个任务。`,verifying:`xopc 正在根据完成标准核验结果。`,waiting:`任务正在等待外部条件满足。`,blocked:`当前存在阻塞条件,解除后才能继续。`,needsUser:`xopc 需要你的输入或批准后才能继续。`,review:`执行结果已经准备好,等待你验收。`,completed:`任务已经完成并关闭。`,ended:`任务已经结束,不会继续执行。`,paused:`已暂停自动推进和催办。恢复后仍需满足其他等待条件。`},statusSummary:`当前状态`,taskLabel:`任务`,taskDescription:`任务描述与目标`,editTaskField:`编辑`,saveTaskField:`保存`,cancelTaskField:`取消`,noTaskDescription:`添加任务背景、范围和交付要求。`,taskProperties:`任务属性`,taskPhase:`阶段`,priority:`优先级`,dueDate:`截止日期`,executorLabel:`执行 Agent`,priorityLabels:{low:`低优先级`,normal:`普通优先级`,high:`高优先级`,critical:`紧急`},unassigned:`未指定执行者`,noDueDate:`无截止时间`,updatedAt:`更新于 {{date}}`,successDefinition:`怎样才算完成`,taskDefinition:`任务定义`,criteriaProgress:`{{verified}}/{{total}} 已验证`,taskRelations:`任务关系`,dependencies:`前置任务`,dependents:`后续任务`,noDependencies:`没有前置任务`,noDependents:`没有后续任务`,editDependencies:`编辑前置任务`,saveDependencies:`保存关系`,cancelDependencyEdit:`取消`,dependenciesDescription:`所选任务全部完成后,xopc 才会开始推进当前任务。`,linkDependencies:`关联前置任务`,linkedDependencies:`已关联 {{count}} 个前置任务`,dependencySearchPlaceholder:`搜索任务名称`,noDependencyMatches:`没有匹配的任务`,noDependencyCandidates:`没有可选的其他任务`,removeDependency:`移除前置任务:{{task}}`,dependencyUpdateFailed:`前置任务更新失败,请刷新后重试。`,expectedOutputs:`预期输出`,constraints:`约束与边界`,approvalRequired:`需要你批准`,latestResult:`最新结果`,remainingWork:`还差什么`,nextAction:`下一步`,yourDecision:`只需你决定`,noRemainingWork:`已覆盖全部完成标准。`,noDecisionNeeded:`暂时不需要你做任何事,xopc 会继续推进。`,contextUsed:`本次使用的上下文`,contextSources:`信息来源`,contextAssumptions:`当前假设`,contextRisks:`风险`,contextRoleLabels:{input:`输入`,reference:`参考`,constraint:`约束`,deliverable:`交付物`,evidence:`证据`},contextKindLabels:{document:`文档`,file:`文件`,url:`链接`,session:`对话`,memory:`记忆`,task:`任务`,artifact:`产物`,source:`来源`},currentTask:`当前任务`,executionHistory:`历史执行记录({{count}})`,receiptStatuses:{succeeded:`执行成功`,failed:`执行失败`,cancelled:`已取消`},unresolvedCriteria:`待验证标准`,resultFeedback:`这件事做好了吗?`,doneWell:`结果有帮助`,needsFix:`结果没帮助`,correctionPlaceholder:`告诉 xopc 哪里不对、你真正想要的结果是什么`,submitCorrection:`修正并继续`,feedbackThanks:`收到,我会据此继续改进。`,correctionStarted:`收到,已重新打开并开始修正。`,noDefinition:`系统正在进一步明确完成标准。未明确前不会把事情误判为已完成。`,backToWork:`返回任务列表`,openTaskConversation:`进入对话`,taskNotFound:`没有找到这个任务`,runTask:`开始推进`,scheduleTask:`安排执行`,scheduleRecurringTask:`定时执行`,approveTask:`确认完成`,reopenTask:`重新打开`,moreActions:`更多操作`,pauseTask:`暂停推进`,resumeTask:`继续推进`,cancelTask:`结束事项`,cancelActiveRun:`取消当前执行`,deleteTask:`永久删除任务`,deleteTaskTitle:`永久删除这个任务?`,deleteTaskDescription:`将永久删除“{{title}}”及其执行记录、上下文和回执。关联对话、工作区文件和外部产物不会被删除。`,confirmDeleteTask:`永久删除`,keepTask:`保留任务`,deleteActiveTaskBlocked:`请先结束当前执行,再永久删除任务。`,actionFailed:`操作失败,请重试。`,verificationStatuses:{passed:`已验证`,failed:`验证未通过`,unverified:`待验证`}}:{newWork:`Ask xopc`,dialogTitle:`What do you want to get done?`,dialogDescription:`This opens a new conversation. xopc will answer or start working, and create a task only when the work needs ongoing progress.`,intentLabel:`Tell xopc what you need`,intentPlaceholder:`For example: summarize this week’s meeting notes and suggest next week’s priorities`,intentSuggestion:`Summarize this week’s meeting notes and suggest next week’s priorities`,submit:`Open conversation and start`,projectLabel:`Project`,monitoringLabel:`Follow-up policy`,monitoringModes:{observe:`Observe only`,ask_before_action:`Ask before acting`,auto_low_risk:`Auto-run low-risk actions`},existingProject:`Existing project`,newProject:`New project`,needsAttention:`Needs your attention`,waitingStatus:`Current status`,runAttention:`Run issues`,running:`xopc is working`,continue:`Continue`,recent:`Recent conversations`,evidenceCount:`evidence items`,remainingCount:`remaining`,projects:`Long-term projects`,emptyRunning:`No conversations are running`,emptyContinue:`No ongoing items yet`,openChat:`Open conversation`,whyNow:`Why now`,impact:`Impact`,workDone:`AI checked`,recommendation:`Recommendation`,policyReason:`Policy decision`,proposedAction:`Proposed action`,actionStates:{not_authorized:`Suggested only; not authorized for auto-run`,approval_required:`Waiting for your approval`,pending:`Queued to run`,executing:`Running`,completed:`Auto-run completed`,rejected:`Rejected`,failed:`Execution failed`},judgmentReasons:`Why this is recommended`,rejectedAlternatives:`Alternatives not chosen`,uncertainty:`Uncertainty`,snooze:`Tomorrow`,dismiss:`Dismiss`,feedbackPlaceholder:`Tell AI how to judge this kind of event next time…`,applyFeedback:`Update future judgments`,evidence:`Evidence references`,useful:`Useful`,notUseful:`Not useful`,taskStatuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Blocked`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`},taskProgress:{title:`xopc owns this task`,open:`View task`,decide:`Review and decide`,evidence:`verified evidence`,statuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Needs you`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`}},detailStatuses:{captured:`Not scheduled`,ready:`Ready to start`,queued:`Queued`,running:`In progress`,verifying:`Verifying`,waiting:`Waiting`,blocked:`Blocked`,needsUser:`Needs your attention`,review:`Ready for review`,completed:`Completed`,ended:`Ended`,paused:`Paused`},detailStatusDescriptions:{captured:`This task is captured but has not entered the work queue. Schedule it when you are ready.`,ready:`This task is ready for xopc to start.`,queued:`This task is queued and will start when resources are available.`,running:`xopc is currently working on this task.`,verifying:`xopc is checking the result against the completion criteria.`,waiting:`This task is waiting for an external condition.`,blocked:`A blocking condition must be resolved before work can continue.`,needsUser:`xopc needs your input or approval before continuing.`,review:`The result is ready for your review.`,completed:`This task is complete and closed.`,ended:`This task has ended and will not continue.`,paused:`Automatic progress and reminders are paused. Other waiting conditions still apply after resuming.`},statusSummary:`Current status`,taskLabel:`Task`,taskDescription:`Description and objective`,editTaskField:`Edit`,saveTaskField:`Save`,cancelTaskField:`Cancel`,noTaskDescription:`Add background, scope, and delivery requirements.`,taskProperties:`Task properties`,taskPhase:`Phase`,priority:`Priority`,dueDate:`Due date`,executorLabel:`Agent`,priorityLabels:{low:`Low priority`,normal:`Normal priority`,high:`High priority`,critical:`Critical`},unassigned:`No assignee`,noDueDate:`No due date`,updatedAt:`Updated {{date}}`,successDefinition:`Definition of done`,taskDefinition:`Task definition`,criteriaProgress:`{{verified}}/{{total}} verified`,taskRelations:`Task relationships`,dependencies:`Dependencies`,dependents:`Dependent tasks`,noDependencies:`No dependencies`,noDependents:`No dependent tasks`,editDependencies:`Edit dependencies`,saveDependencies:`Save relationships`,cancelDependencyEdit:`Cancel`,dependenciesDescription:`xopc starts this task after every selected task is complete.`,linkDependencies:`Link dependencies`,linkedDependencies:`Linked dependencies: {{count}}`,dependencySearchPlaceholder:`Search tasks`,noDependencyMatches:`No matching tasks`,noDependencyCandidates:`There are no other tasks to select`,removeDependency:`Remove dependency: {{task}}`,dependencyUpdateFailed:`Dependencies could not be updated. Refresh and try again.`,expectedOutputs:`Expected outputs`,constraints:`Constraints and boundaries`,approvalRequired:`Your approval is required`,latestResult:`Latest result`,remainingWork:`What remains`,nextAction:`Next action`,yourDecision:`Your one decision`,noRemainingWork:`All completion criteria are covered.`,noDecisionNeeded:`Nothing is needed from you. xopc will keep moving this forward.`,contextUsed:`Context used for this task`,contextSources:`Sources`,contextAssumptions:`Current assumptions`,contextRisks:`Risks`,contextRoleLabels:{input:`Input`,reference:`Reference`,constraint:`Constraint`,deliverable:`Deliverable`,evidence:`Evidence`},contextKindLabels:{document:`Document`,file:`File`,url:`Link`,session:`Conversation`,memory:`Memory`,task:`Task`,artifact:`Artifact`,source:`Source`},currentTask:`Current task`,executionHistory:`Execution history ({{count}})`,receiptStatuses:{succeeded:`Succeeded`,failed:`Failed`,cancelled:`Cancelled`},unresolvedCriteria:`Criteria still to verify`,resultFeedback:`Was this done well?`,doneWell:`Helpful result`,needsFix:`Unhelpful result`,correctionPlaceholder:`Tell xopc what is wrong and what the right task should be`,submitCorrection:`Fix and continue`,feedbackThanks:`Got it. I will use this to improve future work.`,correctionStarted:`Got it. This was reopened and correction has started.`,noDefinition:`xopc is still clarifying the completion criteria. It will not mark this done before they are explicit.`,backToWork:`Back to tasks`,openTaskConversation:`Open conversation`,taskNotFound:`This task was not found`,runTask:`Start working`,scheduleTask:`Schedule work`,scheduleRecurringTask:`Schedule`,approveTask:`Mark complete`,reopenTask:`Reopen`,moreActions:`More actions`,pauseTask:`Pause`,resumeTask:`Continue`,cancelTask:`End task`,cancelActiveRun:`Cancel active run`,deleteTask:`Delete task permanently`,deleteTaskTitle:`Delete this task permanently?`,deleteTaskDescription:`This permanently deletes “{{title}}” and its execution records, context, and receipts. Linked conversations, workspace files, and external artifacts are kept.`,confirmDeleteTask:`Delete permanently`,keepTask:`Keep task`,deleteActiveTaskBlocked:`End the active run before deleting this task permanently.`,actionFailed:`The action failed. Please try again.`,verificationStatuses:{passed:`Verified`,failed:`Verification failed`,unverified:`Not verified`}}}var Vs=`task`;function Hs(e){return`/chat/task/${encodeURIComponent(e)}`}function Us(e,t){let[n,r=``]=e.split(`?`),i=new URLSearchParams(r);return i.set(Vs,t),`${n}?${i.toString()}`}function Ws(e,t){let n=new URLSearchParams(t);n.delete(Vs);let r=n.toString();return r?`${e}?${r}`:e}async function Gs(e,t){let n=Rt[e],r=n.input.parse(t),i=`/api/capabilities/operations/${encodeURIComponent(e)}`,a=await q(J(i)),o=await q(J(`${i}/invocations`),{method:`POST`,body:JSON.stringify({majorVersion:a.majorVersion,descriptorDigest:a.descriptorDigest,input:r})});return n.output.parse(o.data)}async function Ks(e){return Et.parse(await q(J(`/api/tasks`),{method:`POST`,body:JSON.stringify(e)}))}async function qs(e){return Gs(`xopc.tasks.get`,{id:e})}async function Js(e){return q(J(`/api/tasks/${encodeURIComponent(e)}/conversation`),{method:`POST`})}async function Ys(e,t,n){return await q(J(`/api/tasks/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({...t,expectedVersion:n})}),qs(e)}async function Xs(e){await q(J(`/api/tasks/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Zs(e,t,n,r=crypto.randomUUID()){return await q(J(`/api/tasks/${encodeURIComponent(e)}/commands`),{method:`POST`,body:JSON.stringify({idempotencyKey:r,expectedVersion:n,command:t})}),qs(e)}async function Qs(e,t,n){return await q(J(`/api/task-runs/${encodeURIComponent(t)}/cancel`),{method:`POST`,body:JSON.stringify({expectedVersion:n,reason:`Cancelled by user`})}),qs(e)}async function $s(e,t,n){return await q(J(`/api/tasks/${encodeURIComponent(e)}/handoff`),{method:`POST`,body:JSON.stringify({toAgentId:t,expectedVersion:n,idempotencyKey:crypto.randomUUID()})}),qs(e)}async function ec(e,t,n){return await q(J(`/api/tasks/${encodeURIComponent(e)}/dependencies`),{method:`PUT`,body:JSON.stringify({dependsOnTaskIds:t,expectedVersion:n})}),qs(e)}async function tc(e,t,n){return await q(J(`/api/tasks/${encodeURIComponent(e)}/board-position`),{method:`PUT`,body:JSON.stringify({beforeTaskId:t,expectedVersion:n})}),qs(e)}async function nc(e,t,n){await q(J(`/api/task-runs/${encodeURIComponent(e)}/feedback`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({rating:t,reason:n?.trim()||void 0})})}function rc(e){return q(J(`/api/home${e?`?locale=${encodeURIComponent(e)}`:``}`)).then(Vt)}function ic(e){return q(J(`/api/home/advisor/refresh`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),locale:e})})}function ac(){return q(J(`/api/home/advisor/history`)).then(e=>zt.parse(e))}async function oc(e,t){return It.parse(await q(J(`/api/home/opportunities/${encodeURIComponent(e.id)}/action`),{method:`POST`,body:JSON.stringify({idempotencyKey:crypto.randomUUID(),expectedRevision:e.revision,mode:t})}))}function sc(e,t){let n=crypto.randomUUID();return q(J(`/api/home/opportunities/${encodeURIComponent(e.id)}/feedback`),{method:`POST`,body:JSON.stringify({...t,idempotencyKey:n,expectedRevision:e.revision})}).then(()=>({ok:!0,idempotencyKey:n}))}function cc(e,t){return q(J(`/api/home/opportunities/${encodeURIComponent(e)}/feedback/undo`),{method:`POST`,body:JSON.stringify({idempotencyKey:t})})}function lc(e,t){return q(J(`/api/home/decisions/respond`),{method:`POST`,body:JSON.stringify({...e,decision:t})})}function uc(e){return q(J(`/api/home/attention/acknowledge`),{method:`POST`,body:JSON.stringify(e)})}function dc(e){return q(J(`/api/home/attention/retry`),{method:`POST`,body:JSON.stringify(e)})}function fc(e,t){return e?[`task-detail`,e,t??``]:null}function pc(e,t){return t.source!==`user`||e===void 0||t.version>e}function mc(e){let t=Se(e=>e.conversationId),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=(0,Z.useRef)(``),l=(0,Z.useRef)(void 0),u=Zt(fc(e,t),()=>qs(e),{keepPreviousData:!1,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshInterval:e=>e&&[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)?5e3:0});return l.current=u.data?.task.version,(0,Z.useEffect)(()=>{r(null),a(!1),s(null),c.current=``},[e]),(0,Z.useEffect)(()=>{let t=u.data;if(!t||t.conversation.activeConversationId)return;let n=`${e}:${t.task.version}`;c.current!==n&&(c.current=n,a(!0),s(null),Js(e).then(()=>c.current===n?u.mutate():void 0).catch(e=>{c.current===n&&s(e)}).finally(()=>{c.current===n&&a(!1)}))},[u.data,u.mutate,e]),(0,Z.useEffect)(()=>{let t,n=()=>{window.clearTimeout(t),t=window.setTimeout(()=>void u.mutate(),120)},i=t=>{let i=Dt.safeParse(t.detail);!i.success||i.data.taskId!==e||pc(l.current,i.data)&&(r(i.data),n())},a=()=>n();return window.addEventListener(`task-changed-v2`,i),window.addEventListener(`gateway-realtime-connected`,a),window.addEventListener(`realtime-gap`,a),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,i),window.removeEventListener(`gateway-realtime-connected`,a),window.removeEventListener(`realtime-gap`,a)}},[u.mutate,e]),{...u,lastChange:n,conversationLoading:i,conversationError:o}}function hc(e,t){return e===`closed`?`border-success/35 text-success`:t===`waiting`||t===`blocked`?`border-warning/40 text-warning`:`border-accent/40 text-accent`}var gc=(0,Z.memo)(function(e){let t=(0,Q.c)(50),{taskId:n}=e,r=b(),i=Ee(_c),a;t[0]===i?a=t[1]:(a=Bs(i),t[0]=i,t[1]=a);let o=a,{data:s}=mc(n);if(!s)return null;let{task:c,operationalState:l}=s,u=s.receipts[0],d=s.attention.length>0,f;t[2]!==l||t[3]!==c.phase?(f=c.phase!==`closed`&&[`queued`,`running`,`verifying`].includes(l),t[2]=l,t[3]=c.phase,t[4]=f):f=t[4];let p=f,m=d?s.attention[0]?.summary??u?.nextAction??u?.summary:c.phase===`closed`?u?.summary:u?.nextAction??u?.summary??o.noDecisionNeeded,h;t[5]===u?.evidence?h=t[6]:(h=u?.evidence.filter(vc).length??0,t[5]=u?.evidence,t[6]=h);let g=h,_=o.taskProgress.title,v;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(sa,{className:`size-4`,"aria-hidden":!0}),t[7]=v):v=t[7];let x;t[8]===p?x=t[9]:(x=p?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[8]=p,t[9]=x);let S;t[10]===x?S=t[11]:(S=(0,$.jsxs)(`span`,{className:`relative mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[v,x]}),t[10]=x,t[11]=S);let C;t[12]===o.taskProgress.title?C=t[13]:(C=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.taskProgress.title}),t[12]=o.taskProgress.title,t[13]=C);let w;t[14]!==l||t[15]!==c.phase?(w=K(`rounded-full border px-1.5 py-0.5 text-[10px] font-medium`,hc(c.phase,l)),t[14]=l,t[15]=c.phase,t[16]=w):w=t[16];let T;t[17]!==l||t[18]!==w||t[19]!==c.phase?(T=(0,$.jsxs)(`span`,{className:w,children:[c.phase,` · `,l]}),t[17]=l,t[18]=w,t[19]=c.phase,t[20]=T):T=t[20];let E;t[21]!==o.taskProgress.evidence||t[22]!==g?(E=g>0?(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[g,` `,o.taskProgress.evidence]}):null,t[21]=o.taskProgress.evidence,t[22]=g,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E||t[26]!==C?(D=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[C,T,E]}),t[24]=T,t[25]=E,t[26]=C,t[27]=D):D=t[27];let O;t[28]===c.title?O=t[29]:(O=(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-5 text-fg`,children:c.title}),t[28]=c.title,t[29]=O);let k;t[30]===m?k=t[31]:(k=m?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:m}):null,t[30]=m,t[31]=k);let A;t[32]!==D||t[33]!==O||t[34]!==k?(A=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[D,O,k]}),t[32]=D,t[33]=O,t[34]=k,t[35]=A):A=t[35];let j=`${r.pathname}${r.search}`,M;t[36]!==j||t[37]!==c.id?(M=Us(j,c.id),t[36]=j,t[37]=c.id,t[38]=M):M=t[38];let N=d?o.taskProgress.decide:o.taskProgress.open,P;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[39]=P):P=t[39];let F;t[40]!==M||t[41]!==N?(F=(0,$.jsxs)(y,{to:M,className:`inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[N,P]}),t[40]=M,t[41]=N,t[42]=F):F=t[42];let L;t[43]!==A||t[44]!==F||t[45]!==S?(L=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[S,A,F]}),t[43]=A,t[44]=F,t[45]=S,t[46]=L):L=t[46];let R;return t[47]!==o.taskProgress.title||t[48]!==L?(R=(0,$.jsx)(`section`,{className:`mb-6 rounded-xl border border-edge bg-surface-panel px-3 py-3 sm:px-4`,"aria-label":_,"aria-live":`polite`,children:L}),t[47]=o.taskProgress.title,t[48]=L,t[49]=R):R=t[49],R});function _c(e){return e.language}function vc(e){return e.strength===`verified`}var yc={transition:`transition-colors duration-150 ease-out`,press:`transition-transform duration-150 ease-out active:scale-95 motion-reduce:transition-none motion-reduce:active:scale-100`,pressCard:`transition-transform duration-150 ease-out active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:scale-100`,focusRingPanel:`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,focusRingBase:`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,disabled:`disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none`},bc=`touch-target rounded-lg p-2 text-fg-muted transition-colors transition-transform duration-150 ease-out hover:bg-surface-hover hover:text-fg active:scale-95 motion-reduce:transition-none motion-reduce:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`;function xc(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function Sc(e){let t=(0,Q.c)(8),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onAgentDecide:s,onCancel:c}=e;if(!n)return null;let l;return t[0]!==a||t[1]!==s||t[2]!==c||t[3]!==o||t[4]!==n||t[5]!==i||t[6]!==r?(l=(0,$.jsx)(Cc,{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onAgentDecide:s,onCancel:c},n.requestId),t[0]=a,t[1]=s,t[2]=c,t[3]=o,t[4]=n,t[5]=i,t[6]=r,t[7]=l):l=t[7],l}function Cc(e){let t=(0,Q.c)(70),{prompt:n,submitting:r,submitError:i,labels:a,onSubmit:o,onAgentDecide:s,onCancel:c}=e,[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(0),p=(0,Z.useRef)(null),m,h;t[0]===n.expiresAt?(m=t[1],h=t[2]):(m=()=>{if(!n.expiresAt)return;let e=window.setInterval(()=>f(wc),1e3);return()=>window.clearInterval(e)},h=[n.expiresAt],t[0]=n.expiresAt,t[1]=m,t[2]=h),(0,Z.useEffect)(m,h);let g,_;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p.current?.focus()},_=[],t[3]=g,t[4]=_):(g=t[3],_=t[4]),(0,Z.useEffect)(g,_);let v;t[5]===o?v=t[6]:(v=e=>{o(e)},t[5]=o,t[6]=v);let y=v,b=n.expiresAt?Math.max(0,Math.ceil((n.expiresAt-Date.now())/1e3)):null,x=`clarify-meta-${n.requestId}`,S=i?`clarify-err-${n.requestId}`:void 0,C;t[7]!==c||t[8]!==r?(C=e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),c())},t[7]=c,t[8]=r,t[9]=C):C=t[9];let w=C,T=Array.isArray(n.choices)&&n.choices.length>=2,E;t[10]!==a.clarifySuggestedChoice||t[11]!==n.suggestedAnswer?(E=n.suggestedAnswer?a.clarifySuggestedChoice.replace(`{{text}}`,n.suggestedAnswer):null,t[10]=a.clarifySuggestedChoice,t[11]=n.suggestedAnswer,t[12]=E):E=t[12];let D=E,O;t[13]!==a.clarifyTimeRemaining||t[14]!==b?(O=b===null?null:a.clarifyTimeRemaining.replace(`{{time}}`,xc(b)),t[13]=a.clarifyTimeRemaining,t[14]=b,t[15]=O):O=t[15];let k=O,A=a.clarifyRegionAria,j;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(j=K(`mb-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-sm outline-none`,yc.focusRingPanel),t[16]=j):j=t[16];let M;t[17]===a.clarifyResumeHint?M=t[18]:(M=(0,$.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:a.clarifyResumeHint}),t[17]=a.clarifyResumeHint,t[18]=M);let N;t[19]===n.question?N=t[20]:(N=(0,$.jsx)(ie,{content:n.question,compact:!0,className:`mb-3`}),t[19]=n.question,t[20]=N);let P=n.kind===`approval`?a.clarifyApprovalTimeout:a.clarifyDurableNote,F;t[21]===P?F=t[22]:(F=(0,$.jsx)(`li`,{children:P}),t[21]=P,t[22]=F);let I;t[23]===k?I=t[24]:(I=k?(0,$.jsx)(`li`,{children:k}):null,t[23]=k,t[24]=I);let L;t[25]!==x||t[26]!==F||t[27]!==I?(L=(0,$.jsxs)(`ul`,{id:x,className:`mb-3 list-inside list-disc space-y-1 text-xs text-fg-muted`,children:[F,I]}),t[25]=x,t[26]=F,t[27]=I,t[28]=L):L=t[28];let R;t[29]!==S||t[30]!==i?(R=i?(0,$.jsx)(`div`,{id:S,role:`alert`,className:`mb-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:i}):null,t[29]=S,t[30]=i,t[31]=R):R=t[31];let z;t[32]!==l||t[33]!==T||t[34]!==a.clarifyChoicesGroupAria||t[35]!==a.clarifyCustomLabel||t[36]!==a.clarifyPlaceholder||t[37]!==a.clarifySend||t[38]!==a.clarifyUseSuggested||t[39]!==o||t[40]!==y||t[41]!==n.choices||t[42]!==n.suggestedAnswer||t[43]!==r||t[44]!==D?(z=T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`max-h-[min(40vh,16rem)] overflow-y-auto overflow-x-hidden pr-1 [scrollbar-gutter:stable]`,"aria-label":a.clarifyChoicesGroupAria,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:[n.choices.map(e=>(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:r,className:K(`min-h-9 w-full justify-start rounded-lg px-3 py-2 text-left text-sm font-normal shadow-none`,`hover:border-edge`),onClick:()=>y(e),children:e},e)),n.suggestedAnswer?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:r,className:K(`min-h-9 w-full justify-start rounded-lg border border-dashed border-edge px-3 py-2 text-left text-sm font-normal text-fg-muted`,`hover:border-edge hover:text-fg`),onClick:()=>y(n.suggestedAnswer),children:D}):null]})}),(0,$.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:a.clarifyCustomLabel}),(0,$.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&o(t)},children:[(0,$.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:r||!l.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend})]})]})]}):(0,$.jsxs)(`form`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end`,onSubmit:e=>{e.preventDefault();let t=l.trim();t&&(o(t),u(``))},children:[(0,$.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:r,placeholder:a.clarifyPlaceholder,"aria-label":a.clarifyPlaceholder,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-3 py-2 text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent disabled:opacity-50`}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:r||!l.trim(),className:`shrink-0 rounded-lg px-4 py-2 shadow-surface`,children:a.clarifySend}),n.suggestedAnswer?(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:r,className:`shrink-0 rounded-lg px-3 py-2 text-sm font-normal text-fg-muted shadow-none hover:text-fg`,onClick:()=>y(n.suggestedAnswer),children:a.clarifyUseSuggested}):null]}),t[32]=l,t[33]=T,t[34]=a.clarifyChoicesGroupAria,t[35]=a.clarifyCustomLabel,t[36]=a.clarifyPlaceholder,t[37]=a.clarifySend,t[38]=a.clarifyUseSuggested,t[39]=o,t[40]=y,t[41]=n.choices,t[42]=n.suggestedAnswer,t[43]=r,t[44]=D,t[45]=z):z=t[45];let B;t[46]!==a.clarifyAgentDecide||t[47]!==s||t[48]!==n.kind||t[49]!==r?(B=n.kind===`input`&&s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:()=>void s(),children:a.clarifyAgentDecide}):null,t[46]=a.clarifyAgentDecide,t[47]=s,t[48]=n.kind,t[49]=r,t[50]=B):B=t[50];let V;t[51]===c?V=t[52]:(V=()=>void c(),t[51]=c,t[52]=V);let H;t[53]!==a.clarifyCancel||t[54]!==r||t[55]!==V?(H=(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:r,className:`text-fg-muted hover:text-fg`,onClick:V,children:a.clarifyCancel}),t[53]=a.clarifyCancel,t[54]=r,t[55]=V,t[56]=H):H=t[56];let U;t[57]!==B||t[58]!==H?(U=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle pt-3`,children:[B,H]}),t[57]=B,t[58]=H,t[59]=U):U=t[59];let W;return t[60]!==a.clarifyRegionAria||t[61]!==x||t[62]!==w||t[63]!==M||t[64]!==N||t[65]!==L||t[66]!==R||t[67]!==z||t[68]!==U?(W=(0,$.jsxs)(`section`,{ref:p,tabIndex:-1,"aria-label":A,"aria-describedby":x,onKeyDown:w,className:j,children:[M,N,L,R,z,U]}),t[60]=a.clarifyRegionAria,t[61]=x,t[62]=w,t[63]=M,t[64]=N,t[65]=L,t[66]=R,t[67]=z,t[68]=U,t[69]=W):W=t[69],W}function wc(e){return e+1}function Tc(e){if(typeof e==`string`)try{return Tc(JSON.parse(e))}catch{return null}return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Ec(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>t[n]??``)}function Dc(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)?.split(`.`).at(-1)??``}var Oc={automation:`automation`,browser_automation:`browser`,browser_use:`browser`,clarify:`clarification`,computer_use:`computer`,create_desktop_pet:`desktopPet`,create_share:`share`,delegate_task:`delegation`,image_generate:`imageGeneration`,image:`imageInspection`,language_diagnostics:`diagnostics`,managed_job:`job`,memory_maintenance:`memoryMaintenance`,knowledge_get:`memoryRead`,knowledge_write:`memoryUpdate`,user_context_get:`memoryRead`,user_context_update:`memoryUpdate`,publish_artifacts:`publish`,update_plan:`planning`,read_media:`mediaRead`,review_workspace:`review`,send_media:`mediaSend`,send_message:`message`,session_recall:`sessionRecall`,session_search:`sessionSearch`,session_status:`sessionStatus`,skill_install:`skillInstall`,skill_manage:`skillManage`,skills_marketplace_search:`skillSearch`,skills_list:`skillSearch`,skill_view:`skillView`,text_to_speech:`speech`,structured_output:`structuredOutput`,todo:`todo`,tool_manual:`manual`,web_extract:`webExtract`,workflow:`workflow`,xopc_require_connection:`connection`};function kc(e){let t=Dc(e);return t===`xopc_use`||t in Oc}var Ac=new Set([`list`,`get`,`get_card`,`history`,`list_milestones`,`list_updates`,`mail_sources`,`preview_edit`,`resolve_workspace`]),jc=new Set([`create`,`create_milestone`,`create_update`,`follow_up`,`start`]),Mc=new Set([`add_context`,`append`,`command`,`remove_context`,`update`,`update_dependencies`,`update_follow_up`,`update_milestone`]),Nc=new Set([`delete`]),Pc=new Set([`run`,`resume`]),Fc=new Set([`cancel`,`pause`]),Ic=new Set([`check`,`validate`]),Lc=new Set([`open`]),Rc=new Set([`continue_card`]);function zc(e){return Ac.has(e)?`inspect`:jc.has(e)?`create`:Mc.has(e)?`update`:Nc.has(e)?`remove`:Pc.has(e)?`run`:Fc.has(e)?`stop`:Ic.has(e)?`validate`:Lc.has(e)?`open`:Rc.has(e)?`continue`:`use`}function Bc(e,t){return e===`project`&&t.includes(`milestone`)?`milestone`:e===`project`&&t.includes(`update`)?`projectUpdate`:e===`project`?`project`:e===`automation`?`automation`:e===`note`?`note`:e===`task`?`task`:e===`task_run`?`taskRun`:e===`local_app`?`localApp`:e===`settings`?`settings`:e===`context`?`context`:e===`scene`?`scene`:e===`chat_preview`?`chatPreview`:`productItem`}function Vc(e){return(e.trim().split(`__`).at(-1)?.split(`.`).at(-1)??e.trim()).replace(/[-_]+/g,` `).replace(/\s+/g,` `).trim()||`tool`}var Hc={list:`inspect`,get:`inspect`,read:`inspect`,fetch:`inspect`,find:`inspect`,search:`inspect`,query:`inspect`,create:`create`,add:`create`,generate:`create`,install:`create`,update:`update`,edit:`update`,write:`update`,append:`update`,set:`update`,delete:`remove`,remove:`remove`,uninstall:`remove`,run:`run`,execute:`run`,start:`run`,trigger:`run`,stop:`stop`,cancel:`stop`,pause:`stop`,validate:`validate`,check:`validate`,test:`validate`,verify:`validate`,analyze:`validate`,review:`validate`,open:`open`,navigate:`open`,continue:`continue`,resume:`continue`};function Uc(e,t,n){let[r,...i]=Vc(e).split(` `),a=Hc[r.toLowerCase()],o=i.join(` `).trim();return!a||!o?null:Ec(n.actions[a][t],{object:o})}function Wc(e,t,n,r,i,a){let o=Dc(e);if(o===`xopc_use`){let e=Tc(t),i=typeof e?.mode==`string`?e.mode.trim().toLowerCase():``,a=typeof e?.command==`string`?e.command.trim().toLowerCase():``,o=zc(a),s=Bc(i,a);return Ec(r.actions[o][n],{object:r.objects[s]})}let s=Oc[o];if(s){let e=r.builtins[s][n],i=Tc(t),a=s===`skillView`?i?.name:void 0;return typeof a==`string`&&a.trim()?`${e} · ${a.trim().replace(/\s+/g,` `).slice(0,100)}`:e}let c=a??Ut(e,n===`running`?`running`:`completed`);return c.category!==`other`||c.action!==`use`?Kc(e,i,c):Uc(e,n,r)??Ec(r.fallback[n],{name:Vc(e)})}function Gc(e,t){if(e===`user_context_search`||e===`knowledge_search`)return`memorySearch`;let n=t??Ut(e,`running`);return n.category===`memory`&&n.action===`search`?`memorySearch`:n.category===`web`&&n.action===`search`?`webSearch`:n.category===`code`&&n.action===`search`?`codeSearch`:n.category===`other`&&n.action===`search`?`search`:n.category===`file`&&n.action===`read`?`readFile`:n.category===`file`&&n.action===`list`?`listDir`:n.category===`file`&&n.action===`write`?`writeFile`:n.category===`file`&&n.action===`edit`?`editFile`:n.category===`command`&&n.action===`execute`?`runCommand`:n.category===`navigation`&&n.action===`open`?`openUrl`:n.category===`web`&&n.action===`read`?`fetchUrl`:`other`}function Kc(e,t,n){let r=n??Ut(e,`running`);if(r.category===`planning`)return t.updatePlan??t.unknownTool.replace(`{{name}}`,e);let i=Gc(e,r);return i===`webSearch`?t.searchedWeb:i===`memorySearch`?t.searchedMemory??t.searched??t.searchedWeb:i===`codeSearch`?t.searchedCode??t.searched??t.searchedWeb:i===`search`?t.searched??t.searchedWeb:i===`readFile`?t.readFile:i===`runCommand`?t.runCommand:i===`listDir`?t.listDirectory:i===`writeFile`?t.writeFile:i===`editFile`?t.editFile:i===`openUrl`?t.openUrl:i===`fetchUrl`?t.fetchUrl:t.unknownTool.replace(`{{name}}`,e.trim()||`tool`)}function qc(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Jc(){return qc(await q(J(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Yc(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),qc(await q(J(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function Xc(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),qc(await q(J(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function Zc(e,t){return qc(await q(J(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Qc(e,t,n){let r=await q(J(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return rn(),qc(r,`Could not install Store connector.`).instance}async function $c(){return qc(await q(J(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function el(e,t){return qc(await q(J(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`,body:JSON.stringify({accountId:t})}),`Could not start connector authorization.`).authorization}async function tl(e,t=12e4){let n=Date.now()+t;for(;Date.now()<n;){let t=(await $c()).find(t=>t.instanceId===e);if(!t)throw Error(`Connector installation is unavailable.`);if(t.authStatus===`connected`)return t;if(t.status===`failed`||t.connectionStatus===`error`)throw Error(t.lastError??`Connector authorization failed.`);await new Promise(e=>window.setTimeout(e,1e3))}throw Error(`Connector authorization timed out.`)}async function nl(){return qc(await q(J(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function rl(e,t){qc(await q(J(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e,replaceBackendId:t})}),`Could not enable the connection service.`)}async function il(e){await q(J(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify(e)})}async function al(e){await q(J(`/api/connectors/composio/backends/${encodeURIComponent(e)}`),{method:`DELETE`})}async function ol(e){await q(J(`/api/connectors/composio/accounts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function sl(e,t){let n=await q(J(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return rn(),qc(n,`Could not install connector.`).instance}async function cl(e,t={}){return qc(await q(J(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function ll(e,t){return qc(await q(J(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function ul(e){await q(J(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),rn()}async function dl(e){return qc(await q(J(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function fl(){return qc(await q(J(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function pl(e){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/auth-configs`)),`Could not load Composio auth configs.`).auth}async function ml(e,t,n=12e4,r){let i=Date.now()+n,a=1500;for(;Date.now()<i;){if(r){let e=await hl(r);if(e.status===`failed`)throw Error(`Authorization failed or a different account was authorized. The original account was not changed.`);if(e.status===`expired`)throw Error(`Authorization expired. Start a new connection.`);if(e.status!==`succeeded`){await new Promise(e=>window.setTimeout(e,a)),a=Math.min(5e3,a*1.5);continue}}let n=(await fl().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function hl(e){return qc(await q(J(`/api/connectors/composio/authorizations/${encodeURIComponent(e)}`)),`Could not check authorization.`).attempt}async function gl(e,t){return qc(await q(J(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function _l(e,t){await q(J(`/api/connectors/composio/accounts/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})}async function vl(e){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function yl(e){await q(J(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function bl(e){await q(J(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function xl(e){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Sl(e,t){let n=await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return rn(),qc(n,`Could not update Composio scope.`).scope}async function Cl(e){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function wl(e,t){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function Tl(e){return qc(await q(J(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function El(e=50){return qc(await q(J(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function Dl(e){return qc(await q(J(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function Ol(){return qc(await q(J(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function kl(e){return qc(await q(J(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function Al(e,t){return qc(await q(J(`/api/connectors/composio/accounts/${encodeURIComponent(e)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update connector sync policy.`).policy}async function jl(e){return qc(await q(J(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function Ml(e=`pending`){return qc(await q(J(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function Nl(e,t){return qc(await q(J(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}async function Pl(e,t){let n=await q(J(`/api/connectors/${encodeURIComponent(e)}/${t?`enable`:`disable`}`),{method:`POST`});return rn(),qc(n,`Could not update connector state.`).instance}function Fl({voice:e,conversationId:t,m:n}){let r=Se(e=>e.conversationId),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(!1),s=(0,Z.useRef)(null),[c,l]=(0,Z.useState)(null),u=Zt(r?[`voice-approvals`,t,r]:null,()=>Ml(),{refreshInterval:3e3}),d=u.data?.filter(e=>e.conversationId===t)??[],f=async e=>{if(!o.current){o.current=!0,a(!0),l(null);try{await e()}catch(e){l(e instanceof Error?e.message:String(e))}finally{o.current=!1,a(!1)}}},p=(t,n)=>{let r=e.clarification;if(!r)return;let i=`${r.requestId}\n${r.version}\n${t}\n${n??``}`;return s.current?.signature!==i&&(s.current={signature:i,idempotencyKey:crypto.randomUUID()}),f(async()=>{await q(J(`/api/clarifications/${encodeURIComponent(r.requestId)}/responses`),{method:`POST`,body:JSON.stringify({action:t,answer:n,expectedVersion:r.version,idempotencyKey:s.current.idempotencyKey})}),s.current=null,e.dismissClarification(r.requestId)})};return(0,$.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[e.activities.map(e=>(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[Kc(e.toolName,{searchedWeb:n.stepSearchedWeb,searchedMemory:n.stepSearchedMemory,searchedCode:n.stepSearchedCode,readFile:n.stepReadFile,runCommand:n.stepRunCommand,listDirectory:n.stepListDirectory,writeFile:n.stepWriteFile,editFile:n.stepEditFile,openUrl:n.stepOpenUrl,fetchUrl:n.stepFetchUrl,unknownTool:n.stepUnknownTool}),` · `,e.status===`running`?n.callWorking:e.status===`failed`?n.callWorkFailed:n.callWorkDone]},e.toolCallId)),(0,$.jsx)(Sc,{prompt:e.clarification,labels:n,submitting:i,submitError:c,onSubmit:e=>p(`answer`,e),onAgentDecide:()=>p(`agent_decide`),onCancel:()=>p(`cancel`)}),d.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`p`,{className:`font-medium`,children:n.callApproval}),(0,$.jsx)(`p`,{children:e.actionId}),(0,$.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(e.argumentsPreview,null,2)}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:[`denied`,`approved`].map(t=>(0,$.jsx)(X,{variant:`secondary`,disabled:i,onClick:()=>void f(async()=>{await Nl(e.id,t),await u.mutate()}),children:t===`approved`?n.callApprove:n.callDeny},t))})]},e.id)),c&&!e.clarification?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600`,children:c}):null]})}var Il=Oe()(sn(e=>({captions:!0,microphoneId:``,setCaptions:t=>e({captions:t}),setMicrophoneId:t=>e({microphoneId:t})}),{name:`xopc-voice-preferences`}));function Ll(){let e=Il.getState().microphoneId;return{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,...e?{deviceId:{exact:e}}:{}}}function Rl(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var zl=`xopc.activity-center.v2`,Bl=80,Vl=720*60*60*1e3;function Hl(e){return e===`error`?`failed`:e===`warning`?`attention`:`done`}function Ul(){if(!(typeof window>`u`))return window.location.hash.replace(/^#/,``)||`${window.location.pathname}${window.location.search}`||void 0}function Wl(){try{let e=globalThis.localStorage?.getItem(zl);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t.items))return[];let n=Date.now()-Vl,r=t.items.filter(e=>e&&typeof e.id==`string`&&typeof e.title==`string`).filter(e=>Number.isFinite(e.updatedAt)&&e.updatedAt>=n).slice(0,Bl);return r.length!==t.items.length&&Gl(r),r}catch{return[]}}function Gl(e){try{globalThis.localStorage?.setItem(zl,JSON.stringify({items:e}))}catch{}}function Kl(e){return`${e.toString(36)}-${Math.random().toString(36).slice(2,8)}`}var ql=Oe(e=>({items:Wl(),add:t=>e(e=>{let n=t.title.trim();if(!n)return e;let r=Date.now(),i=t.tone??`info`,a=t.dedupeKey?e.items.findIndex(e=>e.dedupeKey===t.dedupeKey):-1,o=[{id:a>=0?e.items[a].id:Kl(r),tone:i,status:t.status??Hl(i),title:n,message:t.message?.trim()||void 0,source:t.source?.trim()||void 0,href:t.href??Ul(),dedupeKey:t.dedupeKey,createdAt:a>=0?e.items[a].createdAt:r,updatedAt:r,read:t.read??!1,occurrences:a>=0?e.items[a].occurrences+1:1},...a>=0?e.items.filter((e,t)=>t!==a):e.items].slice(0,Bl);return Gl(o),{items:o}}),markAllRead:()=>e(e=>{let t=e.items.map(e=>({...e,read:!0}));return Gl(t),{items:t}}),remove:t=>e(e=>{let n=e.items.filter(e=>e.id!==t);return Gl(n),{items:n}}),clearFinished:()=>e(e=>{let t=e.items.filter(e=>e.status!==`done`);return Gl(t),{items:t}}),clear:()=>{Gl([]),e({items:[]})}}));function Jl(e){ql.getState().add(e)}function Yl(e,t,n,r){let i=n?t.replace(/\{\{(\w+)\}\}/g,(e,t)=>String(n[t]??``)):t;Jl({tone:e,title:i,href:r?.href,dedupeKey:`action-feedback:${e}:${i}`})}var Xl=mt([`transcription`,`transcription.stream`,`speech`,`speech.stream`,`conversation`]),Zl=ot({protocolVersion:pt(1),serviceVersion:ut().int().positive(),modes:ft(Xl),transport:pt(`websocket-pcm`),inputFormat:ot({encoding:pt(`pcm_s16le`),sampleRate:pt(16e3),channels:pt(1)}),outputFormat:ot({encoding:pt(`pcm_s16le`),sampleRate:pt(24e3),channels:pt(1)}),turnDetection:ft(pt(`server_vad`)),bargeIn:lt(),tools:lt(),resumable:pt(!1),voices:ft(ot({id:Y().min(1),name:Y(),languages:ft(Y())})),defaultVoice:Y().min(1).optional(),limits:ot({maxFrameBytes:ut().int().positive().max(65536),maxSessionSeconds:ut().int().positive()})}),Ql=ot({mode:Xl,model:Y().min(1).max(200),voice:Y().min(1).max(200).optional()}),$l=ot({revision:Y().min(1),catalogVersion:Y().nullable(),selections:ft(Ql),models:ft(ot({id:Y(),name:Y(),voice:Zl}))}),eu=32,tu=1481592883,nu=3,ru=1,iu=2,au=1,ou=64*1024,su=new TextEncoder,cu=new TextDecoder(`utf-8`,{fatal:!0});function lu(e){let t=su.encode(e.id);if(!t.length||t.length>160||!Number.isInteger(e.connectionEpoch)||e.connectionEpoch<1||e.connectionEpoch>4294967295||!Number.isInteger(e.seq)||e.seq<1||e.seq>4294967295||!Number.isFinite(e.timestampMs)||e.timestampMs<0||e.durationMs!==20||e.flags<0||e.flags>3||!e.audio.length||e.audio.length%2||eu+t.length+e.audio.length>ou)throw Error(`Invalid voice media frame`);let n=new Uint8Array(eu+t.length+e.audio.length),r=new DataView(n.buffer);return r.setUint32(0,tu),r.setUint8(4,nu),r.setUint8(5,e.kind),r.setUint8(6,au),r.setUint8(7,e.flags),r.setUint32(8,e.connectionEpoch),r.setUint32(12,e.seq),r.setFloat64(16,e.timestampMs),r.setUint16(24,e.durationMs),r.setUint16(26,t.length),r.setUint32(28,e.audio.length),n.set(t,eu),n.set(e.audio,eu+t.length),n}function uu(e,t){if(e.length<=eu||e.length>ou)throw Error(`Invalid voice media frame`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint8(5),i=n.getUint32(8),a=n.getUint32(12),o=n.getFloat64(16),s=n.getUint16(24),c=n.getUint16(26),l=n.getUint32(28),u=eu+c,d=n.getUint8(7);if(n.getUint32(0)!==tu||n.getUint8(4)!==nu||r!==t||n.getUint8(6)!==au||d>3||!i||!a||!Number.isFinite(o)||o<0||s!==20||!c||c>160||!l||l%2||u+l!==e.length)throw Error(`Invalid voice media header`);return{kind:r,connectionEpoch:i,id:cu.decode(e.subarray(eu,u)),seq:a,timestampMs:o,durationMs:s,flags:d,audio:e.slice(u)}}function du(e){let t=uu(e,iu);return{connectionEpoch:t.connectionEpoch,responseId:t.id,seq:t.seq,mediaTimestampMs:t.timestampMs,durationMs:t.durationMs,audio:t.audio}}function fu(e){return lu({kind:ru,connectionEpoch:e.connectionEpoch,id:e.utteranceId,seq:e.audioSeq,timestampMs:e.capturedAtMonotonicMs,durationMs:e.durationMs,flags:!!e.start|(e.end?2:0),audio:e.audio})}var pu=class{session;eventSeq=0;audioSeq=0;ready=!1;closed=!1;cancelled=new Set;constructor(e){this.session=e}event(e){if(this.closed)throw Error(`Voice session closed`);if(e.sessionId!==this.session.sessionId||e.seq!==this.eventSeq+1)throw Error(`Invalid voice event sequence`);if(this.eventSeq=e.seq,e.type===`session.ready`){if(this.ready||e.payload.connectionEpoch!==this.session.connectionEpoch||e.payload.purpose!==this.session.purpose||e.payload.inputMode!==this.session.inputMode||e.payload.inputFormat.sampleRate!==this.session.inputFormat.sampleRate||e.payload.mode!==this.session.mode||e.payload.route.engine!==this.session.route.engine)throw Error(`Voice session mismatch`);this.ready=!0}e.type===`response.cancelled`&&this.cancel(e.payload.responseId),e.type===`session.closed`&&(this.ready=!1,this.closed=!0)}audio(e){if(!this.ready||e.connectionEpoch!==this.session.connectionEpoch||e.seq!==this.audioSeq+1)throw Error(`Invalid voice audio sequence`);return this.audioSeq=e.seq,!this.cancelled.has(e.responseId)}cancel(e){if(!this.cancelled.has(e)){if(this.cancelled.size>=1e4)throw Error(`Voice response limit exceeded`);this.cancelled.add(e)}}},mu=`/api/voice/realtime/v3/ws`,hu=64*1024,gu=15e3,_u=rt(),vu=ut().int().nonnegative(),yu=mt([`dictation`,`conversation`]),bu=mt([`natural`,`assistant`]),xu=pt(`server_vad`),Su=mt([`zh`,`en`]),Cu=ot({encoding:pt(`pcm_s16le`),sampleRate:ct([pt(16e3),pt(24e3)]),channels:pt(1)}),wu=ot({provider:Y().min(1).max(100),model:Y().min(1).max(200),managed:lt()}),Tu=it(`engine`,[ot({engine:pt(`dictation`),stt:wu}),ot({engine:pt(`agent`),stt:wu,tts:wu}),ot({engine:pt(`omni`),omni:wu})]),Eu=ot({available:lt(),reasonCode:mt([`VOICE_DISABLED`,`PROVIDER_UNAVAILABLE`]).optional()});ht({enabled:lt(),defaultMode:bu,omni:wu.nullable(),stt:wu.nullable(),tts:wu.extend({voice:Y().optional()}).nullable(),capabilities:ot({dictation:Eu,assistant:Eu,natural:Eu,languages:ft(Su),bargeIn:lt(),mediaTransports:dt([pt(`websocket-pcm`)])})}),ot({purpose:yu,mode:bu.optional(),conversationId:Y().min(1).max(512).optional(),language:Su.optional(),supportedProtocolVersions:dt([pt(3)]),mediaPreferences:dt([pt(`websocket-pcm`)])}).superRefine((e,t)=>{e.purpose===`conversation`&&!e.conversationId&&t.addIssue({code:`custom`,path:[`conversationId`],message:`conversationId is required for conversation`}),e.purpose!==`conversation`&&e.mode!==void 0&&t.addIssue({code:`custom`,path:[`mode`],message:`mode is only supported for conversation`})});var Du=ot({sessionId:_u,ticket:Y().min(32).max(512),ticketExpiresAt:gt(),websocketPath:pt(mu),protocolVersion:pt(3),connectionEpoch:ut().int().positive(),purpose:yu,mode:bu.optional(),inputMode:xu,bargeIn:lt(),inputFormat:Cu,media:ot({transport:pt(`websocket-pcm`),codec:pt(`pcm_s16le`),frameDurationMs:pt(20)}),limits:ot({maxBinaryFrameBytes:pt(hu),maxSessionMs:ut().int().positive(),idleTimeoutMs:ut().int().positive()}),route:Tu}),Ou=(e,t)=>ot({protocolVersion:pt(3),messageId:_u,type:pt(e),sentAt:vu,payload:t});it(`type`,[Ou(`session.start`,ot({sessionId:_u,ticket:Y().min(32).max(512)})),Ou(`session.metric`,ot({responseId:Y().min(1).max(160),metric:mt([`speech_end_to_audio_received`,`local_stop`]),durationMs:ut().finite().min(0).max(6e5)})),Ou(`input.mute`,ot({muted:lt()})),Ou(`input.commit`,ot({})),Ou(`response.stop_playback`,ot({responseId:Y().min(1).max(160)})),Ou(`task.cancel`,ot({taskId:Y().min(1).max(160)})),Ou(`response.audio.played`,ot({responseId:Y().min(1).max(160),playedDurationMs:ut().int().nonnegative().max(36e5)})),Ou(`session.stop`,ot({reason:mt([`user_finished`,`surface_closed`,`replaced`])})),Ou(`session.ping`,ot({}))]);var ku=ot({utteranceId:Y().min(1).max(160),revision:ut().int().positive(),text:Y().max(32*1024),language:Su.optional()}),Au=(e,t)=>ot({protocolVersion:pt(3),eventId:_u,seq:ut().int().positive(),type:pt(e),sentAt:vu,sessionId:_u,payload:t}),ju=it(`type`,[Au(`session.ready`,ot({purpose:yu,mode:bu.optional(),connectionEpoch:ut().int().positive(),inputMode:xu,inputFormat:Cu,media:ot({transport:pt(`websocket-pcm`),codec:pt(`pcm_s16le`),frameDurationMs:pt(20)}),route:Tu,heartbeatIntervalMs:pt(gu)})),Au(`input.speech_started`,ot({utteranceId:Y().min(1).max(160)})),Au(`input.speech_stopped`,ot({utteranceId:Y().min(1).max(160)})),Au(`input.transcript.delta`,ku),Au(`input.transcript.final`,ku),Au(`turn.decision`,ot({turnId:Y().min(1).max(160),disposition:mt([`complete`,`incomplete`,`backchannel`,`wait`]),confidence:ut().min(0).max(1),source:mt([`provider`,`semantic`,`heuristic`]),committed:lt()})),Au(`turn.committed`,ot({turnId:Y().min(1).max(160)})),Au(`response.created`,ot({responseId:Y().min(1).max(160)})),Au(`task.created`,ot({responseId:Y().min(1).max(160),taskId:Y().min(1).max(160)})),Au(`task.activity`,ot({taskId:Y().min(1).max(160),toolCallId:Y().min(1).max(160),toolName:Y().min(1).max(256),status:mt([`running`,`completed`,`failed`])})),Au(`task.done`,ot({taskId:Y().min(1).max(160),status:mt([`completed`,`failed`,`cancelled`,`suspended`])})),Au(`response.clarification`,ot({responseId:Y().min(1).max(160),requestId:Y().min(1).max(160),kind:mt([`input`,`approval`]),question:Y().min(1).max(8e3),choices:ft(Y().max(1e3)).max(20).optional(),suggestedAnswer:Y().max(1e3).optional(),version:ut().int().positive(),createdAt:ut().nonnegative(),expiresAt:ut().nonnegative().optional()})),Au(`response.text.delta`,ot({responseId:Y().min(1).max(160),delta:Y().max(32*1024)})),Au(`response.text.done`,ot({responseId:Y().min(1).max(160)})),Au(`response.audio.started`,ot({responseId:Y().min(1).max(160),format:Cu})),Au(`response.audio.done`,ot({responseId:Y().min(1).max(160)})),Au(`response.done`,ot({responseId:Y().min(1).max(160),finishReason:mt([`completed`,`text_only`,`audio_partial`]),audio:lt()})),Au(`response.cancelled`,ot({responseId:Y().min(1).max(160),reason:mt([`barge_in`,`client_cancelled`,`session_closed`])})),Au(`session.pong`,ot({})),Au(`session.error`,ot({code:Y().min(1).max(80),message:Y().min(1).max(500),recoverable:lt()})),Au(`session.closed`,ot({reason:Y().min(1).max(160)}))]);function Mu(e){return ju.parse(e)}function Nu(e,t){return{protocolVersion:3,messageId:crypto.randomUUID(),type:e,sentAt:Date.now(),payload:t}}function Pu(e){let t=new URL(J(e));return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}var Fu=class e{socket;session;receive;heartbeatId;inputRemainder=new Uint8Array;utteranceId=crypto.randomUUID();inputSeq=0;constructor(e,t){this.socket=e,this.session=t,this.receive=new pu(t)}static async preflight(e){await q(J(`/api/voice/realtime/preflight`),{method:`POST`,signal:e.signal,body:JSON.stringify({purpose:e.purpose,mode:e.mode,conversationId:e.conversationId,supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})})}static async connect(t){t.signal?.throwIfAborted();let n=await q(J(`/api/voice/realtime/sessions`),{method:`POST`,signal:t.signal,body:JSON.stringify({purpose:t.purpose,...t.mode?{mode:t.mode}:{},...t.conversationId?{conversationId:t.conversationId}:{},supportedProtocolVersions:[3],mediaPreferences:[`websocket-pcm`]})}),r=Du.parse(n.payload);t.signal?.throwIfAborted();let i=new WebSocket(Pu(r.websocketPath));i.binaryType=`arraybuffer`;let a=new e(i,r);return await new Promise((e,n)=>{let o=!1,s,c=e=>{o||(o=!0,s!==void 0&&window.clearTimeout(s),i.close(),n(e))};s=window.setTimeout(()=>c(Error(`Realtime voice connection timed out`)),15e3);let l=()=>{o?i.close():c(Error(`Realtime voice connection cancelled`))};if(t.signal?.addEventListener(`abort`,l,{once:!0}),i.addEventListener(`close`,()=>t.signal?.removeEventListener(`abort`,l),{once:!0}),t.signal?.aborted){l();return}i.onerror=()=>c(Error(`Realtime voice connection failed`)),i.onclose=e=>{o?t.onClose?.(e.reason):c(Error(e.reason||`Realtime voice connection closed`))},i.onopen=()=>{i.send(JSON.stringify(Nu(`session.start`,{sessionId:r.sessionId,ticket:r.ticket})))},i.onmessage=n=>{if(typeof n.data!=`string`){try{let e=du(new Uint8Array(n.data));a.receive.audio(e)&&t.onAudio?.(e.audio.slice().buffer,e.responseId)}catch{i.close(4400,`Invalid voice audio frame`)}return}try{let i=Mu(JSON.parse(n.data));if(a.receive.event(i),t.onEvent(i),i.type===`session.ready`&&!o){if(i.payload.connectionEpoch!==r.connectionEpoch||i.payload.mode!==r.mode)throw Error(`Voice session mismatch`);o=!0,window.clearTimeout(s),a.startHeartbeat(i.payload.heartbeatIntervalMs),e()}else i.type===`session.error`&&!i.payload.recoverable&&c(Error(i.payload.message))}catch(e){o?i.close(4400,`Invalid voice protocol frame`):c(e instanceof Error?e:Error(String(e)))}}}),a}sendAudio(e){if(!e.byteLength||this.socket.readyState!==WebSocket.OPEN)return;let t=new Uint8Array(e),n=new Uint8Array(this.inputRemainder.byteLength+t.byteLength);n.set(this.inputRemainder),n.set(t,this.inputRemainder.byteLength);let r=0;for(;r+640<=n.byteLength;){let e=fu({connectionEpoch:this.session.connectionEpoch,utteranceId:this.utteranceId,audioSeq:++this.inputSeq,capturedAtMonotonicMs:performance.now(),durationMs:20,...this.inputSeq===1?{start:!0}:{},audio:n.slice(r,r+640)});this.socket.send(e.buffer),r+=640}this.inputRemainder=n.slice(r)}reportMetric(e,t,n){this.sendControl(`session.metric`,{responseId:e,metric:t,durationMs:Math.min(6e5,Math.max(0,n))})}setInputMuted(e){this.sendControl(`input.mute`,{muted:e}),this.inputRemainder=new Uint8Array,e||(this.utteranceId=crypto.randomUUID(),this.inputSeq=0)}commit(){this.sendControl(`input.commit`,{})}cancelResponse(e){this.sendControl(`response.stop_playback`,{responseId:e})}acknowledgeAudio(e,t){this.sendControl(`response.audio.played`,{responseId:e,playedDurationMs:Math.floor(t/48)})}stop(e=`user_finished`){this.stopHeartbeat(),this.socket.readyState===WebSocket.OPEN?this.sendControl(`session.stop`,{reason:e}):this.socket.close()}sendControl(e,t){this.socket.readyState===WebSocket.OPEN&&(e===`response.stop_playback`&&`responseId`in t&&this.receive.cancel(t.responseId),this.socket.send(JSON.stringify(Nu(e,t))))}startHeartbeat(e){this.stopHeartbeat(),this.heartbeatId=window.setInterval(()=>this.sendControl(`session.ping`,{}),e),this.socket.addEventListener(`close`,()=>this.stopHeartbeat(),{once:!0})}stopHeartbeat(){this.heartbeatId!==void 0&&(window.clearInterval(this.heartbeatId),this.heartbeatId=void 0)}},Iu=1.7,Lu=class{context=new AudioContext({sampleRate:24e3});output=this.context.createGain();limiter=this.context.createDynamicsCompressor();sources=new Set;nextStartTime=0;hasStartedAudio=!1;constructor(){this.output.gain.value=Iu,this.limiter.threshold.value=-6,this.limiter.knee.value=6,this.limiter.ratio.value=12,this.limiter.attack.value=.003,this.limiter.release.value=.12,this.output.connect(this.limiter),this.limiter.connect(this.context.destination)}async start(){await this.context.resume()}get hasPendingAudio(){return this.sources.size>0}enqueue(e,t,n=24e3){if(e.byteLength<2||this.context.state===`closed`)return;let r=new DataView(e),i=new Float32Array(Math.floor(e.byteLength/2));for(let e=0;e<i.length;e+=1)i[e]=r.getInt16(e*2,!0)/32768;let a=this.context.createBuffer(1,i.length,n);a.copyToChannel(i,0);let o=this.context.createBufferSource();o.buffer=a,o.connect(this.output);let s=this.hasStartedAudio?.015:.08,c=Math.max(this.context.currentTime+s,this.nextStartTime);o.start(c),this.hasStartedAudio=!0,this.nextStartTime=c+a.duration,this.sources.add(o),o.onended=()=>{this.sources.delete(o)&&(o.disconnect(),t())}}duck(e){if(this.context.state===`closed`)return;let t=e?Iu*.15:Iu;this.output.gain.cancelScheduledValues(this.context.currentTime),this.output.gain.setTargetAtTime(t,this.context.currentTime,.015)}clear(){for(let e of this.sources){e.onended=null;try{e.stop()}catch{}e.disconnect()}this.sources.clear(),this.nextStartTime=this.context.currentTime,this.hasStartedAudio=!1,this.duck(!1)}async close(){this.clear(),this.output.disconnect(),this.limiter.disconnect(),this.context.state!==`closed`&&await this.context.close()}},Ru=`/assets/pcm-capture-worklet-uW_SEACy.js`,zu=16e3;function Bu(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];return Math.min(1,Math.sqrt(t/e.length))}function Vu(e,t,n=zu){if(t===n)return e;let r=Math.max(1,Math.round(e.length*n/t)),i=new Float32Array(r),a=t/n;for(let t=0;t<r;t+=1){let n=t*a,r=Math.min(e.length-1,Math.floor(n)),o=Math.min(e.length-1,r+1),s=n-r;i[t]=e[r]*(1-s)+e[o]*s}return i}function Hu(e,t=zu){let n=new ArrayBuffer(44+e.length*2),r=new DataView(n),i=(e,t)=>{for(let n=0;n<t.length;n+=1)r.setUint8(e+n,t.charCodeAt(n))};i(0,`RIFF`),r.setUint32(4,36+e.length*2,!0),i(8,`WAVE`),i(12,`fmt `),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),i(36,`data`),r.setUint32(40,e.length*2,!0);for(let t=0;t<e.length;t+=1){let n=Math.max(-1,Math.min(1,e[t]));r.setInt16(44+t*2,n<0?n*32768:n*32767,!0)}return n}function Uu(e){let t=new ArrayBuffer(e.length*2),n=new DataView(t);for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,r<0?r*32768:r*32767,!0)}return t}var Wu=class{sourceRate;targetRate;pending=new Float32Array;position=0;constructor(e,t=zu){if(this.sourceRate=e,this.targetRate=t,e<=0||t<=0)throw Error(`PCM sample rates must be positive`)}push(e){if(e.length===0)return new ArrayBuffer(0);let t=new Float32Array(this.pending.length+e.length);t.set(this.pending),t.set(e,this.pending.length);let n=this.sourceRate/this.targetRate,r=[];for(;this.position+1<t.length;){let e=Math.floor(this.position),i=this.position-e;r.push(t[e]*(1-i)+t[e+1]*i),this.position+=n}let i=Math.min(t.length-1,Math.floor(this.position));return this.pending=t.slice(i),this.position-=i,Uu(Float32Array.from(r))}flush(){if(this.pending.length===0)return new ArrayBuffer(0);let e=this.pending[Math.min(this.pending.length-1,Math.floor(this.position))];return this.pending=new Float32Array,this.position=0,Uu(Float32Array.of(e))}},Gu=`xopc-pcm-capture`,Ku=1e3,qu=class e{context;source;node;mutedOutput;options;sampleRate;paused=!1;accepting=!0;processorFailed=!1;stopPromise;flushResolve;constructor(e,t,n,r,i){this.context=e,this.source=t,this.node=n,this.mutedOutput=r,this.options=i,this.sampleRate=e.sampleRate,this.node.port.onmessage=e=>{if(e.data.type===`flushed`){this.flushResolve?.();return}if(!this.accepting||this.paused)return;let t=new Float32Array(e.data.buffer);if(this.options.onSamples(t),this.options.onAudioLevel){let e=Bu(t);this.options.onAudioLevel({level:e,speaking:e>=(this.options.speechThreshold??.015)})}},this.node.onprocessorerror=()=>{this.processorFailed=!0,this.flushResolve?.()}}static async start(t,n){if(typeof AudioWorkletNode>`u`)throw Error(`PCM audio recording is not supported in this browser`);let r=new AudioContext;try{await r.audioWorklet.addModule(Ru);let i=r.createMediaStreamSource(t),a=new AudioWorkletNode(r,Gu),o=r.createGain();o.gain.value=0;let s=new e(r,i,a,o,n);return i.connect(a),a.connect(o),o.connect(r.destination),await r.resume(),s}catch(e){throw await r.close().catch(()=>void 0),e}}pause(){this.paused=!0}resume(){this.paused=!1}stop(){return this.stopPromise??=this.finish(),this.stopPromise}cancel(){this.accepting&&(this.accepting=!1,this.flushResolve?.(),this.flushResolve=void 0,this.disconnect(),this.context.close().catch(()=>void 0))}async finish(){this.accepting&&(this.processorFailed||await this.flushWorklet(),this.flushResolve=void 0,this.accepting&&(this.accepting=!1,this.disconnect(),await this.context.close().catch(()=>void 0)))}flushWorklet(){return new Promise(e=>{let t=!1,n=()=>{t||(t=!0,globalThis.clearTimeout(r),e())},r=globalThis.setTimeout(n,Ku);this.flushResolve=n;try{this.node.port.postMessage(`flush`)}catch{n()}})}disconnect(){this.node.port.onmessage=null,this.node.onprocessorerror=null,this.source.disconnect(),this.node.disconnect(),this.mutedOutput.disconnect()}},Ju=null;function Yu(e){return Ju&&Ju!==e?!1:(Ju=e,!0)}function Xu(e){Ju===e&&(Ju=null)}function Zu(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function Qu(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function $u(e){return e===`requesting`||e===`starting`}async function ed(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function td(e){return e instanceof DOMException||e instanceof Error?e.name:``}function nd(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=td(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function rd(e){let{disabled:t,chat:n,onTranscript:r}=e,[i,a]=(0,Z.useState)(`idle`),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(`idle`),[S,C]=(0,Z.useState)(!1),w=(0,Z.useRef)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),N=(0,Z.useRef)(void 0),P=(0,Z.useRef)(null),[F,I]=(0,Z.useState)(`dictation`),L=(0,Z.useRef)(Symbol(`voice-capture`)),R=(0,Z.useRef)(`idle`),z=(0,Z.useRef)(0),B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useRef)(null),U=(0,Z.useRef)(void 0),W=(0,Z.useRef)(null),G=(0,Z.useRef)(null),ee=(0,Z.useRef)(null),te=(0,Z.useRef)(new Map),ne=(0,Z.useRef)(!1),re=(0,Z.useRef)(()=>{}),ie=(0,Z.useRef)(new Map),ae=(0,Z.useRef)(null),oe=(0,Z.useRef)(null),se=(0,Z.useRef)(!1),ce=(0,Z.useRef)(null),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)(0),de=(0,Z.useRef)(6e5),fe=(0,Z.useRef)(null),pe=(0,Z.useRef)(r);pe.current=r;let me=(0,Z.useCallback)(e=>{R.current=e,a(e)},[]),he=(0,Z.useCallback)(()=>{fe.current!=null&&(clearInterval(fe.current),fe.current=null)},[]),ge=(0,Z.useCallback)(()=>{G.current?.getTracks().forEach(e=>e.stop()),G.current=null},[]),_e=(0,Z.useCallback)(()=>{Xu(L.current),z.current+=1,P.current?.abort(),P.current=null,he(),ge(),B.current?.cancel(),B.current=null,V.current=null,H.current=null;let e=W.current;W.current=null,e?.close(),ee.current=null,s(0),l(0),d(``),p(``),h(``),x(`idle`),_([]),y(null),ce.current=null,w.current=!1,C(!1),A(!1),ie.current.clear(),te.current.clear(),ne.current=!1,ae.current=null,oe.current=null},[ge,he]),ve=(0,Z.useCallback)(()=>{_e(),me(`idle`)},[_e,me]),ye=(0,Z.useCallback)(()=>{H.current?.stop(`user_finished`),ve(),E(null),O(null),M(null)},[ve]),be=(0,Z.useCallback)(async()=>{if(ne.current)return;ne.current=!0;let e=z.current,t=[...te.current.values()].join(` `).trim();if(ge(),he(),B.current?.cancel(),B.current=null,me(`transcribing`),!t){Yl(`warning`,n.voiceTranscribeEmpty),ve();return}let r=t;try{let e=await q(J(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:t}),signal:AbortSignal.any([P.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(r=e.payload.text)}catch{if(e!==z.current)return;Yl(`warning`,n.voiceRefinementFailed)}e===z.current&&(pe.current(r),ve())},[ve,n.voiceRefinementFailed,n.voiceTranscribeEmpty,ge,he,me]),xe=(0,Z.useCallback)(e=>{M(e);let t=R.current;if(!(t===`idle`||t===`error`||ne.current)){if(!N.current){if(t===`transcribing`&&e===`input_committed`){be();return}he(),ge(),B.current?.cancel(),B.current=null,H.current=null,E(n.voiceTranscribeFailed),me(`error`);return}ve()}},[be,ve,n.voiceTranscribeFailed,ge,he,me]),K=(0,Z.useCallback)(()=>{he(),fe.current=setInterval(()=>{let e=ee.current;if(e===null)return;let t=performance.now()-e;if(s(Math.max(0,t/1e3)),t>=de.current&&R.current===`recording`){if(!N.current){re.current();return}M(`session_limit`),H.current?.stop(`user_finished`),ve()}},200)},[ve,he]),Se=(0,Z.useCallback)(async(e,r,i)=>{if(t||R.current!==`idle`||e===`conversation`&&!i)return;if(!Yu(L.current)){E(n.callCaptureBusy),e===`dictation`&&Yl(`error`,n.callCaptureBusy);return}N.current=i;let a=new AbortController;P.current=a,E(null),O(null),M(null);let o=++z.current,c=()=>o===z.current;I(e),U.current=r,h(``),me(`starting`);let u=`permission`;try{if(e===`conversation`){let e=new Lu;if(W.current=e,await e.start(),!c()){e.close();return}}if(u=`session`,await Fu.preflight({purpose:e,...e===`conversation`?{mode:r,conversationId:i}:{},signal:a.signal}),!c())return;u=`permission`;let t=window.electronAPI?.system,o=await ed();if(!c()||!$u(R.current))return;if(t&&o!==`granted`){me(`requesting`);let e=await t.requestMicrophone();if(!c())return;let n=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||n)throw Error(`Microphone permission denied`)}else !t&&o!==`granted`&&me(`requesting`);if(!c()||!$u(R.current))return;me(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),u=`media`;let f=await navigator.mediaDevices.getUserMedia({audio:Ll()});if(!c()||!$u(R.current)){f.getTracks().forEach(e=>e.stop());return}G.current=f,u=`session`,te.current.clear();let m=await Fu.connect({purpose:e,signal:a.signal,...e===`conversation`?{mode:r,conversationId:i}:{},onEvent:t=>{if(c()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!Rl(ie.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&d(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();d(``),p(n),n&&e===`dictation`&&(te.current.set(t.payload.utteranceId,n),[...te.current.values()].join(` `).length>=2e4&&R.current===`recording`&&re.current(),p([...te.current.values()].join(` `)))}if(t.type===`input.speech_stopped`&&(ce.current=performance.now(),W.current?.duck(!1)),t.type===`response.created`&&(W.current?.clear(),ae.current=t.payload.responseId,se.current=!1,le.current=!1,ue.current=0,h(``),_([]),y(null),x(`thinking`)),t.type===`task.created`&&ae.current===t.payload.responseId&&(oe.current=t.payload.taskId),t.type===`task.activity`&&oe.current===t.payload.taskId){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};_(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&oe.current===t.payload.taskId&&(oe.current=null,_([])),t.type===`response.clarification`&&ae.current===t.payload.responseId&&y(t.payload),t.type===`response.text.delta`&&ae.current===t.payload.responseId&&h(e=>e+t.payload.delta),t.type===`response.audio.started`&&ae.current===t.payload.responseId&&x(`speaking`),t.type===`response.done`&&ae.current===t.payload.responseId&&(se.current=!0,W.current?.hasPendingAudio||(ae.current=null,x(`idle`))),t.type===`response.cancelled`&&ae.current===t.payload.responseId&&(ae.current=null,x(`idle`),W.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&Yl(`warning`,n.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&Yl(`warning`,n.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let r=t.payload.code===`PROVIDER_UNAVAILABLE`,i=t.payload.code===`CONTEXT_CHANGED`?n.voiceContextChanged:r?n.voiceSttNotConfigured:t.payload.message;E(i),O(`session`),A(r),e===`dictation`&&Yl(`error`,i,void 0,r?{href:`/settings/capabilities/voice`}:void 0),H.current?.stop(`surface_closed`),e===`conversation`?_e():(he(),ge(),B.current?.cancel(),B.current=null,H.current=null),me(`error`)}}},onAudio:(e,t)=>{if(!c())return;let n=ae.current;!n||t!==n||(le.current||(le.current=!0,ce.current!==null&&H.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-ce.current),ce.current=null),W.current?.enqueue(e,()=>{ae.current===n&&(ue.current+=e.byteLength,H.current?.acknowledgeAudio(n,ue.current),se.current&&!W.current?.hasPendingAudio&&(ae.current=null,x(`idle`)))}))},onClose:e=>{c()&&xe(e)}});if(!c()){m.stop(`surface_closed`);return}H.current=m,de.current=m.session.limits.maxSessionMs,u=`recorder`;let g,v=[],b=await qu.start(f,{onSamples:e=>{if(!c()||w.current)return;if(!g){v.push(e);return}let t=(V.current??g).push(e);t&&m.sendAudio(t)},onAudioLevel:({level:t,speaking:n})=>{c()&&(w.current||(l(Math.min(1,t*8)),e===`conversation`&&m.session.bargeIn&&ae.current&&W.current?.duck(n)))}});if(!c()||!$u(R.current)){b.cancel(),m.stop(`surface_closed`),f.getTracks().forEach(e=>e.stop());return}g=new Wu(b.sampleRate,m.session.inputFormat.sampleRate);for(let e of v)m.sendAudio(g.push(e));V.current=g,B.current=b,ee.current=performance.now(),s(0),me(`recording`),K()}catch(t){if(!c())return;let r=nd(u,t);console.error(`[chat:voice] realtime capture start failed`,{stage:u,kind:r,errorName:td(t),errorMessage:t instanceof Error?t.message:String(t)}),H.current?.stop(`surface_closed`),_e(),me(r===`session`?`error`:`idle`);let i=r===`session`&&Zu(t),a=r===`permission`?n.voiceMicDenied:r===`device`?n.voiceMicUnavailable:r===`recorder`?n.voiceRecorderFailed:i?n.voiceSttNotConfigured:t instanceof Error?t.message:n.voiceSttNotConfigured;E(a),O(r),A(i),e===`dictation`&&Yl(`error`,a,void 0,i?{href:`/settings/capabilities/voice`}:void 0)}},[t,xe,n,_e,K,ge,he,me]),Ce=(0,Z.useCallback)(()=>{if(N.current)return;if(R.current===`error`&&te.current.size){be();return}if(R.current!==`recording`)return;me(`transcribing`),he(),ge();let e=B.current,t=z.current;B.current=null,e?.stop().then(()=>{if(t!==z.current)return;let e=V.current?.flush();e&&H.current?.sendAudio(e),H.current?.commit()}).catch(()=>{t===z.current&&(Yl(`error`,n.voiceTranscribeFailed),H.current?.stop(`surface_closed`),_e(),me(`error`))})},[be,n.voiceTranscribeFailed,_e,ge,he,me]);re.current=Ce,(0,Z.useEffect)(()=>()=>{Xu(L.current),z.current+=1,P.current?.abort(),B.current?.cancel(),H.current?.stop(`surface_closed`),W.current?.close(),ge(),he()},[ge,he]);let we=(0,Z.useCallback)(()=>{R.current===`error`&&(_e(),me(`idle`),Se(F,U.current,N.current))},[Se,F,_e,me]),Te=(0,Z.useCallback)(()=>Se(`dictation`),[Se]),Ee=(0,Z.useCallback)((e,t)=>Se(`conversation`,t,e),[Se]),De=(0,Z.useCallback)(()=>{let e=performance.now(),t=ae.current;W.current?.clear(),ae.current=null,x(`idle`),t&&(H.current?.reportMetric(t,`local_stop`,performance.now()-e),H.current?.cancelResponse(t))},[]),Oe=(0,Z.useCallback)(()=>{let e=!w.current;w.current=e,G.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=B.current,n=H.current;t&&n&&(V.current=new Wu(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),d(``),l(0),W.current?.duck(!1),C(e)},[]);return{phase:i,voiceActive:i!==`idle`,elapsedLabel:Qu(o),audioLevel:c,partialTranscript:u,finalTranscript:f,responseText:m,activities:g,clarification:v,dismissClarification:e=>y(t=>t?.requestId===e?null:t),responsePhase:b,muted:S,error:T,failureKind:D,settingsRequired:k,endedReason:j,mode:F,startVoiceInput:Te,startVoiceConversation:Ee,interruptResponse:De,toggleMute:Oe,cancelVoiceInput:ye,confirmVoiceInput:Ce,retryVoiceInput:we}}var id=(0,Z.createContext)(null);function ad(){let e=(0,Z.useContext)(id);if(!e)throw Error(`VoiceCallProvider is required`);return e}function od(e){let t=(0,Q.c)(154),{children:n}=e,r=Ee(fd),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i.chat,[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),f=Il(dd),p=Il(ud),m;t[2]===a?m=t[3]:(m={disabled:!1,chat:a,onTranscript:ld},t[2]=a,t[3]=m);let h=rd(m),g=(0,Z.useRef)(!1),_=(0,Z.useRef)(0),v=h.voiceActive&&h.phase!==`error`,b=h.phase===`recording`,x;t[4]!==v||t[5]!==h?(x=e=>{if(g.current||v)return;g.current=!0;let t=_.current+=1;h.cancelVoiceInput(),s(e),h.startVoiceConversation(e.conversationId).finally(()=>{t===_.current&&(g.current=!1)})},t[4]=v,t[5]=h,t[6]=x):x=t[6];let S=x,C=v?o?.conversationId??null:null,w;t[7]===S?w=t[8]:(w=e=>{S(e),l(!0)},t[7]=S,t[8]=w);let T;t[9]!==v||t[10]!==C||t[11]!==w?(T={active:v,conversationId:C,open:w},t[9]=v,t[10]=C,t[11]=w,t[12]=T):T=t[12];let E=T,D;t[13]!==v||t[14]!==b||t[15]!==a.callConnecting||t[16]!==a.callDisconnected||t[17]!==a.callFailed||t[18]!==a.callListening||t[19]!==a.callMicMuted||t[20]!==a.callReady||t[21]!==a.callWaiting||t[22]!==a.callWorking||t[23]!==a.voiceSpeaking||t[24]!==a.voiceThinking||t[25]!==h.activities||t[26]!==h.clarification||t[27]!==h.endedReason||t[28]!==h.error||t[29]!==h.muted||t[30]!==h.responsePhase?(D=h.error?a.callFailed:v?b?h.clarification?a.callWaiting:h.activities.some(cd)?a.callWorking:h.responsePhase===`speaking`?a.voiceSpeaking:h.responsePhase===`thinking`?a.voiceThinking:h.muted?a.callMicMuted:a.callListening:a.callConnecting:h.endedReason?a.callDisconnected:a.callReady,t[13]=v,t[14]=b,t[15]=a.callConnecting,t[16]=a.callDisconnected,t[17]=a.callFailed,t[18]=a.callListening,t[19]=a.callMicMuted,t[20]=a.callReady,t[21]=a.callWaiting,t[22]=a.callWorking,t[23]=a.voiceSpeaking,t[24]=a.voiceThinking,t[25]=h.activities,t[26]=h.clarification,t[27]=h.endedReason,t[28]=h.error,t[29]=h.muted,t[30]=h.responsePhase,t[31]=D):D=t[31];let O=D,k;t[32]===h?k=t[33]:(k=()=>{_.current+=1,g.current=!1,h.cancelVoiceInput(),s(null),l(!1),d(!1)},t[32]=h,t[33]=k);let A=k,j=`/settings/capabilities/voice?returnTo=${encodeURIComponent(`/chat/${encodeURIComponent(o?.conversationId??``)}`)}`,M;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>l(!1),t[34]=M):M=t[34];let N;t[35]!==a.callSettings||t[36]!==j?(N=(0,$.jsx)(y,{to:j,onClick:M,className:`text-sm text-accent-fg hover:underline`,children:a.callSettings}),t[35]=a.callSettings,t[36]=j,t[37]=N):N=t[37];let P=N,I;t[38]!==b||t[39]!==A||t[40]!==c||t[41]!==a.callEnd||t[42]!==a.callMute||t[43]!==a.callUnmute||t[44]!==a.voiceConversation||t[45]!==O||t[46]!==o||t[47]!==h.elapsedLabel||t[48]!==h.muted||t[49]!==h.toggleMute?(I=o&&!c?(0,$.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 flex max-w-[calc(100vw-2.5rem)] items-center gap-3 rounded-xl border border-edge bg-surface-panel p-3 shadow-float`,role:`region`,"aria-label":a.voiceConversation,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`min-w-0 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:o.name}),(0,$.jsxs)(`span`,{className:`block text-xs text-fg-muted`,children:[O,` · `,h.elapsedLabel]})]}),(0,$.jsx)(X,{variant:`ghost`,disabled:!b,onClick:h.toggleMute,"aria-label":h.muted?a.callUnmute:a.callMute,children:h.muted?(0,$.jsx)(mi,{className:`size-4`}):(0,$.jsx)(hi,{className:`size-4`})}),(0,$.jsx)(X,{variant:`ghost`,onClick:A,"aria-label":a.callEnd,children:(0,$.jsx)(Mi,{className:`size-4 text-red-500`})})]}):null,t[38]=b,t[39]=A,t[40]=c,t[41]=a.callEnd,t[42]=a.callMute,t[43]=a.callUnmute,t[44]=a.voiceConversation,t[45]=O,t[46]=o,t[47]=h.elapsedLabel,t[48]=h.muted,t[49]=h.toggleMute,t[50]=I):I=t[50];let L=!!(o&&c),R;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{e||l(!1)},t[51]=R):R=t[51];let z=o?.name,B;t[52]===z?B=t[53]:(B=(0,$.jsx)(tt,{className:`truncate font-medium`,children:z}),t[52]=z,t[53]=B);let V;t[54]===a.callSessionHint?V=t[55]:(V=(0,$.jsx)(Ze,{className:`text-xs text-fg-muted`,children:a.callSessionHint}),t[54]=a.callSessionHint,t[55]=V);let H;t[56]!==B||t[57]!==V?(H=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[B,V]}),t[56]=B,t[57]=V,t[58]=H):H=t[58];let U;t[59]===u?U=t[60]:(U=()=>d(!u),t[59]=u,t[60]=U);let W;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(F,{className:`size-4`}),t[61]=W):W=t[61];let G;t[62]!==a.callMore||t[63]!==u||t[64]!==U?(G=(0,$.jsx)(X,{variant:`ghost`,onClick:U,"aria-label":a.callMore,"aria-expanded":u,children:W}),t[62]=a.callMore,t[63]=u,t[64]=U,t[65]=G):G=t[65];let ee;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>l(!1),t[66]=ee):ee=t[66];let te;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(me,{className:`size-4`}),t[67]=te):te=t[67];let ne;t[68]===a.callMinimize?ne=t[69]:(ne=(0,$.jsx)(X,{variant:`ghost`,onClick:ee,"aria-label":a.callMinimize,children:te}),t[68]=a.callMinimize,t[69]=ne);let re;t[70]!==G||t[71]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex`,children:[G,ne]}),t[70]=G,t[71]=ne,t[72]=re):re=t[72];let ae;t[73]!==H||t[74]!==re?(ae=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[H,re]}),t[73]=H,t[74]=re,t[75]=ae):ae=t[75];let oe;t[76]!==f||t[77]!==a.callCaptions||t[78]!==u||t[79]!==p||t[80]!==P?(oe=u?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-4 py-2`,children:[(0,$.jsxs)(X,{variant:`ghost`,"aria-pressed":f,onClick:()=>p(!f),children:[(0,$.jsx)(sr,{className:`size-4`}),a.callCaptions]}),P]}):null,t[76]=f,t[77]=a.callCaptions,t[78]=u,t[79]=p,t[80]=P,t[81]=oe):oe=t[81];let se;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(Zn,{className:`size-10 text-accent-fg`,"aria-hidden":`true`}),t[82]=se):se=t[82];let ce;t[83]===O?ce=t[84]:(ce=(0,$.jsx)(`p`,{className:`text-lg font-medium`,role:`status`,children:O}),t[83]=O,t[84]=ce);let le=v?h.elapsedLabel:a.callContinuity,ue=b&&h.muted&&h.responsePhase!==`idle`?` · ${a.callMicMuted}`:``,de;t[85]!==le||t[86]!==ue?(de=(0,$.jsxs)(`p`,{className:`mt-1 text-xs tabular-nums text-fg-muted`,children:[le,ue]}),t[85]=le,t[86]=ue,t[87]=de):de=t[87];let fe;t[88]!==ce||t[89]!==de?(fe=(0,$.jsxs)(`div`,{children:[ce,de]}),t[88]=ce,t[89]=de,t[90]=fe):fe=t[90];let pe;t[91]!==a.callErrorDetails||t[92]!==h.error?(pe=h.error?(0,$.jsxs)(`details`,{className:`text-sm text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:a.callErrorDetails}),(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 break-words text-xs`,children:h.error})]}):null,t[91]=a.callErrorDetails,t[92]=h.error,t[93]=pe):pe=t[93];let he;t[94]!==v||t[95]!==a.callSetupHint||t[96]!==P||t[97]!==h.failureKind?(he=!v&&h.failureKind===`session`?(0,$.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:a.callSetupHint}),P]}):null,t[94]=v,t[95]=a.callSetupHint,t[96]=P,t[97]=h.failureKind,t[98]=he):he=t[98];let ge;t[99]!==f||t[100]!==b||t[101]!==a.callYou||t[102]!==o?.name||t[103]!==h.finalTranscript||t[104]!==h.partialTranscript||t[105]!==h.responseText?(ge=b&&f?(0,$.jsxs)(`div`,{className:`space-y-3 text-sm leading-relaxed`,children:[h.partialTranscript||h.finalTranscript?(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-fg-subtle`,children:a.callYou}),h.partialTranscript||h.finalTranscript]}):null,h.responseText?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`mb-1 block text-xs text-fg-subtle`,children:o?.name}),(0,$.jsx)(ie,{content:h.responseText,compact:!0,codeCopy:!1,renderMermaid:!1})]}):null]}):null,t[99]=f,t[100]=b,t[101]=a.callYou,t[102]=o?.name,t[103]=h.finalTranscript,t[104]=h.partialTranscript,t[105]=h.responseText,t[106]=ge):ge=t[106];let _e;t[107]===o?_e=t[108]:(_e=o?.taskId?(0,$.jsx)(gc,{taskId:o.taskId}):null,t[107]=o,t[108]=_e);let ve;t[109]!==b||t[110]!==a||t[111]!==o||t[112]!==h?(ve=b&&o?(0,$.jsx)(Fl,{voice:h,conversationId:o.conversationId,m:a},o.conversationId):null,t[109]=b,t[110]=a,t[111]=o,t[112]=h,t[113]=ve):ve=t[113];let ye;t[114]!==fe||t[115]!==pe||t[116]!==he||t[117]!==ge||t[118]!==_e||t[119]!==ve?(ye=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain px-5 py-5`,children:[se,fe,pe,he,ge,_e,ve]}),t[114]=fe,t[115]=pe,t[116]=he,t[117]=ge,t[118]=_e,t[119]=ve,t[120]=ye):ye=t[120];let be;t[121]!==v||t[122]!==b||t[123]!==a.callMute||t[124]!==a.callReconnect||t[125]!==a.callUnmute||t[126]!==a.voiceResponseInterrupt||t[127]!==S||t[128]!==o||t[129]!==h.interruptResponse||t[130]!==h.muted||t[131]!==h.responsePhase||t[132]!==h.toggleMute?(be=v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(X,{variant:`secondary`,disabled:!b,onClick:h.toggleMute,"aria-pressed":h.muted,children:[h.muted?(0,$.jsx)(mi,{className:`size-4`}):(0,$.jsx)(hi,{className:`size-4`}),h.muted?a.callUnmute:a.callMute]}),h.responsePhase===`idle`?null:(0,$.jsx)(X,{variant:`ghost`,onClick:h.interruptResponse,children:a.voiceResponseInterrupt})]}):(0,$.jsxs)(X,{variant:`primary`,onClick:()=>{o&&S(o)},children:[(0,$.jsx)(Ni,{className:`size-4`}),a.callReconnect]}),t[121]=v,t[122]=b,t[123]=a.callMute,t[124]=a.callReconnect,t[125]=a.callUnmute,t[126]=a.voiceResponseInterrupt,t[127]=S,t[128]=o,t[129]=h.interruptResponse,t[130]=h.muted,t[131]=h.responsePhase,t[132]=h.toggleMute,t[133]=be):be=t[133];let K;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(Mi,{className:`size-4 text-red-500`}),t[134]=K):K=t[134];let q;t[135]!==A||t[136]!==a.callEnd?(q=(0,$.jsxs)(X,{variant:`secondary`,onClick:A,children:[K,a.callEnd]}),t[135]=A,t[136]=a.callEnd,t[137]=q):q=t[137];let Se;t[138]!==be||t[139]!==q?(Se=(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-center gap-2 border-t border-edge px-3 pb-[max(.75rem,env(safe-area-inset-bottom))] pt-3`,children:[be,q]}),t[138]=be,t[139]=q,t[140]=Se):Se=t[140];let Ce;t[141]!==ae||t[142]!==oe||t[143]!==ye||t[144]!==Se?(Ce=(0,$.jsx)($e,{children:(0,$.jsxs)(et,{onInteractOutside:sd,className:`xopc-dialog-content-pane fixed bottom-3 right-3 z-[71] flex h-[min(480px,85dvh)] w-[min(380px,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay text-fg shadow-float focus:outline-none`,children:[ae,oe,ye,Se]})}),t[141]=ae,t[142]=oe,t[143]=ye,t[144]=Se,t[145]=Ce):Ce=t[145];let we;t[146]!==L||t[147]!==Ce?(we=(0,$.jsx)(nt,{open:L,onOpenChange:R,modal:!1,children:Ce}),t[146]=L,t[147]=Ce,t[148]=we):we=t[148];let Te;return t[149]!==n||t[150]!==E||t[151]!==I||t[152]!==we?(Te=(0,$.jsxs)(id.Provider,{value:E,children:[n,I,we]}),t[149]=n,t[150]=E,t[151]=I,t[152]=we,t[153]=Te):Te=t[153],Te}function sd(e){return e.preventDefault()}function cd(e){return e.status===`running`}function ld(){}function ud(e){return e.setCaptions}function dd(e){return e.captions}function fd(e){return e.language}var pd=`[-webkit-app-region:drag]`,md=`[-webkit-app-region:no-drag]`,hd=`h-14 shrink-0 items-center`;function gd(e){let t=(0,Q.c)(8),{alt:n,className:r,"aria-hidden":i}=e,a=n?.trim()?n:void 0,o=i??(a?void 0:!0),s;t[0]===r?s=t[1]:(s=K(`relative inline-block shrink-0 overflow-hidden`,r),t[0]=r,t[1]=s);let c,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`img`,{className:`size-full object-contain dark:hidden`,src:`/logo.svg`,alt:``,"aria-hidden":`true`}),l=(0,$.jsx)(`img`,{className:`hidden size-full object-contain dark:block`,src:`/logo-dark.svg`,alt:``,"aria-hidden":`true`}),t[2]=c,t[3]=l):(c=t[2],l=t[3]);let u;return t[4]!==o||t[5]!==a||t[6]!==s?(u=(0,$.jsxs)(`span`,{className:s,role:`img`,"aria-hidden":o,"aria-label":a,children:[c,l]}),t[4]=o,t[5]=a,t[6]=s,t[7]=u):u=t[7],u}var _d=`w-full max-w-md sm:max-w-lg`,vd=`w-full`,yd=`focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none focus-visible:border-edge data-[state=open]:border-edge`,bd=`focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none focus-visible:border-edge`,xd=`focus:outline-none focus-visible:outline-none focus:ring-0 focus:ring-offset-0 focus:shadow-none focus:border-edge-strong focus-visible:border-edge-strong`,Sd=`focus:outline-none focus-visible:outline-none focus:ring-0 focus:ring-offset-0 focus:shadow-none`,Cd=`inline-flex w-fit max-w-full min-w-[10rem] max-w-lg justify-between`,wd={showKey:!1,revealed:void 0,revealLoading:!1,revealErr:null,copied:!1};function Td(e,t){switch(t.type){case`reset-reveal`:return{...e,showKey:!1,revealed:void 0,revealErr:null};case`toggle-show`:return{...e,showKey:!e.showKey};case`reveal-start`:return{...e,revealLoading:!0,revealErr:null};case`reveal-success`:return{...e,revealed:t.value,revealLoading:!1,showKey:!0,revealErr:null};case`reveal-error`:return{...e,revealed:null,revealLoading:!1,revealErr:t.message};case`copied`:return{...e,copied:!0};case`clear-copied`:return{...e,copied:!1};case`invalidate-reveal`:return{...e,revealed:void 0,showKey:!1}}}function Ed(e){let{value:t,reveal:n,loadFailedLabel:r=`Failed to load secret`,baselineValue:i}=e,[a,o]=(0,Z.useReducer)(Td,wd),s=cn(t),c=!!(i?.trim()&&t===i&&!s),l=(0,Z.useRef)(n);l.current=n;let u=(0,Z.useRef)({masked:s,value:t,unchangedConcealed:c});(!s&&!c&&(u.current.masked||u.current.unchangedConcealed)||u.current.value!==t&&!c)&&o({type:`reset-reveal`}),u.current={masked:s,value:t,unchangedConcealed:c};let d=c&&!a.showKey?ln(t.length):s&&a.showKey&&typeof a.revealed==`string`?a.revealed:t,f=c&&!a.showKey?`password`:c&&a.showKey?`text`:s?a.showKey&&typeof a.revealed==`string`?`text`:`password`:a.showKey?`text`:`password`,p=c&&!a.showKey,m=c&&t.trim()||!s&&t.trim()&&!cn(t)?t.trim():typeof a.revealed==`string`&&a.revealed.length>0?a.revealed:``,h=m.length>0,g=(0,Z.useCallback)(async()=>{m&&await Yt(m)&&(o({type:`copied`}),window.setTimeout(()=>o({type:`clear-copied`}),2e3))},[m]),_=(0,Z.useCallback)(async()=>{if(c||!s){o({type:`toggle-show`});return}if(a.revealed!==void 0){o({type:`toggle-show`});return}if(!l.current){o({type:`toggle-show`});return}o({type:`reveal-start`});try{o({type:`reveal-success`,value:await l.current()})}catch(e){o({type:`reveal-error`,message:e instanceof Error?e.message:r})}},[r,s,c,a.revealed]),v=(0,Z.useCallback)((e,t)=>{p||(s&&typeof a.revealed==`string`&&a.showKey&&e!==a.revealed&&o({type:`invalidate-reveal`}),t(e))},[s,p,a.revealed,a.showKey]),y=a.revealLoading||!s&&!c&&!t.trim()||s&&!n&&a.revealed===void 0;return{masked:s,unchangedConcealed:c,showKey:a.showKey,revealed:a.revealed,revealLoading:a.revealLoading,revealErr:a.revealErr,copied:a.copied,inputValue:d,inputType:f,readOnly:p,copyEnabled:h,copySecret:g,toggleEye:_,onInputChange:v,eyeDisabled:y}}var Dd=K(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-3 pr-20 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,xd,`dark:border-edge`);function Od(e){let t=(0,Q.c)(69),{id:n,name:r,ariaDescribedBy:i,ariaInvalid:a,value:o,onChange:s,placeholder:c,disabled:l,readOnly:u,className:d,inputClassName:f,labels:p,reveal:m,loadFailedLabel:h,maskedHelp:g,notInConfigFile:_,baselineValue:v,autoComplete:y,onKeyDown:b,inputRef:x}=e,S=l===void 0?!1:l,C=u===void 0?!1:u,w=y===void 0?`off`:y,T;t[0]!==v||t[1]!==h||t[2]!==m||t[3]!==o?(T={value:o,reveal:m,loadFailedLabel:h,baselineValue:v},t[0]=v,t[1]=h,t[2]=m,t[3]=o,t[4]=T):T=t[4];let{masked:E,showKey:D,revealed:O,revealLoading:k,revealErr:A,copied:M,inputValue:P,inputType:F,readOnly:I,copyEnabled:R,copySecret:z,toggleEye:B,onInputChange:V,eyeDisabled:H}=Ed(T),U=C||I,W;t[5]===d?W=t[6]:(W=K(`flex flex-col gap-1.5`,d),t[5]=d,t[6]=W);let G;t[7]!==E||t[8]!==g?(G=E&&g?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g}):null,t[7]=E,t[8]=g,t[9]=G):G=t[9];let ee=a||void 0,te=E?void 0:c,ne;t[10]!==s||t[11]!==V?(ne=s?e=>V(e.target.value,s):void 0,t[10]=s,t[11]=V,t[12]=ne):ne=t[12];let re;t[13]===f?re=t[14]:(re=K(Dd,f),t[13]=f,t[14]=re);let ie;t[15]!==i||t[16]!==w||t[17]!==S||t[18]!==n||t[19]!==x||t[20]!==F||t[21]!==P||t[22]!==r||t[23]!==b||t[24]!==U||t[25]!==re||t[26]!==ee||t[27]!==te||t[28]!==ne?(ie=(0,$.jsx)(`input`,{ref:x,id:n,name:r,"aria-describedby":i,"aria-invalid":ee,type:F,autoComplete:w,spellCheck:!1,disabled:S,readOnly:U,value:P,placeholder:te,onChange:ne,onKeyDown:b,className:re}),t[15]=i,t[16]=w,t[17]=S,t[18]=n,t[19]=x,t[20]=F,t[21]=P,t[22]=r,t[23]=b,t[24]=U,t[25]=re,t[26]=ee,t[27]=te,t[28]=ne,t[29]=ie):ie=t[29];let ae;t[30]!==M||t[31]!==R||t[32]!==z||t[33]!==S||t[34]!==p.copied||t[35]!==p.copy?(ae=R?(0,$.jsx)(`button`,{type:`button`,className:K(`rounded p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel),title:M?p.copied:p.copy,"aria-label":M?p.copied:p.copy,disabled:S,onClick:()=>void z(),children:M?(0,$.jsx)(j,{className:`size-3.5`}):(0,$.jsx)(N,{className:`size-3.5`})}):null,t[30]=M,t[31]=R,t[32]=z,t[33]=S,t[34]=p.copied,t[35]=p.copy,t[36]=ae):ae=t[36];let oe;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(oe=K(`rounded p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg disabled:opacity-40`,yc.transition,yc.press,yc.focusRingPanel),t[37]=oe):oe=t[37];let se=D?p.hide:p.show,ce=D?p.hide:p.show,le=S||H,de;t[38]===B?de=t[39]:(de=()=>void B(),t[38]=B,t[39]=de);let fe;t[40]!==k||t[41]!==D?(fe=k?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):D?(0,$.jsx)(Ar,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t[40]=k,t[41]=D,t[42]=fe):fe=t[42];let pe;t[43]!==se||t[44]!==ce||t[45]!==le||t[46]!==de||t[47]!==fe?(pe=(0,$.jsx)(`button`,{type:`button`,className:oe,title:se,"aria-label":ce,disabled:le,onClick:de,children:fe}),t[43]=se,t[44]=ce,t[45]=le,t[46]=de,t[47]=fe,t[48]=pe):pe=t[48];let me;t[49]!==ae||t[50]!==pe?(me=(0,$.jsxs)(`div`,{className:`absolute right-1 top-1/2 flex -translate-y-1/2 gap-0.5`,children:[ae,pe]}),t[49]=ae,t[50]=pe,t[51]=me):me=t[51];let he;t[52]!==ie||t[53]!==me?(he=(0,$.jsxs)(`div`,{className:`relative min-w-0`,children:[ie,me]}),t[52]=ie,t[53]=me,t[54]=he):he=t[54];let ge;t[55]!==E||t[56]!==_||t[57]!==A||t[58]!==O||t[59]!==D?(ge=E&&D&&O===null&&!A&&_?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400/90`,children:_}):null,t[55]=E,t[56]=_,t[57]=A,t[58]=O,t[59]=D,t[60]=ge):ge=t[60];let _e;t[61]===A?_e=t[62]:(_e=A?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:A}):null,t[61]=A,t[62]=_e);let ve;return t[63]!==he||t[64]!==ge||t[65]!==_e||t[66]!==W||t[67]!==G?(ve=(0,$.jsxs)(`div`,{className:W,children:[G,he,ge,_e]}),t[63]=he,t[64]=ge,t[65]=_e,t[66]=W,t[67]=G,t[68]=ve):ve=t[68],ve}var kd={show:`Show`,hide:`Hide`,copy:`Copy`,copied:`Copied`};function Ad(e){return{show:e.show,hide:e.hide,copy:e.copy,copied:e.copied}}function jd(e){return Ad(e)}function Md(e){return{show:e.show,hide:e.hide,copy:`Copy`,copied:`Copied`}}async function Nd(e){try{let t=await De(e);if(t.ok){let e=await t.json();return e.conversationId?{status:`valid`,conversationId:e.conversationId}:{status:`failed`}}return{status:t.status===401||t.status===403?`rejected`:`failed`}}catch{return{status:`unreachable`}}}function Pd({baseUrl:e,onSubmit:t,footerLeft:n,className:r,tokenInputRef:i}){let a=Ee(e=>e.language),o=xe(a).token,[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=(0,Z.useRef)(null),m=(0,Z.useCallback)(e=>{p.current=e,typeof i==`function`?i(e):i&&(i.current=e)},[i]);async function h(){let e=s.trim();if(!e){u(a===`zh`?`请输入 Token`:`Please enter a token`),p.current?.focus();return}if(d)return;f(!0);let n=await Nd(e);if(f(!1),n.status!==`valid`){u(n.status===`rejected`?o.tokenRejected:n.status===`unreachable`?o.gatewayUnreachable:o.tokenVerificationFailed),p.current?.focus();return}t(n.conversationId),c(``),u(``)}return(0,$.jsxs)(`form`,{className:K(`flex flex-col gap-3`,r),"aria-busy":d,onSubmit:e=>{e.preventDefault(),h()},children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.gatewayUrl}),(0,$.jsx)(`output`,{className:`truncate rounded-md border border-edge bg-surface-hover px-3 py-2 font-mono text-sm text-fg-muted`,children:e})]}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a===`zh`?`网关访问凭据`:`Gateway access credential`}),(0,$.jsx)(Od,{id:`gateway-token`,name:`gateway-token`,inputRef:m,value:s,disabled:d,ariaDescribedBy:l?`gateway-token-error`:void 0,ariaInvalid:!!l,onChange:e=>{c(e),u(``)},placeholder:a===`zh`?`Token 或 Password`:`Token or password`,labels:Md(o)}),l?(0,$.jsx)(`p`,{id:`gateway-token-error`,className:`text-xs text-danger`,role:`alert`,children:l}):null]}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[n,(0,$.jsxs)(X,{type:`submit`,variant:`primary`,disabled:d,children:[d?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,d?o.connecting:o.save]})]})]})}var Fd=[`compact`,`default`,`large`];function Id(e){document.documentElement.dataset.fontScale=e}function Ld(){try{let e=localStorage.getItem(`xopc-web-font-scale`),t=`default`;if(e){let n=JSON.parse(e).state?.preference;n&&Fd.includes(n)&&(t=n)}Id(t)}catch{Id(`default`)}}var Rd=Oe(sn(e=>({preference:`default`,setPreference:t=>{Id(t),e({preference:t})}}),{name:`xopc-web-font-scale`}));function zd(){Id(Rd.getState().preference)}var Bd=`default`,Vd={light:{default:`#f7f8fa`,emerald:`#f0fdf4`,clay:`#fffaf0`,dawn:`#accdec`,porcelain:`#f6f0e7`},dark:{default:`#14171c`,emerald:`#000000`,clay:`#0a1a1a`,dawn:`#172433`,porcelain:`#211c19`}};function Hd(e,t){let n=document.head;if(!n)return;let r=n.querySelector(`meta[name="theme-color"][data-xopc-theme-color="true"]`);r||(r=document.createElement(`meta`),r.setAttribute(`name`,`theme-color`),r.setAttribute(`data-xopc-theme-color`,`true`),n.appendChild(r)),r.setAttribute(`content`,Vd[e][t])}function Ud(){return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1}function Wd(e){return e===`system`?Ud()?`dark`:`light`:e}function Gd(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function Kd(e){return e==="default"||e===`emerald`||e===`clay`||e===`dawn`||e===`porcelain`?e:Bd}function qd(e){window.electronAPI?.theme?.setPreference(e).catch(()=>{})}function Jd(e,t,n){let r=document.documentElement,i=()=>{r.classList.toggle(`dark`,e===`dark`),r.dataset.theme=e,r.dataset.colorScheme=t,Hd(e,t)},a=document;n&&!Gd()&&typeof a.startViewTransition==`function`?a.startViewTransition(i):i()}function Yd(){try{let e=localStorage.getItem(`xopc-web-theme`),t=`system`,n=Bd;if(e){let r=JSON.parse(e);r.state?.preference&&(t=r.state.preference),r.state&&`colorScheme`in r.state&&(n=Kd(r.state.colorScheme))}Jd(Wd(t),n,!1),qd(t)}catch{Jd(Wd(`system`),`default`,!1)}}var Xd=Oe(sn((e,t)=>({preference:`system`,colorScheme:Bd,resolved:Wd(`system`),setPreference:n=>{let r=Wd(n),{resolved:i,colorScheme:a}=t();Jd(r,a,r!==i),e({preference:n,resolved:r}),qd(n)},setColorScheme:n=>{let{resolved:r}=t();Jd(r,n,!0),e({colorScheme:n})}}),{name:`xopc-web-theme`,merge:(e,t)=>{let n=e??{};return{...t,...n,colorScheme:Kd(n.colorScheme)}}}));function Zd(){let{preference:e,colorScheme:t}=Xd.getState(),n=Wd(e);Jd(n,t,!1),Xd.setState({resolved:n}),qd(e)}function Qd(){let e=globalThis.matchMedia?.(`(prefers-color-scheme: dark)`);if(!e)return()=>{};let t=()=>{let{preference:e,colorScheme:t}=Xd.getState();if(e!==`system`)return;let n=Wd(`system`),r=Xd.getState().resolved;Jd(n,t,n!==r),Xd.setState({resolved:n})};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}var $d=[`language`,`theme`,`font`];function ef(e){let t=(0,Q.c)(59),{variant:n,sections:r}=e,i=r===void 0?$d:r,a=Ee(sf),o=Ee(of),s=Xd(af),c=Xd(rf),l=Rd(nf),u=Rd(tf),d;t[0]===a?d=t[1]:(d=xe(a),t[0]=a,t[1]=d);let f=d.appearanceSettings,p=n===`page`?`w-full max-w-[min(100%,12rem)] shrink-0 sm:ml-auto sm:w-auto sm:max-w-[11rem]`:n===`toolbar`?`w-auto min-w-[6.5rem] max-w-[10rem] shrink-0 sm:min-w-[7.5rem]`:`w-full`,m;t[2]===p?m=t[3]:(m=K(vd,p),t[2]=p,t[3]=m);let h=m,g=n===`page`?`flex flex-col gap-2 border-b border-edge-subtle px-4 py-3.5 last:border-b-0 sm:flex-row sm:items-center sm:justify-between sm:gap-6 sm:px-5 sm:py-4`:`flex flex-col gap-1.5`,_;t[4]===i?_=t[5]:(_=e=>i.includes(e),t[4]=i,t[5]=_);let v=_;if(n===`toolbar`){let e;t[6]!==f||t[7]!==a||t[8]!==h||t[9]!==o||t[10]!==v?(e=v(`language`)?(0,$.jsxs)(E,{className:h,value:a,"aria-label":f.languageTitle,onChange:e=>o(e.target.value),children:[(0,$.jsx)(O,{value:`en`,children:f.langOptionEn}),(0,$.jsx)(O,{value:`zh`,children:f.langOptionZh})]}):null,t[6]=f,t[7]=a,t[8]=h,t[9]=o,t[10]=v,t[11]=e):e=t[11];let n;t[12]!==f||t[13]!==h||t[14]!==c||t[15]!==v||t[16]!==s?(n=v(`theme`)?(0,$.jsxs)(E,{className:h,value:s,"aria-label":f.themeTitle,onChange:e=>c(e.target.value),children:[(0,$.jsx)(O,{value:`light`,children:f.themeOptionLight}),(0,$.jsx)(O,{value:`dark`,children:f.themeOptionDark}),(0,$.jsx)(O,{value:`system`,children:f.themeOptionSystem})]}):null,t[12]=f,t[13]=h,t[14]=c,t[15]=v,t[16]=s,t[17]=n):n=t[17];let r;t[18]!==f||t[19]!==l||t[20]!==h||t[21]!==u||t[22]!==v?(r=v(`font`)?(0,$.jsxs)(E,{className:h,value:l,"aria-label":f.fontScaleTitle,onChange:e=>u(e.target.value),children:[(0,$.jsx)(O,{value:`compact`,children:f.fontScaleCompact}),(0,$.jsx)(O,{value:`default`,children:f.fontScaleDefault}),(0,$.jsx)(O,{value:`large`,children:f.fontScaleLarge})]}):null,t[18]=f,t[19]=l,t[20]=h,t[21]=u,t[22]=v,t[23]=r):r=t[23];let i;return t[24]!==e||t[25]!==n||t[26]!==r?(i=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[e,n,r]}),t[24]=e,t[25]=n,t[26]=r,t[27]=i):i=t[27],i}let y=n===`sidebar`&&`flex flex-col gap-4`,b;t[28]===y?b=t[29]:(b=K(y),t[28]=y,t[29]=b);let x;t[30]!==f||t[31]!==a||t[32]!==g||t[33]!==h||t[34]!==o||t[35]!==v||t[36]!==n?(x=v(`language`)?(0,$.jsxs)(`div`,{className:g,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:f.languageTitle}),n===`page`?null:(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.languageDescription})]}),(0,$.jsxs)(E,{className:h,value:a,"aria-label":f.languageTitle,onChange:e=>o(e.target.value),children:[(0,$.jsx)(O,{value:`en`,children:f.langOptionEn}),(0,$.jsx)(O,{value:`zh`,children:f.langOptionZh})]})]}):null,t[30]=f,t[31]=a,t[32]=g,t[33]=h,t[34]=o,t[35]=v,t[36]=n,t[37]=x):x=t[37];let S;t[38]!==f||t[39]!==g||t[40]!==h||t[41]!==c||t[42]!==v||t[43]!==s||t[44]!==n?(S=v(`theme`)?(0,$.jsxs)(`div`,{className:g,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:f.themeTitle}),n===`page`?null:(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.themeDescription})]}),(0,$.jsxs)(E,{className:h,value:s,"aria-label":f.themeTitle,onChange:e=>c(e.target.value),children:[(0,$.jsx)(O,{value:`light`,children:f.themeOptionLight}),(0,$.jsx)(O,{value:`dark`,children:f.themeOptionDark}),(0,$.jsx)(O,{value:`system`,children:f.themeOptionSystem})]})]}):null,t[38]=f,t[39]=g,t[40]=h,t[41]=c,t[42]=v,t[43]=s,t[44]=n,t[45]=S):S=t[45];let C;t[46]!==f||t[47]!==l||t[48]!==g||t[49]!==h||t[50]!==u||t[51]!==v||t[52]!==n?(C=v(`font`)?(0,$.jsxs)(`div`,{className:g,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:f.fontScaleTitle}),n===`page`?null:(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:f.fontScaleDescription})]}),(0,$.jsxs)(E,{className:h,value:l,"aria-label":f.fontScaleTitle,onChange:e=>u(e.target.value),children:[(0,$.jsx)(O,{value:`compact`,children:f.fontScaleCompact}),(0,$.jsx)(O,{value:`default`,children:f.fontScaleDefault}),(0,$.jsx)(O,{value:`large`,children:f.fontScaleLarge})]})]}):null,t[46]=f,t[47]=l,t[48]=g,t[49]=h,t[50]=u,t[51]=v,t[52]=n,t[53]=C):C=t[53];let w;return t[54]!==C||t[55]!==b||t[56]!==x||t[57]!==S?(w=(0,$.jsxs)(`div`,{className:b,children:[x,S,C]}),t[54]=C,t[55]=b,t[56]=x,t[57]=S,t[58]=w):w=t[58],w}function tf(e){return e.setPreference}function nf(e){return e.preference}function rf(e){return e.setPreference}function af(e){return e.preference}function of(e){return e.setLanguage}function sf(e){return e.language}var cf={settingsImports:`imports`,settingsOverview:`overview`,settingsAppearance:`appearance`,settingsKeyboardShortcuts:`keyboard-shortcuts`,settingsSystem:`system`,settingsDesktopPet:`desktop-pet`,settingsDesktopApp:`desktop-app`,settingsAgentDefaults:`agent-defaults`,settingsGateway:`gateway`,settingsRuntimes:`runtimes`,settingsDevices:`devices`,settingsHeartbeat:`heartbeat`,settingsTunnel:`remote-access`,settingsShares:`shares`};function lf(e){return cf[e]??null}var uf=new Set([`settingsSystem`,`settingsDesktopPet`,`settingsDesktopApp`]),df={id:`system`,tabs:[`settingsSystem`,`settingsDesktopPet`,`settingsDesktopApp`]},ff=[{id:`general`,tabs:[`settingsOverview`,`settingsAppearance`,`settingsKeyboardShortcuts`]},{id:`capabilities`,tabs:[`settingsModels`,`settingsVoice`,`settingsSearch`,`settingsAgentDefaults`]},{id:`integrations`,tabs:[`settingsAgentBrowser`,`settingsComputerUse`]},{id:`connection`,tabs:[`settingsDevices`,`settingsTunnel`,`settingsShares`]},{id:`system`,tabs:[`settingsGateway`,`settingsRuntimes`,`settingsImports`,`sessions`,`logs`]}],pf=`https://xopcai.github.io/xopc`;function mf(e){return e===`zh`?`${pf}/zh/`:`${pf}/`}function hf(e,t){let n=t.replace(/^\/+/,``).replace(/\.md$/,``);return e===`zh`?`${pf}/zh/${n}`:`${pf}/${n}`}function gf(e,t){let n=hf(e,`remote-access`);return t?`${n}#${t}`:n}function _f(e){if(e===`settingsKeyboardShortcuts`)return`/settings/keyboard-shortcuts`;if(e===`settingsAgentBrowser`)return`/settings/agent-browser`;if(e===`settingsComputerUse`)return`/settings/computer-use`;if(e===`settingsModels`)return yf(`models`);if(e===`settingsVoice`)return yf(`voice`);if(e===`settingsSearch`)return yf(`search`);let t=lf(e);return t?`/settings/${t}`:e===`sessions`||e===`logs`?`/settings/${e}`:`/${e}`}var vf=[`models`,`image`,`voice`,`search`];function yf(e){return`/settings/capabilities/${e}`}function bf(e,t){return e===`settingsModels`?t===yf(`models`)||t===yf(`image`):t===_f(e)}function xf(){let e=(0,Q.c)(49),t=Se(Tf),n=Se(wf),r=Se(Cf),i=Ee(Sf),a;e[0]===i?a=e[1]:(a=xe(i),e[0]=i,e[1]=a);let o=a,s=o.gatewayLanding,c=o.appearanceSettings.pageTitle,l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ef,{variant:`toolbar`,sections:[`language`,`theme`]}),e[2]=l):l=e[2];let u;e[3]===c?u=e[4]:(u=(0,$.jsx)(`div`,{className:`flex h-14 shrink-0 items-center justify-end px-3 sm:px-4 ${pd}`,children:(0,$.jsx)(`div`,{className:md,role:`group`,"aria-label":c,children:l})}),e[3]=c,e[4]=u);let d;e[5]===o.appBrand?d=e[6]:(d=(0,$.jsx)(gd,{className:`size-14 shrink-0`,alt:o.appBrand}),e[5]=o.appBrand,e[6]=d);let f;e[7]===s.headline?f=e[8]:(f=(0,$.jsx)(`h1`,{className:`text-balance text-xl font-semibold tracking-tight text-fg`,children:s.headline}),e[7]=s.headline,e[8]=f);let p;e[9]===s.subline?p=e[10]:(p=(0,$.jsx)(`p`,{className:`max-w-md text-sm leading-relaxed text-fg-muted`,children:s.subline}),e[9]=s.subline,e[10]=p);let m;e[11]!==d||e[12]!==f||e[13]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[d,f,p]}),e[11]=d,e[12]=f,e[13]=p,e[14]=m):m=e[14];let h;e[15]!==s.sessionExpired||e[16]!==n?(h=n?(0,$.jsx)(`div`,{className:`mt-5 rounded-lg border border-danger/30 bg-danger/10 px-3 py-2.5 text-sm text-fg`,role:`status`,children:s.sessionExpired}):null,e[15]=s.sessionExpired,e[16]=n,e[17]=h):h=e[17];let g;e[18]!==t||e[19]!==r?(g=(0,$.jsx)(Pd,{baseUrl:t,onSubmit:r,className:`mt-6`}),e[18]=t,e[19]=r,e[20]=g):g=e[20];let _;e[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(cr,{className:`size-4 shrink-0 transition-transform duration-150 group-open:rotate-180`,"aria-hidden":!0}),e[21]=_):_=e[21];let v;e[22]===s.tokenHelpSummary?v=e[23]:(v=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 font-medium text-fg hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.tokenHelpSummary,_]}),e[22]=s.tokenHelpSummary,e[23]=v);let y;e[24]===s.tokenHelpOnboard?y=e[25]:(y=(0,$.jsx)(`p`,{children:s.tokenHelpOnboard}),e[24]=s.tokenHelpOnboard,e[25]=y);let b;e[26]===s.tokenHelpLink?b=e[27]:(b=(0,$.jsx)(`p`,{children:s.tokenHelpLink}),e[26]=s.tokenHelpLink,e[27]=b);let x;e[28]!==y||e[29]!==b?(x=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 leading-relaxed`,children:[y,b]}),e[28]=y,e[29]=b,e[30]=x):x=e[30];let S;e[31]!==v||e[32]!==x?(S=(0,$.jsxs)(`details`,{className:`group mt-6 border-t border-edge-subtle pt-4 text-sm text-fg-muted`,children:[v,x]}),e[31]=v,e[32]=x,e[33]=S):S=e[33];let C;e[34]===i?C=e[35]:(C=hf(i,`gateway`),e[34]=i,e[35]=C);let w;e[36]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(I,{className:`size-3.5 opacity-80`,"aria-hidden":!0}),e[36]=w):w=e[36];let T;e[37]!==s.docsGatewayLink||e[38]!==C?(T=(0,$.jsx)(`div`,{className:`mt-5 flex justify-center text-sm`,children:(0,$.jsxs)(`a`,{href:C,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent hover:underline`,children:[s.docsGatewayLink,w]})}),e[37]=s.docsGatewayLink,e[38]=C,e[39]=T):T=e[39];let E;e[40]!==S||e[41]!==T||e[42]!==m||e[43]!==h||e[44]!==g?(E=(0,$.jsx)(`main`,{id:`app-main-content`,className:`flex flex-1 flex-col items-center justify-center px-4 py-10 sm:px-6`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-edge bg-surface-panel p-6 shadow-popover sm:p-8`,children:[m,h,g,S,T]})}),e[40]=S,e[41]=T,e[42]=m,e[43]=h,e[44]=g,e[45]=E):E=e[45];let D;return e[46]!==E||e[47]!==u?(D=(0,$.jsxs)(`div`,{className:`relative flex min-h-full flex-1 flex-col bg-surface-base`,children:[u,E]}),e[46]=E,e[47]=u,e[48]=D):D=e[48],D}function Sf(e){return e.language}function Cf(e){return e.setBrowserSession}function wf(e){return e.tokenExpired}function Tf(e){return e.baseUrl}function Ef(){return An()?window.electronAPI?.platform??`web`:`web`}function Df({runtime:e,sidebarCollapsed:t,mobileNavOpen:n}){let r=e===`darwin`,i=e===`linux`,a=e===`web`,o=a||i||r&&!t&&!n;return{sidebarChromeVisible:o||n,sidebarQuickActionsVisible:o,sidebarChromeDraggable:r,sidebarLeadingInsetClass:r?`pl-[88px]`:``,mainHeaderDraggable:r,mainHeaderQuickActionsVisible:(a||i)&&t||r&&t&&!n,mainHeaderLeadingInsetClass:r&&t?`pl-[88px]`:``,collapsedNewChatVisible:a&&t}}var Of=(0,Z.memo)(function(e){let t=(0,Q.c)(8),{className:n}=e,r=Ee(kf),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=K(`size-8 shrink-0 rounded-xl p-0`,md,n),t[2]=n,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(ve,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==a.titleBarCommandPalette||t[6]!==o?(c=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:o,title:a.titleBarCommandPalette,"aria-label":a.titleBarCommandPalette,onClick:Af,children:s}),t[5]=a.titleBarCommandPalette,t[6]=o,t[7]=c):c=t[7],c});function kf(e){return e.language}function Af(){return window.dispatchEvent(new CustomEvent(`open-command-palette`))}function jf(e,t,n){if(!e)return{entries:[t],index:0};if(e.entries[e.index]===t)return e;if(n===`PUSH`){let n=[...e.entries.slice(0,e.index+1),t];return{entries:n,index:n.length-1}}if(n===`REPLACE`){let n=[...e.entries];return n[e.index]=t,{entries:n,index:e.index}}let r=e.entries.indexOf(t);return r>=0?{entries:e.entries,index:r}:{entries:[t],index:0}}var Mf;function Nf(){let e=(0,Q.c)(10),t=b(),n=g(),r;e[0]!==t.key||e[1]!==n?(r=()=>(Mf=jf(Mf,t.key,n),Mf),e[0]=t.key,e[1]=n,e[2]=r):r=e[2];let[i,a]=(0,Z.useState)(r),o,s;e[3]!==t.key||e[4]!==n?(o=()=>{Mf=jf(Mf,t.key,n),a(Mf)},s=[t.key,n],e[3]=t.key,e[4]=n,e[5]=o,e[6]=s):(o=e[5],s=e[6]),(0,Z.useLayoutEffect)(o,s);let c=i.index>0,l=i.index<i.entries.length-1,u;return e[7]!==c||e[8]!==l?(u={canGoBack:c,canGoForward:l},e[7]=c,e[8]=l,e[9]=u):u=e[9],u}var Pf=(0,Z.memo)(function(e){let t=(0,Q.c)(24),{className:n}=e,r=Ee(Ff),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i,o=l(),{canGoBack:s,canGoForward:c}=Nf();if(!An())return null;let u;t[2]===n?u=t[3]:(u=K(`flex shrink-0 items-center gap-0.5`,n),t[2]=n,t[3]=u);let d=!s,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=K(`size-7 shrink-0 rounded-md p-0`,md),t[4]=f):f=t[4];let p;t[5]===o?p=t[6]:(p=()=>o(-1),t[5]=o,t[6]=p);let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Jn,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}),t[7]=m):m=t[7];let h;t[8]!==a.historyBack||t[9]!==d||t[10]!==p?(h=(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:d,className:f,title:a.historyBack,"aria-label":a.historyBack,onClick:p,children:m}),t[8]=a.historyBack,t[9]=d,t[10]=p,t[11]=h):h=t[11];let g=!c,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=K(`size-7 shrink-0 rounded-md p-0`,md),t[12]=_):_=t[12];let v;t[13]===o?v=t[14]:(v=()=>o(1),t[13]=o,t[14]=v);let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Yn,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}),t[15]=y):y=t[15];let b;t[16]!==a.historyForward||t[17]!==v||t[18]!==g?(b=(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:g,className:_,title:a.historyForward,"aria-label":a.historyForward,onClick:v,children:y}),t[16]=a.historyForward,t[17]=v,t[18]=g,t[19]=b):b=t[19];let x;return t[20]!==b||t[21]!==u||t[22]!==h?(x=(0,$.jsxs)(`div`,{className:u,children:[h,b]}),t[20]=b,t[21]=u,t[22]=h,t[23]=x):x=t[23],x});function Ff(e){return e.language}var If=(0,Z.memo)(function(e){let t=(0,Q.c)(8),{className:n}=e,r=Ee(Lf),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i.notes,o;t[2]===n?o=t[3]:(o=K(`size-8 shrink-0 rounded-xl p-0`,md,n),t[2]=n,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(oa,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==a.quickCapturePlaceholder||t[6]!==o?(c=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:o,title:a.quickCapturePlaceholder,"aria-label":a.quickCapturePlaceholder,onClick:Rf,children:s}),t[5]=a.quickCapturePlaceholder,t[6]=o,t[7]=c):c=t[7],c});function Lf(e){return e.language}function Rf(){return window.dispatchEvent(new CustomEvent(`open-quick-capture`))}var zf=`xopc-web-sidebar-collapsed`,Bf=`xopc-web-sidebar-expanded-width-px`;function Vf(){try{return globalThis.localStorage?.getItem(zf)===`1`}catch{return!1}}function Hf(e){try{globalThis.localStorage?.setItem(zf,e?`1`:`0`)}catch{}}function Uf(e){return Math.min(480,Math.max(248,Math.round(e)))}function Wf(){try{let e=globalThis.localStorage?.getItem(Bf);if(e==null)return Uf(256);let t=Number.parseInt(e,10);return Uf(Number.isFinite(t)?t:256)}catch{return Uf(256)}}function Gf(e){try{globalThis.localStorage?.setItem(Bf,String(e))}catch{}}var Kf=Oe((e,t)=>({collapsed:Vf(),setCollapsed:t=>{e({collapsed:t}),queueMicrotask(()=>Hf(t))},toggleCollapsed:()=>{t().setCollapsed(!t().collapsed)},expandedWidthPx:Wf(),setExpandedWidthPx:n=>{let r=Uf(n);t().expandedWidthPx!==r&&(e({expandedWidthPx:r}),queueMicrotask(()=>Gf(r)))}})),qf=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{variant:n,className:r}=e,i=n===void 0?`sidebar`:n,a=Ee(Jf),o;t[0]===a?o=t[1]:(o=xe(a),t[0]=a,t[1]=o);let s=o,c=Kf(Yf),l=Kf(Xf),u=i===`sidebar`?`hidden md:inline-flex`:`inline-flex`,d;t[2]!==r||t[3]!==u?(d=K(`size-8 shrink-0 rounded-xl p-0`,u,md,r),t[2]=r,t[3]=u,t[4]=d):d=t[4];let f=!c,p=c?s.sidebarExpand:s.sidebarCollapse,m;t[5]===l?m=t[6]:(m=()=>l(),t[5]=l,t[6]=m);let h;t[7]===c?h=t[8]:(h=c?(0,$.jsx)(Oi,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}):(0,$.jsx)(Di,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0}),t[7]=c,t[8]=h);let g;return t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==m||t[13]!==h?(g=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:d,"aria-expanded":f,"aria-controls":`app-sidebar`,"aria-label":p,onClick:m,children:h}),t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g):g=t[14],g});function Jf(e){return e.language}function Yf(e){return e.collapsed}function Xf(e){return e.toggleCollapsed}var Zf=(0,Z.memo)(function(e){let t=(0,Q.c)(10),{sidebarToggleVariant:n,className:r}=e,i;t[0]===r?i=t[1]:(i=K(`flex min-w-0 shrink-0 items-center gap-0.5`,r),t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=(0,$.jsx)(qf,{variant:n}),t[2]=n,t[3]=a);let o,s,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(If,{}),s=(0,$.jsx)(Of,{}),c=(0,$.jsx)(Pf,{}),t[4]=o,t[5]=s,t[6]=c):(o=t[4],s=t[5],c=t[6]);let l;return t[7]!==i||t[8]!==a?(l=(0,$.jsxs)(`div`,{className:i,children:[a,o,s,c]}),t[7]=i,t[8]=a,t[9]=l):l=t[9],l}),Qf=(0,Z.memo)(function(e){let t=(0,Q.c)(4),{className:n}=e,{pathname:r}=b(),i=Kf($f),a=Df({runtime:Ef(),sidebarCollapsed:i,mobileNavOpen:!1});if(r.startsWith(`/settings`)||!i||!a.mainHeaderQuickActionsVisible||a.mainHeaderLeadingInsetClass)return null;let o;t[0]===n?o=t[1]:(o=K(`hidden md:flex`,n),t[0]=n,t[1]=o);let s;return t[2]===o?s=t[3]:(s=(0,$.jsx)(Zf,{sidebarToggleVariant:`main`,className:o}),t[2]=o,t[3]=s),s});function $f(e){return e.collapsed}var ep=Oe(e=>({mobileNavOpen:!1,setMobileNavOpen:t=>e({mobileNavOpen:t}),toggleMobileNav:()=>e(e=>({mobileNavOpen:!e.mobileNavOpen}))})),tp=(0,Z.memo)(function(){let e=(0,Q.c)(12),t=Ee(np),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n,i=ep(rp),a=ep(ip),o=i&&`hidden`,s;e[2]===o?s=e[3]:(s=K(`size-11 shrink-0 rounded-xl p-0 md:hidden`,md,o),e[2]=o,e[3]=s);let c;e[4]===a?c=e[5]:(c=()=>a(!0),e[4]=a,e[5]=c);let l;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(ci,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),e[6]=l):l=e[6];let u;return e[7]!==r.openMenu||e[8]!==i||e[9]!==s||e[10]!==c?(u=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:s,"aria-expanded":i,"aria-controls":`app-sidebar`,"aria-label":r.openMenu,title:r.openMenu,onClick:c,children:l}),e[7]=r.openMenu,e[8]=i,e[9]=s,e[10]=c,e[11]=u):u=e[11],u});function np(e){return e.language}function rp(e){return e.mobileNavOpen}function ip(e){return e.setMobileNavOpen}function ap(e){let t=(0,Q.c)(40),{items:n,activeTab:r,onChange:i,ariaLabel:a,tabIdPrefix:o,panelIdPrefix:s,className:c,buttonClassName:l,selectedClassName:u,unselectedClassName:d,countClassName:f,onReorder:p}=e,m=u===void 0?`bg-surface-active text-fg`:u,h=d===void 0?`text-fg-muted hover:bg-surface-hover hover:text-fg`:d,[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{_(null),y(null)},t[0]=b):b=t[0];let x=b,S;t[1]===c?S=t[2]:(S=K(`-mx-1 flex gap-1 overflow-x-auto overscroll-x-contain px-1 pb-1`,c),t[1]=c,t[2]=S);let C;t[3]===p?C=t[4]:(C=e=>{if(!p)return;let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||y(null)},t[3]=p,t[4]=C);let w;t[5]!==r||t[6]!==n||t[7]!==i?(w=e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)||!n.length)return;e.preventDefault();let t=n.findIndex(e=>e.id===r),a=e.key===`Home`?0:e.key===`End`?n.length-1:(Math.max(0,t)+(e.key===`ArrowRight`?1:-1)+n.length)%n.length;i(n[a].id);let o=e.currentTarget.querySelectorAll(`[role="tab"]`)[a];o?.focus(),o?.scrollIntoView({block:`nearest`,inline:`nearest`})},t[5]=r,t[6]=n,t[7]=i,t[8]=w):w=t[8];let T;if(t[9]!==r||t[10]!==l||t[11]!==f||t[12]!==g||t[13]!==v||t[14]!==n||t[15]!==i||t[16]!==p||t[17]!==s||t[18]!==m||t[19]!==o||t[20]!==h){let e;t[22]!==r||t[23]!==l||t[24]!==f||t[25]!==g||t[26]!==v||t[27]!==i||t[28]!==p||t[29]!==s||t[30]!==m||t[31]!==o||t[32]!==h?(e=e=>{let{id:t,icon:n,label:a,count:c,suffix:u,title:d}=e,b=t===r,S=g===t,C=v?.id===t&&v.position===`before`,w=v?.id===t&&v.position===`after`;return(0,$.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":b,tabIndex:b?0:-1,id:o?`${o}-${t}`:void 0,"aria-controls":s?`${s}-${t}`:void 0,"aria-grabbed":p?S:void 0,draggable:!!p,title:d,className:K(`touch-target relative inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,yc.press,b?m:h,p&&`cursor-grab active:cursor-grabbing`,S&&`scale-[0.98] border border-edge bg-surface-active/60 opacity-55 shadow-surface`,(C||w)&&!S&&`bg-surface-hover text-fg`,l),onClick:()=>i(t),onDragStart:e=>{p&&(_(t),y(null),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t))},onDragOver:e=>{if(!p||!g)return;if(g===t){y(null);return}e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientX<n.left+n.width/2?`before`:`after`;y(e=>e?.id===t&&e.position===r?e:{id:t,position:r})},onDrop:e=>{!p||!g||g===t||(e.preventDefault(),p(g,t,v?.id===t?v.position:`before`),x())},onDragEnd:x,children:[C?(0,$.jsx)(`span`,{className:`pointer-events-none absolute -left-0.5 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-full bg-accent shadow-[0_0_0_2px_var(--color-surface-panel)]`,"aria-hidden":!0}):null,n?(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,$.jsx)(`span`,{children:a}),c==null?null:(0,$.jsx)(`span`,{className:K(`rounded-full bg-surface-hover px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,f),children:c}),u,w?(0,$.jsx)(`span`,{className:`pointer-events-none absolute -right-0.5 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-full bg-accent shadow-[0_0_0_2px_var(--color-surface-panel)]`,"aria-hidden":!0}):null]},t)},t[22]=r,t[23]=l,t[24]=f,t[25]=g,t[26]=v,t[27]=i,t[28]=p,t[29]=s,t[30]=m,t[31]=o,t[32]=h,t[33]=e):e=t[33],T=n.map(e),t[9]=r,t[10]=l,t[11]=f,t[12]=g,t[13]=v,t[14]=n,t[15]=i,t[16]=p,t[17]=s,t[18]=m,t[19]=o,t[20]=h,t[21]=T}else T=t[21];let E;return t[34]!==a||t[35]!==S||t[36]!==C||t[37]!==w||t[38]!==T?(E=(0,$.jsx)(`nav`,{"aria-label":a,className:S,role:`tablist`,onDragLeave:C,onKeyDown:w,children:T}),t[34]=a,t[35]=S,t[36]=C,t[37]=w,t[38]=T,t[39]=E):E=t[39],E}var op=()=>s(()=>import(`./sessions-page-C6FwYIRA.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])),sp=()=>s(()=>import(`./automations-page-CGMErk_w.js`),__vite__mapDeps([40,4,1,41,42,2,3,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,8,49,11,10,12,13,14,16,17,18,50,51,52,53,54,37,25,55,56,31,57])),cp=()=>s(()=>import(`./scenes-page-GXJ-b3dO.js`),__vite__mapDeps([58,1,2,3,4,5,6,7,8,10,9,11,12,13,14,15,16,17,18,59,26,27,28,31,60,30])),lp=()=>s(()=>import(`./browser-automations-page-CZYCvSSU.js`),__vite__mapDeps([61,1,4,6,7,9,51,37,27,28,31,5,15,16,57,10,11,12,3,13,14,17,18])),up=()=>s(()=>import(`./home-page-CoBivEvx.js`),__vite__mapDeps([62,1,2,3,4,5,6,7,49,9,50,51,39,54,63,24,26,12,13,14,27,28,15,31,16,64])),dp=()=>s(()=>import(`./task-detail-page-Dk8Bmlhw.js`),__vite__mapDeps([65,1,42,2,3,4,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,49,10,11,12,13,14,16,17,18,50,52,39,20,22,66,31,67,68,60,30,69,70,71,25])),fp=()=>s(()=>import(`./projects-page-DcqylysA.js`),__vite__mapDeps([72,1,2,3,4,5,6,7,10,9,11,12,13,14,15,16,17,18,20,30,24,25,26,27,28,31])),pp=()=>s(()=>import(`./project-detail-page-CRQGCRSU.js`),__vite__mapDeps([73,1,74,4,75,8,76,42,2,3,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,77,11,10,12,13,14,16,17,18,50,78,52,39,56,30,54,37,25,31,60,79,49,68,53,80,21,41,51,55,57,81,82,63,83,84,85,66,29,67,86,87,88,89,69,70,71])),mp=()=>s(()=>import(`./notes-page-BFm7XnWH.js`),__vite__mapDeps([90,1,42,2,3,4,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,8,77,11,10,12,13,14,16,17,18,50,78,52,39,56,30,54,37,25,31,60,79,59,63,91,84])),hp=()=>s(()=>import(`./workflows-page-BrL6dzf0.js`),__vite__mapDeps([92,1,93,74,4,75,8,76,42,2,3,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,94,11,10,12,13,14,16,17,18,78,52,53,59,21,95,22,37,25,55,56,31,84,96,97,64,98])),gp=()=>s(()=>import(`./capabilities-page-DH3aDk53.js`),__vite__mapDeps([99,1,7,4,6,27,28,16,15,100,25,9,12,3,5,13,14,31])),_p=()=>s(()=>import(`./user-model-page-C_SPNZbP.js`),__vite__mapDeps([101,1,2,3,4,5,6,7,8,9,11,10,12,13,14,15,16,17,18,50,51,52,20,53,30,54,37,24,25,85,26,27,28,31,67,68])),vp=()=>s(()=>import(`./logs-page-BK8ol1q0.js`),__vite__mapDeps([102,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,19,103,25,26,27,28,31,38,39,47])),yp=()=>s(()=>import(`./settings-page-CWS9yOH3.js`),__vite__mapDeps([104,1,4,6,7,27,28])),bp=()=>s(()=>import(`./browser-settings-page-DDz9PE6m.js`),__vite__mapDeps([105,1,4,6,7,8,9,10,11,12,3,5,13,14,15,16,17,18,50,19,39,56,20,103,30,81,27,28,29,31,34,35,106,38])),xp=()=>s(()=>import(`./computer-settings-page-BfZaf516.js`),__vite__mapDeps([107,1,4,6,7,8,108,9,27,28,31,5,15,16,32,33,34,38,39])),Sp=()=>s(()=>import(`./extension-page-DH5vFbBw.js`),__vite__mapDeps([109,1,4,6,7])),Cp=()=>s(()=>import(`./extension-settings-page-hGKovxxC.js`),__vite__mapDeps([110,1,4,6,7,8,10,9,11,12,3,5,13,14,15,16,17,18,27,28,29,30,31,111,106,38,39,112,113,34])),wp=()=>s(()=>import(`./extension-debug-page-Bs8_FYCm.js`),__vite__mapDeps([114,1,4,27,28,38,39,9,15])),Tp=()=>s(()=>import(`./share-preview-page-CcRi2yGy.js`),__vite__mapDeps([115,1,7,42,2,3,4,5,6,9,19,24,26,27,28,15,43,44,45,46,47,48,16])),Ep=()=>s(()=>import(`./local-apps-page-CCvA9d9L.js`),__vite__mapDeps([116,1,4,6,7,8,117,9,24,27,28,31,5,15,16])),Dp=()=>s(()=>import(`./local-app-workbench-page-Di82Oacm.js`),__vite__mapDeps([118,1,2,3,4,5,6,7,8,9,11,50,51,39,30,119,26,27,28,46,45,31,15,16,64,98,60])),Op=()=>s(()=>import(`./product-open-page-DwEEO0Ak.js`),__vite__mapDeps([120,4,1,6,7,8,27,28,44,45,46,16,15])),kp=()=>s(()=>Promise.resolve().then(()=>gZ),void 0),Ap=()=>s(()=>import(`./work-discovery-overlay-ClB6T-dm.js`),__vite__mapDeps([121,1,2,3,4,5,26,9,27,28,31,15])),jp=()=>s(()=>import(`./setup-status-panel-BhGKiTPf.js`),__vite__mapDeps([122,1,4,6,7,8,50,9,30,123,27,28,15,32,33,34,35,36,37,106,16,38,39,124,125])),Mp=()=>s(()=>import(`./appearance-settings-Uts-MQ7K.js`),__vite__mapDeps([126,1,4,10,9,11,12,3,5,13,14,15,16,17,18,27,28,34,8,35,38,39])),Np=()=>s(()=>import(`./keyboard-shortcuts-settings-CMitbles.js`),__vite__mapDeps([127,1,4,27,28,15,38,39,9,124])),Pp=()=>s(()=>import(`./system-settings-panel-C_lajq9u.js`),__vite__mapDeps([128,1,4,9,39,27,28,15,36,37,38,124])),Fp=()=>s(()=>import(`./desktop-pet-settings-B5JGIfqn.js`),__vite__mapDeps([129,1,4,6,7,9,10,11,12,3,5,13,14,15,16,17,18,39,82,96,27,28,130,38,124])),Ip=()=>s(()=>import(`./app-management-settings-panel-BrIji9B5.js`),__vite__mapDeps([131,1,2,3,4,5,8,78,9,27,28,15,31,16,36,37,106,38,39,47,124,17])),Lp=()=>s(()=>import(`./capabilities-settings-panel-C8jMZAJl.js`),__vite__mapDeps([132,1,7,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,50,39,56,80,30,37,24,26,27,28,29,31,34,133,134,32,33,35,36,106,38,112,113,124,125])),Rp=()=>s(()=>import(`./gateway-settings-BIsiP-JI.js`),__vite__mapDeps([135,1,4,6,7,8,10,9,11,12,3,5,13,14,15,16,17,18,30,136,137,27,28,31,34,35,36,37,106,38,39,125])),zp=()=>s(()=>import(`./runtime-tools-settings-panel-De7HmmBu.js`),__vite__mapDeps([138,1,4,8,10,9,11,12,3,5,13,14,15,16,17,18,50,19,27,28,31,35,106,38,39])),Bp=()=>s(()=>import(`./remote-access-hub-Cq5MaiRW.js`),__vite__mapDeps([139,1,2,3,4,5,6,7,8,11,9,78,39,108,30,136,119,140,27,28,15,31,141,16,34,36,37,35,38,47,17])),Vp=()=>s(()=>import(`./shares-settings-DNmcCBfX.js`),__vite__mapDeps([142,1,2,3,4,5,6,7,8,11,9,10,12,13,14,15,16,17,18,78,20,30,22,24,26,27,28,31,34,36,37,106,38,39,47])),Hp=()=>s(()=>import(`./agent-defaults-settings-panel-DHJyAT7t.js`),__vite__mapDeps([143,1,4,6,7,8,10,9,11,12,3,5,13,14,15,16,17,18,50,103,25,26,27,28,29,30,31,32,33,34,133,38,39,113])),Up=()=>s(()=>import(`./management-settings-CebXkEtB.js`),__vite__mapDeps([144,1,2,3,4,5,6,7,8,9,68,10,11,12,13,14,15,16,17,18,24,25,26,27,28,31,145,50,51,19,39,146,141,108,30,119,34,36,37,43,44,45,46,106,38])),Wp=new Set;function Gp(e){Wp.has(e)||(Wp.add(e),e().catch(()=>{Wp.delete(e)}))}function Kp(e){let[t]=e.split(/[?#]/,1);return t||`/`}function qp(e){Gp(yp);let t=e.slice(10);if(t===`overview`)return Gp(jp);if(t===`appearance`)return Gp(Mp);if(t===`keyboard-shortcuts`)return Gp(Np);if(t===`system`)return Gp(Pp);if(t===`desktop-pet`)return Gp(Fp);if(t===`desktop-app`)return Gp(Ip);if(t.startsWith(`capabilities/`))return Gp(Lp);if(t===`gateway`)return Gp(Rp);if(t===`runtimes`)return Gp(zp);if(t===`devices`)return Gp(Up);if(t===`tunnel`||t===`remote-access`)return Gp(Bp);if(t===`shares`)return Gp(Vp);if(t===`agent-defaults`)return Gp(Hp);if(t===`agent-browser`)return Gp(bp);if(t===`computer-use`)return Gp(xp)}function Jp(e){if(!e.startsWith(`/`))return;let t=Kp(e);if(t===`/capabilities`||t.startsWith(`/capabilities/`))return Gp(gp);if(t===`/user-model`)return Gp(_p);if(t===`/automations`)return Gp(sp);if(t===`/scenes`||t.startsWith(`/scenes/`))return Gp(cp);if(t===`/browser-automations`)return Gp(lp);if(t===`/`)return Gp(up);if(t.startsWith(`/tasks/`))return Gp(dp);if(t===`/projects`)return Gp(fp);if(t.startsWith(`/projects/`))return Gp(pp);if(t===`/notes`||t.startsWith(`/notes/`))return Gp(mp);if(t===`/workflows`||t.startsWith(`/workflows/`))return Gp(hp);if(t.startsWith(`/extensions/`))return Gp(Sp);if(t===`/local-apps`)return Gp(Ep);if(t.startsWith(`/local-apps/`))return Gp(Dp);if(t===`/open`)return Gp(Op);if(t===`/onboarding/workspace`)return Gp(kp);if(t.startsWith(`/share/`))return Gp(Tp);if(t===`/settings/sessions`)return Gp(op);if(t===`/settings/logs`)return Gp(vp);if(t===`/settings/extensions/debug`)return Gp(wp);if(t.startsWith(`/settings/ext/`))return Gp(Cp);if(t.startsWith(`/settings/`))return qp(t)}function Yp(e){let t=(0,Q.c)(39),{fallback:n}=e,r=b(),i=l(),a=Ee(Qp),o,s,c,u,d,f;if(t[0]!==n||t[1]!==a||t[2]!==r.pathname||t[3]!==r.search){f=Symbol.for(`react.early_return_sentinel`);bb0:{o=xe(a).productNavigation,s=Ma(r.pathname);let e;if(t[10]!==r.pathname||t[11]!==r.search?(e=Na(r.pathname,r.search),t[10]=r.pathname,t[11]=r.search,t[12]=e):e=t[12],u=e,!s||!u||!Fa(r.pathname)){f=n;break bb0}let i=Pa(s);c=i.sections.map(e=>({id:e.id,label:o.sections[e.id]})),d=new Map(i.sections.map(Zp))}t[0]=n,t[1]=a,t[2]=r.pathname,t[3]=r.search,t[4]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f}else o=t[4],s=t[5],c=t[6],u=t[7],d=t[8],f=t[9];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p=d,m;t[13]!==i||t[14]!==p?(m=e=>{let t=p.get(e);t&&(Jp(t),i(t))},t[13]=i,t[14]=p,t[15]=m):m=t[15];let h=m,g=o.domains[s],_;t[16]===g?_=t[17]:(_=(0,$.jsx)(`h1`,{className:`sr-only`,children:g}),t[16]=g,t[17]=_);let v=`${s}-section-tab`,y=`${s}-section-panel`,x;t[18]!==h||t[19]!==o.sectionsAria||t[20]!==c||t[21]!==u||t[22]!==v||t[23]!==y?(x=(0,$.jsx)(`div`,{className:`hidden xl:block`,children:(0,$.jsx)(ap,{items:c,activeTab:u,onChange:h,ariaLabel:o.sectionsAria,tabIdPrefix:v,panelIdPrefix:y,className:`pb-0`,buttonClassName:`h-9 py-1.5`})}),t[18]=h,t[19]=o.sectionsAria,t[20]=c,t[21]=u,t[22]=v,t[23]=y,t[24]=x):x=t[24];let S;t[25]===c?S=t[26]:(S=c.map(Xp),t[25]=c,t[26]=S);let C=o.domains[s],w;t[27]===h?w=t[28]:(w=e=>h(e),t[27]=h,t[28]=w);let T;t[29]!==o.sectionsAria||t[30]!==u||t[31]!==C||t[32]!==w||t[33]!==S?(T=(0,$.jsx)(A,{value:u,options:S,placeholder:C,allowEmpty:!1,ariaLabel:o.sectionsAria,triggerClassName:`h-9 w-auto min-w-[7.5rem] bg-surface-panel xl:hidden`,contentClassName:`min-w-[12rem]`,onChange:w}),t[29]=o.sectionsAria,t[30]=u,t[31]=C,t[32]=w,t[33]=S,t[34]=T):T=t[34];let E;return t[35]!==T||t[36]!==_||t[37]!==x?(E=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,x,T]}),t[35]=T,t[36]=_,t[37]=x,t[38]=E):E=t[38],E}function Xp(e){return{value:e.id,label:e.label}}function Zp(e){return[e.id,e.path]}function Qp(e){return e.language}var $p={startExtra:null,main:null,end:null},em=Oe(e=>({...$p,setPageHeader:t=>e(t),clearPageHeader:()=>e($p)})),tm=(0,Z.memo)(function(){let e=(0,Q.c)(28),{pathname:t}=b(),n=em(nm),r=em(rm),i=em(im),a=em(am),o=Kf(om),s=ep(sm),c;e[0]===t?c=e[1]:(c=t.startsWith(`/settings`),e[0]=t,e[1]=c);let l=!c,u,d,f;if(e[2]!==a||e[3]!==s||e[4]!==o){let t=Df({runtime:Ef(),sidebarCollapsed:o,mobileNavOpen:s});f=K(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-1 bg-surface-panel`,hd,t.mainHeaderDraggable&&`[-webkit-app-region:drag]`,`px-3 sm:gap-4 sm:px-5 xl:px-6`,a),e[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=K(`flex min-w-0 shrink-0 items-center gap-1 sm:gap-2.5`,md),e[8]=u):u=e[8],d=t.mainHeaderLeadingInsetClass?(0,$.jsx)(Zf,{sidebarToggleVariant:`main`,className:K(`hidden md:flex`,t.mainHeaderLeadingInsetClass)}):null,e[2]=a,e[3]=s,e[4]=o,e[5]=u,e[6]=d,e[7]=f}else u=e[5],d=e[6],f=e[7];let p;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Qf,{}),e[9]=p):p=e[9];let m;e[10]===l?m=e[11]:(m=l?(0,$.jsx)(tp,{}):null,e[10]=l,e[11]=m);let h;e[12]!==n||e[13]!==u||e[14]!==d||e[15]!==m?(h=(0,$.jsxs)(`div`,{className:u,children:[d,p,m,n]}),e[12]=n,e[13]=u,e[14]=d,e[15]=m,e[16]=h):h=e[16];let g;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=K(`w-fit max-w-full`,md),e[17]=g):g=e[17];let _;e[18]===r?_=e[19]:(_=(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col justify-center overflow-hidden`,children:(0,$.jsx)(`div`,{className:g,children:(0,$.jsx)(Yp,{fallback:r})})}),e[18]=r,e[19]=_);let v;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(`flex min-w-0 shrink-0 items-center justify-end gap-2`,md),e[20]=v):v=e[20];let y;e[21]===i?y=e[22]:(y=(0,$.jsx)(`div`,{className:v,children:i}),e[21]=i,e[22]=y);let x;return e[23]!==y||e[24]!==f||e[25]!==h||e[26]!==_?(x=(0,$.jsxs)(`header`,{className:f,children:[h,_,y]}),e[23]=y,e[24]=f,e[25]=h,e[26]=_,e[27]=x):x=e[27],x});function nm(e){return e.startExtra}function rm(e){return e.main}function im(e){return e.end}function am(e){return e.className}function om(e){return e.collapsed}function sm(e){return e.mobileNavOpen}var cm=`
5
-
6
- `,lm=/\r\n/g,um=`xopc.npmPendingRestart`;function dm(e){let t=e?.postUpdate;if(!t||typeof t!=`object`)return!1;let n=t.restart;if(!n||typeof n!=`object`)return!1;let r=n;return r.ok===!0&&[`in-process`,`daemon`,`unmanaged`].includes(String(r.mode))}function fm(e,t){try{sessionStorage.setItem(um,JSON.stringify({installedVersion:e,automaticRestart:t}))}catch{}window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e,automaticRestart:t}})),t&&window.dispatchEvent(new Event(`gateway-restart-initiated`))}var pm=typeof window<`u`&&window.electronAPI?.updater!==void 0;function mm(){return null}function hm(e){if(!(!e||typeof window>`u`))try{let t=sessionStorage.getItem(um);if(!t)return;let n=JSON.parse(t),r=typeof n.installedVersion==`string`?n.installedVersion.trim():``;r&&r===e&&sessionStorage.removeItem(um)}catch{}}function gm(e){return hm(e.currentVersion),e}function _m(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(()=>mm()),[o,s]=(0,Z.useState)(pm?{state:`idle`}:mm()),c=(0,Z.useRef)(null),l=pm||i!==null;(0,Z.useEffect)(()=>{if(l)return;ym().then(e=>t(gm(e))).catch(()=>{});let e=e=>{let n=e.detail;if(n===null)t(e=>e&&gm({...e,updateAvailable:!1,latestVersion:null,channel:null}));else if(n&&typeof n==`object`){let e=n;t(gm({currentVersion:e.currentVersion??``,updateAvailable:!0,latestVersion:e.latestVersion??null,channel:e.channel??null}))}};return window.addEventListener(`update-available`,e),()=>window.removeEventListener(`update-available`,e)},[l]),(0,Z.useEffect)(()=>{if(!pm)return;let e=window.electronAPI.updater;return e.getStatus().then(e=>s(e)),e.onStatusChanged(e=>s(e))},[]),(0,Z.useEffect)(()=>{},[]),(0,Z.useEffect)(()=>()=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]);let u=(0,Z.useCallback)(async()=>{if(l)return!1;try{let e=await we(J(`/api/update/check`),{method:`POST`});if(!e.ok)return!1;let n=await e.json();return n.payload?(t(gm(n.payload)),!0):!1}catch{return!1}},[l]),d=(0,Z.useCallback)(async()=>{if(l)return{ok:!1,error:`not-applicable`,message:`npm update is not used in the desktop app.`,status:400};r(!0);try{let e=await we(J(`/api/update/run/stream`),{method:`POST`,headers:{Accept:`text/event-stream`}});if(!e.ok||!e.body){let t=await e.text().catch(()=>``),n=`HTTP ${e.status}`;try{let e=JSON.parse(t);typeof e.message==`string`&&(n=e.message)}catch{t&&(n=t.slice(0,500))}return{ok:!1,error:e.status===409?`busy`:`unknown`,message:n,status:e.status}}let t=await bm(e.body);if(t.ok&&t.result){let e=t.result;if(e&&typeof e==`object`&&e.status===`ok`&&typeof e.installedVersion==`string`){let t=dm(e);fm(e.installedVersion,t)}else e&&typeof e==`object`&&e.status===`up-to-date`&&typeof e.latestVersion==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-installed`,{detail:{version:e.latestVersion}}))}return t}catch(e){return{ok:!1,error:`network`,message:e instanceof Error?e.message:String(e),status:0}}finally{r(!1)}},[l]),f=(0,Z.useCallback)(()=>{if(pm){window.electronAPI.updater.check();return}},[i]),p=(0,Z.useCallback)(()=>{pm&&window.electronAPI.updater.quitAndInstall()},[]);return{npm:e,electron:pm?o:i??o,isElectron:l,checkNow:u,runNpmUpdate:d,npmUpdateRunning:n,electronCheck:f,electronQuitAndInstall:p}}var vm=null;async function ym(){return vm||(vm=(async()=>{let e=await we(J(`/api/update/status`));if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).payload})().finally(()=>{vm=null}),vm)}async function bm(e){let t=e.getReader(),n=new TextDecoder,r=``,i=null,a=e=>{try{let t=JSON.parse(e);typeof t.line==`string`&&window.dispatchEvent(new CustomEvent(`xopc:npm-update-progress`,{detail:{line:t.line,source:t.source===`stderr`?`stderr`:`stdout`}}))}catch{}},o=e=>{let t=``,n=``;for(let r of e.split(`
7
- `)){let e=r.replace(/\r$/,``);e.startsWith(`event:`)?t=e.slice(6).trim():e.startsWith(`data:`)&&(n+=e.slice(5).trimStart())}if(n){if(t===`progress`){a(n);return}if(t===`result`)try{let e=JSON.parse(n);i=e.ok?{ok:!0,result:e.result??null}:{ok:!1,error:String(e.error??`unknown`),message:String(e.message??`Update failed`),status:e.error===`busy`?409:400,result:e.result??null}}catch{i={ok:!1,error:`parse`,message:`Invalid update stream`,status:0}}}};try{let e=async()=>{if(i!==null)return i;let{done:a,value:s}=await t.read();if(a)return i;r+=n.decode(s,{stream:!0}),r=r.replace(lm,`
8
- `);let c=r.split(cm);r=c.pop()??``;for(let e of c)e.length&&o(e);return e()},a=await e();if(a)return a}finally{t.releaseLock()}return i??{ok:!1,error:`no-result`,message:`Update stream ended without a result`,status:0}}var xm=`xopc.updateReminder.dismissed`,Sm=typeof window<`u`&&window.electronAPI?.updater!==void 0,Cm=`xopc:electron-update-recheck`;function wm(){if(typeof window>`u`)return{};try{let e=localStorage.getItem(xm);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`?t:{}}catch{return{}}}var Tm=160;function Em(e){let t=e.trim();return t.length<=Tm?t:`${t.slice(0,Tm-1)}…`}function Dm(){let{npm:e,electron:t,isElectron:n,electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}=_m(),[o,s]=(0,Z.useState)(wm),[c,l]=(0,Z.useState)({downloading:!1,electronError:!1}),[u,d]=(0,Z.useState)(()=>{if(typeof window>`u`||Sm)return null;try{let e=sessionStorage.getItem(um);if(!e)return null;let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;return n?{version:n,automatic:t.automaticRestart===!0}:null}catch{return null}}),f=(0,Z.useRef)(t?.state);f.current!==t?.state&&(f.current=t?.state,t?.state!==`downloading`&&c.downloading&&l(e=>({...e,downloading:!1})),t?.state!==`error`&&c.electronError&&l(e=>({...e,electronError:!1})));let p=(0,Z.useRef)(null);if(u&&e?.currentVersion===u.version&&p.current!==u.version){p.current=u.version;try{sessionStorage.removeItem(um)}catch{}d(null)}(0,Z.useEffect)(()=>{if(n)return;let e=()=>{try{let e=sessionStorage.getItem(um);if(!e){d(null);return}let t=JSON.parse(e),n=typeof t.installedVersion==`string`?t.installedVersion.trim():``;d(n?{version:n,automatic:t.automaticRestart===!0}:null)}catch{d(null)}};return e(),window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[n]),(0,Z.useEffect)(()=>{let e=()=>{l(e=>({...e,downloading:!1})),s(e=>{let t={...e};delete t.electronReady;try{localStorage.setItem(xm,JSON.stringify(t))}catch{}return t})};return window.addEventListener(Cm,e),()=>window.removeEventListener(Cm,e)},[]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.version?.trim();t&&s(e=>{let n={...e,npm:t};try{localStorage.setItem(xm,JSON.stringify(n))}catch{}return n})};return window.addEventListener(`xopc:npm-update-installed`,e),()=>window.removeEventListener(`xopc:npm-update-installed`,e)},[]);let m=(0,Z.useMemo)(()=>n&&t?.state===`downloaded`&&t.version?o.electronReady===t.version?{kind:`none`}:{kind:`electron-ready`,version:t.version}:n&&t?.state===`downloading`&&!c.downloading?{kind:`electron-downloading`,percent:Math.round(t.percent??0)}:n&&t?.state===`error`&&t.message&&!c.electronError?{kind:`electron-error`,message:Em(t.message)}:!n&&u&&e&&e.currentVersion!==u.version?u.automatic?{kind:`npm-restarting`,version:u.version}:{kind:`npm-restart-required`,version:u.version}:!n&&e?.updateAvailable&&e.latestVersion?o.npm===e.latestVersion?{kind:`none`}:{kind:`npm`,version:e.latestVersion,channel:e.channel}:{kind:`none`},[o.npm,o.electronReady,t,c.downloading,c.electronError,n,e,u]);return{show:m,dismiss:(0,Z.useCallback)(()=>{if(m.kind===`electron-downloading`){l(e=>({...e,downloading:!0}));return}if(m.kind===`electron-error`){l(e=>({...e,electronError:!0}));return}if(m.kind===`npm-restart-required`||m.kind===`npm-restarting`){try{sessionStorage.removeItem(um)}catch{}d(null);return}if(m.kind===`none`)return;let e={...o};m.kind===`npm`?e.npm=m.version:m.kind===`electron-ready`&&(e.electronReady=m.version);try{localStorage.setItem(xm,JSON.stringify(e))}catch{}s(e)},[o,m]),electronQuitAndInstall:r,runNpmUpdate:i,npmUpdateRunning:a}}var Om={version:`0.0.329`,commit:`aa1a4456859a189181905626f5416544208db5cb`,buildTimeIso:`2026-09-24T17:57:03.425Z`};function km(){return function(e,t){switch(t.type){case`start`:return e.loading?e:{...e,loading:!0,error:null};case`success`:return{data:t.data,loading:!1,error:null};case`error`:return{data:t.data,loading:!1,error:t.error};case`patch`:return{...e,data:t.updater(e.data)}}}}function Am(e,t,n){let{enabled:r=!0,initial:i,errorData:a}=n,[o,s]=(0,Z.useReducer)(km(),void 0,()=>({data:i,loading:!1,error:null})),c=(0,Z.useRef)(e);c.current=e;let l=(0,Z.useRef)(a);l.current=a;let u=(0,Z.useRef)(i);u.current=i,(0,Z.useEffect)(()=>{if(!r)return;let e=!1;return s({type:`start`}),c.current().then(t=>{e||s({type:`success`,data:t})}).catch(t=>{if(e)return;let n=l.current;s({type:`error`,data:typeof n==`function`?n(t):n===void 0?u.current:n,error:t})}),()=>{e=!0}},[r,...t]);let d=(0,Z.useCallback)(e=>{s({type:`patch`,updater:typeof e==`function`?e:()=>e})},[]);return{...o,setData:d}}var jm=`https://github.com/xopcai/xopc`,Mm=new Intl.DateTimeFormat(`zh-CN`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}),Nm=new Intl.DateTimeFormat(`en-US`,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function Pm(e,t){let n=new Date(e);if(Number.isNaN(n.getTime()))return e;try{return(t===`zh`?Mm:Nm).format(n)}catch{return n.toISOString()}}function Fm({open:e,onOpenChange:t}){let n=Ee(e=>e.language),r=xe(n),i=r.aboutDialog,a=r.updatePanel,{isElectron:o,electron:s,electronCheck:c,checkNow:l,npm:u,runNpmUpdate:d,npmUpdateRunning:f}=_m(),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),{data:x}=Am(async()=>{let e=await q(J(`/health`));return typeof e.version==`string`?e.version:null},[e],{enabled:e,initial:null,errorData:null}),S=(0,Z.useCallback)(e=>{e||(m(!1),g(!1),v(!1),b(null)),t(e)},[t]),C=(0,Z.useCallback)(async()=>{b(null);let e=xe(n).updatePanel,t=await d();if(t.ok){Jl({tone:`success`,title:e.updateSuccess,message:dm(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}b(`${t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed}: ${t.message}`)},[d,n]),w=Om.commit,T=n===`zh`?`zh-CN`:`en-US`,E=Pm(Om.buildTimeIso,T),D=new Date().getFullYear(),O=i.copyright.replace(`{year}`,String(D));return(0,$.jsx)(nt,{open:e,onOpenChange:S,children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[200] bg-scrim`}),(0,$.jsxs)(et,{className:K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[201] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-3`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#ff5f57]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#febc2e]`}),(0,$.jsx)(`span`,{className:`size-3 rounded-full bg-[#28c840]`})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2 pt-1`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":i.close,children:(0,$.jsx)(ye,{className:`size-4`,strokeWidth:2})})})}),(0,$.jsxs)(`div`,{className:`-mt-2 flex flex-col items-center text-center`,children:[(0,$.jsx)(gd,{className:`size-[4.5rem]`,alt:r.appBrand}),(0,$.jsx)(tt,{className:`mt-3 text-xl font-semibold tracking-tight text-fg`,children:r.appBrand}),(0,$.jsx)(Ze,{className:`sr-only`,children:i.windowTitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 space-y-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-center gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.versionLabel}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2 sm:justify-start`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[13px] text-fg tabular-nums`,children:Om.version}),(0,$.jsx)(`button`,{type:`button`,className:K(`shrink-0 rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,`transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{o?(window.dispatchEvent(new CustomEvent(Cm)),m(!0),c()):(m(!0),v(!1),g(!0),(async()=>{let e=await l();g(!1),e||v(!0)})())},disabled:o&&[`checking`,`available`,`downloading`,`downloaded`].includes(s?.state??``)||!o&&(h||f),children:o&&s?.state===`checking`||!o&&h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ue,{className:`size-3 animate-spin`}),i.checkUpdatesChecking]}):i.checkUpdates})]})]}),o&&p&&(0,$.jsx)(Im,{state:s?.state,version:s?.version,percent:s?.percent,d:i}),!o&&p&&(0,$.jsx)(Lm,{checking:h,checkFailed:_,npm:u,npmUpdateRunning:f,upgradeError:y,onUpgrade:C,d:i,tp:a}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`pt-0.5 text-fg-muted`,children:i.commitLabel}),(0,$.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg`,children:w})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.buildDateLabel}),(0,$.jsx)(`span`,{className:`text-right text-[13px] text-fg sm:text-left`,children:E})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-[5.5rem_1fr] items-baseline gap-x-3 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:i.gatewayVersionLabel}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[13px] text-fg sm:text-left`,children:x??i.gatewayUnavailable})]}),(0,$.jsx)(`p`,{className:`pt-0.5 text-[11px] text-fg-subtle`,children:i.consoleBuildHint})]}),(0,$.jsxs)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 text-center text-[11px] leading-relaxed text-fg-muted`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`a`,{className:`text-accent-fg underline decoration-accent-fg/40 underline-offset-2 hover:decoration-accent-fg`,href:jm,target:`_blank`,rel:`noopener noreferrer`,children:i.repositoryLink})}),(0,$.jsx)(`p`,{className:`mt-2`,children:O})]})]})]})]})})}function Im(e){let t=(0,Q.c)(29),{state:n,version:r,percent:i,d:a}=e;if(!n||n===`idle`)return null;if(n===`checking`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ue,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===a.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesChecking})]}),t[1]=a.checkUpdatesChecking,t[2]=n),n}if(n===`not-available`){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(fr,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===a.checkUpdatesUpToDate?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesUpToDate})]}),t[4]=a.checkUpdatesUpToDate,t[5]=n),n}if(n===`available`){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Vi,{className:`size-3.5`}),t[6]=e):e=t[6];let n;t[7]!==a.checkUpdatesAvailable||t[8]!==r?(n=a.checkUpdatesAvailable.replace(`{version}`,r??`?`),t[7]=a.checkUpdatesAvailable,t[8]=r,t[9]=n):n=t[9];let i;return t[10]===n?i=t[11]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[10]=n,t[11]=i),i}if(n===`downloading`){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(P,{className:`size-3.5 motion-safe:animate-[bounce_1s_ease-out_infinite]`}),t[12]=e):e=t[12];let n=a.checkUpdatesDownloading,r;if(t[13]!==a.checkUpdatesDownloading||t[14]!==i){let e;t[16]===i?e=t[17]:(e=Math.round(i??0),t[16]=i,t[17]=e),r=n.replace(`{percent}`,String(e)),t[13]=a.checkUpdatesDownloading,t[14]=i,t[15]=r}else r=t[15];let o;return t[18]===r?o=t[19]:(o=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:r})]}),t[18]=r,t[19]=o),o}if(n===`downloaded`){let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(P,{className:`size-3.5`}),t[20]=e):e=t[20];let n;t[21]!==a.checkUpdatesDownloaded||t[22]!==r?(n=a.checkUpdatesDownloaded.replace(`{version}`,r??`?`),t[21]=a.checkUpdatesDownloaded,t[22]=r,t[23]=n):n=t[23];let i;return t[24]===n?i=t[25]:(i=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] font-semibold text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[24]=n,t[25]=i),i}if(n===`error`){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dr,{className:`size-3.5`}),t[26]=e):e=t[26];let n;return t[27]===a.checkUpdatesError?n=t[28]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:a.checkUpdatesError})]}),t[27]=a.checkUpdatesError,t[28]=n),n}return null}function Lm(e){let t=(0,Q.c)(28),{checking:n,checkFailed:r,npm:i,npmUpdateRunning:a,upgradeError:o,onUpgrade:s,d:c,tp:l}=e;if(n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ue,{className:`size-3.5 animate-spin`}),t[0]=e):e=t[0];let n;return t[1]===c.checkUpdatesChecking?n=t[2]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesChecking})]}),t[1]=c.checkUpdatesChecking,t[2]=n),n}if(r){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dr,{className:`size-3.5`}),t[3]=e):e=t[3];let n;return t[4]===c.checkUpdatesError?n=t[5]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-red-500 dark:text-red-400`,children:[e,(0,$.jsx)(`span`,{children:c.checkUpdatesError})]}),t[4]=c.checkUpdatesError,t[5]=n),n}if(a){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ue,{className:`size-3.5 animate-spin`}),t[6]=e):e=t[6];let n;return t[7]===l.updateRunning?n=t[8]:(n=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-fg-muted`,children:[e,(0,$.jsx)(`span`,{children:l.updateRunning})]}),t[7]=l.updateRunning,t[8]=n),n}if(o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dr,{className:`mt-0.5 size-3.5 shrink-0`}),t[9]=e):e=t[9];let n;return t[10]===o?n=t[11]:(n=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-red-500 dark:text-red-400`,role:`alert`,children:[e,(0,$.jsx)(`span`,{children:o})]}),t[10]=o,t[11]=n),n}if(i?.updateAvailable&&i.latestVersion){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Vi,{className:`mt-0.5 size-3.5 shrink-0`}),t[12]=e):e=t[12];let n;t[13]!==i.latestVersion||t[14]!==l.reminderNpm?(n=l.reminderNpm.replace(`{{version}}`,i.latestVersion),t[13]=i.latestVersion,t[14]=l.reminderNpm,t[15]=n):n=t[15];let r;t[16]===n?r=t[17]:(r=(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-[12px] text-accent-fg`,children:[e,(0,$.jsx)(`span`,{children:n})]}),t[16]=n,t[17]=r);let a;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(a=K(`w-full rounded-lg bg-accent px-3 py-1.5 text-center text-xs font-medium text-on-accent`,`hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,`disabled:pointer-events-none disabled:opacity-50`),t[18]=a):a=t[18];let o;t[19]!==s||t[20]!==l.updateNow?(o=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:a,children:l.updateNow}),t[19]=s,t[20]=l.updateNow,t[21]=o):o=t[21];let c;return t[22]!==r||t[23]!==o?(c=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[r,o]}),t[22]=r,t[23]=o,t[24]=c):c=t[24],c}let u;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(fr,{className:`size-3.5`}),t[25]=u):u=t[25];let d;return t[26]===c.checkUpdatesUpToDate?d=t[27]:(d=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-[12px] text-green-600 dark:text-green-400`,children:[u,(0,$.jsx)(`span`,{children:c.checkUpdatesUpToDate})]}),t[26]=c.checkUpdatesUpToDate,t[27]=d),d}var Rm=K(`flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-overlay`),zm=K(`overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,`dark:border-edge`);function Bm(e){let t=(0,Q.c)(14),{selected:n,label:r,onSelect:i}=e,a=n&&`bg-accent-soft text-accent-fg hover:bg-accent-soft`,o;t[0]===a?o=t[1]:(o=K(`touch-target flex w-full items-center justify-between gap-2 rounded-none px-3 py-2 text-left text-sm font-medium leading-5 text-fg`,`transition-colors duration-150 ease-out hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:r}),t[2]=r,t[3]=s);let c=n?`opacity-100`:`opacity-0`,l;t[4]===c?l=t[5]:(l=K(`size-4 shrink-0`,c),t[4]=c,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(S,{className:l,strokeWidth:2,"aria-hidden":!0}),t[6]=l,t[7]=u);let d;return t[8]!==i||t[9]!==n||t[10]!==o||t[11]!==s||t[12]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:o,onClick:i,children:[s,u]}),t[8]=i,t[9]=n,t[10]=o,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}function Vm(e){let t=(0,Q.c)(209),{onNavigate:n,onAboutClick:r,onSupportClick:i}=e,[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),l=Ee(qm),u=Ee(Km),d=Xd(Gm),f=Xd(Wm),p=Rd(Um),m=Rd(Hm),h;t[0]===l?h=t[1]:(h=xe(l),t[0]=l,t[1]=h);let g=h,_=g.appearanceSettings,v=l===`zh`?_.langOptionZh:_.langOptionEn,b=d===`light`?_.themeOptionLight:d===`dark`?_.themeOptionDark:_.themeOptionSystem,x=p===`compact`?_.fontScaleCompact:p===`large`?_.fontScaleLarge:_.fontScaleDefault,S=typeof window<`u`?window.electronAPI?.pet:void 0,C=!!S,w=s?.visible?_.hideDesktopPet:_.showDesktopPet,T,E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{if(!S)return;let e=!1;S.getState().then(t=>{e||c(t)});let t=S.onStateChanged(t=>{e||c(t)});return()=>{e=!0,t()}},E=[S],t[2]=T,t[3]=E):(T=t[2],E=t[3]),(0,Z.useEffect)(T,E);let D;t[4]===s?.visible?D=t[5]:(D=async()=>{S&&(s?.visible?await S.hide():await S.show(),c(await S.getState()))},t[4]=s?.visible,t[5]=D);let O=D,k;t[6]===a?k=t[7]:(k=e=>K(`absolute left-full top-0 z-[60] min-w-[8.75rem] max-w-[min(calc(100vw-2rem),12rem)]`,`ml-2 sm:ml-2.5`,a===e?`block`:`hidden`),t[6]=a,t[7]=k);let A=k,j;t[8]===a?j=t[9]:(j=e=>K(`absolute left-full top-0 z-[55] h-full w-8 sm:w-9`,a===e?`pointer-events-auto`:`pointer-events-none`),t[8]=a,t[9]=j);let M=j,N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=()=>o(null),t[10]=N):N=t[10];let P;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>o(`lang`),t[11]=P):P=t[11];let F=a===`lang`&&`bg-surface-hover`,L;t[12]===F?L=t[13]:(L=K(Rm,F),t[12]=F,t[13]=L);let R=a===`lang`,z;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ce,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=z):z=t[14];let B;t[15]===_.languageTitle?B=t[16]:(B=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.languageTitle}),t[15]=_.languageTitle,t[16]=B);let V;t[17]===v?V=t[18]:(V=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:v}),t[17]=v,t[18]=V);let H;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[19]=H):H=t[19];let U;t[20]!==L||t[21]!==R||t[22]!==B||t[23]!==V?(U=(0,$.jsxs)(`button`,{type:`button`,className:L,"aria-haspopup":`menu`,"aria-expanded":R,children:[z,B,V,H]}),t[20]=L,t[21]=R,t[22]=B,t[23]=V,t[24]=U):U=t[24];let W;t[25]===M?W=t[26]:(W=M(`lang`),t[25]=M,t[26]=W);let G;t[27]===W?G=t[28]:(G=(0,$.jsx)(`div`,{className:W,"aria-hidden":!0}),t[27]=W,t[28]=G);let ee;t[29]===A?ee=t[30]:(ee=A(`lang`),t[29]=A,t[30]=ee);let te=l===`en`,ne;t[31]===u?ne=t[32]:(ne=()=>u(`en`),t[31]=u,t[32]=ne);let re;t[33]!==_.langOptionEn||t[34]!==te||t[35]!==ne?(re=(0,$.jsx)(Bm,{selected:te,label:_.langOptionEn,onSelect:ne}),t[33]=_.langOptionEn,t[34]=te,t[35]=ne,t[36]=re):re=t[36];let ie=l===`zh`,ae;t[37]===u?ae=t[38]:(ae=()=>u(`zh`),t[37]=u,t[38]=ae);let oe;t[39]!==_.langOptionZh||t[40]!==ie||t[41]!==ae?(oe=(0,$.jsx)(Bm,{selected:ie,label:_.langOptionZh,onSelect:ae}),t[39]=_.langOptionZh,t[40]=ie,t[41]=ae,t[42]=oe):oe=t[42];let se;t[43]!==re||t[44]!==oe?(se=(0,$.jsxs)(`div`,{className:zm,children:[re,oe]}),t[43]=re,t[44]=oe,t[45]=se):se=t[45];let le;t[46]!==_.languageTitle||t[47]!==ee||t[48]!==se?(le=(0,$.jsx)(`div`,{className:ee,role:`menu`,"aria-label":_.languageTitle,children:se}),t[46]=_.languageTitle,t[47]=ee,t[48]=se,t[49]=le):le=t[49];let ue;t[50]!==U||t[51]!==G||t[52]!==le?(ue=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:P,children:[U,G,le]}),t[50]=U,t[51]=G,t[52]=le,t[53]=ue):ue=t[53];let de;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(de=()=>o(`theme`),t[54]=de):de=t[54];let fe=a===`theme`&&`bg-surface-hover`,pe;t[55]===fe?pe=t[56]:(pe=K(Rm,fe),t[55]=fe,t[56]=pe);let me=a===`theme`,he;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(Ei,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[57]=he):he=t[57];let ge;t[58]===_.themeTitle?ge=t[59]:(ge=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.themeTitle}),t[58]=_.themeTitle,t[59]=ge);let _e;t[60]===b?_e=t[61]:(_e=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:b}),t[60]=b,t[61]=_e);let ve;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[62]=ve):ve=t[62];let ye;t[63]!==pe||t[64]!==me||t[65]!==ge||t[66]!==_e?(ye=(0,$.jsxs)(`button`,{type:`button`,className:pe,"aria-haspopup":`menu`,"aria-expanded":me,children:[he,ge,_e,ve]}),t[63]=pe,t[64]=me,t[65]=ge,t[66]=_e,t[67]=ye):ye=t[67];let be;t[68]===M?be=t[69]:(be=M(`theme`),t[68]=M,t[69]=be);let q;t[70]===be?q=t[71]:(q=(0,$.jsx)(`div`,{className:be,"aria-hidden":!0}),t[70]=be,t[71]=q);let Se;t[72]===A?Se=t[73]:(Se=A(`theme`),t[72]=A,t[73]=Se);let Ce=d===`light`,we;t[74]===f?we=t[75]:(we=()=>f(`light`),t[74]=f,t[75]=we);let Te;t[76]!==_.themeOptionLight||t[77]!==Ce||t[78]!==we?(Te=(0,$.jsx)(Bm,{selected:Ce,label:_.themeOptionLight,onSelect:we}),t[76]=_.themeOptionLight,t[77]=Ce,t[78]=we,t[79]=Te):Te=t[79];let De=d===`dark`,Oe;t[80]===f?Oe=t[81]:(Oe=()=>f(`dark`),t[80]=f,t[81]=Oe);let J;t[82]!==_.themeOptionDark||t[83]!==De||t[84]!==Oe?(J=(0,$.jsx)(Bm,{selected:De,label:_.themeOptionDark,onSelect:Oe}),t[82]=_.themeOptionDark,t[83]=De,t[84]=Oe,t[85]=J):J=t[85];let ke=d===`system`,Ae;t[86]===f?Ae=t[87]:(Ae=()=>f(`system`),t[86]=f,t[87]=Ae);let je;t[88]!==_.themeOptionSystem||t[89]!==ke||t[90]!==Ae?(je=(0,$.jsx)(Bm,{selected:ke,label:_.themeOptionSystem,onSelect:Ae}),t[88]=_.themeOptionSystem,t[89]=ke,t[90]=Ae,t[91]=je):je=t[91];let Me;t[92]!==Te||t[93]!==J||t[94]!==je?(Me=(0,$.jsxs)(`div`,{className:zm,children:[Te,J,je]}),t[92]=Te,t[93]=J,t[94]=je,t[95]=Me):Me=t[95];let Ne;t[96]!==_.themeTitle||t[97]!==Se||t[98]!==Me?(Ne=(0,$.jsx)(`div`,{className:Se,role:`menu`,"aria-label":_.themeTitle,children:Me}),t[96]=_.themeTitle,t[97]=Se,t[98]=Me,t[99]=Ne):Ne=t[99];let Pe;t[100]!==ye||t[101]!==q||t[102]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:de,children:[ye,q,Ne]}),t[100]=ye,t[101]=q,t[102]=Ne,t[103]=Pe):Pe=t[103];let Fe;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=()=>o(`font`),t[104]=Fe):Fe=t[104];let Ie=a===`font`&&`bg-surface-hover`,Le;t[105]===Ie?Le=t[106]:(Le=K(Rm,Ie),t[105]=Ie,t[106]=Le);let Re=a===`font`,ze;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,$.jsx)(ha,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[107]=ze):ze=t[107];let Be;t[108]===_.fontScaleTitle?Be=t[109]:(Be=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.fontScaleTitle}),t[108]=_.fontScaleTitle,t[109]=Be);let Ve;t[110]===x?Ve=t[111]:(Ve=(0,$.jsx)(`span`,{className:`max-w-20 truncate text-xs font-medium text-fg-muted`,children:x}),t[110]=x,t[111]=Ve);let He;t[112]===Symbol.for(`react.memo_cache_sentinel`)?(He=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[112]=He):He=t[112];let Ue;t[113]!==Le||t[114]!==Re||t[115]!==Be||t[116]!==Ve?(Ue=(0,$.jsxs)(`button`,{type:`button`,className:Le,"aria-haspopup":`menu`,"aria-expanded":Re,children:[ze,Be,Ve,He]}),t[113]=Le,t[114]=Re,t[115]=Be,t[116]=Ve,t[117]=Ue):Ue=t[117];let We;t[118]===M?We=t[119]:(We=M(`font`),t[118]=M,t[119]=We);let Ge;t[120]===We?Ge=t[121]:(Ge=(0,$.jsx)(`div`,{className:We,"aria-hidden":!0}),t[120]=We,t[121]=Ge);let Ke;t[122]===A?Ke=t[123]:(Ke=A(`font`),t[122]=A,t[123]=Ke);let qe=p===`compact`,Je;t[124]===m?Je=t[125]:(Je=()=>m(`compact`),t[124]=m,t[125]=Je);let Ye;t[126]!==_.fontScaleCompact||t[127]!==qe||t[128]!==Je?(Ye=(0,$.jsx)(Bm,{selected:qe,label:_.fontScaleCompact,onSelect:Je}),t[126]=_.fontScaleCompact,t[127]=qe,t[128]=Je,t[129]=Ye):Ye=t[129];let Xe=p==="default",Ze;t[130]===m?Ze=t[131]:(Ze=()=>m(`default`),t[130]=m,t[131]=Ze);let Qe;t[132]!==_.fontScaleDefault||t[133]!==Xe||t[134]!==Ze?(Qe=(0,$.jsx)(Bm,{selected:Xe,label:_.fontScaleDefault,onSelect:Ze}),t[132]=_.fontScaleDefault,t[133]=Xe,t[134]=Ze,t[135]=Qe):Qe=t[135];let $e=p===`large`,et;t[136]===m?et=t[137]:(et=()=>m(`large`),t[136]=m,t[137]=et);let tt;t[138]!==_.fontScaleLarge||t[139]!==$e||t[140]!==et?(tt=(0,$.jsx)(Bm,{selected:$e,label:_.fontScaleLarge,onSelect:et}),t[138]=_.fontScaleLarge,t[139]=$e,t[140]=et,t[141]=tt):tt=t[141];let nt;t[142]!==Ye||t[143]!==Qe||t[144]!==tt?(nt=(0,$.jsxs)(`div`,{className:zm,children:[Ye,Qe,tt]}),t[142]=Ye,t[143]=Qe,t[144]=tt,t[145]=nt):nt=t[145];let rt;t[146]!==_.fontScaleTitle||t[147]!==Ke||t[148]!==nt?(rt=(0,$.jsx)(`div`,{className:Ke,role:`menu`,"aria-label":_.fontScaleTitle,children:nt}),t[146]=_.fontScaleTitle,t[147]=Ke,t[148]=nt,t[149]=rt):rt=t[149];let it;t[150]!==Ue||t[151]!==Ge||t[152]!==rt?(it=(0,$.jsxs)(`div`,{className:`relative`,onMouseEnter:Fe,children:[Ue,Ge,rt]}),t[150]=Ue,t[151]=Ge,t[152]=rt,t[153]=it):it=t[153];let at;t[154]!==w||t[155]!==O?(at=C?(0,$.jsxs)(`button`,{type:`button`,className:Rm,onClick:()=>void O(),onMouseEnter:()=>o(null),onFocus:()=>o(null),children:[(0,$.jsx)(ji,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:w})]}):null,t[154]=w,t[155]=O,t[156]=at):at=t[156];let ot;t[157]===Symbol.for(`react.memo_cache_sentinel`)?(ot=(0,$.jsx)(`div`,{className:`my-2 h-px bg-edge-subtle`,role:`separator`}),t[157]=ot):ot=t[157];let st;t[158]===r?st=t[159]:(st=()=>r?.(),t[158]=r,t[159]=st);let ct,lt,ut;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(ct=()=>o(null),lt=()=>o(null),ut=(0,$.jsx)($r,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[160]=ct,t[161]=lt,t[162]=ut):(ct=t[160],lt=t[161],ut=t[162]);let dt;t[163]===_.aboutApp?dt=t[164]:(dt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:_.aboutApp}),t[163]=_.aboutApp,t[164]=dt);let Y;t[165]!==st||t[166]!==dt?(Y=(0,$.jsxs)(`button`,{type:`button`,className:Rm,onClick:st,onMouseEnter:ct,onFocus:lt,children:[ut,dt]}),t[165]=st,t[166]=dt,t[167]=Y):Y=t[167];let ft;t[168]===l?ft=t[169]:(ft=mf(l),t[168]=l,t[169]=ft);let pt,mt,ht;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>o(null),mt=()=>o(null),ht=(0,$.jsx)(er,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[170]=pt,t[171]=mt,t[172]=ht):(pt=t[170],mt=t[171],ht=t[172]);let gt;t[173]===g.sidebar.helpDocs?gt=t[174]:(gt=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.sidebar.helpDocs}),t[173]=g.sidebar.helpDocs,t[174]=gt);let _t;t[175]===Symbol.for(`react.memo_cache_sentinel`)?(_t=(0,$.jsx)(I,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:2,"aria-hidden":!0}),t[175]=_t):_t=t[175];let vt;t[176]!==ft||t[177]!==gt?(vt=(0,$.jsxs)(`a`,{href:ft,target:`_blank`,rel:`noopener noreferrer`,className:Rm,onMouseEnter:pt,onFocus:mt,children:[ht,gt,_t]}),t[176]=ft,t[177]=gt,t[178]=vt):vt=t[178];let yt;t[179]===i?yt=t[180]:(yt=()=>i?.(),t[179]=i,t[180]=yt);let bt,xt,St;t[181]===Symbol.for(`react.memo_cache_sentinel`)?(bt=()=>o(null),xt=()=>o(null),St=(0,$.jsx)(fi,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[181]=bt,t[182]=xt,t[183]=St):(bt=t[181],xt=t[182],St=t[183]);let Ct;t[184]===g.supportReport.menu?Ct=t[185]:(Ct=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-left`,children:g.supportReport.menu}),t[184]=g.supportReport.menu,t[185]=Ct);let wt;t[186]!==yt||t[187]!==Ct?(wt=(0,$.jsxs)(`button`,{type:`button`,className:Rm,onClick:yt,onMouseEnter:bt,onFocus:xt,children:[St,Ct]}),t[186]=yt,t[187]=Ct,t[188]=wt):wt=t[188];let Tt,Et,Dt;t[189]===Symbol.for(`react.memo_cache_sentinel`)?(Et=K(Rm,`text-accent-fg hover:bg-accent-soft hover:text-accent-fg`),Dt=()=>o(null),Tt=()=>o(null),t[189]=Tt,t[190]=Et,t[191]=Dt):(Tt=t[189],Et=t[190],Dt=t[191]);let Ot;t[192]===n?Ot=t[193]:(Ot=()=>n?.(),t[192]=n,t[193]=Ot);let kt;t[194]===Symbol.for(`react.memo_cache_sentinel`)?(kt=(0,$.jsx)(Ji,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[194]=kt):kt=t[194];let At;t[195]===_.openFullPreferences?At=t[196]:(At=(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:_.openFullPreferences}),t[195]=_.openFullPreferences,t[196]=At);let jt;t[197]!==Ot||t[198]!==At?(jt=(0,$.jsxs)(y,{to:`/settings/overview`,className:Et,onMouseEnter:Dt,onFocus:Tt,onClick:Ot,children:[kt,At]}),t[197]=Ot,t[198]=At,t[199]=jt):jt=t[199];let Mt;return t[200]!==jt||t[201]!==ue||t[202]!==Pe||t[203]!==it||t[204]!==at||t[205]!==Y||t[206]!==vt||t[207]!==wt?(Mt=(0,$.jsxs)(`div`,{className:`w-[min(calc(100vw-2rem),13rem)] shrink-0 py-0.5`,onMouseLeave:N,children:[ue,Pe,it,at,ot,Y,vt,wt,jt]}),t[200]=jt,t[201]=ue,t[202]=Pe,t[203]=it,t[204]=at,t[205]=Y,t[206]=vt,t[207]=wt,t[208]=Mt):Mt=t[208],Mt}function Hm(e){return e.setPreference}function Um(e){return e.preference}function Wm(e){return e.setPreference}function Gm(e){return e.preference}function Km(e){return e.setLanguage}function qm(e){return e.language}var Jm=`open-support-report`;function Ym(e={}){window.dispatchEvent(new CustomEvent(Jm,{detail:e}))}var Xm=(0,Z.lazy)(()=>s(()=>import(`./device-pairing-wizard-DFYK_Ywf.js`).then(e=>e.n).then(e=>({default:e.DevicePairingWizard})),__vite__mapDeps([145,1,2,3,4,5,6,7,8,50,9,51,19,39,26,27,28,15,146,31,16,141,108,30,119,34,36,37,43,44,45,46,17])));function Zm({collapsed:e=!1,onNavigate:t}){let n=xe(Ee(e=>e.language)),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{s(()=>import(`./settings-page-CWS9yOH3.js`),__vite__mapDeps([104,1,4,6,7,27,28])),s(()=>import(`./sessions-page-C6FwYIRA.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])),s(()=>import(`./logs-page-BK8ol1q0.js`),__vite__mapDeps([102,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,19,103,25,26,27,28,31,38,39,47])),s(()=>import(`./automations-page-CGMErk_w.js`),__vite__mapDeps([40,4,1,41,42,2,3,5,6,7,9,19,24,26,27,28,15,43,44,45,46,47,48,8,49,11,10,12,13,14,16,17,18,50,51,52,53,54,37,25,55,56,31,57])),s(()=>import(`./capabilities-page-DH3aDk53.js`),__vite__mapDeps([99,1,7,4,6,27,28,16,15,100,25,9,12,3,5,13,14,31]))},[]),(0,$.jsxs)(`div`,{className:K(`flex shrink-0 flex-col`,e&&`mt-auto`,e?`items-center px-1 py-2`:`p-3`),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:K(`mb-2 flex min-h-10 items-center gap-2 rounded-lg px-3 text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,e&&`justify-center px-2`),"aria-label":n.endpointToolsSettings.deviceAccess.flow.title,children:[(0,$.jsx)(_i,{className:`size-4 shrink-0`}),e?null:n.endpointToolsSettings.deviceAccess.flow.title]}),c?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Xm,{open:!0,onOpenChange:l})}):null,(0,$.jsxs)(hn,{open:r,onOpenChange:i,children:[e?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:`rounded-full outline-none ring-offset-surface-base transition-transform hover:opacity-95 active:scale-95 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 motion-reduce:active:scale-100`,title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(gd,{className:`size-10`,alt:n.appBrand})}),(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:K(`flex size-10 shrink-0 items-center justify-center rounded-xl text-fg-muted outline-none ring-offset-surface-base transition-colors`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:(0,$.jsx)(Ji,{className:`size-[17px]`,strokeWidth:1.5})})})]}):(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-1 rounded-xl p-1`,children:[(0,$.jsx)(y,{to:`/user-model`,onClick:()=>t?.(),className:K(`flex size-10 shrink-0 items-center justify-center rounded-full text-left outline-none transition-transform duration-150 ease-out`,`hover:bg-surface-active/70`,`hover:opacity-95 active:scale-95`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),title:n.nav.profile,"aria-label":n.nav.profile,children:(0,$.jsx)(gd,{className:`size-8`,alt:n.appBrand})}),(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:K(`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-xl px-2 text-left text-fg-muted transition-colors`,`outline-none hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,r&&`bg-accent-soft text-accent-fg`),"aria-expanded":r,"aria-haspopup":`dialog`,title:n.sidebar.appMenuAria,"aria-label":n.sidebar.appMenuAria,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-semibold leading-tight text-fg`,children:n.appBrand}),(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:n.appearanceSettings.quickMenuHint})]}),(0,$.jsx)(Ji,{className:`size-[18px] shrink-0`,strokeWidth:1.5})]})})]}),(0,$.jsx)(gn,{children:(0,$.jsx)(yn,{className:K(`z-50 w-max max-w-[min(calc(100vw-1rem),28rem)] overflow-visible`,`rounded-xl border border-edge bg-surface-overlay p-2 shadow-popover dark:border-edge`),side:`top`,align:e?`center`:`end`,sideOffset:8,collisionPadding:12,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),children:(0,$.jsx)(Vm,{onNavigate:()=>{i(!1),t?.()},onAboutClick:()=>{o(!0),i(!1)},onSupportClick:()=>{i(!1),Ym()}})})})]}),(0,$.jsx)(Fm,{open:a,onOpenChange:o})]})}var Qm={work:rr,automation:Ca,capabilities:ri,apps:nr};function $m(e){let t=(0,Q.c)(9),{collapsed:n,onNavigate:r}=e,i=n===void 0?!1:n,{pathname:a}=b(),o=Ee(eh),s;t[0]===o?s=t[1]:(s=xe(o),t[0]=o,t[1]=s);let c=s.productNavigation,l;t[2]===a?l=t[3]:(l=Ma(a),t[2]=a,t[3]=l);let u=l,d;return t[4]!==u||t[5]!==i||t[6]!==c||t[7]!==r?(d=Aa.map(e=>{let t=Qm[e.id],n=c.domains[e.id],a=u===e.id;return(0,$.jsxs)(y,{to:e.path,"aria-current":a?`page`:void 0,className:K(`flex w-full items-center text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i?`justify-center rounded-xl p-2.5`:`gap-2 rounded-lg px-3 py-2 text-left`,a?`bg-surface-active text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),title:n,onMouseEnter:()=>Jp(e.path),onFocus:()=>Jp(e.path),onClick:r,children:[(0,$.jsx)(t,{className:`size-4 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),i?null:(0,$.jsx)(`span`,{className:`truncate`,children:n})]},e.id)}),t[4]=u,t[5]=i,t[6]=c,t[7]=r,t[8]=d):d=t[8],d}function eh(e){return e.language}var th={sources:[],purposes:[],activity:``,project:``,days:``,status:`visible`,agentId:``,details:!1};function nh(e){return!!(e.sources.length||e.purposes.length||e.activity||e.project||e.days||e.agentId||e.status!==`visible`)}function rh(e,t,n=Date.now()){return{search:t.trim()||void 0,sources:e.sources.length?e.sources:void 0,purposes:e.purposes.length?e.purposes:[...Eo],activity:e.activity||void 0,projectId:e.project&&e.project!==`__unassigned`?e.project:void 0,unassigned:e.project===`__unassigned`||void 0,updatedAfter:e.days?n-Number(e.days)*864e5:void 0,status:e.status===`visible`?void 0:e.status,excludeArchived:e.status!==`archived`,agentId:e.agentId||void 0,sortBy:`updatedAt`,sortOrder:`desc`}}function ih(e){return`xopc-session-filters-v1:${e}`}function ah(e){try{let t=Do.safeParse({sources:e.sources,purposes:e.purposes,activity:e.activity||void 0,agentId:e.agentId||void 0});return t.success?{...th,...t.data,sources:t.data.sources??[],purposes:t.data.purposes??[],activity:t.data.activity??``,agentId:t.data.agentId??``,project:typeof e.project==`string`?e.project:``,days:typeof e.days==`string`&&[``,`7`,`30`,`60`].includes(e.days)?e.days:``,status:e.status===`pinned`||e.status===`archived`?e.status:`visible`,details:e.details===!0}:{...th}}catch{return{...th}}}function oh(e){try{return ah(JSON.parse(localStorage.getItem(ih(e))??`{}`))}catch{return{...th}}}function sh(e,t){try{localStorage.setItem(ih(e),JSON.stringify(t))}catch{}}var ch=`xopc.webchat.newSessionPreferences`;function lh(){if(globalThis.localStorage===void 0)return hs();try{let e=globalThis.localStorage.getItem(ch);return ys(e?JSON.parse(e):null)}catch{return hs()}}function uh(e){try{globalThis.localStorage?.setItem(ch,JSON.stringify(e))}catch{}return e}function dh(e){return uh(bs(lh(),e))}function fh(e,t){return uh(xs(lh(),e,t))}function ph(e){return uh(Ss(lh(),e))}function mh(e,t){return uh(ws(lh(),e,t))}async function hh(e){let t=new URLSearchParams;e?.status&&t.set(`status`,e.status),e?.search?.trim()&&t.set(`search`,e.search.trim()),e?.sortBy&&t.set(`sortBy`,e.sortBy),e?.sortOrder&&t.set(`sortOrder`,e.sortOrder),e?.limit&&t.set(`limit`,String(e.limit)),e?.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return q(J(`/api/projects${n?`?${n}`:``}`))}async function gh(e){return(await q(J(`/api/projects/${encodeURIComponent(e)}`))).project}async function _h(e){let t=await q(J(`/api/projects/${encodeURIComponent(e)}/operating-view`));return Ha.parse(t&&typeof t==`object`?t.view:void 0)}async function vh(e,t={}){let n=new URLSearchParams;n.set(`visibility`,`timeline`),t.includeRelated&&n.set(`includeRelated`,`true`),t.limit&&n.set(`limit`,String(t.limit)),t.offset&&n.set(`offset`,String(t.offset));let r=n.toString();return q(J(`/api/projects/${encodeURIComponent(e)}/activity${r?`?${r}`:``}`))}async function yh(e){return(await q(J(`/api/projects`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)})).project}async function bh(e){let t=await q(J(`/api/projects/infer-defaults`),{method:`POST`,body:JSON.stringify(e)});return{inference:t.inference,defaultAgentId:t.defaultAgentId,executionMode:t.executionMode}}async function xh(e,t,n){return(await q(J(`/api/projects/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({...t,expectedVersion:n})})).project}async function Sh(e,t,n){return xh(e,{name:t},n)}async function Ch(e,t){return xh(e,{status:`archived`},t)}async function wh(e,t){return xh(e,{status:`active`},t)}async function Th(e,t){return(await q(J(`/api/projects/${encodeURIComponent(e)}/pin`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({expectedVersion:t})})).project}async function Eh(e,t){return(await q(J(`/api/projects/${encodeURIComponent(e)}/unpin`),{method:`POST`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({expectedVersion:t})})).project}async function Dh(e,t){await q(J(`/api/projects/${encodeURIComponent(e)}`),{method:`DELETE`,headers:{"idempotency-key":crypto.randomUUID()},body:JSON.stringify({expectedVersion:t})})}async function Oh(e){return(await q(J(`/api/projects/${encodeURIComponent(e)}/sessions?limit=100`))).sessions}async function kh(e){await q(J(`/api/projects/${encodeURIComponent(e)}/digest-knowledge`),{method:`POST`,body:JSON.stringify({})})}async function Ah(e,t){return(await q(J(`/api/projects/${encodeURIComponent(e)}/blockers`),{method:`POST`,body:JSON.stringify(t)})).blocker}async function jh(e,t){let n=await q(J(`/api/files/contexts/project/${encodeURIComponent(e)}`)),r=Wt.parse(n.space),i=new URLSearchParams;t&&i.set(`path`,t);let a=i.toString(),o=Kt.parse(await q(J(`/api/files/spaces/${encodeURIComponent(r.id)}/children${a?`?${a}`:``}`)));return{ok:!0,root:``,path:t??``,parentPath:t?.includes(`/`)?t.slice(0,t.lastIndexOf(`/`)):null,entries:o.items.map(e=>({fileId:e.id,name:e.name,path:e.relativePath,type:e.kind,size:e.size,updatedAt:new Date(e.modifiedAt).toISOString()}))}}async function Mh(e){let t=await q(J(`/api/files/contexts/project/${encodeURIComponent(e)}`)),n=Wt.parse(t.space),r=qt.parse(await q(J(`/api/files/spaces/${encodeURIComponent(n.id)}/root`)));return{fileId:r.resource.id,name:r.resource.name}}async function Nh(e,t,n=50){let r=await q(J(`/api/files/contexts/project/${encodeURIComponent(e)}`)),i=Wt.parse(r.space),a=new URLSearchParams({q:t.trim(),limit:String(n),spaceId:i.id});return Kt.parse(await q(J(`/api/files/search?${a}`))).items.map(e=>({name:e.name,path:e.relativePath,isDirectory:e.kind===`directory`}))}async function Ph(e,t){let n=lh(),r=t?Cs(n,t):void 0,i=await q(J(`/api/sessions`),{method:`POST`,body:JSON.stringify({projectId:e,...t?{agentId:t}:{},...r?{initialAgentConfig:{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}}:{}})});if(!r){let e=i.session.routing?.agentId,t=e?Cs(n,e):void 0;t&&await q(J(`/api/sessions/${encodeURIComponent(i.session.key)}/agent-config`),{method:`PATCH`,body:JSON.stringify({model:t.modelRef,...t.thinkingLevel?{thinkingLevel:t.thinkingLevel}:{}})})}return i.session}async function Fh(){let e=[];for(let t=0;;){let n=await hh({limit:100,offset:t,sortBy:`name`,sortOrder:`asc`});if(e.push(...n.items),t+=n.items.length,!n.items.length||t>=n.total)return e}}var Ih=e=>`xopc-session-views-v1:${e}`;function Lh(e){try{let t=JSON.parse(localStorage.getItem(Ih(e))??`[]`);return Array.isArray(t)?t.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&e.name.trim()).slice(0,20).map(e=>({id:e.id,name:e.name.slice(0,60),filters:ah(e.filters??{}),search:typeof e.search==`string`?e.search.slice(0,500):``})):[]}catch{return[]}}function Rh(e,t){try{return localStorage.setItem(Ih(e),JSON.stringify(t)),!0}catch{return!1}}var zh=`rounded-md px-2 py-1.5 text-xs text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,Bh=`flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`;function Vh(e){let t=(0,Q.c)(10),{label:n,summary:r,onClick:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-xs text-fg-muted`,title:r,children:r}),t[2]=r,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(lr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==n||t[6]!==i||t[7]!==a||t[8]!==o?(c=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-10 w-full min-w-0 items-center gap-3 rounded-md px-2 py-2 text-left text-sm hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":n,children:[a,o,s]}),t[5]=n,t[6]=i,t[7]=a,t[8]=o,t[9]=c):c=t[9],c}function Hh(e){let t=(0,Q.c)(261),{filters:n,onChange:r,search:i,onSearch:a,labels:o,gateway:s,agents:c}=e,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(`home`),[p,m]=(0,Z.useState)(``),h;t[0]===s?h=t[1]:(h=()=>Lh(s),t[0]=s,t[1]=h);let[g,_]=(0,Z.useState)(h),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),C=(0,Z.useRef)(null),w=(0,Z.useRef)(`home`),E=(0,Z.useId)(),D=(0,Z.useId)(),O;if(t[2]!==n||t[3]!==g||t[4]!==i){let e;t[6]!==n||t[7]!==i?(e=e=>e.search===i&&JSON.stringify(e.filters)===JSON.stringify(n),t[6]=n,t[7]=i,t[8]=e):e=t[8],O=g.find(e),t[2]=n,t[3]=g,t[4]=i,t[5]=O}else O=t[5];let k=O,A;t[9]!==n.project||t[10]!==s||t[11]!==l||t[12]!==d?(A=l&&d===`project`||n.project?[`session-filter-projects`,s]:null,t[9]=n.project,t[10]=s,t[11]=l,t[12]=d,t[13]=A):A=t[13];let{data:j,error:M,mutate:N}=Zt(A,Fh),P;t[14]!==n||t[15]!==r?(P=e=>r({...n,...e}),t[14]=n,t[15]=r,t[16]=P):P=t[16];let I=P,L;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>{f(e),m(``),x(!1)},t[17]=L):L=t[17];let R=L,z;t[18]===d?z=t[19]:(z=()=>R(d===`save`?`views`:[`purposes`,`status`,`agent`].includes(d)?`advanced`:`home`),t[18]=d,t[19]=z);let B=z,V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>{u(e),e&&R(`home`)},t[20]=V):V=t[20];let H=V,U,W;t[21]!==l||t[22]!==d?(U=()=>{l&&w.current!==d&&(C.current?.querySelector(`[data-page-autofocus]`))?.focus(),w.current=d},W=[l,d],t[21]=l,t[22]=d,t[23]=U,t[24]=W):(U=t[23],W=t[24]),(0,Z.useLayoutEffect)(U,W);let G;t[25]===n?G=t[26]:(G=nh({...n,activity:``}),t[25]=n,t[26]=G);let ee=G,te=n.status!==`visible`,ne;t[27]!==n.activity||t[28]!==n.agentId||t[29]!==n.days||t[30]!==n.project||t[31]!==n.purposes.length||t[32]!==n.sources.length||t[33]!==te?(ne=[n.sources.length,n.purposes.length,n.project,n.days,n.agentId,n.activity,te].filter(Boolean),t[27]=n.activity,t[28]=n.agentId,t[29]=n.days,t[30]=n.project,t[31]=n.purposes.length,t[32]=n.sources.length,t[33]=te,t[34]=ne):ne=t[34];let re=ne.length,ie=n.status!==`visible`,ae;t[35]!==n.agentId||t[36]!==n.purposes.length||t[37]!==ie?(ae=[n.purposes.length,n.agentId,ie].filter(Boolean),t[35]=n.agentId,t[36]=n.purposes.length,t[37]=ie,t[38]=ae):ae=t[38];let oe=ae.length,se;t[39]===o.selectedCount?se=t[40]:(se=e=>o.selectedCount.replace(`{{count}}`,String(e)),t[39]=o.selectedCount,t[40]=se);let ce=se,le;t[41]!==n.sources||t[42]!==o.all||t[43]!==o.sources?(le=n.sources.length?n.sources.map(e=>o.sources[e]).join(` · `):o.all,t[41]=n.sources,t[42]=o.all,t[43]=o.sources,t[44]=le):le=t[44];let ue=le,de;t[45]!==n.purposes||t[46]!==o.all||t[47]!==o.purposes?(de=n.purposes.length?n.purposes.map(e=>o.purposes[e]).join(` · `):o.all,t[45]=n.purposes,t[46]=o.all,t[47]=o.purposes,t[48]=de):de=t[48];let fe=de,pe;t[49]!==n.project||t[50]!==o.unassigned||t[51]!==j?(pe=n.project===`__unassigned`?o.unassigned:j?.find(e=>e.id===n.project)?.name??n.project,t[49]=n.project,t[50]=o.unassigned,t[51]=j,t[52]=pe):pe=t[52];let me=pe,he;t[53]!==n.days||t[54]!==o.anyTime||t[55]!==o.days?(he=n.days?o.days.replace(`{{days}}`,n.days):o.anyTime,t[53]=n.days,t[54]=o.anyTime,t[55]=o.days,t[56]=he):he=t[56];let ge=he,_e;t[57]!==o.agent||t[58]!==o.filters||t[59]!==o.moreFilters||t[60]!==o.project||t[61]!==o.purposesLabel||t[62]!==o.saveView||t[63]!==o.savedViews||t[64]!==o.sourcesLabel||t[65]!==o.status||t[66]!==o.time?(_e={home:o.filters,sources:o.sourcesLabel,purposes:o.purposesLabel,project:o.project,time:o.time,status:o.status,agent:o.agent,advanced:o.moreFilters,views:o.savedViews,save:o.saveView},t[57]=o.agent,t[58]=o.filters,t[59]=o.moreFilters,t[60]=o.project,t[61]=o.purposesLabel,t[62]=o.saveView,t[63]=o.savedViews,t[64]=o.sourcesLabel,t[65]=o.status,t[66]=o.time,t[67]=_e):_e=t[67];let be=_e,xe,q,Se,Ce,we;if(t[68]!==c||t[69]!==B||t[70]!==n.agentId||t[71]!==n.days||t[72]!==n.project||t[73]!==n.purposes||t[74]!==n.sources||t[75]!==n.status||t[76]!==o||t[77]!==p||t[78]!==d||t[79]!==I||t[80]!==j){let e;if(t[86]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[86]=e):e=t[86],we=e,d===`sources`){let e;t[87]===o.sources?e=t[88]:(e=e=>({value:e,label:o.sources[e]}),t[87]=o.sources,t[88]=e),q=To.map(e),we=n.sources;let r;t[89]===I?r=t[90]:(r=e=>I({sources:e}),t[89]=I,t[90]=r),xe=r}else if(d===`purposes`){let e;t[91]===o.purposes?e=t[92]:(e=e=>({value:e,label:o.purposes[e]}),t[91]=o.purposes,t[92]=e),q=Eo.map(e),we=n.purposes;let r;t[93]===I?r=t[94]:(r=e=>I({purposes:e}),t[93]=I,t[94]=r),xe=r}else if(d===`project`){q=[{value:``,label:o.allProjects},{value:`__unassigned`,label:o.unassigned},...(j??[]).map(Wh)],n.project&&!q.some(e=>e.value===n.project)&&q.push({value:n.project,label:n.project});let e;t[95]===n.project?e=t[96]:(e=[n.project],t[95]=n.project,t[96]=e),we=e;let r;t[97]!==B||t[98]!==I?(r=e=>{let[t]=e;I({project:t}),B()},t[97]=B,t[98]=I,t[99]=r):r=t[99],xe=r}else if(d===`time`){q=[{value:``,label:o.anyTime},...[`7`,`30`,`60`].map(e=>({value:e,label:o.days.replace(`{{days}}`,e)}))];let e;t[100]===n.days?e=t[101]:(e=[n.days],t[100]=n.days,t[101]=e),we=e;let r;t[102]!==B||t[103]!==I?(r=e=>{let[t]=e;I({days:t}),B()},t[102]=B,t[103]=I,t[104]=r):r=t[104],xe=r}else if(d===`status`){q=[`visible`,`pinned`,`archived`].map(e=>({value:e,label:o[e]}));let e;t[105]===n.status?e=t[106]:(e=[n.status],t[105]=n.status,t[106]=e),we=e;let r;t[107]!==B||t[108]!==I?(r=e=>{let[t]=e;I({status:t}),B()},t[107]=B,t[108]=I,t[109]=r):r=t[109],xe=r}else if(d===`agent`){q=[{value:``,label:o.allAgents},...c.map(Uh)],n.agentId&&!q.some(e=>e.value===n.agentId)&&q.push({value:n.agentId,label:n.agentId});let e;t[110]===n.agentId?e=t[111]:(e=[n.agentId],t[110]=n.agentId,t[111]=e),we=e;let r;t[112]!==B||t[113]!==I?(r=e=>{let[t]=e;I({agentId:t}),B()},t[112]=B,t[113]=I,t[114]=r):r=t[114],xe=r}Se=d===`project`||d===`agent`,Ce=q?.filter(e=>e.label.toLocaleLowerCase().includes(p.trim().toLocaleLowerCase())),t[68]=c,t[69]=B,t[70]=n.agentId,t[71]=n.days,t[72]=n.project,t[73]=n.purposes,t[74]=n.sources,t[75]=n.status,t[76]=o,t[77]=p,t[78]=d,t[79]=I,t[80]=j,t[81]=xe,t[82]=q,t[83]=Se,t[84]=Ce,t[85]=we}else xe=t[81],q=t[82],Se=t[83],Ce=t[84],we=t[85];let Te=Ce,Ee;t[115]!==n.details||t[116]!==r||t[117]!==d||t[118]!==I?(Ee=()=>{d===`sources`?I({sources:[]}):d===`purposes`?I({purposes:[]}):r({...th,details:n.details})},t[115]=n.details,t[116]=r,t[117]=d,t[118]=I,t[119]=Ee):Ee=t[119];let De=Ee,Oe=l&&`bg-surface-hover opacity-100`,J;t[120]===Oe?J=t[121]:(J=K(Bh,`relative size-6 text-fg-subtle opacity-0 transition-[color,background-color,opacity] group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100 [@media(hover:none)]:opacity-100`,Oe),t[120]=Oe,t[121]=J);let ke=`${o.filters}${re?` (${re})`:``}`,Ae;t[122]!==re||t[123]!==o.filters||t[124]!==ce?(Ae=re?`${o.filters} · ${ce(re)}`:o.filters,t[122]=re,t[123]=o.filters,t[124]=ce,t[125]=Ae):Ae=t[125];let je;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(je=(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),t[126]=je):je=t[126];let Me;t[127]!==re||t[128]!==i?(Me=re>0||i.trim()?(0,$.jsx)(`span`,{className:`absolute top-0.5 right-0.5 size-1 rounded-full bg-fg-muted`,"aria-hidden":!0}):null,t[127]=re,t[128]=i,t[129]=Me):Me=t[129];let Ne;t[130]!==J||t[131]!==ke||t[132]!==Ae||t[133]!==Me?(Ne=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:J,"aria-label":ke,title:Ae,children:[je,Me]})}),t[130]=J,t[131]=ke,t[132]=Ae,t[133]=Me,t[134]=Ne):Ne=t[134];let Pe;t[135]!==B||t[136]!==d?(Pe=e=>{d!==`home`&&(e.preventDefault(),B())},t[135]=B,t[136]=d,t[137]=Pe):Pe=t[137];let Fe;t[138]!==B||t[139]!==o.back||t[140]!==d||t[141]!==Se?(Fe=d===`home`?null:(0,$.jsx)(`button`,{type:`button`,className:Bh,"aria-label":o.back,onClick:B,"data-page-autofocus":!Se&&d!==`save`?``:void 0,children:(0,$.jsx)(Jn,{className:`size-4`,"aria-hidden":!0})}),t[138]=B,t[139]=o.back,t[140]=d,t[141]=Se,t[142]=Fe):Fe=t[142];let Ie=be[d],Le;t[143]!==D||t[144]!==Ie?(Le=(0,$.jsx)(`span`,{id:D,className:`min-w-0 flex-1 truncate px-1 font-medium`,children:Ie}),t[143]=D,t[144]=Ie,t[145]=Le):Le=t[145];let Re;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),t[146]=Re):Re=t[146];let ze;t[147]===o.close?ze=t[148]:(ze=(0,$.jsx)(_n,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Bh,"aria-label":o.close,children:Re})}),t[147]=o.close,t[148]=ze);let Be;t[149]!==Fe||t[150]!==Le||t[151]!==ze?(Be=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-edge px-2 py-2`,children:[Fe,Le,ze]}),t[149]=Fe,t[150]=Le,t[151]=ze,t[152]=Be):Be=t[152];let Ve;t[153]!==o.searchOptions||t[154]!==p||t[155]!==Se?(Ve=Se?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsx)(`input`,{type:`search`,"data-page-autofocus":!0,value:p,onChange:e=>m(e.target.value),placeholder:o.searchOptions,"aria-label":o.searchOptions,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-1.5 text-sm outline-none focus:border-edge-strong focus:ring-1 focus:ring-edge-strong`})}):null,t[153]=o.searchOptions,t[154]=p,t[155]=Se,t[156]=Ve):Ve=t[156];let He;t[157]!==o.search||t[158]!==a||t[159]!==d||t[160]!==i?(He=d===`home`?(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:(0,$.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-edge bg-surface-base px-2 py-1.5 focus-within:border-edge-strong focus-within:ring-1 focus-within:ring-edge-strong`,children:[(0,$.jsx)(ve,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:o.search,"aria-label":o.search,className:`min-w-0 w-full bg-transparent text-sm text-fg outline-none`})]})}):null,t[157]=o.search,t[158]=a,t[159]=d,t[160]=i,t[161]=He):He=t[161];let Ue;t[162]!==oe||t[163]!==ee||t[164]!==n.activity||t[165]!==n.details||t[166]!==o||t[167]!==r||t[168]!==d||t[169]!==me||t[170]!==g.length||t[171]!==ce||t[172]!==k?.name||t[173]!==ue||t[174]!==ge?(Ue=d===`home`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex gap-1 rounded-md bg-surface-base p-1`,role:`group`,"aria-label":o.filters,children:[``,`manual`,`automatic`].map(e=>(0,$.jsx)(`button`,{type:`button`,"data-page-autofocus":e===``?``:void 0,className:K(zh,`min-w-0 flex-1 px-1`,!ee&&n.activity===e&&`bg-surface-active text-fg`),"aria-pressed":!ee&&n.activity===e,onClick:()=>{r({...th,details:n.details,activity:e}),u(!1)},children:e?o[e]:o.all},e))}),(0,$.jsx)(Vh,{label:o.sourcesLabel,summary:ue,onClick:()=>R(`sources`)}),(0,$.jsx)(Vh,{label:o.project,summary:me||o.allProjects,onClick:()=>R(`project`)}),(0,$.jsx)(Vh,{label:o.time,summary:ge,onClick:()=>R(`time`)}),(0,$.jsx)(`div`,{className:`my-2 border-t border-edge`}),(0,$.jsx)(Vh,{label:o.moreFilters,summary:oe?ce(oe):``,onClick:()=>R(`advanced`)}),(0,$.jsx)(Vh,{label:o.savedViews,summary:k?.name??(g.length?String(g.length):``),onClick:()=>R(`views`)})]}):null,t[162]=oe,t[163]=ee,t[164]=n.activity,t[165]=n.details,t[166]=o,t[167]=r,t[168]=d,t[169]=me,t[170]=g.length,t[171]=ce,t[172]=k?.name,t[173]=ue,t[174]=ge,t[175]=Ue):Ue=t[175];let We;t[176]!==xe||t[177]!==o.noOptions||t[178]!==o.projectError||t[179]!==o.retry||t[180]!==Te||t[181]!==q||t[182]!==d||t[183]!==M||t[184]!==j||t[185]!==N||t[186]!==be||t[187]!==we?(We=q&&xe?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{options:Te??[],values:we,multiple:d===`sources`||d===`purposes`,onChange:xe,ariaLabel:be[d]}),d===`project`&&!j&&!M?(0,$.jsxs)(`div`,{"aria-busy":`true`,className:`space-y-3 p-2`,children:[(0,$.jsx)(xn,{className:`h-5 w-3/4`}),(0,$.jsx)(xn,{className:`h-5 w-2/3`})]}):null,d===`project`&&M?(0,$.jsxs)(`div`,{role:`alert`,className:`p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:o.projectError}),(0,$.jsx)(`button`,{type:`button`,className:zh,onClick:()=>void N(),children:o.retry})]}):null,!Te?.length&&!(d===`project`&&!j)?(0,$.jsx)(`p`,{className:`p-2 text-xs text-fg-muted`,children:o.noOptions}):null]}):null,t[176]=xe,t[177]=o.noOptions,t[178]=o.projectError,t[179]=o.retry,t[180]=Te,t[181]=q,t[182]=d,t[183]=M,t[184]=j,t[185]=N,t[186]=be,t[187]=we,t[188]=We):We=t[188];let Ge;t[189]!==c||t[190]!==n.agentId||t[191]!==n.details||t[192]!==n.status||t[193]!==o||t[194]!==d||t[195]!==I||t[196]!==fe?(Ge=d===`advanced`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Vh,{label:o.purposesLabel,summary:fe,onClick:()=>R(`purposes`)}),(0,$.jsx)(Vh,{label:o.status,summary:o[n.status],onClick:()=>R(`status`)}),c.length>1||n.agentId?(0,$.jsx)(Vh,{label:o.agent,summary:c.find(e=>e.id===n.agentId)?.name??(n.agentId||o.allAgents),onClick:()=>R(`agent`)}):null,(0,$.jsxs)(`label`,{className:`mt-2 flex min-h-10 items-center gap-3 border-t border-edge px-2 pt-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.details,onChange:e=>I({details:e.target.checked})}),o.details]})]}):null,t[189]=c,t[190]=n.agentId,t[191]=n.details,t[192]=n.status,t[193]=o,t[194]=d,t[195]=I,t[196]=fe,t[197]=Ge):Ge=t[197];let Ke;t[198]!==s||t[199]!==o.deleteView||t[200]!==o.noViews||t[201]!==r||t[202]!==a||t[203]!==d||t[204]!==g||t[205]!==k?.id?(Ke=d===`views`?(0,$.jsxs)($.Fragment,{children:[g.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-sm text-fg-muted`,children:o.noViews}),g.map(e=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-10 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-2 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>{r(e.filters),a(e.search),u(!1)},"aria-pressed":k?.id===e.id,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:e.name}),k?.id===e.id?(0,$.jsx)(S,{className:`size-4 shrink-0`,"aria-hidden":!0}):null]}),(0,$.jsx)(`button`,{type:`button`,className:Bh,"aria-label":o.deleteView.replace(`{{name}}`,e.name),onClick:()=>{let t=g.filter(t=>t.id!==e.id);Rh(s,t)?(_(t),x(!1)):x(!0)},children:(0,$.jsx)(pa,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))]}):null,t[198]=s,t[199]=o.deleteView,t[200]=o.noViews,t[201]=r,t[202]=a,t[203]=d,t[204]=g,t[205]=k?.id,t[206]=Ke):Ke=t[206];let qe;t[207]!==n||t[208]!==E||t[209]!==s||t[210]!==o.saveViewHint||t[211]!==o.viewLimit||t[212]!==o.viewName||t[213]!==d||t[214]!==g||t[215]!==i||t[216]!==v?(qe=d===`save`?(0,$.jsxs)(`form`,{id:E,className:`space-y-3 p-1`,onSubmit:e=>{e.preventDefault();let t=v.trim();if(!t||g.length>=20)return;let r=[...g,{id:crypto.randomUUID(),name:t,filters:n,search:i}];if(!Rh(s,r)){x(!0);return}_(r),y(``),R(`views`)},children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:o.viewName}),(0,$.jsx)(`input`,{"data-page-autofocus":!0,value:v,onChange:e=>y(e.target.value),maxLength:60,placeholder:o.viewName,"aria-label":o.viewName,className:`w-full rounded-md border border-edge bg-surface-base px-2 py-2 focus-visible:ring-2 focus-visible:ring-accent`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.saveViewHint}),g.length>=20?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.viewLimit}):null]}):null,t[207]=n,t[208]=E,t[209]=s,t[210]=o.saveViewHint,t[211]=o.viewLimit,t[212]=o.viewName,t[213]=d,t[214]=g,t[215]=i,t[216]=v,t[217]=qe):qe=t[217];let Je;t[218]!==o.viewSaveError||t[219]!==b?(Je=b?(0,$.jsx)(`p`,{role:`alert`,className:`p-2 text-xs text-danger`,children:o.viewSaveError}):null,t[218]=o.viewSaveError,t[219]=b,t[220]=Je):Je=t[220];let Ye;t[221]!==d||t[222]!==Ue||t[223]!==We||t[224]!==Ge||t[225]!==Ke||t[226]!==qe||t[227]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-2`,"data-session-filter-scroll":!0,children:[Ue,We,Ge,Ke,qe,Je]},d),t[221]=d,t[222]=Ue,t[223]=We,t[224]=Ge,t[225]=Ke,t[226]=qe,t[227]=Je,t[228]=Ye):Ye=t[228];let Xe;t[229]!==De||t[230]!==re||t[231]!==o.clear||t[232]!==o.clearSelection||t[233]!==o.saveView||t[234]!==d||t[235]!==g.length||t[236]!==we?(Xe=d===`home`||d===`sources`||d===`purposes`?(0,$.jsx)(`button`,{type:`button`,className:zh,disabled:d===`home`?!re:!we.length,onClick:De,children:d===`home`?o.clear:o.clearSelection}):d===`views`?(0,$.jsx)(`button`,{type:`button`,className:zh,disabled:g.length>=20,onClick:()=>R(`save`),children:o.saveView}):(0,$.jsx)(`span`,{}),t[229]=De,t[230]=re,t[231]=o.clear,t[232]=o.clearSelection,t[233]=o.saveView,t[234]=d,t[235]=g.length,t[236]=we,t[237]=Xe):Xe=t[237];let Ze;t[238]!==B||t[239]!==E||t[240]!==o.done||t[241]!==o.saveView||t[242]!==d||t[243]!==g.length||t[244]!==v?(Ze=d===`save`?(0,$.jsx)(`button`,{type:`submit`,form:E,className:K(zh,`bg-surface-active text-fg`),disabled:!v.trim()||g.length>=20,children:o.saveView}):(0,$.jsx)(`button`,{type:`button`,className:K(zh,`bg-surface-active text-fg`),onClick:()=>d===`home`?u(!1):B(),children:o.done}),t[238]=B,t[239]=E,t[240]=o.done,t[241]=o.saveView,t[242]=d,t[243]=g.length,t[244]=v,t[245]=Ze):Ze=t[245];let Qe;t[246]!==Xe||t[247]!==Ze?(Qe=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge px-3 py-2`,children:[Xe,Ze]}),t[246]=Xe,t[247]=Ze,t[248]=Qe):Qe=t[248];let $e;t[249]!==D||t[250]!==Pe||t[251]!==Be||t[252]!==Ve||t[253]!==He||t[254]!==Ye||t[255]!==Qe?($e=(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{ref:C,side:`bottom`,align:`start`,sideOffset:8,collisionPadding:12,sticky:`always`,"aria-labelledby":D,className:`z-50 flex h-[min(26rem,calc(100dvh-1.5rem))] max-h-[var(--radix-popover-content-available-height)] w-[min(20rem,calc(100vw-1.5rem))] max-w-[var(--radix-popover-content-available-width)] flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel text-sm text-fg shadow-popover`,onEscapeKeyDown:Pe,children:[Be,Ve,He,Ye,Qe]})}),t[249]=D,t[250]=Pe,t[251]=Be,t[252]=Ve,t[253]=He,t[254]=Ye,t[255]=Qe,t[256]=$e):$e=t[256];let et;return t[257]!==l||t[258]!==Ne||t[259]!==$e?(et=(0,$.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,$.jsxs)(hn,{open:l,onOpenChange:H,children:[Ne,$e]})}),t[257]=l,t[258]=Ne,t[259]=$e,t[260]=et):et=t[260],et}function Uh(e){return{value:e.id,label:e.name||e.id}}function Wh(e){return{value:e.id,label:e.name}}function Gh(e,t,n,r){var i=this,a=(0,Z.useRef)(null),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)(null),l=(0,Z.useRef)([]),u=(0,Z.useRef)(),d=(0,Z.useRef)(),f=(0,Z.useRef)(e),p=(0,Z.useRef)(!0),m=(0,Z.useRef)(),h=(0,Z.useRef)();f.current=e;var g=typeof window<`u`,_=!t&&t!==0&&g;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=+t||0;var v=!!(n||={}).leading,y=!(`trailing`in n)||!!n.trailing,b=!!n.flushOnExit&&y,x=`maxWait`in n,S=`debounceOnServer`in n&&!!n.debounceOnServer,C=x?Math.max(+n.maxWait||0,t):null,w=(0,Z.useMemo)(function(){var e=function(e){var t=l.current,n=u.current;return l.current=u.current=null,o.current=e,s.current=s.current||e,d.current=f.current.apply(n,t)},n=function(e,t){_&&cancelAnimationFrame(c.current),c.current=_?requestAnimationFrame(e):setTimeout(e,t)},w=function(e){if(!p.current)return!1;var n=e-a.current;return!a.current||n>=t||n<0||x&&e-o.current>=C},T=function(t){return c.current=null,y&&l.current?e(t):(l.current=u.current=null,d.current)},E=function e(){var r=Date.now();if(v&&s.current===o.current&&D(),w(r))return T(r);if(p.current){var i=t-(r-a.current);n(e,x?Math.min(i,C-(r-o.current)):i)}},D=function(){r&&r({})},O=function(){if(g||S){var r,s=Date.now(),f=w(s);if(l.current=[].slice.call(arguments),u.current=i,a.current=s,b&&!m.current&&(m.current=function(){globalThis.document?.visibilityState===`hidden`&&h.current.flush()},(r=globalThis.document)==null||r.addEventListener==null||r.addEventListener(`visibilitychange`,m.current)),f){if(!c.current&&p.current)return o.current=a.current,n(E,t),v?e(a.current):d.current;if(x)return n(E,t),e(a.current)}return c.current||n(E,t),d.current}};return O.cancel=function(){var e=c.current;e&&(_?cancelAnimationFrame(c.current):clearTimeout(c.current)),o.current=0,l.current=a.current=u.current=c.current=null,e&&r&&r({})},O.isPending=function(){return!!c.current},O.flush=function(){return c.current?T(Date.now()):d.current},O},[v,x,t,C,y,b,_,g,S,r]);return h.current=w,(0,Z.useEffect)(function(){return p.current=!0,function(){var e;b&&h.current.flush(),m.current&&=((e=globalThis.document)==null||e.removeEventListener==null||e.removeEventListener(`visibilitychange`,m.current),null),p.current=!1}},[b]),w}function Kh(e,t){return e===t}function qh(e,t,n){var r=n&&n.equalityFn||Kh,i=(0,Z.useRef)(e),a=(0,Z.useState)({})[1],o=Gh((0,Z.useCallback)(function(e){i.current=e,a({})},[a]),t,n,a),s=(0,Z.useRef)(e);return r(s.current,e)||(o(e),s.current=e),[i.current,o]}var Jh=new Map;async function Yh(e){let t=Co(e),n=Jh.get(t);if(n)return n;let r=J(`/api/sessions${mo(e)}`),i=(async()=>{let e=await jn(r);if(!e.ok){let t=await e.json().catch(()=>({})),n=typeof t.error==`string`?t.error:t.error?.message;throw Error(n??`HTTP ${e.status}`)}return await e.json()})().finally(()=>{Jh.delete(t)});return Jh.set(t,i),i}async function Xh(e){return fo(await q(J(bo(e))))}async function Zh(e){let t=await q(J(xo(e.containerId)),{method:`PUT`,body:JSON.stringify({itemIds:e.itemIds,expectedRevision:e.expectedRevision})});if(!t.ok||!t.layout)throw Error(t.error??`Failed to save sidebar order`);return t.layout}async function Qh(){return uo(await q(J(yo())))}async function $h(e,t){let n=ro(await q(J(ho(e,t))));if(!n.session)throw Error(`Session not found`);return n.session}async function eg(e){let t=await q(J(`/api/sessions/resolve`),{method:`POST`,body:JSON.stringify(e)});if(!t.ok||!t.payload)throw Error(t.error??`Session not found`);return t.payload}async function tg(e){so(await q(J(So(e,`delete`)),{method:`DELETE`}))}async function ng(e,t){return{renamed:co(await q(J(So(e,`rename`)),{method:`POST`,body:JSON.stringify({name:t})})).renamed===!0}}async function rg(e){so(await q(J(So(e,`archive`)),{method:`POST`}))}async function ig(e){so(await q(J(So(e,`unarchive`)),{method:`POST`}))}async function ag(e){so(await q(J(So(e,`pin`)),{method:`POST`}))}async function og(e){so(await q(J(So(e,`unpin`)),{method:`POST`}))}async function sg(e){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/export?format=json`))).content}var cg=30;function lg(e,t){let n=(0,Q.c)(47),r;n[0]===e?r=n[1]:(r=()=>oh(e),n[0]=e,n[1]=r);let[i,a]=(0,Z.useState)(r),[o,s]=(0,Z.useState)(``),[c]=qh(o,250),[l,u]=(0,Z.useState)(!1),d;n[2]!==i||n[3]!==o?(d=nh(i)||!!o.trim(),n[2]=i,n[3]=o,n[4]=d):d=n[4];let f=d,p;n[5]!==f||n[6]!==e||n[7]!==t?(p=f&&t?[`session-filter-projects`,e]:null,n[5]=f,n[6]=e,n[7]=t,n[8]=p):p=n[8];let{data:m}=Zt(p,Fh),h;n[9]!==c||n[10]!==i?(h=rh(i,c),n[9]=c,n[10]=i,n[11]=h):h=n[11];let g=h,_;n[12]!==f||n[13]!==e||n[14]!==g||n[15]!==t?(_=(n,r)=>!t||!f||r&&!r.hasMore?null:[`session-discovery`,e,t,g,n],n[12]=f,n[13]=e,n[14]=g,n[15]=t,n[16]=_):_=n[16];let v;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!1},n[17]=v):v=n[17];let{data:y,error:b,isValidating:x,size:S,setSize:C,mutate:w}=en(_,fg,v),T;n[18]===e?T=n[19]:(T=t=>{a(t),sh(e,t)},n[18]=e,n[19]=T);let E=T,D;n[20]===w?D=n[21]:(D=()=>{u(!1),w()},n[20]=w,n[21]=D);let O=D,k,A;n[22]===f?(k=n[23],A=n[24]):(k=()=>{if(!f)return;let e=()=>u(!0),t=[`session-list-refresh`,`session-created`,`session-updated`,`session-transcript-updated`,`project-updated`];return t.forEach(t=>window.addEventListener(t,e)),()=>t.forEach(t=>window.removeEventListener(t,e))},A=[f],n[22]=f,n[23]=k,n[24]=A),(0,Z.useEffect)(k,A);let j;n[25]===y?j=n[26]:(j=[...new Map(y?.flatMap(dg).map(ug)??[]).values()],n[25]=y,n[26]=j);let M=j,N=y?.[0]?.total??0,P=!b&&(!y||o!==c),F;n[27]===y?F=n[28]:(F=y?.at(-1)?.hasMore??!1,n[27]=y,n[28]=F);let I=x&&!!y,L;n[29]!==C||n[30]!==S?(L=()=>void C(S+1),n[29]=C,n[30]=S,n[31]=L):L=n[31];let R;return n[32]!==f||n[33]!==b||n[34]!==i||n[35]!==M||n[36]!==l||n[37]!==m||n[38]!==O||n[39]!==o||n[40]!==N||n[41]!==P||n[42]!==F||n[43]!==I||n[44]!==L||n[45]!==E?(R={projects:m,filters:i,updateFilters:E,search:o,setSearch:s,active:f,items:M,total:N,loading:P,error:b,hasMore:F,loadingMore:I,loadMore:L,refresh:O,pendingUpdate:l},n[32]=f,n[33]=b,n[34]=i,n[35]=M,n[36]=l,n[37]=m,n[38]=O,n[39]=o,n[40]=N,n[41]=P,n[42]=F,n[43]=I,n[44]=L,n[45]=E,n[46]=R):R=n[46],R}function ug(e){return[e.key,e]}function dg(e){return e.items}function fg(e){let[,,,t,n]=e;return Yh({...t,limit:cg,offset:n*cg})}function pg(e,t){let{source:n,purpose:r}=Oo(e),i=r===`chat`?[t.sources[n]]:[t.purposes[r]];return r!==`chat`&&n!==`other`&&!(r===`automation`&&n===`automation`)&&!(r===`system`&&n===`system`)&&i.push(t.sources[n]),r===`chat`&&n===`other`&&e.sourceChannel&&i.push(e.sourceChannel),[...new Set(i)].join(` · `)}var mg={feishu:`/channel-icons/feishu.svg`,lark:`/channel-icons/lark.svg`,telegram:`/channel-icons/telegram.svg`,wechat:`/channel-icons/wechat.svg`,weixin:`/channel-icons/weixin.svg`};function hg(e){let t=(0,Q.c)(16),{sourceChannel:n,className:r,session:i}=e,a=Oo(i??{sourceChannel:n}),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={automation:M,workflow:xa,subagent:se,system:qi},t[0]=o):o=t[0];let s=o,c=a.purpose===`chat`?void 0:s[a.purpose];if(c){let e;t[1]===r?e=t[2]:(e=K(`shrink-0`,r),t[1]=r,t[2]=e);let n;return t[3]!==c||t[4]!==e?(n=(0,$.jsx)(c,{className:e,strokeWidth:1.75,"aria-hidden":!0}),t[3]=c,t[4]=e,t[5]=n):n=t[5],n}let l=mg[n.trim().toLowerCase()];if(l&&[`telegram`,`wechat`,`feishu`].includes(a.source)){let e;t[6]===r?e=t[7]:(e=K(`shrink-0`,r),t[6]=r,t[7]=e);let n;return t[8]!==l||t[9]!==e?(n=(0,$.jsx)(`img`,{src:l,alt:``,draggable:!1,className:e,"aria-hidden":!0}),t[8]=l,t[9]=e,t[10]=n):n=t[10],n}let u=a.source===`workbench`?pe:a.source===`browser`?ki:a.source===`terminal`?ca:a.source===`api`?Ri:de,d;t[11]===r?d=t[12]:(d=K(`shrink-0`,r),t[11]=r,t[12]=d);let f;return t[13]!==u||t[14]!==d?(f=(0,$.jsx)(u,{className:d,strokeWidth:1.75,"aria-hidden":!0}),t[13]=u,t[14]=d,t[15]=f):f=t[15],f}var gg=e=>J(`/api/projects/${encodeURIComponent(e)}/understanding`);function _g(e){return q(gg(e))}function vg(e){return q(gg(e),{method:`POST`})}function yg(e,t){return q(gg(e),{method:`PATCH`,body:JSON.stringify({content:t})})}function bg(e){return e===`queued`||e===`probing`||e===`analyzing`}function xg(){let e=(0,Q.c)(2),t=Ee(Sg),n;return e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n),n.projectsPage.understanding}function Sg(e){return e.language}function Cg(e){let t=(0,Q.c)(14),{checked:n,onChange:r,disabled:i}=e,a=xg(),o;t[0]===r?o=t[1]:(o=e=>r(e.target.checked),t[0]=r,t[1]=o);let s;t[2]!==n||t[3]!==i||t[4]!==o?(s=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1 accent-accent`,checked:n,disabled:i,onChange:o}),t[2]=n,t[3]=i,t[4]=o,t[5]=s):s=t[5];let c;t[6]===a.hint?c=t[7]:(c=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:a.hint}),t[6]=a.hint,t[7]=c);let l;t[8]!==a.auto||t[9]!==c?(l=(0,$.jsxs)(`span`,{children:[a.auto,c]}),t[8]=a.auto,t[9]=c,t[10]=l):l=t[10];let u;return t[11]!==s||t[12]!==l?(u=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2.5 text-sm text-fg`,children:[s,l]}),t[11]=s,t[12]=l,t[13]=u):u=t[13],u}function wg(e){let t=(0,Q.c)(11),n=Se(Dg),r=Se(Eg),i;t[0]!==r||t[1]!==n||t[2]!==e?(i=r?[`project-understanding`,n,r,e]:null,t[0]=r,t[1]=n,t[2]=e,t[3]=i):i=t[3];let a;t[4]===e?a=t[5]:(a=()=>_g(e),t[4]=e,t[5]=a);let o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(o={refreshInterval:Tg,revalidateOnFocus:!1},t[6]=o):o=t[6];let s=Zt(i,a,o),{mutate:c}=s,l,u;return t[7]!==c||t[8]!==e?(l=()=>{let t=t=>{t.detail?.id===e&&c()};return window.addEventListener(`project-updated`,t),()=>window.removeEventListener(`project-updated`,t)},u=[c,e],t[7]=c,t[8]=e,t[9]=l,t[10]=u):(l=t[9],u=t[10]),(0,Z.useEffect)(l,u),s}function Tg(e){return bg(e?.status)?3e3:0}function Eg(e){return e.conversationId}function Dg(e){return e.baseUrl}function Og({projectId:e,onStarted:t,className:n}){let r=xg(),{data:i,mutate:a}=wg(e),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),u=bg(i?.status),d=async()=>{s(!0),l(!1);try{await vg(e),await a(),t?.()}catch{l(!0)}finally{s(!1)}};return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`button`,{type:`button`,className:n??`text-xs text-fg-muted hover:text-fg disabled:opacity-50`,disabled:o||u,onClick:()=>void d(),children:u||o?r.running:i?.status===`failed`||i?.status===`canceled`?r.retry:i?.status===`completed`?r.refresh:r.start}),c?(0,$.jsx)(`p`,{role:`alert`,className:`px-2 text-xs text-danger`,children:r.failed}):null]})}function kg({projectId:e}){let t=xg(),{data:n,error:r,isLoading:i,mutate:a}=wg(e),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=async()=>{d(!0),p(!1);try{await yg(e,c),await a(),s(!1)}catch{p(!0)}finally{d(!1)}};return i?(0,$.jsx)(xn,{className:`h-12 w-full rounded-xl`}):(0,$.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-panel px-5 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:bg(n?.status)?t.running:n?.status===`failed`||n?.status===`canceled`||r?t.failed:t.title}),bg(n?.status)?null:(0,$.jsx)(Og,{projectId:e})]}),n?.overview?(0,$.jsxs)(`details`,{className:`mt-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-fg-muted`,children:t.view}),o?(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,$.jsx)(`textarea`,{"aria-label":t.title,className:`min-h-48 w-full rounded-lg border border-edge bg-surface-base p-3 text-sm text-fg`,value:c,onChange:e=>l(e.target.value),maxLength:6e3,disabled:u}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{onClick:()=>void m(),disabled:u||!c.trim(),children:t.save}),(0,$.jsx)(X,{variant:`ghost`,disabled:u,onClick:()=>s(!1),children:t.cancel})]}),f?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:t.saveFailed}):null]}):(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:n.overview}),(0,$.jsx)(`button`,{type:`button`,className:`mt-2 text-xs text-fg-subtle hover:text-fg`,onClick:()=>{l(n.overview??``),s(!0)},children:t.edit})]})]}):null]})}function Ag(e,t){if(!e||typeof e!=`object`)return!0;let n=e.key??e.conversationId;return typeof n!=`string`||!n.trim()||!t.has(n)}var jg=null;async function Mg(){return jg||(jg=Ng().finally(()=>{jg=null}),jg)}async function Ng(){let e=await we(J(`/api/agents`));if(e.ok){let t=await e.json();if(t.ok&&t.payload?.defaultId&&Array.isArray(t.payload.agents)){let e=t.payload.defaultId.trim().toLowerCase(),n=t.payload.agents.filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase(),name:typeof e.name==`string`&&e.name.trim()?e.name.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,...typeof e.avatar==`string`&&e.avatar.trim()?{avatar:e.avatar.trim()}:{},skills:(e.effective?.skills?.mode===`selected`?e.effective.skills.include??[]:[]).filter(e=>typeof e==`string`&&!!e.trim())}));if(n.length>0)return{defaultId:e,items:n}}}let t=(await on()).payload?.config?.agents,n=(t?.defaultId??`main`).trim().toLowerCase(),r=(Array.isArray(t?.list)?t.list:[]).filter(e=>!!(e&&typeof e.id==`string`&&e.id.trim())).map(e=>({id:e.id.trim().toLowerCase()}));return r.length===0?{defaultId:n,items:[{id:n}]}:{defaultId:n,items:r}}var Pg=`[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62})`,Fg=RegExp(`\\/skill:(${Pg})`,`g`);function Ig(){return new RegExp(Fg.source,`g`)}var Lg=RegExp(`(\\/skill:${Pg})$`),Rg=RegExp(`(\\/skill:${Pg})([ \\t\\f\\v\\u00a0]*)$`),zg=RegExp(`^${Pg}$`);function Bg(e){return zg.test(e.trim())}function Vg(e,t){let n=e.trim(),r=t.trim();return n&&Bg(n)?`/skill:${n}${r?` ${r}`:` `}`:r||null}function Hg(e,t,n){let r=e.trim(),i=t?.trim()??``;if(!r&&!i)return null;let a=new URLSearchParams;return r&&a.set(`draft`,r),a.set(`autoSend`,`1`),i&&a.set(`attachmentsHandoff`,i),n?.projectScope===`none`&&a.set(`projectScope`,`none`),`/chat/new?${a.toString()}`}function Ug(e){let t=e.startsWith(`?`)?e.slice(1):e;if(!t)return``;let n=new URLSearchParams(t),r=new URLSearchParams,i=n.get(`skill`),a=n.get(`slash`),o=n.get(`draft`),s=n.get(`autoSend`),c=n.get(`attachmentHandoff`),l=n.get(`attachmentsHandoff`),u=n.get(`agentSetup`);i&&r.set(`skill`,i),a&&r.set(`slash`,a),o&&r.set(`draft`,o),s===`1`&&r.set(`autoSend`,`1`),c&&r.set(`attachmentHandoff`,c),l&&r.set(`attachmentsHandoff`,l),u===`1`&&r.set(`agentSetup`,`1`),n.get(`scene`)===`find-skills`&&r.set(`scene`,`find-skills`);let d=r.toString();return d?`?${d}`:``}function Wg(e){let t=e.startsWith(`?`)?e.slice(1):e,n=new URLSearchParams(t),r=n.get(`projectId`)?.trim();return r?{kind:`project`,projectId:r}:n.get(`projectScope`)===`none`?{kind:`none`}:{kind:`remember-last`}}function Gg(e){let t=e?.trim();return t?`/chat/new?projectId=${encodeURIComponent(t)}`:`/chat/new?projectScope=none`}var Kg=`xopc-pending-agent-run-changed`;function qg(e){typeof window>`u`||window.dispatchEvent(new CustomEvent(Kg,{detail:{chatId:e}}))}var Jg=/^No API key found for (\S+)/i;function Yg(e){try{let t=JSON.parse(e);return typeof t.kind!=`string`||typeof t.message!=`string`?null:{kind:t.kind,code:typeof t.code==`string`?t.code:t.kind,provider:typeof t.provider==`string`?t.provider:void 0,modelRef:typeof t.modelRef==`string`?t.modelRef:void 0,deepLink:typeof t.deepLink==`string`?t.deepLink:void 0,message:t.message}}catch{return null}}function Xg(){return{kind:`send_failed`,code:`send_failed`,message:`Send failed`}}function Zg(e){return{kind:`session_not_found`,code:`session_not_found`,message:e}}function Qg(e){let t=e.trim();if(!t)return null;if(t.startsWith(`{`)){let e=Yg(t);if(e)return e}let n=Jg.exec(t);return n?{kind:`provider_setup_required`,code:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:t===`Assistant turn failed`||t.startsWith(`Error: `)?{kind:`unknown`,code:`unknown`,message:t.startsWith(`Error: `)?t.slice(7):t}:{kind:`unknown`,code:`unknown`,message:t}}function $g(e){return e.kind!==`provider_setup_required`&&e.kind!==`provider_auth_invalid`||!e.provider?null:{kind:e.kind,provider:e.provider,deepLink:e.deepLink??`/settings/capabilities/models`,message:e.message}}function e_(e){return typeof e==`object`&&!!e&&`role`in e}function t_(e){if(!e||typeof e!=`object`)return!1;let t=e.type;return t===`tool_use`||t===`tool_call`||t===`toolCall`}function n_(e){return typeof e==`object`&&!!e}function r_(e){return typeof e.id==`string`&&e.id.length>0?e.id:crypto.randomUUID()}function i_(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function a_(e){return i_(e.args??e.arguments??e.input??e.function?.arguments)??{}}function o_(e){if(typeof e==`string`){let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}return Date.now()}function s_(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`string`)return;let t=Date.parse(e);return Number.isNaN(t)?void 0:t}var c_=3e5;function l_(e,t,n){let r=new URLSearchParams({uri:e.trim()});return t?.trim()&&r.set(`conversationId`,t.trim()),n?.trim()&&r.set(`taskId`,n.trim()),`/api/media/read?${r.toString()}`}function u_(e){if(typeof e.content==`string`&&e.content.length>0)return e.content;if(typeof e.data==`string`&&e.data.length>0)return e.data}var d_=[`.txt`,`.csv`,`.tsv`,`.md`,`.json`,`.xml`,`.html`,`.css`,`.js`,`.ts`,`.jsx`,`.tsx`,`.yml`,`.yaml`];function f_(e,t){let n=t.trim();if(n.startsWith(`data:`))return n;let r=n.replace(/\s/g,``);return`data:${e&&typeof e==`string`&&e.includes(`/`)?e:`application/octet-stream`};base64,${r}`}function p_(e){if(e==null||e===``)throw Error(`Missing file data`);let t=e;if(e.startsWith(`data:`)){let n=e.match(/base64,(.+)/);n&&(t=n[1])}let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}function m_(e){let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(1)} ${t[n]}`}function h_(e){let t=e.toLowerCase();for(let[e,n]of[[`.pdf`,`application/pdf`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.bmp`,`image/bmp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.ico`,`image/x-icon`],[`.tif`,`image/tiff`],[`.tiff`,`image/tiff`],[`.avif`,`image/avif`],[`.jxl`,`image/jxl`]])if(t.endsWith(e))return n}function g_(e,t){return(t?.startsWith(`text/`)??!1)||d_.some(t=>e.toLowerCase().endsWith(t))}function __(e){if(Array.isArray(e))return e.map(e=>v_(e))}function v_(e){if(!e||typeof e!=`object`)return{name:`file`,mimeType:`application/octet-stream`};let t=e,n=y_(t.uri),r=b_(t.name),i=x_(t.mimeType,r),a=typeof t.type==`string`?t.type:void 0,o=a===`photo`||a===`image`||i.startsWith(`image/`)?`image`:a===`voice`||a===`audio`||i.startsWith(`audio/`)?`voice`:a;return{id:typeof t.id==`string`?t.id:void 0,name:r,mimeType:i,type:o,size:typeof t.size==`number`?t.size:void 0,uri:n,bucket:typeof t.bucket==`string`?t.bucket:void 0,path:typeof t.path==`string`?t.path:void 0}}function y_(e){return typeof e==`string`&&e.trim().startsWith(`media://`)?e.trim():void 0}function b_(e){return typeof e==`string`&&e.trim().length>0?e.trim():`file`}function x_(e,t){if(typeof e==`string`&&e.trim().length>0){let t=e.trim();if(t.toLowerCase().split(`;`)[0]?.trim()!==`application/octet-stream`)return t}return h_(t)??`application/octet-stream`}function S_(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function C_(e){if(!e?.length)return;let t=[],n=new Set;for(let r of e){let e=S_(r);n.has(e)||(n.add(e),t.push(r))}return t.length?t:void 0}var w_=`[Startup context loaded by runtime]`,T_=`...[additional startup memory truncated]...`,E_=`END_QUOTED_NOTES`;function D_(...e){return e.filter(e=>e.length>0).join(`
9
-
10
- `)}function O_(e){if(!e.includes(w_))return e;let t=e.replace(/^\uFEFF/,``);if(!t.startsWith(w_))return e;let n=-1,r=t.lastIndexOf(E_);if(r>=0)n=r+16;else{let e=t.indexOf(T_);e>=0&&(n=e+43)}if(n<0){let n=t.slice(35),r=n.indexOf(`
11
-
12
- `);return r>=0?n.slice(r+2).replace(/^\s+/,``):e}return t.slice(n).replace(/^\s+/,``)}function k_(e){if(typeof e!=`string`||!e.includes(`## Skill:`))return e;let t=e.indexOf(`## Skill:`),n=e.slice(0,t).replace(/\s+$/,``),r=e.slice(t),i=r.match(/## Skill:\s*([^\s\r\n]+)/);if(!i)return e;let a=i[1]??``;if(!a)return e;let o=[...r.matchAll(/\*\*Arguments\*\*:\s*([^\r\n]+)/g)],s=o.length>0?(o[o.length-1]?.[1]??``).trim():``,c=s?`/skill:${a} ${s}`:`/skill:${a}`,l=r.length;if(o.length>0){let e=o[o.length-1];l=(e.index??0)+e[0].length}return D_(n,c,r.slice(l).replace(/^\s+/,``))}function A_(e){return e.includes(`<file path=`)?e.replace(/<file\s+path="[^"]*">\r?\n[\s\S]*?<\/file>(?:\r?\n)*/g,``).replace(/\n{3,}/g,`
13
-
14
- `).trim():e}function j_(e){let t=O_(e);return t=$o(t),t=A_(t),t=es(t),t=N_(t),k_(t)}var M_=/(?:\n{2,})?\[(?:Image description:|\d+ image\(s\) attached(?:; no image-capable model is available to describe them\.| but could not be described:))[\s\S]*\]\s*$/;function N_(e){return e.replace(M_,``).trimEnd()}function P_(e){return U_(e)}function F_(e){if(e.type!==`thinking`)return``;let t=e;return typeof t.text==`string`?t.text:typeof t.thinking==`string`?t.thinking:``}function I_(e,t){let n=e.map(e=>({...e})),r=new Map;for(let e=0;e<n.length;e++){let t=n[e];t.type===`tool_use`&&r.set(t.id,e)}for(let e of t){if(e.type===`tool_use`&&r.has(e.id)){let t=r.get(e.id);n[t]={...e};continue}if(e.type===`thinking`&&n.length>0){let t=n[n.length-1];if(t.type===`thinking`&&F_(t)===F_(e))continue}e.type===`tool_use`&&r.set(e.id,n.length),n.push({...e})}return n}function L_(e){if(e.length<2)return e;let t=[];for(let n of e){if(n.role!==`assistant`){t.push(n);continue}let e=t[t.length-1];e?.role===`assistant`?(e.content=I_(e.content,n.content),n.timestamp!=null&&(e.timestamp=n.timestamp),n.completedAt!=null&&(e.completedAt=n.completedAt),n.renderKey&&(e.renderKey=n.renderKey),!e.turnId&&n.turnId&&(e.turnId=n.turnId),n.progressiveRender&&(e.progressiveRender=!0),n.usage&&(e.usage=n.usage),n.outcome&&(e.outcome=n.outcome),n.attachments?.length&&(e.attachments=C_([...e.attachments??[],...n.attachments]))):t.push({...n,content:[...n.content]})}return t}function R_(e){return e.filter(e=>e.type===`text`).map(e=>e.text.trim()).filter(Boolean).join(`
15
- `)}function z_(e){return e.filter(e=>e.type===`thinking`).map(e=>(e.text??``).trim()).filter(Boolean).join(`
16
- `)}function B_(e){return e.filter(e=>e.type===`tool_use`).map(e=>{let t=typeof e.result==`string`?e.result.trim():JSON.stringify(e.result??``);return`${e.name}|${e.status}|${t}`}).join(`
17
- `)}function V_(e){return e.filter(e=>e.type===`review`).map(e=>JSON.stringify(e)).join(`
18
- `)}function H_(e,t){return e.role!==`assistant`||t.role!==`assistant`?!1:R_(e.content)===R_(t.content)&&z_(e.content)===z_(t.content)&&B_(e.content)===B_(t.content)&&V_(e.content)===V_(t.content)&&JSON.stringify(e.outcome??null)===JSON.stringify(t.outcome??null)}function U_(e){let t=[];for(let n of e){if(!e_(n))continue;let e=n,r=String(e.role??``);if(r!==`system`){if(r===`toolResult`||r===`tool`){ev(t,e);continue}if(r===`user`){t.push(K_(e));continue}if(r===`assistant`){t.push(Y_(e));continue}}}return L_(t)}function W_(e){return e.filter(e=>e.type===`text`).map(e=>({...e,text:j_(e.text)})).filter(e=>!!e.text?.trim())}function G_(e){return C_([...__(e.media)??[],...__(e.attachments)??[]])}function K_(e){let t=e.content,n=typeof t==`string`?(()=>{let e=j_(t);return e.trim()?[{type:`text`,text:e}]:[]})():W_(iv(t));return{role:`user`,...e.turnId?{turnId:e.turnId}:{},content:n,attachments:G_(e),contextRefs:q_(e.metadata),userTurnDocument:J_(e.metadata),timestamp:typeof e.timestamp==`number`?e.timestamp:o_(e.timestamp),usage:e.usage}}function q_(e){let t=X_(e)?.sourceContexts;if(!Array.isArray(t))return;let n=t.flatMap(e=>{let t=X_(e);return!t||t.kind!==`note`&&t.kind!==`file`&&t.kind!==`session`&&t.kind!==`browser_tab`&&t.kind!==`mcp_resource`||typeof t.sourceId!=`string`||typeof t.version!=`string`||typeof t.title!=`string`?[]:[{...typeof t.refId==`string`?{refId:t.refId}:{},kind:t.kind,sourceId:t.sourceId,version:t.version,title:t.title,...typeof t.tokenEstimate==`number`?{tokenEstimate:t.tokenEstimate}:{},...t.truncated===!0?{truncated:!0}:{},...t.kind===`file`&&(t.fileKind===`file`||t.fileKind===`directory`)?{fileKind:t.fileKind}:{}}]});return n.length>0?n:void 0}function J_(e){let t=X_(e)?.userTurnDocument;return us(t)?t:void 0}function Y_(e){let t=$_(e);Q_(t,e.metadata);let n=_t(X_(e.metadata)?.turnOutcome);return{role:`assistant`,...e.turnId?{turnId:e.turnId}:{},content:t,attachments:G_(e),...n?{outcome:n}:{},timestamp:typeof e.timestamp==`number`?e.timestamp:o_(e.timestamp),usage:e.usage}}function X_(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Z_(e){let t=X_(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=X_(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function Q_(e,t){let n=Z_(X_(t)?.review);n&&(e.some(e=>e.type===`review`&&e.target===n.target)||e.push(n))}function $_(e){let t=s_(e.timestamp),n=iv(e.rawContent,t),r=n.length>0?n:iv(e.content,t),i=e.tool_calls;if(Array.isArray(i))for(let e of i){if(!e?.id||r.some(t=>t.type===`tool_use`&&t.id===e.id))continue;let n=e.function?.arguments;if(typeof n==`string`)try{n=JSON.parse(n)}catch{}r.push({type:`tool_use`,id:e.id,name:e.function?.name||`tool`,input:n,status:`running`,startedAt:t})}let a=e.toolCalls;if(Array.isArray(a))for(let e=0;e<a.length;e+=1){let n=a[e],i=typeof n.id==`string`&&n.id?n.id:`tool-call-${e}-${n.name||`tool`}`,o=typeof n.result==`string`,s=r.find(e=>e.type===`tool_use`&&e.id===i);if(s){s.status=o?n.isError?`error`:`done`:s.status,s.result=o?n.result:s.result,s.details=n.details??s.details,o&&(s.completedAt=t,s.durationMs=s.startedAt!=null&&t!=null?Math.max(0,t-s.startedAt):s.durationMs);continue}r.push({type:`tool_use`,id:i,name:n.name||`tool`,input:n.args,status:o?n.isError?`error`:`done`:`running`,result:o?n.result:void 0,details:n.details,startedAt:t,completedAt:o?t:void 0,durationMs:o&&t!=null?0:void 0})}for(let e of r){if(e.type!==`tool_use`)continue;let t=e.details===void 0?e.result:{details:e.details,result:e.result};e.activity=Ut(e.name,e.status===`running`?`running`:e.status===`error`?`failed`:`completed`,t)}let o=r.some(e=>e.type===`tool_use`)?`narration`:`answer`;for(let e of r)e.type===`text`&&!e.presentation&&(e.presentation=o);return r}function ev(e,t){let n=tv(e);if(!n)return;let r=String(t.tool_call_id??t.toolCallId??``),i=nv(t.content),a=!!t.isError,o=s_(t.timestamp),s=r?n.content.find(e=>e.type===`tool_use`&&e.id===r):void 0;if(s){s.status=a?`error`:`done`,s.result=i,s.details=t.details,s.activity=Ut(s.name,a?`failed`:`completed`,{details:t.details,result:i}),s.completedAt=o,s.startedAt!=null&&o!=null&&(s.durationMs=Math.max(0,o-s.startedAt));return}let c=n.content.filter(e=>e.type===`tool_use`&&e.status===`running`);c.length===1&&(c[0].status=a?`error`:`done`,c[0].result=i,c[0].details=t.details,c[0].activity=Ut(c[0].name,a?`failed`:`completed`,{details:t.details,result:i}),c[0].completedAt=o,c[0].startedAt!=null&&o!=null&&(c[0].durationMs=Math.max(0,o-c[0].startedAt)))}function tv(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`)return e[t];return null}function nv(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>n_(e)&&e.type===`text`).map(e=>String(e.text??``)).join(`
19
- `):String(e??``)}function rv(e){let t=e.source?.data;if(typeof t==`string`&&t.length>0)return{type:`image`,source:{data:t}};let n=e.data;if(typeof n!=`string`||n.length===0)return null;let r=n.trim();return r.startsWith(`data:`)?{type:`image`,source:{data:r}}:{type:`image`,source:{data:`data:${typeof e.mimeType==`string`&&e.mimeType.includes(`/`)?e.mimeType:`image/png`};base64,${r.replace(/\s/g,``)}`}}}function iv(e,t){if(e==null)return[];if(typeof e==`string`)return e.trim()?[{type:`text`,text:e}]:[];if(!Array.isArray(e))return[{type:`text`,text:String(e)}];let n=[];for(let r of e){if(!n_(r))continue;let e=r.type;if(e===`text`&&typeof r.text==`string`){let e=r.presentation===`pending`||r.presentation===`narration`||r.presentation===`answer`?r.presentation:void 0;n.push({type:`text`,text:r.text,...e?{presentation:e}:{}})}else if(e===`thinking`){let e=typeof r.thinking==`string`?r.thinking:typeof r.text==`string`?r.text:``;n.push({type:`thinking`,text:e,streaming:!1})}else if(e===`image`){let e=rv(r);e&&n.push(e)}else if(e===`review`){let e=Z_(r);e&&n.push(e)}else if(e===`tool_use`||e===`tool_call`){if(!t_(r))continue;let e=r_(r),i=String(r.name??r.function?.name??`tool`),a=r.input??r.function?.arguments;n.push({type:`tool_use`,id:e,toolCallId:e,name:i,input:a,status:`done`,startedAt:t,result:typeof r.result==`string`?r.result:void 0,details:r.details})}else if(e===`toolCall`){if(!t_(r))continue;let e=r_(r),i=String(r.name??r.function?.name??`tool`);n.push({type:`tool_use`,id:e,toolCallId:e,name:i,input:a_(r),status:`done`,startedAt:t,result:typeof r.result==`string`?r.result:void 0,details:r.details})}}return n}function av(e){return e.replace(/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}[^\]]*\]\s+/,``)}function ov(e){return(e??[]).filter(e=>e.type===`text`&&!!e.text).map(e=>j_(av(e.text))).join(`
20
-
21
- `).trim()}function sv(e,t){let n=e[t];if(!n||n.role!==`user`)return!1;for(let n=t+1;n<e.length;n++)if(e[n].role===`user`)return!1;return!0}function cv(e){if(e?.length)return e.map(e=>{let t=e.data??e.content;return{id:e.id,type:e.type??(e.mimeType?.startsWith(`image/`)?`image`:`document`),mimeType:e.mimeType,...t?{data:t}:{},name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...e.bucket?{bucket:e.bucket}:{},...e.path?{path:e.path}:{},durationSeconds:e.durationSeconds}})}function lv(e){return e===`user`}function uv(e,t){if(t<0||t>=e.length)return null;let n=e[t];if(!n||!lv(n.role))return null;let r=0;for(let n=0;n<=t;n++){let t=e[n];t&&lv(t.role)&&(r+=1)}return r-1}function dv(e,t){let n=1;for(let r=t+1;r<e.length;r++){let t=e[r];if(t&&lv(t.role))break;n+=1}return n}function fv(e){let t=typeof e.timestamp==`number`&&Number.isFinite(e.timestamp)?e.timestamp:Date.now();if(Array.isArray(e.content)||typeof e.content==`string`){let[n]=U_([{role:`user`,turnId:typeof e.turnId==`string`?e.turnId:void 0,content:e.content,media:e.media,attachments:e.attachments,metadata:e.metadata,timestamp:t}]);return n??null}let n=typeof e.text==`string`?j_(e.text.trim()):``,r=__(e.media);return!n&&!r?.length?null:{role:`user`,turnId:typeof e.turnId==`string`?e.turnId:void 0,content:n?[{type:`text`,text:n}]:[],attachments:r,timestamp:t}}var pv=12e4;function mv(e,t){if(!lv(e.role)||!lv(t.role))return!1;let n=ov(e.content).trim(),r=ov(t.content).trim(),i=e.attachments?.length??0,a=t.attachments?.length??0,o=i===0||a>=i;return!!(o&&n&&r&&(n===r||r.startsWith(n))||i>0&&o&&Math.abs((t.timestamp??0)-(e.timestamp??0))<=pv)}function hv(e,t){return!lv(e.role)||!lv(t.role)?!1:e.timestamp===t.timestamp?!0:ov(e.content)===ov(t.content)}function gv(e,t){let n=e.length-1,r=e[n];if(!r||!lv(r.role)||r.turnId)return e;let i=[...e];return i[n]={...r,turnId:t},i}var _v=32*1024*1024,vv=1e4,yv,bv=new Set;function xv(e,t){yv={type:`endpoint`,endpointId:e,token:t};for(let e of bv)e(yv);bv.clear()}function Sv(e){!yv||e&&yv.token!==e||(yv=void 0)}function Cv(e){return yv?Promise.resolve(yv):e?.aborted?Promise.reject(e.reason):new Promise((t,n)=>{let r=e=>{o(),t(e)},i=()=>{o(),n(e?.reason??new DOMException(`Aborted`,`AbortError`))},a=globalThis.setTimeout(()=>{o(),n(Error(`Endpoint connection is not ready`))},vv),o=()=>{globalThis.clearTimeout(a),bv.delete(r),e?.removeEventListener(`abort`,i)};bv.add(r),e?.addEventListener(`abort`,i,{once:!0})})}var wv=25*1024*1024,Tv=mt([`web`,`desktop`,`mobile`,`browser`]),Ev=mt([`foreground`,`background`]),Dv=mt([`read`,`write`,`destructive`]),Ov=mt([`never`,`always`]),kv=mt([`text`,`json`,`file`]),Av=mt([`public`,`personal`]),jv=Y().min(1).max(160),Mv=Y().min(32).max(160).regex(/^[A-Za-z0-9_-]+$/);it(`type`,[ot({type:pt(`endpoint`),endpointId:jv}),ot({type:pt(`channel`),channel:Y().min(1).max(64)}),ot({type:pt(`system`),source:mt([`cli`,`automation`,`heartbeat`,`workflow`,`internal`])})]).options[0].extend({token:Mv});var Nv=rt(),Pv=ut().int().nonnegative(),Fv=at(Y(),st()),Iv=ot({name:Y().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120),title:Y().min(1).max(120),description:Y().min(1).max(2e3),inputSchema:Fv,outputSchema:Fv,policyId:Y().regex(/^[a-z][a-z0-9_.-]+$/).max(120),sensitivity:Av,effect:Dv,confirmation:Ov,requiresForeground:lt(),requiredPermissions:ft(Y().min(1).max(120)).max(20),timeoutMs:ut().int().min(1e3).max(3e5),maxConcurrency:ut().int().min(1).max(4),supportsCancellation:lt(),idempotent:lt(),resultKinds:ft(kv).min(1).max(3)});ot({principalId:jv,displayName:Y().min(1).max(120),kind:Tv,platform:Y().min(1).max(80),publicKey:Y().min(32).max(2048)}),ot({endpointId:jv});var Lv=Y().regex(/^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)+$/).max(120);ot({jobId:rt(),endpointId:jv,capability:Lv,input:Fv,idempotencyKey:jv,consentGrantId:jv,createdAt:Pv,expiresAt:Pv}),ot({jobId:rt(),status:mt([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),updatedAt:Pv,output:Fv.optional(),error:ot({code:jv,message:Y().min(1).max(2e3)}).optional()}),ot({eventId:rt(),endpointId:jv,subscriptionId:jv,eventType:Lv,data:Fv,occurredAt:Pv});var Rv=ot({principalId:jv,endpointId:jv,connectionInstanceId:rt(),displayName:Y().min(1).max(120),kind:Tv,platform:Y().min(1).max(80),appVersion:Y().min(1).max(80),availability:Ev,nonce:jv,signedAt:Pv,signature:Y().min(16).max(1024),tools:ft(Iv).max(100)}),zv=ot({invocationId:rt(),toolCallId:jv,toolName:Iv.shape.name,arguments:Fv,descriptorRevision:Y().min(1).max(128),confirmationRequired:lt(),deadlineAt:Pv,uploadGrant:ot({path:Y().startsWith(`/`).max(500),token:jv,maxBytes:ut().int().positive(),maxFiles:ut().int().min(1).max(20),expiresAt:Pv}).optional()}),Bv=ot({invocationId:rt(),reason:Y().min(1).max(500)}),Vv=ot({invocationId:rt()}),Hv=it(`type`,[ot({type:pt(`text`),text:Y().max(256*1024)}),ot({type:pt(`json`),value:st()}),ot({type:pt(`file`),fileId:jv,name:Y().min(1).max(255),mimeType:Y().min(1).max(255),size:ut().int().nonnegative(),sha256:Y().regex(/^[a-f0-9]{64}$/)})]),Uv=mt([`ENDPOINT_OFFLINE`,`ENDPOINT_NOT_FOREGROUND`,`ENDPOINT_DISCONNECTED`,`TOOL_NOT_FOUND`,`TOOL_REVISION_MISMATCH`,`INVALID_ARGUMENTS`,`PERMISSION_DENIED`,`USER_DENIED`,`TOOL_BUSY`,`TOOL_TIMEOUT`,`TOOL_CANCELLED`,`RESULT_TOO_LARGE`,`PROTOCOL_ERROR`]),Wv=(e,t)=>ot({protocolVersion:pt(2),messageId:Nv,type:pt(e),sentAt:Pv,payload:t}),Gv=it(`type`,[Wv(`endpoint.availability_changed`,ot({availability:Ev})),Wv(`tool.received`,Vv),Wv(`tool.progress`,ot({invocationId:rt(),message:Y().max(500).optional(),percent:ut().min(0).max(100).optional()})),Wv(`tool.result`,ot({invocationId:rt(),content:ft(Hv).min(1).max(20),details:Fv.optional()})),Wv(`tool.error`,ot({invocationId:rt(),code:Uv,message:Y().min(1).max(2e3)})),Wv(`tool.cancelled`,Vv)]),Kv=it(`type`,[Wv(`tool.invoke`,zv),Wv(`tool.cancel`,Bv)]),qv={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`text`],properties:{type:{const:`text`},text:{type:`string`,maxLength:256*1024}}}},Jv={type:`array`,minItems:1,maxItems:20,items:{type:`object`,additionalProperties:!1,required:[`type`,`fileId`,`name`,`mimeType`,`size`,`sha256`],properties:{type:{const:`file`},fileId:{type:`string`,minLength:1,maxLength:160},name:{type:`string`,minLength:1,maxLength:255},mimeType:{type:`string`,minLength:1,maxLength:255},size:{type:`integer`,minimum:0},sha256:{type:`string`,pattern:`^[a-f0-9]{64}$`}}}};function Yv(e){if(e===null)return`null`;if(typeof e==`string`||typeof e==`boolean`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Canonical JSON only supports finite numbers`);return JSON.stringify(e)}if(typeof e!=`object`)throw Error(`Canonical JSON does not support ${typeof e}`);if(Array.isArray(e))return`[${e.map(Yv).join(`,`)}]`;let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw Error(`Canonical JSON only supports plain objects`);let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${Yv(n[e])}`).join(`,`)}}`}function Xv(e){let{signature:t,...n}=e;return Yv(n)}var Zv=256*1024,Qv=15e3,$v=45e3,ey=[`realtime.capability-negotiation.v1`],ty=mt([`web`,`desktop`,`mobile`,`browser_extension`,`tui`,`mcp`]),ny=Y().min(1).max(512),ry=Y().regex(/^[a-z][a-z0-9_.-]*$/).max(160),iy=rt(),ay=ut().int().nonnegative(),oy=ut().int().positive(),sy=Y().min(1).max(160),cy=(e,t)=>ht({protocolVersion:pt(2),messageId:iy,kind:pt(e),sentAt:ay,payload:t}),ly=ht({topic:ny,afterSeq:ut().int().nonnegative().optional()});it(`kind`,[cy(`realtime.hello`,ht({ticket:Y().min(32).max(512),clientId:Y().min(1).max(160),clientKind:ty,subscriptions:ft(ly).max(100).default([]),capabilities:ft(sy).max(64).optional(),endpoint:Rv.optional()})),cy(`realtime.subscribe`,ht({subscriptions:ft(ly).min(1).max(100)})),cy(`realtime.unsubscribe`,ht({topics:ft(ny).min(1).max(100)})),cy(`realtime.ping`,ht({})),cy(`endpoint.message`,Gv)]);var uy=ht({topic:ny,seq:oy,event:ry,data:st()}),dy=it(`kind`,[cy(`realtime.ready`,ht({connectionId:rt(),heartbeatIntervalMs:pt(Qv),heartbeatTimeoutMs:pt($v),negotiatedCapabilities:ft(sy).max(64).optional(),endpoint:ht({endpointId:Y().min(1).max(160),turnToken:Y().min(32).max(160)}).optional()})),cy(`realtime.event`,uy),cy(`realtime.subscribed`,ht({topic:ny,cursor:ut().int().nonnegative()})),cy(`realtime.gap`,ht({topic:ny,requestedSeq:ut().int().nonnegative(),earliestSeq:oy,recoverable:lt()})),cy(`realtime.pong`,ht({})),cy(`realtime.error`,ht({code:Y().min(1).max(80),message:Y().min(1).max(500)})),cy(`endpoint.message`,Kv)]);function fy(e){return dy.parse(e)}var py=class extends Error{retryable;constructor(e,t){super(e),this.retryable=t,this.name=`RealtimeConnectionError`}},my=class extends Error{bytes;maxBytes;constructor(e,t){super(`Realtime client frame is ${e} bytes; maximum is ${t} bytes`),this.bytes=e,this.maxBytes=t,this.name=`RealtimeFrameTooLargeError`}};function hy(e){if(typeof e==`string`)return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(e);if(ArrayBuffer.isView(e)){let t=Uint8Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return new TextDecoder().decode(t)}throw Error(`Realtime server sent a non-text frame`)}function gy(e){return e===1009||e===4400||e===4401||e===4409||e===4413}var _y=class{options;desiredSubscriptions=new Map;cursors=new Map;socket;reconnectTimer;heartbeatTimer;connectionTimer;ticketAbort;generation=0;reconnectAttempts=0;shouldReconnect=!1;ready=!1;lastServerMessageAt=0;endpointBinding;reconnectWhenSocketOpens=!1;offeredCapabilities=new Set;constructor(e){this.options=e}connect(){this.shouldReconnect||(this.shouldReconnect=!0,this.open(!1))}disconnect(){this.shouldReconnect=!1,this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client disconnected`),this.socket=void 0,this.options.onStateChange?.(`disconnected`)}reconnect(){this.reconnectWhenSocketOpens=!1,this.generation+=1,this.clearTimers(),this.ready=!1,this.endpointBinding?.onDisconnected?.(),this.socket?.close(1e3,`Client reconnecting`),this.socket=void 0,this.reconnectAttempts=0,this.shouldReconnect=!0,this.open(!0)}subscribe(e,t){this.desiredSubscriptions.set(e,t),t!==void 0&&this.cursors.set(e,t),this.ready&&this.sendSubscriptions([{topic:e,afterSeq:this.cursors.get(e)??t}])}unsubscribe(e){this.desiredSubscriptions.delete(e),this.ready&&this.send(this.clientMessage(`realtime.unsubscribe`,{topics:[e]}))}sendEndpointMessage(e){if(!this.ready)throw Error(`Realtime connection is not ready`);this.send(this.clientMessage(`endpoint.message`,e))}setEndpoint(e){this.endpointBinding=e,this.refreshEndpointConnection()}clearEndpoint(e){if(e&&this.endpointBinding!==e)return;let t=this.endpointBinding;this.endpointBinding=void 0,t?.onDisconnected?.(),this.refreshEndpointConnection()}refreshEndpointConnection(){if(this.shouldReconnect){if(this.socket?.readyState===0){this.reconnectWhenSocketOpens=!0;return}this.reconnect()}}async open(e){let t=++this.generation,n=this.options.connectionTimeoutMs??15e3,r=new AbortController;this.ticketAbort?.abort(),this.ticketAbort=r;let i,a=!1,o,s=(e,n=!0)=>{a||t!==this.generation||(a=!0,this.clearConnectionTimer(),r.abort(),this.ticketAbort===r&&(this.ticketAbort=void 0),this.ready=!1,this.offeredCapabilities.clear(),this.endpointBinding?.onDisconnected?.(),this.clearHeartbeat(),this.socket===i&&(this.socket=void 0),i&&(i.onopen=null,i.onmessage=null,i.onerror=null,i.onclose=null,i.close(4e3,e.slice(0,120))),this.shouldReconnect&&n?this.scheduleReconnect(e):this.shouldReconnect?(this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e)):this.options.onStateChange?.(`disconnected`))};this.connectionTimer=setTimeout(()=>s(`Realtime connection timed out`),n),this.options.onStateChange?.(e?`reconnecting`:`connecting`);try{let[e,n]=await Promise.all([this.options.issueTicket(r.signal),this.endpointBinding?.createHello()]),c=e.ticket;if(2<e.realtime.minVersion)throw new py(`CLIENT_UPDATE_REQUIRED`,!1);if(2>e.realtime.maxVersion)throw new py(`GATEWAY_UPDATE_REQUIRED`,!1);let l=ey.filter(t=>e.realtime.capabilities.includes(t));if(a||!this.shouldReconnect||t!==this.generation)return;this.offeredCapabilities=new Set(l??[]),i=this.options.createWebSocket(this.options.getWebSocketUrl()),this.socket=i,i.onopen=()=>{if(t!==this.generation)return;if(this.reconnectWhenSocketOpens){this.reconnect();return}let e=[...this.desiredSubscriptions].map(([e,t])=>({topic:e,afterSeq:this.cursors.get(e)??t}));this.send(this.clientMessage(`realtime.hello`,{ticket:c,clientId:this.options.clientId,clientKind:this.options.clientKind,subscriptions:e,...l?.length?{capabilities:l}:{},...n?{endpoint:n}:{}}))},i.onmessage=e=>{if(t!==this.generation)return;let n=()=>{if(!(a||t!==this.generation))return this.handleServerMessage(hy(e.data))};if(!o){try{let e=n();if(!e)return;let t=e.catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=t,t.finally(()=>{o===t&&(o=void 0)})}catch(e){s(e instanceof Error?e.message:`Invalid realtime server message`)}return}let r=o.then(n).catch(e=>s(e instanceof Error?e.message:`Invalid realtime server message`)).then(()=>void 0);o=r,r.finally(()=>{o===r&&(o=void 0)})},i.onerror=()=>{},i.onclose=e=>{s(e.reason||`WebSocket closed (${e.code??0})`,!gy(e.code))}}catch(e){s(e instanceof Error?e.message:`Realtime connection failed`,!(e instanceof py)||e.retryable)}}handleServerMessage(e){let t=fy(JSON.parse(e));if(this.lastServerMessageAt=Date.now(),t.kind===`realtime.ready`){let e=t.payload.negotiatedCapabilities??[];if(e.some(e=>!this.offeredCapabilities.has(e)))throw Error(`Realtime server negotiated a capability the client did not offer`);this.ready=!0,this.reconnectAttempts=0,this.clearConnectionTimer(),this.ticketAbort=void 0,this.options.onStateChange?.(`connected`),this.options.onCapabilities?.(e),t.payload.endpoint&&this.endpointBinding?.onReady(t.payload.endpoint),this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{if(this.ready){if(Date.now()-this.lastServerMessageAt>=t.payload.heartbeatTimeoutMs){this.reconnect();return}this.send(this.clientMessage(`realtime.ping`,{}))}},t.payload.heartbeatIntervalMs)}else if(t.kind===`realtime.event`){let e=this.cursors.get(t.payload.topic);if(e!==void 0&&t.payload.seq<=e)return;this.options.onEvent?.(t.payload),this.cursors.set(t.payload.topic,t.payload.seq)}else if(t.kind===`realtime.subscribed`)this.cursors.set(t.payload.topic,t.payload.cursor),this.options.onSubscribed?.(t.payload);else if(t.kind===`realtime.gap`)return this.cursors.set(t.payload.topic,t.payload.earliestSeq-1),this.options.onGap?.(t.payload);else t.kind===`realtime.error`?this.options.onStateChange?.(`error`,t.payload.message):t.kind===`endpoint.message`&&(this.endpointBinding?.onMessage(t.payload),this.options.onEndpointMessage?.(t.payload))}sendSubscriptions(e){this.send(this.clientMessage(`realtime.subscribe`,{subscriptions:e}))}clientMessage(e,t){let n=this.options.createMessageId?.()??globalThis.crypto?.randomUUID?.();if(!n)throw Error(`RealtimeClient requires createMessageId when crypto.randomUUID is unavailable`);return{protocolVersion:2,messageId:n,kind:e,sentAt:Date.now(),payload:t}}send(e){if(!this.socket||this.socket.readyState!==1)return;let t=JSON.stringify(e),n=new TextEncoder().encode(t).byteLength;if(n>262144)throw new my(n,Zv);this.socket.send(t)}scheduleReconnect(e){if(!this.shouldReconnect)return;this.reconnectAttempts+=1;let t=this.options.maxReconnectAttempts;if(t!==void 0&&this.reconnectAttempts>t){this.shouldReconnect=!1,this.options.onStateChange?.(`error`,e);return}this.options.onStateChange?.(`reconnecting`,e);let n=Math.min(3e4,1e3*2**Math.min(this.reconnectAttempts-1,5)),r=Math.round(n*(.5+Math.random()*.5));this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.open(!0)},r)}clearHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}clearTimers(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0,this.clearConnectionTimer(),this.ticketAbort?.abort(),this.ticketAbort=void 0,this.clearHeartbeat()}clearConnectionTimer(){this.connectionTimer&&clearTimeout(this.connectionTimer),this.connectionTimer=void 0}},vy=500,yy=null,by;function xy(e){by=e,yy!==null&&clearTimeout(yy),yy=setTimeout(()=>{yy=null;let e=by;by=void 0,window.dispatchEvent(new CustomEvent(`config-reload`,{detail:e}))},vy)}function Sy(e,t){if(e===`config.reload`){xy(t);return}window.dispatchEvent(new CustomEvent(e.replace(/[._]/g,`-`),{detail:t}))}var Cy=Oe(()=>({connectionState:`idle`,error:null}));function wy(e){Cy.setState(e)}var Ty=new Map,Ey=new Map,Dy,Oy;function ky(){let e=`xopc:realtime-client-id`,t=sessionStorage.getItem(e);if(t)return t;let n=crypto.randomUUID();return sessionStorage.setItem(e,n),n}function Ay(){let e=new URL(J(`/api/realtime/v1/ws`));return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.toString()}function jy(){let e=ky(),t=window.electronAPI?`desktop`:`web`,n=new _y({clientId:e,clientKind:t,getWebSocketUrl:Ay,issueTicket:async n=>{let r=await fetch(J(`/api/realtime/tickets`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:e,clientKind:t,protocolVersion:2}),signal:n}),i=await r.json().catch(()=>null);if(!r.ok||!i?.payload?.ticket||!i.payload.realtime)throw Error(i?.error?.message??`Realtime ticket failed (${r.status})`);return{ticket:i.payload.ticket,realtime:i.payload.realtime}},createWebSocket:e=>new WebSocket(e),onStateChange:(e,t)=>{wy({connectionState:e,error:t??null}),e===`connected`&&window.dispatchEvent(new CustomEvent(`gateway-realtime-connected`))},onEvent:e=>{(e.topic===`gateway`||e.topic===`sessions`)&&Sy(e.event,e.data);let t=Ey.get(e.topic);(t===void 0||e.seq>t)&&Ey.set(e.topic,e.seq);for(let t of Ty.get(e.topic)??[])if(!(t.cursor!==void 0&&e.seq<=t.cursor))try{t.listener.onEvent(e)}catch(e){console.error(`[realtime] topic listener failed:`,e)}finally{t.cursor=Math.max(t.cursor??0,e.seq)}},onGap:async e=>{window.dispatchEvent(new CustomEvent(`realtime-gap`,{detail:e}));let t=[...Ty.get(e.topic)??[]].filter(t=>!e.recoverable||t.cursor===void 0||t.cursor<e.earliestSeq-1),n=await Promise.allSettled(t.map(t=>t.listener.onGap?.(e)));for(let e of n)e.status===`rejected`&&console.error(`[realtime] topic gap handler failed:`,e.reason)}});Dy?.disconnect(),Dy=n,Oy&&n.setEndpoint(Oy),n.subscribe(`gateway`,Ey.get(`gateway`)),n.subscribe(`sessions`,Ey.get(`sessions`));for(let e of Ty.keys())n.subscribe(e,Ey.get(e));return wy({connectionState:`connecting`,error:null}),n.connect(),()=>{Dy===n&&(n.disconnect(),Dy=void 0)}}function My(e){return Oy=e,Dy?.setEndpoint(e),()=>{Oy===e&&(Oy=void 0,Dy?.clearEndpoint(e))}}function Ny(e){Dy?.sendEndpointMessage(e)}function Py(){Dy?.reconnect()}function Fy(e,t,n){let r=Ty.get(e)??new Set,i=r.size===0,a=Ey.get(e),o={listener:t,cursor:n??a};if(r.add(o),Ty.set(e,r),i){let t=n??a;Ey.set(e,t),Dy?.subscribe(e,t)}else n!==void 0&&(a===void 0||n<a)&&Dy?.subscribe(e,n);return()=>{let t=Ty.get(e);t?.delete(o),(!t||t.size===0)&&(Ty.delete(e),Ey.delete(e),Dy?.unsubscribe(e))}}function Iy(e){return`xopc:submission:${e}`}function Ly(e,t){try{let n=sessionStorage.getItem(Iy(e));if(n){let e=JSON.parse(n);if(e.fingerprint===t&&typeof e.clientMessageId==`string`)return e.clientMessageId}}catch{}let n=crypto.randomUUID();try{sessionStorage.setItem(Iy(e),JSON.stringify({clientMessageId:n,fingerprint:t}))}catch{}return n}function Ry(e,t){try{let n=sessionStorage.getItem(Iy(e));if(!n)return;JSON.parse(n).clientMessageId===t&&sessionStorage.removeItem(Iy(e))}catch{}}async function zy(e,t){if(t.aborted)throw new DOMException(`Aborted`,`AbortError`);e!==0&&await new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(new DOMException(`Aborted`,`AbortError`))},a=setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}async function By(e,t,n,r){let i;for(let a of ko){await zy(a,n);let o=new AbortController,s=setTimeout(()=>o.abort(),Ao),c=()=>o.abort();n.addEventListener(`abort`,c,{once:!0});try{let a=await we(e,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"X-Xopc-Expected-Session-Key":r}:{}},body:t,signal:o.signal});if(n.throwIfAborted(),!Mo(a.status))return a;i=Error(`Session input temporarily unavailable (${a.status})`)}catch(e){if(n.aborted)throw e;i=e}finally{clearTimeout(s),n.removeEventListener(`abort`,c)}}throw i instanceof Error?i:Error(`Session input request failed`)}function Vy(e){return`xopc:pendingRun:${e}`}function Hy(e){try{let t=globalThis.sessionStorage?.getItem(Vy(e));if(!t)return!1;let n=JSON.parse(t);return typeof n.runId==`string`&&n.runId.trim().length>0}catch{return!1}}function Uy(e){try{let t=globalThis.sessionStorage?.getItem(Vy(e));if(!t)return null;let n=JSON.parse(t);return(typeof n.runId==`string`?n.runId.trim():``)||null}catch{return null}}function Wy(e,t){let n=t.trim();if(n)try{let t=Vy(e),r=JSON.parse(sessionStorage.getItem(t)??`{}`),i=r.runId===n&&typeof r.lastSeq==`number`?r.lastSeq:0;sessionStorage.setItem(t,JSON.stringify({runId:n,lastSeq:i})),qg(e)}catch{}}function Gy(e,t){try{let n=sessionStorage.getItem(Vy(e));if(!n)return 0;let r=JSON.parse(n);return r.runId===t&&typeof r.lastSeq==`number`?r.lastSeq:0}catch{return 0}}function Ky(e,t,n){if(!(!Number.isInteger(n)||n<1))try{let r=Vy(e),i=sessionStorage.getItem(r);if(!i)return;let a=JSON.parse(i);if(a.runId!==t||n<=(typeof a.lastSeq==`number`?a.lastSeq:0))return;sessionStorage.setItem(r,JSON.stringify({runId:t,lastSeq:n}))}catch{}}function qy(e,t){let n=String(e??``).trim(),r=String(t??``).trim();if(!n||!r)return!1;try{let e=Vy(n),t=sessionStorage.getItem(e);return!t||JSON.parse(t).runId!==r?!1:(sessionStorage.removeItem(e),qg(n),!0)}catch{return!1}}function Jy(){let e=[];try{for(let t=0;t<sessionStorage.length;t+=1){let n=sessionStorage.key(t);if(!n?.startsWith(`xopc:pendingRun:`))continue;let r=n.slice(16).trim(),i=sessionStorage.getItem(n);if(!r||!i)continue;let a=JSON.parse(i),o=typeof a.runId==`string`?a.runId.trim():``;o&&e.push({conversationId:r,runId:o})}}catch{return e}return e}var Yy=class{_abort;_chatId=``;_trackedRunId;_streamCleanup;_streamFinish;_terminalCallbacks;get isSending(){return!!this._abort}get activeChatId(){return this._chatId}isStreamingFor(e){return!!this._abort&&this._chatId===e}isTrackingRun(e,t){return this.isStreamingFor(e)&&this._trackedRunId===t}reconcileTerminal(e,t,n){return!this.isTrackingRun(e,t)||!this._streamFinish?!1:(this._terminalCallbacks?.onResult({runId:t,conversationId:e,status:n}),this._streamFinish(!0),!0)}reconcileInactive(e,t){return!this.isTrackingRun(e,t)||!this._streamFinish?!1:(this._streamFinish(!1),!0)}async send(e,t,n,r,i,a,o,s,c){if(this.isSending)throw Error(`A submission is already in progress`);if(o&&c)throw Error(`Application context requires a new input`);let l=c===void 0?void 0:Lt(c);n=n===void 0?void 0:structuredClone(n),s=s===void 0?void 0:structuredClone(s),this._trackedRunId=void 0;let u=new AbortController;this._abort=u,this._chatId=t;try{let c=n&&n.length>10?n.slice(0,10):n,d=qb.getState().sessions[t];if(d?.modelConfigSaving)throw Error(`Wait for model configuration to finish saving`);let f=d?.configVersion,p=await Cv(u.signal),m=Ly(t,`${jo({content:e,attachments:c,thinking:r,contextRefs:s,appContext:l})}:${f??``}${o?`:replace:${o}`:``}`),h=await By(J(a?`/api/tasks/${encodeURIComponent(a)}/inputs`:o?`/api/sessions/${encodeURIComponent(t)}/turns/${encodeURIComponent(o)}/replace`:`/api/sessions/${encodeURIComponent(t)}/inputs`),JSON.stringify({clientMessageId:m,configVersion:f,delivery:`next`,content:e,attachments:c,thinking:r,origin:p,contextRefs:s,appContext:l}),u.signal,a?t:void 0);if(!h.ok){let e=await h.json().catch(()=>({}));throw e.error?.code===`CONFIG_CHANGED`&&window.dispatchEvent(new CustomEvent(`session-model-config-stale`,{detail:{conversationId:t}})),Error(je(h.status,h.statusText,e.error?.message))}let g=await h.json();u.signal.throwIfAborted(),Ry(t,m),i?.onInputAccepted?.();let _=g.payload?.state,v=g.payload?.conversationId?.trim()||t,y=_?.inputs?.find(e=>e.clientMessageId===m);if(_?.activeRunId&&y?.id===_.activeInputId){await this.resume(_.activeRunId,v,i);return}this._abort=void 0}finally{this._abort===u&&(this._abort=void 0)}}abort(){this._notifyServerAbort(),this._abort?.abort(),this._streamCleanup?.(),this._streamCleanup=void 0,this._abort=void 0,this._clearPendingRun()}_notifyServerAbort(){if(this._chatId)try{let e=sessionStorage.getItem(Vy(this._chatId));if(!e)return;let t=JSON.parse(e);if(typeof t.runId!=`string`||!t.runId)return;we(J(`/api/agent/abort`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({runId:t.runId})}).catch(()=>{})}catch{}}async resume(e,t,n){this._trackedRunId=void 0,this._abort=new AbortController,this._chatId=t,this._trackedRunId=e,Wy(t,e);let r=this._wrapTerminalCallbacks(n);this._terminalCallbacks=r.wrapped;let i=await new Promise(n=>{let i=!1,a=e=>{i||(i=!0,this._streamCleanup?.(),this._streamCleanup=void 0,n(e))};this._streamFinish=a;let o=Gy(t,e);this._streamCleanup=Fy(`run:${e}`,{onEvent:n=>{let i=n.data&&typeof n.data==`object`?{...n.data,seq:n.seq}:{type:n.event,seq:n.seq,payload:n.data};this._dispatchStreamEvent(n.event,i,r.wrapped),Ky(t,e,n.seq),(n.event===`run_end`||n.event===`error`)&&a(!0)},onGap:e=>{if(e.recoverable)return r.wrapped?.onReplayGap?.();a(!1)}},o),this._abort?.signal.addEventListener(`abort`,()=>a(!1),{once:!0})});return this._abort=void 0,this._streamFinish=void 0,this._terminalCallbacks=void 0,this._clearPendingRun(),i}_wrapTerminalCallbacks(e){if(!e)return{wrapped:void 0,sawTerminal:!1,onMissingTerminal:()=>{}};let t=!1,n=()=>{t=!0};return{get sawTerminal(){return t},wrapped:{...e,onResult:r=>{t||(n(),e.onResult(r))},onError:r=>{t||(n(),e.onError(r))}},onMissingTerminal:()=>{t||(n(),e.onError(`Agent run ended without a terminal event`))}}}_clearPendingRun(){let e=this._chatId;if(e)try{let t=Vy(e),n=sessionStorage.getItem(t);if(n){let e=JSON.parse(n),t=typeof e?.runId==`string`?e.runId:``;if(this._trackedRunId&&t&&t!==this._trackedRunId)return}sessionStorage.removeItem(t),qg(e)}catch{}this._trackedRunId=void 0}_dispatchStreamEvent(e,t,n){let r=t.payload&&typeof t.payload==`object`?t.payload:{};switch(e){case`run_start`:typeof t.runId==`string`&&this._chatId&&(this._trackedRunId=t.runId,Wy(this._chatId,t.runId)),typeof t.runId==`string`&&n?.onStreamStart(t.runId);break;case`user_message`:{let e=r.message&&typeof r.message==`object`?r.message:{},i=fv({...e,turnId:typeof e.turnId==`string`?e.turnId:t.runId});i&&n?.onUserMessage?.(i);break}case`user_transcript`:{let e=fv({text:r.text,media:r.media,timestamp:t.timestamp,turnId:t.runId});e&&n?.onUserMessage?.(e);break}case`assistant_message_start`:typeof t.runId==`string`&&n?.onStreamStart(t.runId);break;case`assistant_delta`:typeof r.delta==`string`&&r.delta&&n?.onToken(r.delta,typeof r.messageId==`string`?r.messageId:void 0,typeof r.offset==`number`?r.offset:void 0);break;case`thinking_delta`:typeof r.delta==`string`&&r.delta&&n?.onThinking(r.delta,!0);break;case`thinking_end`:n?.onThinkingEnd();break;case`assistant_message_end`:n?.onThinkingEnd(),typeof r.messageId==`string`&&(r.presentation===`narration`||r.presentation===`answer`)&&n?.onAssistantMessageEnd?.(r.messageId,r.presentation,r.usage);break;case`tool_start`:{let e=String(r.toolName||`unknown`),i=typeof r.toolCallId==`string`?r.toolCallId:void 0;if(e===`clarify`)break;n?.onToolStart(e,r.args,i,Zy(t.timestamp),r.activity);break}case`tool_update`:{let e=typeof r.toolName==`string`&&r.toolName?r.toolName:`unknown`,t=typeof r.toolCallId==`string`?r.toolCallId:void 0;r.details!==void 0&&n?.onToolUpdate?.(e,t,r.details),typeof r.textDelta==`string`&&r.textDelta&&n?.onToolUpdate?.(e,t,{textDelta:r.textDelta});break}case`tool_end`:n?.onToolEnd(typeof r.toolName==`string`&&r.toolName?r.toolName:`unknown`,r.status===`error`||r.status===`cancelled`,Xy(r.result),typeof r.toolCallId==`string`?r.toolCallId:void 0,Zy(t.timestamp),r.activity);break;case`review_start`:typeof r.reviewId==`string`&&r.reviewId&&n?.onReviewStart?.({reviewId:r.reviewId,target:typeof r.target==`string`?r.target:`working tree changes`,stage:r.stage===`preparing`?`preparing`:`reviewing`});break;case`review_delta`:typeof r.reviewId==`string`&&typeof r.delta==`string`&&r.delta&&n?.onReviewDelta?.({reviewId:r.reviewId,delta:r.delta});break;case`review_end`:typeof r.reviewId==`string`&&r.reviewId&&n?.onReviewEnd?.({reviewId:r.reviewId,status:r.status===`error`?`error`:`complete`,...typeof r.message==`string`&&r.message?{message:r.message}:{}});break;case`progress`:n?.onProgress({stage:String(r.stage||`thinking`),message:String(r.message||``),detail:r.detail,toolName:r.toolName,completed:typeof r.completed==`number`?r.completed:void 0,total:typeof r.total==`number`?r.total:void 0,timestamp:Date.now()});break;case`compaction`:n?.onCompaction?.({status:r.status||`started`,tokensBefore:typeof r.tokensBefore==`number`?r.tokensBefore:void 0,tokensAfter:typeof r.tokensAfter==`number`?r.tokensAfter:void 0,summary:typeof r.summary==`string`?r.summary:void 0});break;case`turn_plan`:{let e=Qy(r.plan);e.length>0&&n?.onTurnPlanUpdated?.({explanation:typeof r.explanation==`string`&&r.explanation.trim()?r.explanation.trim():void 0,plan:e});break}case`task_plan_updated`:{let e=$y(r.items),t=r.source===`todo`?`todo`:`update_plan`,i=r.scope===`session`?`session`:`turn`,a=typeof r.planId==`string`?r.planId.trim():``,o=typeof r.revision==`number`&&Number.isInteger(r.revision)?r.revision:0;a&&o>0&&n?.onTaskPlanUpdated?.({planId:a,revision:o,source:t,scope:i,explanation:typeof r.explanation==`string`&&r.explanation.trim()?r.explanation.trim():void 0,items:e});break}case`turn_outcome`:{let e=_t(r);e&&n?.onTurnOutcome?.(e);break}case`session_config_updated`:n?.onSessionConfigUpdated?.();break;case`tts_audio`:n?.onTtsAudio?.({uri:String(r.uri||``),mimeType:String(r.mimeType||`audio/mpeg`),name:String(r.name||`voice.mp3`),attachTo:r.attachTo===`last_assistant`?`last_assistant`:void 0,messageId:typeof r.messageId==`string`?r.messageId:void 0});break;case`clarify_request`:{let e=typeof r.requestId==`string`?r.requestId.trim():``,t=typeof r.question==`string`?r.question.trim():``;if(e&&t&&n?.onClarifyRequest){let i=Array.isArray(r.choices)?r.choices.filter(e=>typeof e==`string`&&e.trim().length>0):void 0,a=typeof r.suggestedAnswer==`string`&&r.suggestedAnswer.trim()?r.suggestedAnswer.trim():void 0;n.onClarifyRequest({requestId:e,kind:r.kind===`approval`?`approval`:`input`,question:t,choices:i&&i.length>=2?i:void 0,suggestedAnswer:a,version:typeof r.version==`number`?r.version:1,createdAt:typeof r.createdAt==`number`?r.createdAt:Date.now(),expiresAt:typeof r.expiresAt==`number`?r.expiresAt:void 0})}break}case`workflow_run_started`:{let e=r.workflowRun;if(e?.ok===!0){let t=typeof e.runId==`string`?e.runId:``,r=typeof e.conversationId==`string`?e.conversationId:``,i=typeof e.definitionId==`string`?e.definitionId:``,a=typeof e.parentConversationId==`string`?e.parentConversationId:void 0;t&&r&&i&&n?.onWorkflowRunStarted?.({runId:t,conversationId:r,definitionId:i,parentConversationId:a})}break}case`run_end`:typeof t.runId==`string`&&typeof t.conversationId==`string`&&(r.status===`success`||r.status===`error`||r.status===`cancelled`||r.status===`suspended`)&&n?.onResult({runId:t.runId,conversationId:t.conversationId,status:r.status,...typeof r.summary==`string`&&r.summary?{summary:r.summary}:{}});break;case`error`:n?.onError(String(r.message||JSON.stringify(Xg())));break}}};function Xy(e){if(typeof e==`string`||e==null)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Zy(e){if(typeof e!=`number`||!Number.isFinite(e))throw Error(`Chat stream event is missing a numeric timestamp`);return e}function Qy(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,n=typeof t?.step==`string`?t.step.trim():``,r=t?.status;if(!(!n||r!==`pending`&&r!==`in_progress`&&r!==`completed`))return{step:n,status:r}}).filter(e=>!!e):[]}function $y(e){return Array.isArray(e)?e.flatMap(e=>{let t=e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,n=typeof t?.id==`string`?t.id.trim():``,r=typeof t?.title==`string`?t.title.trim():``,i=t?.status;return!n||!r||i!==`pending`&&i!==`in_progress`&&i!==`completed`&&i!==`cancelled`?[]:[{id:n,title:r,status:i}]}):[]}function eb(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return!r||e.role!==r.role?!1:!e.turnId||!r.turnId||e.turnId===r.turnId})}function tb(e,t,n){let r=e=>lv(e.role);if(n){let i=t.findIndex(e=>r(e)&&e.turnId===n);if(i>=0){let n=t.slice(0,i+1);return eb(e,n)?e:L_(n)}}let i=e.filter(r).length;if(t.filter(r).length<=i)return e;let a=t.filter(r).slice(i);return a.length===0?e:L_([...e,...a])}var nb=`medium`;function rb(){return{name:null,model:``,thinkingLevel:nb,reasoningLevel:`on`,modelSupportsThinking:!1,effectiveWorkspacePath:``,workspaceSource:`agent_default_root`,userContextMode:`enabled`}}var ib=class e{static instance;senders=new Map;resumeRunIds=new Map;userAbortedSessions=new Set;static get(){return e.instance||=new e,e.instance}senderFor(e){let t=this.senders.get(e);return t||(t=new Yy,this.senders.set(e,t)),t}isStreamingFor(e){return this.senders.get(e)?.isStreamingFor(e)??!1}isTrackingRun(e,t){return this.senders.get(e)?.isTrackingRun(e,t)??!1}getResumeRunId(e){return this.resumeRunIds.get(e)??null}setResumeRunId(e,t){t?this.resumeRunIds.set(e,t):this.resumeRunIds.delete(e)}setUserAborted(e,t){t?this.userAbortedSessions.add(e):this.userAbortedSessions.delete(e)}takeUserAborted(e){return this.userAbortedSessions.delete(e)}resetRunTracking(e){this.resumeRunIds.delete(e),this.userAbortedSessions.delete(e)}abort(e){this.senders.get(e)?.abort(),this.senders.delete(e),this.resetRunTracking(e)}reconcileTerminal(e,t,n){let r=this.senders.get(e)?.reconcileTerminal(e,t,n)??!1;return this.resumeRunIds.get(e)===t&&this.resumeRunIds.delete(e),r}reconcileInactive(e,t){let n=this.senders.get(e)?.reconcileInactive(e,t)??!1;return this.resumeRunIds.get(e)===t&&this.resumeRunIds.delete(e),n}releaseIdleSender(e){let t=this.senders.get(e);t&&!t.isSending&&this.senders.delete(e)}}.get();function ab(e){if(e.type!==`thinking`)return``;let t=e;return(typeof t.text==`string`&&t.text.length>0?t.text:typeof t.thinking==`string`?t.thinking:``).trim()}function ob(e){if(e.role!==`assistant`)return!1;for(let t of e.content)if(t.type===`text`&&(t.text||``).trim().length>0||t.type===`thinking`&&ab(t).length>0||t.type===`tool_use`||t.type===`review`)return!0;return!1}function sb(e,t){return e&&e.role===`assistant`?{...e,content:[...e.content]}:{role:`assistant`,content:[],timestamp:t}}function cb(e){return{...e,content:e.content.map(e=>({...e})),attachments:e.attachments?e.attachments.map(e=>({...e})):void 0,contextRefs:e.contextRefs?e.contextRefs.map(e=>({...e})):void 0,userTurnDocument:e.userTurnDocument?{...e.userTurnDocument,parts:e.userTurnDocument.parts.map(e=>({...e}))}:void 0}}function lb(e,t){return`${e??``}${t}`}function ub(e,t){if(!t)return e;if(!e)return t;if(e.endsWith(t))return e;let n=Math.min(e.length,t.length,512);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return e+t.slice(r);return e+t}function db(e,t,n){let r=e??``;return!Number.isInteger(n)||n==null||n<0?null:r.slice(n,n+t.length)===t?r:r.length===n?lb(r,t):null}function fb(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming&&(t.streaming=!1)}function pb(e){let t=e[e.length-1];t?.type===`thinking`&&t.streaming||e.push({type:`thinking`,text:``,streaming:!0})}function mb(e,t,n){let r=e[e.length-1];if(r?.type===`thinking`){n?r.text=ub(r.text||``,t):r.text=t,r.streaming=!0;return}e.push({type:`thinking`,text:t,streaming:!0})}function hb(e){fb(e);for(let t of e)t.type===`thinking`&&typeof t.text==`string`&&(t.text=t.text.trim())}function gb(e){for(let t of e)t.type===`tool_use`&&t.status===`running`&&(t.status=`done`)}function _b(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function vb(e,t,n,r){fb(e);let i=e[e.length-1];if(i?.type===`text`&&i.segmentId===n){i.text=db(i.text,t,r?.offset)??lb(i.text,t);return}if(r?.reconcileHydratedSegment&&n&&i?.type===`text`&&!i.segmentId){let e=db(i.text,t,r.offset);if(e!==null){i.text=e,i.segmentId=n,i.presentation=`pending`;return}}e.push({type:`text`,text:t,...n?{segmentId:n,presentation:`pending`}:{}})}function yb(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type===`text`&&i.segmentId===t){i.presentation=n;return}}}function bb(e){let t=kb(e);if(!t||t.type!==`review`)return null;let n=Array.isArray(t.findings)?t.findings:[],r={type:`review`,target:typeof t.target==`string`?t.target:`working tree changes`,summary:typeof t.summary==`string`?t.summary:``,findings:n.map(e=>{let t=kb(e);if(!t)return null;let n=t.priority===0||t.priority===1||t.priority===2||t.priority===3?t.priority:2,r=typeof t.title==`string`?t.title:``,i=typeof t.body==`string`?t.body:``;if(!r&&!i)return null;let a={title:r,body:i,priority:n};return typeof t.confidenceScore==`number`&&(a.confidenceScore=t.confidenceScore),typeof t.filePath==`string`&&(a.filePath=t.filePath),typeof t.lineStart==`number`&&(a.lineStart=t.lineStart),typeof t.lineEnd==`number`&&(a.lineEnd=t.lineEnd),a}).filter(e=>e!=null),overallCorrectness:t.overallCorrectness===`patch is correct`||t.overallCorrectness===`patch is incorrect`?t.overallCorrectness:`unknown`,overallExplanation:typeof t.overallExplanation==`string`?t.overallExplanation:``};return typeof t.overallConfidenceScore==`number`&&(r.overallConfidenceScore=t.overallConfidenceScore),typeof t.generatedAt==`number`&&(r.generatedAt=t.generatedAt),(t.source===`model`||t.source===`local`)&&(r.source=t.source),r}function xb(e,t){fb(e);let n=bb(t);if(!n)return;let r=e.findIndex(e=>e.type===`review`&&e.target===n.target);if(r>=0){let t=e[r];if(!t||t.type!==`review`)return;e[r]={...n,reviewId:t.reviewId,status:t.status===`error`?`error`:`complete`,analysisMarkdown:t.analysisMarkdown,errorMessage:t.errorMessage};return}e.push(n)}function Sb(e){for(let t of e)t.type===`review`&&(t.status!==`preparing`&&t.status!==`reviewing`||(t.status=`error`,t.errorMessage??=`The review stream ended before a conclusion was returned.`))}function Cb(e,t){fb(e);let n=e.find(e=>e.type===`review`&&e.reviewId===t.reviewId);if(n){n.target=t.target||n.target,n.status=t.stage;return}e.push({type:`review`,reviewId:t.reviewId,target:t.target||`working tree changes`,summary:``,findings:[],overallCorrectness:`unknown`,overallExplanation:``,status:t.stage})}function wb(e,t,n){if(!n)return;let r=e.find(e=>e.type===`review`&&e.reviewId===t);r&&(r.status=`reviewing`,r.analysisMarkdown=ub(r.analysisMarkdown??``,n))}function Tb(e,t,n,r){let i=e.find(e=>e.type===`review`&&e.reviewId===t);i&&(i.status=n,i.errorMessage=n===`error`?r:void 0)}function Eb(e,t,n,r,i,a){fb(e);let o={type:`tool_use`,id:crypto.randomUUID(),toolCallId:r,name:t,activity:a??Ut(t,`running`),input:n,status:`running`,startedAt:i};e.push(o)}function Db(e,t,n,r,i,a,o){for(let s=e.length-1;s>=0;s--){let c=e[s];if(!(c.type!==`tool_use`||c.status!==`running`)&&!(i&&c.toolCallId!==i&&c.id!==i)&&!(!i&&!_b(c.name,t))){c.status=n?`error`:`done`,c.result=r,c.activity=o??Ut(t,n?`failed`:`completed`,r),c.completedAt=a,c.startedAt!=null&&(c.durationMs=Math.max(0,a-c.startedAt));return}}}function Ob(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(a.type===`tool_use`&&a.status===`running`){if(n&&a.toolCallId===n){a.details=Ab(a.details,r);return}if(!n&&_b(a.name,t)){a.details=Ab(a.details,r);return}}}}function kb(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Ab(e,t){let n=kb(t);if(typeof n?.textDelta==`string`){let t=kb(e)??{};return{...t,text:ub(String(t.text??``),n.textDelta)}}if(n?.kind!==`command_output_delta`)return t;let r=kb(e)??{},i=n.stream===`stderr`?`stderr`:`stdout`,a=typeof n.delta==`string`?n.delta:``,o=i===`stdout`?`${String(r.stdout??``)}${a}`:String(r.stdout??``),s=i===`stderr`?`${String(r.stderr??``)}${a}`:String(r.stderr??``);return{...r,command:typeof n.command==`string`?n.command:r.command,cwd:typeof n.cwd==`string`?n.cwd:r.cwd,stdout:o,stderr:s,aggregatedOutput:`${String(r.aggregatedOutput??``)}${a}`}}function jb(e){return e!==`ready`}var Mb={streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1};function Nb(e){return{...rb(),historyStatus:e,messages:[],hasMore:!1,...Mb}}var Pb=0;function Fb(e){let t=cb(e);return t.renderKey??=`chat-row:${++Pb}`,t}function Ib(e){return e.map(Fb)}function Lb(e,t){return e===t?!0:e.role!==t.role||e.timestamp!==t.timestamp||t.renderKey!==void 0&&e.renderKey!==t.renderKey?!1:JSON.stringify({...e,renderKey:void 0})===JSON.stringify({...t,renderKey:void 0})}function Rb(e,t){if(e.turnId&&t.turnId&&e.turnId!==t.turnId||!hv(e,t))return t;let n=t.attachments?.length?t.attachments:e.attachments,r=t.contextRefs?.length?t.contextRefs:e.contextRefs,i=t.userTurnDocument??e.userTurnDocument;return n===t.attachments&&r===t.contextRefs&&i===t.userTurnDocument?t:{...t,attachments:n,contextRefs:r,userTurnDocument:i}}function zb(e,t){let n=e.length!==t.length,r=t.map((t,r)=>{let i=e[r],a=i&&lv(i.role)&&lv(t.role)?Rb(i,t):t;if(i&&Lb(i,a))return i;n=!0;let o=Fb(a);return i?.renderKey&&i.role===a.role&&(!a.renderKey&&i.timestamp===a.timestamp&&i.turnId===a.turnId||a.role===`assistant`&&H_(i,a))&&(o.renderKey=i.renderKey),o});return n?r:e}function Bb(e,t){let n=e.filter(e=>e.deliveryStatus===`failed`);if(n.length===0)return t;let r=e.filter(e=>lv(e.role)&&e.deliveryStatus!==`failed`).length,i=t.filter(e=>lv(e.role)).slice(r),a=n.filter(e=>{let t=i.findIndex(t=>mv(e,t));return t<0?!0:(i.splice(t,1),!1)});return a.length>0?[...t,...a]:t}function Vb(e,t){let n=cb(t),r=e[e.length-1];if(r?.role!==`assistant`)return[...e,Fb(n)];let i=L_([r,n]);return[...e.slice(0,-1),...i]}function Hb(e){let t=e.uri?.trim();return t?`uri:${t}`:e.id?`id:${e.id}`:`name:${e.name??`file`}|${e.mimeType??``}`}function Ub(e,t){let n=[...e??[]],r=Hb(t);return n.some(e=>Hb(e)===r)||n.push({...t}),n}function Wb(e){return{name:e.name,model:e.model,configVersion:e.configVersion,modelConfigSaving:e.modelConfigSaving,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,effectiveWorkspacePath:e.effectiveWorkspacePath,workspaceSource:e.workspaceSource,userContextMode:e.userContextMode,historyStatus:e.historyStatus,messages:Ib(e.messages),hasMore:e.hasMore,streamingMsg:e.streamingMsg?Fb(e.streamingMsg):null,progress:e.progress,taskPlan:e.taskPlan?{...e.taskPlan,items:e.taskPlan.items.map(e=>({...e}))}:null,sending:e.sending,streaming:e.streaming}}function Gb(e){return String(e??``).trim()}function Kb(e){return e?{name:e.name,model:e.model,configVersion:e.configVersion,modelConfigSaving:e.modelConfigSaving,thinkingLevel:e.thinkingLevel,reasoningLevel:e.reasoningLevel,modelSupportsThinking:e.modelSupportsThinking,effectiveWorkspacePath:e.effectiveWorkspacePath,workspaceSource:e.workspaceSource,userContextMode:e.userContextMode}:rb()}var qb=Oe((e,t)=>({focusedConversationId:null,initLoading:!0,loadingMore:!1,shellError:null,sessions:{},setFocusedConversationId:t=>e({focusedConversationId:t}),setInitLoading:t=>e({initLoading:t}),setLoadingMore:t=>e({loadingMore:t}),setShellError:t=>e({shellError:t}),setSessionHistoryStatus:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r];if(t?.historyStatus===n)return e;let i=t??Nb(`unknown`);return{sessions:{...e.sessions,[r]:{...i,historyStatus:n}}}})},patchSessionMeta:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r]??Nb(`unknown`);return{sessions:{...e.sessions,[r]:{...t,...n}}}})},initSessionSnapshot:(t,n)=>{let r=Gb(t);r&&e(e=>({sessions:{...e.sessions,[r]:Wb(n)}}))},setCommittedSnapshot:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r],i=n.hasMore,a=Kb(t);if(n.name!==void 0&&(a.name=n.name),!t){let t=Ib(n.messages);return{sessions:{...e.sessions,[r]:{...a,historyStatus:`ready`,messages:t,hasMore:i,...Mb}}}}if(Jb(t))return{sessions:{...e.sessions,[r]:{...t,...a,historyStatus:`ready`,hasMore:i}}};let o=zb(t.messages,Bb(t.messages,n.messages));return{sessions:{...e.sessions,[r]:{...t,...a,historyStatus:`ready`,messages:o,hasMore:i,...Mb}}}})},updateSessionMessages:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,messages:Ib(n(t.messages))}}}:e})},finalizeStreamingTurn:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r],i=Kb(t),a=t?.hasMore??!1;return{sessions:{...e.sessions,[r]:{...i,historyStatus:`ready`,messages:Vb(t?.messages??[],n),hasMore:a,...Mb}}}})},completeProgressiveRender:(t,n)=>{let r=Gb(t);!r||!n||e(e=>{let t=e.sessions[r];if(!t)return e;let i=!1,a=e=>{if(e.renderKey!==n||!e.progressiveRender)return e;i=!0;let t=cb(e);return delete t.progressiveRender,t},o=t.messages.map(a),s=t.streamingMsg?a(t.streamingMsg):null;return i?{sessions:{...e.sessions,[r]:{...t,messages:o,streamingMsg:s}}}:e})},clearStreamingState:t=>{let n=Gb(t);n&&e(e=>{let t=e.sessions[n];return t?{sessions:{...e.sessions,[n]:{...t,...Mb}}}:e})},clearSession:t=>{let n=Gb(t);n&&e(e=>{if(!(n in e.sessions))return e;let{[n]:t,...r}=e.sessions;return{sessions:r}})},getSessionSnapshot:e=>{let n=Gb(e);if(!n)return;let r=t().sessions[n];return r?Wb(r):void 0},seedSessionIfEmpty:(e,n,r,i,a=!1)=>{let o=Gb(e);!o||t().sessions[o]||t().initSessionSnapshot(o,{...rb(),historyStatus:`ready`,messages:n,hasMore:a,streamingMsg:null,progress:null,taskPlan:null,sending:r,streaming:i})},setSessionFlags:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,...n.sending===void 0?{}:{sending:n.sending},...n.streaming===void 0?{}:{streaming:n.streaming}}}}:e})},setSessionProgress:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r];return t?{sessions:{...e.sessions,[r]:{...t,progress:n}}}:e})},setSessionTaskPlan:(t,n)=>{let r=Gb(t);r&&e(e=>{let t=e.sessions[r];return!t||n.revision<=(t.taskPlan?.revision??0)?e:{sessions:{...e.sessions,[r]:{...t,taskPlan:{...n,items:n.items.map(e=>({...e}))}}}}})},mutateSessionStreaming:(t,n,r=Date.now())=>{let i=Gb(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;let a=sb(t.streamingMsg,r);return a.renderKey??=`assistant-stream:${i}:${r}`,a.progressiveRender=!0,n(a),{sessions:{...e.sessions,[i]:{...t,streamingMsg:cb(a),streaming:!0}}}})},appendAttachmentToCurrentAssistant:(t,n,r)=>{let i=Gb(t);i&&e(e=>{let t=e.sessions[i];if(!t)return e;if(t.streamingMsg?.role===`assistant`){let r=cb(t.streamingMsg);return r.attachments=Ub(r.attachments,n),{sessions:{...e.sessions,[i]:{...t,streamingMsg:r}}}}let r=Ib(t.messages);for(let a=r.length-1;a>=0;a--){let o=r[a];if(o?.role===`assistant`)return r[a]={...o,attachments:Ub(o.attachments,n)},{sessions:{...e.sessions,[i]:{...t,messages:r}}}}return e})},applyHydratedTail:(t,n,r)=>{let i=Gb(t);i&&e(e=>{let t=e.sessions[i];return t?{sessions:{...e.sessions,[i]:{...t,messages:Ib(n),streamingMsg:r?cb(r):null,streaming:!0,sending:!0}}}:e})},appendUserMessageIfMissing:(t,n)=>{let r=Gb(t);!r||!lv(n.role)||e(e=>{let t=e.sessions[r],i=Kb(t);if(!t)return{sessions:{...e.sessions,[r]:{...i,historyStatus:`ready`,messages:Ib([n]),hasMore:!1,...Mb}}};let a=t.messages[t.messages.length-1];if(a&&mv(a,n)){let i={...n,...!n.contextRefs?.length&&a.contextRefs?.length?{contextRefs:a.contextRefs}:{},...!n.userTurnDocument&&a.userTurnDocument?{userTurnDocument:a.userTurnDocument}:{}};return{sessions:{...e.sessions,[r]:{...t,messages:Ib(L_([...t.messages.slice(0,-1),i]))}}}}return t.messages.some(e=>hv(e,n))?e:{sessions:{...e.sessions,[r]:{...t,messages:Ib(L_([...t.messages,n]))}}}})},mergeCommittedFromServer:(t,n,r)=>{let i=Gb(t);i&&e(e=>{let t=e.sessions[i],a=Kb(t),o=r??t?.hasMore??!1;if(!t)return{sessions:{...e.sessions,[i]:{...a,historyStatus:`ready`,messages:Ib(n),hasMore:o,...Mb}}};if(!Jb(t)){let r=Bb(t.messages,n);return{sessions:{...e.sessions,[i]:{...a,historyStatus:`ready`,messages:Ib(r),hasMore:o,...Mb}}}}let s=tb(t.messages,n,t.streamingMsg?.turnId);return s===t.messages&&o===t.hasMore&&t.historyStatus===`ready`?e:{sessions:{...e.sessions,[i]:{...t,historyStatus:`ready`,messages:Ib(s),hasMore:o}}}})},prependHistoryMessages:(t,n,r)=>{let i=Gb(t);i&&e(e=>{let t=e.sessions[i],a=Kb(t);if(!t)return{sessions:{...e.sessions,[i]:{...a,historyStatus:`ready`,messages:Ib(n),hasMore:r,...Mb}}};let o=new Set(t.messages.map(e=>e.timestamp)),s=L_([...n.filter(e=>!o.has(e.timestamp)),...t.messages]);return{sessions:{...e.sessions,[i]:{...t,messages:Ib(s),hasMore:r}}}})}}));function Jb(e){return e?e.streaming||e.sending||!!e.streamingMsg:!1}function Yb(e){return qb.getState().getSessionSnapshot(e)}function Xb(e){return qb.getState().sessions[Gb(e)]?.messages??[]}function Zb(e){let t=Gb(e);if(!t)return!1;let n=qb.getState().sessions[t];return Jb(n)||ib.isStreamingFor(t)?!0:Hy(t)}function Qb(e){let t=qb(t=>Jb(t.sessions[e])),[n,r]=(0,Z.useState)(()=>Zb(e)),i=(0,Z.useRef)(e);return i.current!==e&&(i.current=e,r(Zb(e))),(0,Z.useEffect)(()=>{r(Zb(e))},[e,t]),(0,Z.useEffect)(()=>{let t=t=>{t.detail?.chatId===e&&r(Zb(e))};return window.addEventListener(Kg,t),()=>window.removeEventListener(Kg,t)},[e]),t||n}function $b(e){return e.trim()}var ex=Oe(e=>({runs:{},markRunning:t=>{let n=$b(t);if(!n)return;let r=Date.now();e(e=>{let t=e.runs[n];return{runs:{...e.runs,[n]:{status:`running`,startedAt:t?.status===`running`?t.startedAt:r,updatedAt:r,unread:!1}}}})},markCompleted:(t,n)=>{let r=$b(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`completed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markFailed:(t,n)=>{let r=$b(t);if(!r)return;let i=Date.now();e(e=>{let t=e.runs[r];return{runs:{...e.runs,[r]:{status:`failed`,startedAt:t?.startedAt??i,updatedAt:i,unread:n}}}})},markViewed:t=>{let n=$b(t);n&&e(e=>{let t=e.runs[n];return t?.unread?{runs:{...e.runs,[n]:{...t,unread:!1}}}:e})},clear:t=>{let n=$b(t);n&&e(e=>{if(!(n in e.runs))return e;let{[n]:t,...r}=e.runs;return{runs:r}})}}));function tx(e){ex.getState().markRunning(e)}function nx(e,t){ex.getState().markCompleted(e,t)}function rx(e,t){ex.getState().markFailed(e,t)}function ix(e){ex.getState().clear(e)}function ax(e){ex.setState(t=>({runs:{...t.runs,[e]:{status:`waiting`,startedAt:t.runs[e]?.startedAt??Date.now(),updatedAt:Date.now(),unread:!1}}}))}var ox=`xopc.recentWorkspaceDirs.v1`,sx=10;function cx(){try{let e=localStorage.getItem(ox);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}catch{return[]}}function lx(e){let t=e.trim();if(t)try{let e=[t,...cx().filter(e=>e!==t)].slice(0,sx);localStorage.setItem(ox,JSON.stringify(e))}catch{}}function ux(e){let t=e.trim().replace(/[/\\]+$/,``);if(!t)return e;let n=t.split(/[/\\]/);return n[n.length-1]||t}async function dx(e){let t=typeof window<`u`?window.electronAPI?.file?.openDirectory:void 0;if(!t)return null;let n=e?.trim();return n?t({defaultPath:n}):t()}function fx(e={}){let{initialPath:t,onPicked:n,trackRecent:r=!0}=e,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=typeof window<`u`&&!!window.electronAPI?.file?.openDirectory,l=(0,Z.useCallback)(async e=>{let t=e.trim();t&&(r&&lx(t),await n?.(t))},[n,r]);return{hasNativePicker:c,modalOpen:i,setModalOpen:a,pick:(0,Z.useCallback)(()=>{if(c){(async()=>{s(!0);try{let e=await dx(t);e&&await l(e)}finally{s(!1)}})();return}a(!0)},[l,c,t]),confirmPick:l,picking:o}}function px(){return function(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`saved`:{let n=structuredClone(t.value),r=e.form;return{form:r!==null&&JSON.stringify(r)!==JSON.stringify(t.value)?r:n,baseline:structuredClone(n)}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e}}}function mx(e,t){return{...e,...t.patch}}function hx(e){let{enabled:t,parsed:n,dirty:r,trackedParsedRef:i,dispatch:a,onResetDirty:o}=e;if(!t){i.current!==null&&(i.current=null,a({type:`reset`}),o?.());return}n!==null&&!r&&i.current!==n&&(i.current=n,a({type:`sync`,value:n}))}async function gx(e){let t=new URLSearchParams;e!=null&&e!==``&&t.set(`path`,e);let n=t.toString();return(await q(J(`/api/host/fs/list${n?`?${n}`:``}`))).payload}async function _x(){return(await q(J(`/api/host/fs/meta`))).payload}async function vx(e,t){return(await q(J(`/api/host/fs/directory`),{method:`POST`,body:JSON.stringify({parentPath:e,name:t})})).payload.absolutePath}function yx(){return K(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-sm text-fg`,`placeholder:text-fg-subtle`,xd,`dark:border-edge`)}function bx(e){return/^[A-Za-z]:\\?$/.test(e.replace(/\\$/,`\\`))}function xx(e){return!e||e.currentPath===``?!1:e.parentPath===null?e.currentPath===`/`?!1:!!bx(e.currentPath):!0}var Sx={metaHostname:null,listState:null,listLoading:!1,listError:null,manualPath:``,createFolderOpen:!1,createFolderName:``,createFolderLoading:!1,createFolderError:null,selectedFilePath:``};function Cx({open:e,onOpenChange:t,initialAbsolutePath:n,onConfirm:r,wd:i,selectKind:a=`directory`,fileExtensions:o,title:s,description:c,confirmLabel:l,nested:u=!1}){let d=(0,Z.useId)(),f=(0,Z.useId)(),[p,m]=(0,Z.useReducer)(mx,Sx),{metaHostname:h,listState:g,listLoading:_,listError:v,manualPath:y,createFolderOpen:b,createFolderName:x,createFolderLoading:S,createFolderError:C,selectedFilePath:w}=p,T=(0,Z.useCallback)(async e=>{m({type:`patch`,patch:{listLoading:!0,listError:null,selectedFilePath:``}});try{m({type:`patch`,patch:{listState:await gx(e)}})}catch(e){m({type:`patch`,patch:{listError:e instanceof Error?e.message:String(e),listState:null}})}finally{m({type:`patch`,patch:{listLoading:!1}})}},[]);(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await _x();t||m({type:`patch`,patch:{metaHostname:e.hostname}})}catch{t||m({type:`patch`,patch:{metaHostname:null}})}})(),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!e)return;let t=n?.trim()??``;m({type:`patch`,patch:{manualPath:t,createFolderOpen:!1,createFolderName:``,createFolderLoading:!1,createFolderError:null,selectedFilePath:``}});let r=!1;return(async()=>{m({type:`patch`,patch:{listLoading:!0,listError:null}});try{if(t)try{let e=await gx(t);r||m({type:`patch`,patch:{listState:e}})}catch{let e=await gx();r||m({type:`patch`,patch:{listState:e}})}else{let e=await gx();r||m({type:`patch`,patch:{listState:e}})}}catch(e){let t=e instanceof Error?e.message:String(e);r||m({type:`patch`,patch:{listError:t,listState:null}})}finally{r||m({type:`patch`,patch:{listLoading:!1}})}})(),()=>{r=!0}},[e,n]);let E=e=>{e.isDirectory&&(m({type:`patch`,patch:{selectedFilePath:``}}),T(e.absolutePath))},D=()=>{if(!g)return;let{parentPath:e,currentPath:t}=g;if(e!==null){T(e);return}t===`/`||t===``||bx(t)&&T(void 0)},O=g?.currentPath===``?i.pickerDrives:g?.currentPath??``,k=!!g&&g.currentPath!==``&&!_&&!v,A=o?.map(e=>e.replace(/^\./,``).toLocaleLowerCase()),j=e=>{if(a!==`file-or-directory`||e.isDirectory)return!1;if(!A?.length)return!0;let t=e.name.includes(`.`)?e.name.split(`.`).pop()?.toLocaleLowerCase():``;return!!(t&&A.includes(t))},M=k&&!S,N=()=>{m({type:`patch`,patch:{createFolderOpen:!1,createFolderName:``,createFolderError:null}})},P=async()=>{let e=x.trim();if(!(!g||g.currentPath===``||!e||S)){m({type:`patch`,patch:{createFolderLoading:!0,createFolderError:null}});try{let t=await vx(g.currentPath,e);m({type:`patch`,patch:{createFolderOpen:!1,createFolderName:``,createFolderError:null}}),await T(t)}catch(e){let t=e?.status;m({type:`patch`,patch:{createFolderError:t===409?i.pickerCreateFolderExists:t===400?i.pickerCreateFolderInvalid:t===403?i.pickerCreateFolderPermission:i.pickerCreateFolderError}})}finally{m({type:`patch`,patch:{createFolderLoading:!1}})}}},F=async()=>{let e=w||g?.currentPath;if(e)try{await r(e),t(!1)}catch{}},I=async()=>{let e=y.trim();if(e)try{await r(e),t(!1)}catch{}},L=_&&g;return(0,$.jsx)(nt,{open:e,onOpenChange:t,children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:K(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[2px]`,u?`z-[139]`:`z-[100]`)}),(0,$.jsxs)(et,{className:K(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,32rem)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,u?`z-[140]`:`z-[101]`,`dark:border-edge`),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:s??i.pathModalTitle}),(0,$.jsx)(Ze,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:c??i.pathModalDescription}),h?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:i.pickerHostHint.replace(`{{hostname}}`,h)}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:_||!xx(g)||!!v,onClick:()=>D(),title:i.pickerUp,children:[(0,$.jsx)(ur,{className:`size-4`,"aria-hidden":!0}),i.pickerUp]}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate rounded-md border border-edge-subtle/80 bg-surface-hover/30 px-2 py-1.5 font-mono text-xs text-fg`,title:O,children:_&&!g?i.pickerLoading:O||`—`}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1 px-2 py-1.5 text-xs`,disabled:!M,onClick:()=>m({type:`patch`,patch:{createFolderOpen:!0,createFolderName:``,createFolderError:null}}),title:i.pickerNewFolder,children:[(0,$.jsx)(Wr,{className:`size-4`,"aria-hidden":!0}),i.pickerNewFolder]})]}),b?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-2`,children:[(0,$.jsx)(`label`,{htmlFor:f,className:`text-xs font-medium text-fg-muted`,children:i.pickerNewFolderName}),(0,$.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2`,children:[(0,$.jsx)(`input`,{id:f,type:`text`,value:x,onChange:e=>m({type:`patch`,patch:{createFolderName:e.target.value,createFolderError:null}}),className:yx(),autoFocus:!0,autoComplete:`off`,spellCheck:!1,disabled:S,onKeyDown:e=>{e.key===`Enter`&&x.trim()?(e.preventDefault(),P()):e.key===`Escape`&&(e.preventDefault(),N())}}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`shrink-0`,disabled:S,onClick:N,children:i.pickerCreateFolderCancel}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`shrink-0`,disabled:!x.trim()||S,onClick:()=>void P(),children:[S?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,i.pickerCreateFolder]})]}),C?(0,$.jsx)(`p`,{className:`mt-1.5 text-xs text-danger`,role:`alert`,children:C}):null]}):null,(0,$.jsxs)(`div`,{className:K(`relative min-h-[12rem] overflow-y-auto rounded-lg border border-edge-subtle/80 bg-surface-hover/20 p-1 dark:border-edge-subtle`,yc.focusRingPanel),role:`listbox`,"aria-label":s??i.pathModalTitle,children:[L?(0,$.jsx)(`div`,{className:`absolute inset-0 z-[1] flex items-center justify-center rounded-lg bg-surface-panel/60`,"aria-hidden":!0,children:(0,$.jsx)(ue,{className:`size-6 animate-spin text-fg-muted`})}):null,_&&!g?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-12 text-sm text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}),i.pickerLoading]}):null,v?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerListError}):null,!_&&g&&!v&&g.entries.length===0?(0,$.jsx)(`p`,{className:`px-2 py-8 text-center text-sm text-fg-muted`,children:i.pickerEmptyFolder}):null,g?.entries.map(e=>{let t=j(e),n=w===e.absolutePath;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,disabled:!e.isDirectory&&!t,className:K(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e.isDirectory||t?`cursor-pointer text-fg hover:bg-surface-hover`:`cursor-default text-fg-muted opacity-60`,n&&`bg-accent-soft text-accent-fg ring-1 ring-inset ring-accent`),onClick:()=>e.isDirectory?E(e):t&&m({type:`patch`,patch:{selectedFilePath:e.absolutePath}}),children:[e.isDirectory?(0,$.jsx)(Hr,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(jr,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.absolutePath)})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:d,className:`text-xs text-fg-muted`,children:i.pickerManualPath}),(0,$.jsx)(`input`,{id:d,type:`text`,value:y,onChange:e=>m({type:`patch`,patch:{manualPath:e.target.value}}),placeholder:i.pathInputPlaceholder,className:yx(),autoComplete:`off`,spellCheck:!1,onKeyDown:e=>{e.key===`Enter`&&y.trim()&&(e.preventDefault(),I())}})]})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-end gap-2 border-t border-edge-subtle/60 pt-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:i.pathModalCancel}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,disabled:!y.trim(),onClick:()=>void I(),children:i.pickerApplyManual}),(0,$.jsx)(X,{type:`button`,disabled:!w&&!k,onClick:()=>void F(),children:l??i.pickerUseThisFolder})]})]})]})})}var wx=(0,Z.createContext)(!1),Tx=20,Ex=12,Dx=5,Ox=60,kx=`application/x-xopc-sidebar-item`;function Ax(e,t,n,r){let i=e.filter(e=>e!==t),a=i.indexOf(n);return a<0?e:(i.splice(a+ +!!r,0,t),i)}function jx(e,t,n){if(!t?.length)return e;let r=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({item:e,index:t,rank:r.get(n(e))})).sort((e,t)=>e.rank!==void 0&&t.rank!==void 0?e.rank-t.rank:e.rank===void 0?t.rank===void 0?e.index-t.index:-1:1).map(({item:e})=>e)}function Mx({spec:e,children:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return e?(0,$.jsxs)(`div`,{draggable:!0,className:K(`relative cursor-grab transition-[opacity,transform] duration-200 ease-out active:cursor-grabbing`,n&&`opacity-50`),onDragStart:t=>{r(!0),t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(kx,JSON.stringify({containerId:e.containerId,itemId:e.itemId}))},onDragEnd:()=>{r(!1),a(null)},onDragOver:e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect();a(e.clientY>=t.top+t.height/2?`after`:`before`)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||a(null)},onDrop:t=>{t.preventDefault();let n=t.currentTarget.getBoundingClientRect(),r=t.clientY>=n.top+n.height/2;a(null);try{let n=JSON.parse(t.dataTransfer.getData(kx));if(n.containerId!==e.containerId||n.itemId===e.itemId)return;e.onReorder(e.containerId,Ax(e.itemIds,n.itemId,e.itemId,r))}catch{}},children:[i===`before`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 top-0 z-30 h-0.5 rounded-full bg-accent`}):null,t,i===`after`?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-x-1 bottom-0 z-30 h-0.5 rounded-full bg-accent`}):null]}):t}function Nx(e,t){return e.name?.trim()||t}function Px(e){let t=/^\/chat\/([^/]+)$/.exec(e);if(!t)return;let n=decodeURIComponent(t[1]);if(n!==`new`)return n}function Fx(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Ix(e){let t=new Date(e.updatedAt).getTime();return Number.isFinite(t)?t:0}function Lx(e,t){return K(`group relative flex min-h-8 w-full min-w-0 items-center rounded-lg pr-1 text-left text-sm leading-5 transition-colors duration-200 ease-out`,t?`pl-[1.125rem]`:`pl-1.5`,`focus-within:outline-none`,e?`bg-surface-active font-medium text-fg`:`font-normal text-fg-muted hover:bg-surface-hover hover:text-fg`)}var Rx=`text-xs font-normal leading-5 text-fg-subtle`,zx=K(Rx,`transition-colors hover:text-fg-muted`);function Bx(e){let t=(0,Q.c)(5),{indented:n}=e,r=(n===void 0?!1:n)&&`pl-7`,i;t[0]===r?i=t[1]:(i=K(`flex items-center gap-2 p-1.5`,r),t[0]=r,t[1]=i);let a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(xn,{className:`h-3 w-4/5 animate-none`}),(0,$.jsx)(xn,{className:`mt-1.5 h-2.5 w-2/5 animate-none`})]}),t[2]=a):a=t[2];let o;return t[3]===i?o=t[4]:(o=(0,$.jsx)(`div`,{className:i,children:a}),t[3]=i,t[4]=o),o}function Vx(){let e=(0,Q.c)(3),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xn,{className:`mb-1.5 h-2.5 w-14 animate-none`}),(0,$.jsx)(Bx,{})]}),n=(0,$.jsx)(xn,{className:`mb-1.5 h-2.5 w-16 animate-none`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 px-2 py-4`,"aria-busy":`true`,children:[t,(0,$.jsxs)(`div`,{children:[n,(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(Bx,{}),(0,$.jsx)(Bx,{indented:!0}),(0,$.jsx)(Bx,{indented:!0})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(xn,{className:`mb-1.5 h-2.5 w-12 animate-none`}),(0,$.jsx)(Bx,{}),(0,$.jsx)(Bx,{})]})]}),e[2]=r):r=e[2],r}var Hx=(0,Z.memo)(function({session:e,isActive:t,indented:n=!1,onNavigate:r,mutate:i,onRequestRename:a,onRequestDelete:o,sb:s,sess:c,clipboard:l,defaultUnnamedTitle:u,contextLabel:d,sort:f}){let p=(0,Z.useContext)(wx),m=Oo(e),h=m.source!==`workbench`||m.purpose!==`chat`,g=pg(e,s.sessionFilters),_=[g,d].filter(Boolean).join(` · `),[v,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=Qb(e.key),w=ex(t=>t.runs[e.key]),T=Nx(e,u),E=e.status===`pinned`,D=C||!!w?.unread,O=async()=>{if(!x){S(!0);try{E?await og(e.key):await ag(e.key),b(!1),i()}catch{}finally{S(!1)}}},k=async()=>{let t=await Yt(e.key);if(b(!1),t){Yl(`success`,s.taskChatIdCopied,void 0,{duration:2e3});return}Yl(`warning`,l.copyFailed,void 0,{duration:4e3})};return(0,$.jsx)(Mx,{spec:f,children:(0,$.jsxs)(`div`,{className:Lx(t,n),children:[(0,$.jsxs)(y,{to:`/chat/${encodeURIComponent(e.key)}`,className:K(`min-w-0 flex-1 self-stretch rounded-lg py-1 outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`flex min-w-0 items-center gap-2`,D?`pr-[4.75rem]`:`pr-12`),title:`${T} — ${_}`,"aria-label":`${T} — ${_}`,onClick:()=>r?.(),onDoubleClick:t=>{t.preventDefault(),t.stopPropagation(),a(e)},children:[h?(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,title:g,children:(0,$.jsx)(hg,{sourceChannel:e.sourceChannel,session:e,className:`size-3.5`})}):null,(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:T}),p?(0,$.jsx)(`span`,{className:`block truncate text-xs font-normal text-fg-muted`,children:_}):null]})]}),C?(0,$.jsxs)(`span`,{className:`pointer-events-none absolute right-2 top-1/2 z-10 flex size-2.5 -translate-y-1/2 items-center justify-center`,title:s.taskSessionAgentRunning,"aria-label":s.taskSessionAgentRunning,children:[(0,$.jsx)(`span`,{className:`absolute size-full animate-ping rounded-full bg-accent/70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative size-2 rounded-full bg-accent`,"aria-hidden":!0})]}):w?.unread?(0,$.jsx)(`span`,{className:K(`pointer-events-none absolute right-2 top-1/2 z-10 size-2.5 -translate-y-1/2 rounded-full`,w.status===`failed`?`bg-red-500`:`bg-emerald-500`),title:w.status===`failed`?s.taskSessionAgentFailed:s.taskSessionAgentCompleted,"aria-label":w.status===`failed`?s.taskSessionAgentFailed:s.taskSessionAgentCompleted}):null,(0,$.jsxs)(`div`,{className:K(`pointer-events-none absolute inset-y-0 z-10 flex items-center opacity-0 transition-opacity`,`group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100`,D?`right-7`:`right-1`,v&&`pointer-events-auto opacity-100`),children:[(0,$.jsx)(`button`,{type:`button`,className:K(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:cursor-wait`),"aria-label":E?c.unpin:c.pin,title:E?c.unpin:c.pin,"aria-pressed":E,disabled:x,onClick:()=>void O(),children:x?(0,$.jsx)(ue,{className:`size-4 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):E?(0,$.jsx)(Fi,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Pi,{className:`size-4 rotate-45`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(hn,{open:v,onOpenChange:b,children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:K(`flex h-8 w-6 shrink-0 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),"aria-label":s.taskSessionMenuAria,title:s.taskSessionMenuAria,"aria-expanded":v,children:(0,$.jsx)(F,{className:`size-4`,strokeWidth:2,"aria-hidden":!0})})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{className:`z-50 w-[9.25rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>{b(!1),a(e)},children:[(0,$.jsx)(he,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s.taskRename]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:()=>void k(),children:[(0,$.jsx)(Cr,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s.taskCopyChatId]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:()=>{b(!1),o(e.key)},children:[(0,$.jsx)(pa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),s.taskDeleteTask]})]})})]})]})]})})});function Ux(e){let t=(0,Q.c)(74),{project:n,onNavigate:r,onPinToggle:i,onRequestRename:a,onArchive:o,onRequestRemove:s,sb:c}=e,[l,u]=(0,Z.useState)(!1),d;t[0]!==n.effectiveWorkspaceRoot||t[1]!==n.workspaceRoot?(d=n.effectiveWorkspaceRoot?.trim()||n.workspaceRoot?.trim()||``,t[0]=n.effectiveWorkspaceRoot,t[1]=n.workspaceRoot,t[2]=d):d=t[2];let f=d,p=!!(f&&window.electronAPI?.shell?.openPath),m=!!n.pinnedAt,h;t[3]!==c.projectOpenInExplorerFailed||t[4]!==c.projectOpenInExplorerUnavailable||t[5]!==f?(h=async()=>{if(!f||!window.electronAPI?.shell?.openPath){Yl(`warning`,c.projectOpenInExplorerUnavailable,void 0,{duration:3500}),u(!1);return}let e=await window.electronAPI.shell.openPath(f);u(!1),e.ok===!1&&Yl(`warning`,e.error||c.projectOpenInExplorerFailed,void 0,{duration:4e3})},t[3]=c.projectOpenInExplorerFailed,t[4]=c.projectOpenInExplorerUnavailable,t[5]=f,t[6]=h):h=t[6];let g=h,_=l&&`opacity-100`,v;t[7]===_?v=t[8]:(v=K(`relative z-10 flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,_,`hover:bg-surface-hover hover:text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[7]=_,t[8]=v);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(F,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[9]=b):b=t[9];let x;t[10]!==l||t[11]!==c.projectMenuAria||t[12]!==v?(x=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:v,"aria-label":c.projectMenuAria,title:c.projectMenuAria,"aria-expanded":l,children:b})}),t[10]=l,t[11]=c.projectMenuAria,t[12]=v,t[13]=x):x=t[13];let S=`/projects/${encodeURIComponent(n.id)}`,C;t[14]===r?C=t[15]:(C=()=>{u(!1),r?.()},t[14]=r,t[15]=C);let w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(I,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=w):w=t[16];let T;t[17]!==c.projectOpen||t[18]!==S||t[19]!==C?(T=(0,$.jsxs)(y,{to:S,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:C,children:[w,c.projectOpen]}),t[17]=c.projectOpen,t[18]=S,t[19]=C,t[20]=T):T=t[20];let E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>u(!1),t[21]=E):E=t[21];let D;t[22]===n.id?D=t[23]:(D=(0,$.jsx)(Og,{projectId:n.id,onStarted:E,className:`flex w-full rounded-md px-2 py-1.5 text-left text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`}),t[22]=n.id,t[23]=D);let O;t[24]!==i||t[25]!==n?(O=()=>{u(!1),i(n)},t[24]=i,t[25]=n,t[26]=O):O=t[26];let k;t[27]===m?k=t[28]:(k=m?(0,$.jsx)(Fi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Pi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=m,t[28]=k);let A=m?c.projectUnpin:c.projectPin,j;t[29]!==O||t[30]!==k||t[31]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:O,children:[k,A]}),t[29]=O,t[30]=k,t[31]=A,t[32]=j):j=t[32];let M;t[33]===g?M=t[34]:(M=()=>void g(),t[33]=g,t[34]=M);let N=!p,P=p?void 0:c.projectOpenInExplorerUnavailable,L;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(oe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[35]=L):L=t[35];let R;t[36]!==c.projectOpenInExplorer||t[37]!==M||t[38]!==N||t[39]!==P?(R=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:text-fg-subtle disabled:hover:bg-transparent`,onClick:M,disabled:N,title:P,children:[L,c.projectOpenInExplorer]}),t[36]=c.projectOpenInExplorer,t[37]=M,t[38]=N,t[39]=P,t[40]=R):R=t[40];let z;t[41]!==a||t[42]!==n?(z=()=>{u(!1),a(n)},t[41]=a,t[42]=n,t[43]=z):z=t[43];let B;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(he,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[44]=B):B=t[44];let V;t[45]!==c.projectRename||t[46]!==z?(V=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:z,children:[B,c.projectRename]}),t[45]=c.projectRename,t[46]=z,t[47]=V):V=t[47];let H;t[48]!==o||t[49]!==n?(H=()=>{u(!1),o(n)},t[48]=o,t[49]=n,t[50]=H):H=t[50];let U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(Kn,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[51]=U):U=t[51];let W;t[52]!==c.projectArchive||t[53]!==H?(W=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-fg transition-colors hover:bg-surface-hover`,onClick:H,children:[U,c.projectArchive]}),t[52]=c.projectArchive,t[53]=H,t[54]=W):W=t[54];let G;t[55]!==s||t[56]!==n?(G=()=>{u(!1),s(n)},t[55]=s,t[56]=n,t[57]=G):G=t[57];let ee;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(pa,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[58]=ee):ee=t[58];let te;t[59]!==c.projectRemove||t[60]!==G?(te=(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs font-medium leading-snug text-red-600 transition-colors hover:bg-surface-hover dark:text-red-400`,onClick:G,children:[ee,c.projectRemove]}),t[59]=c.projectRemove,t[60]=G,t[61]=te):te=t[61];let ne;t[62]!==T||t[63]!==D||t[64]!==j||t[65]!==R||t[66]!==V||t[67]!==W||t[68]!==te?(ne=(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{className:`z-50 w-[12rem] rounded-lg border border-edge bg-surface-panel p-1 shadow-elevated dark:border-edge`,side:`bottom`,align:`end`,sideOffset:4,collisionPadding:12,onCloseAutoFocus:Wx,children:[T,D,j,R,V,W,te]})}),t[62]=T,t[63]=D,t[64]=j,t[65]=R,t[66]=V,t[67]=W,t[68]=te,t[69]=ne):ne=t[69];let re;return t[70]!==l||t[71]!==ne||t[72]!==x?(re=(0,$.jsxs)(hn,{open:l,onOpenChange:u,children:[x,ne]}),t[70]=l,t[71]=ne,t[72]=x,t[73]=re):re=t[73],re}function Wx(e){return e.preventDefault()}function Gx(e){let t=(0,Q.c)(68),{group:n,isExpanded:r,isCollapsed:i,activeConversationId:a,onToggleExpanded:o,onToggleCollapsed:s,onCreateProjectChat:c,onToggleProjectPin:l,onRequestProjectRename:u,onArchiveProject:d,onRequestProjectRemove:f,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,excludedConversationIds:x,projectSort:S,onReorder:C}=e,w;t[0]!==x||t[1]!==n.sessions?(w=x?n.sessions.filter(e=>!x.has(e.key)):n.sessions,t[0]=x,t[1]=n.sessions,t[2]=w):w=t[2];let T=w,E;t[3]!==r||t[4]!==T?(E=r?T:T.slice(0,Dx),t[3]=r,t[4]=T,t[5]=E):E=t[5];let D=E,O=T.length>Dx,k=n.sessionHasMore||O,A=r&&!n.sessionHasMore&&O,j;t[6]===a?j=t[7]:(j=e=>e.key===a,t[6]=a,t[7]=j);let M=T.some(j),N=n.project.name,P=M?`text-fg`:`text-fg-muted`,F;t[8]===P?F=t[9]:(F=K(`group flex h-7 min-w-0 items-center gap-1.5 rounded-lg px-2 text-sm font-medium leading-5`,P),t[8]=P,t[9]=F);let I;t[10]!==n.project.id||t[11]!==s?(I=()=>s(n.project.id),t[10]=n.project.id,t[11]=s,t[12]=I):I=t[12];let L=!i,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Gr,{className:`size-3.5 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=R):R=t[13];let z;t[14]===n.project.name?z=t[15]:(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.project.name}),t[14]=n.project.name,t[15]=z);let B;t[16]!==n.project.name||t[17]!==z||t[18]!==I||t[19]!==L?(B=(0,$.jsxs)(`button`,{type:`button`,className:`flex h-7 min-w-0 flex-1 items-center gap-1 text-left hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:I,title:n.project.name,"aria-expanded":L,children:[R,z]}),t[16]=n.project.name,t[17]=z,t[18]=I,t[19]=L,t[20]=B):B=t[20];let V;t[21]!==n.project||t[22]!==d||t[23]!==p||t[24]!==f||t[25]!==u||t[26]!==l||t[27]!==_?(V=(0,$.jsx)(Ux,{project:n.project,onNavigate:p,onPinToggle:l,onRequestRename:u,onArchive:d,onRequestRemove:f,sb:_}),t[21]=n.project,t[22]=d,t[23]=p,t[24]=f,t[25]=u,t[26]=l,t[27]=_,t[28]=V):V=t[28];let H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=K(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[29]=H):H=t[29];let U;t[30]!==n.project||t[31]!==c?(U=()=>c(n.project),t[30]=n.project,t[31]=c,t[32]=U):U=t[32];let W;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=W):W=t[33];let G;t[34]!==_.projectNewChat||t[35]!==U?(G=(0,$.jsx)(`button`,{type:`button`,className:H,onClick:U,title:_.projectNewChat,"aria-label":_.projectNewChat,children:W}),t[34]=_.projectNewChat,t[35]=U,t[36]=G):G=t[36];let ee;t[37]!==B||t[38]!==V||t[39]!==G||t[40]!==F?(ee=(0,$.jsxs)(`div`,{className:F,children:[B,V,G]}),t[37]=B,t[38]=V,t[39]=G,t[40]=F,t[41]=ee):ee=t[41];let te;t[42]!==a||t[43]!==k||t[44]!==y||t[45]!==b||t[46]!==n.project.id||t[47]!==n.sessionLoading||t[48]!==i||t[49]!==m||t[50]!==p||t[51]!==C||t[52]!==g||t[53]!==h||t[54]!==o||t[55]!==_||t[56]!==v||t[57]!==A||t[58]!==T||t[59]!==D?(te=i?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[D.map(e=>(0,$.jsx)(Hx,{session:e,isActive:a===e.key,indented:!0,onNavigate:p,mutate:m,onRequestRename:h,onRequestDelete:g,sb:_,sess:v,clipboard:y,defaultUnnamedTitle:b,sort:{containerId:`project:${n.project.id}`,itemId:e.key,itemIds:T.map(Kx),onReorder:C}},e.key)),k?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:()=>o(n.project.id),disabled:n.sessionLoading,"aria-busy":n.sessionLoading||void 0,children:[n.sessionLoading?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(cr,{className:K(`size-3.5 transition-transform duration-150 ease-out`,A&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),A?_.projectShowLess:_.projectShowMore]}):null]}),t[42]=a,t[43]=k,t[44]=y,t[45]=b,t[46]=n.project.id,t[47]=n.sessionLoading,t[48]=i,t[49]=m,t[50]=p,t[51]=C,t[52]=g,t[53]=h,t[54]=o,t[55]=_,t[56]=v,t[57]=A,t[58]=T,t[59]=D,t[60]=te):te=t[60];let ne;t[61]!==n.project.name||t[62]!==ee||t[63]!==te?(ne=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":N,children:[ee,te]}),t[61]=n.project.name,t[62]=ee,t[63]=te,t[64]=ne):ne=t[64];let re;return t[65]!==S||t[66]!==ne?(re=(0,$.jsx)(Mx,{spec:S,children:ne}),t[65]=S,t[66]=ne,t[67]=re):re=t[67],re}function Kx(e){return e.key}function qx(e){let t=(0,Q.c)(49),{sessions:n,hasMore:r,loadingMore:i,isCollapsed:a,onToggleCollapsed:o,onCreateChat:s,onLoadMore:c,activeConversationId:l,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,excludedConversationIds:v,onReorder:y,sortable:b}=e,x=b===void 0?!0:b,S;t[0]!==v||t[1]!==n?(S=v?n.filter(e=>!v.has(e.key)):n,t[0]=v,t[1]=n,t[2]=S):S=t[2];let C=S;if(C.length===0&&!r)return null;let w=m.inboxHeading,T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=K(`flex min-w-0 flex-1 items-center gap-1 px-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,zx),t[3]=T):T=t[3];let E=!a,D=m.inboxHeading,O=a&&`-rotate-90`,k;t[4]===O?k=t[5]:(k=K(`size-3.5 transition-transform duration-150 ease-out`,O),t[4]=O,t[5]=k);let A;t[6]===k?A=t[7]:(A=(0,$.jsx)(cr,{className:k,strokeWidth:1.75,"aria-hidden":!0}),t[6]=k,t[7]=A);let j;t[8]!==o||t[9]!==m.inboxHeading||t[10]!==E||t[11]!==A?(j=(0,$.jsxs)(`button`,{type:`button`,className:T,onClick:o,"aria-expanded":E,children:[D,A]}),t[8]=o,t[9]=m.inboxHeading,t[10]=E,t[11]=A,t[12]=j):j=t[12];let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=K(`flex size-7 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-opacity hover:bg-surface-hover hover:text-fg-muted`,`opacity-0 group-hover:opacity-100 focus:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),t[13]=M):M=t[13];let N;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[14]=N):N=t[14];let P;t[15]!==_||t[16]!==s?(P=(0,$.jsx)(`button`,{type:`button`,className:M,onClick:s,title:_,"aria-label":_,children:N}),t[15]=_,t[16]=s,t[17]=P):P=t[17];let F;t[18]!==j||t[19]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center pb-1`,children:[j,P]}),t[18]=j,t[19]=P,t[20]=F):F=t[20];let I=a&&`hidden`,L;t[21]===I?L=t[22]:(L=K(`flex flex-col gap-0.5`,I),t[21]=I,t[22]=L);let R;t[23]!==l||t[24]!==g||t[25]!==_||t[26]!==d||t[27]!==u||t[28]!==y||t[29]!==p||t[30]!==f||t[31]!==m||t[32]!==h||t[33]!==x||t[34]!==C?(R=C.map(e=>(0,$.jsx)(Hx,{session:e,isActive:l===e.key,indented:!0,onNavigate:u,mutate:d,onRequestRename:f,onRequestDelete:p,sb:m,sess:h,clipboard:g,defaultUnnamedTitle:_,sort:x?{containerId:`inbox`,itemId:e.key,itemIds:C.map(Jx),onReorder:y}:void 0},e.key)),t[23]=l,t[24]=g,t[25]=_,t[26]=d,t[27]=u,t[28]=y,t[29]=p,t[30]=f,t[31]=m,t[32]=h,t[33]=x,t[34]=C,t[35]=R):R=t[35];let z;t[36]!==r||t[37]!==i||t[38]!==c||t[39]!==m.projectShowMore?(z=r?(0,$.jsxs)(`button`,{type:`button`,className:`ml-4 flex w-fit items-center gap-1 rounded-lg px-2 py-1 text-xs font-medium text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,onClick:c,disabled:i,"aria-busy":i||void 0,children:[i?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(cr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),m.projectShowMore]}):null,t[36]=r,t[37]=i,t[38]=c,t[39]=m.projectShowMore,t[40]=z):z=t[40];let B;t[41]!==L||t[42]!==R||t[43]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[41]=L,t[42]=R,t[43]=z,t[44]=B):B=t[44];let V;return t[45]!==m.inboxHeading||t[46]!==F||t[47]!==B?(V=(0,$.jsxs)(`section`,{className:`flex flex-col gap-0.5`,"aria-label":w,children:[F,B]}),t[45]=m.inboxHeading,t[46]=F,t[47]=B,t[48]=V):V=t[48],V}function Jx(e){return e.key}function Yx(e){let t=(0,Q.c)(21),{sessions:n,activeConversationId:r,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,onReorder:f}=e;if(n.length===0)return null;let p=l.pinnedSessions,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=K(`px-2 pb-1`,Rx),t[0]=m):m=t[0];let h;t[1]===l.pinnedSessions?h=t[2]:(h=(0,$.jsx)(`h2`,{className:m,children:l.pinnedSessions}),t[1]=l.pinnedSessions,t[2]=h);let g;t[3]!==r||t[4]!==u||t[5]!==d||t[6]!==a||t[7]!==i||t[8]!==f||t[9]!==s||t[10]!==o||t[11]!==c||t[12]!==l||t[13]!==n?(g=n.map(e=>(0,$.jsx)(Hx,{session:e,isActive:r===e.key,onNavigate:i,mutate:a,onRequestRename:o,onRequestDelete:s,sb:c,sess:l,clipboard:u,defaultUnnamedTitle:d,sort:{containerId:`pinned`,itemId:e.key,itemIds:n.map(Xx),onReorder:f}},e.key)),t[3]=r,t[4]=u,t[5]=d,t[6]=a,t[7]=i,t[8]=f,t[9]=s,t[10]=o,t[11]=c,t[12]=l,t[13]=n,t[14]=g):g=t[14];let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:g}),t[15]=g,t[16]=_);let v;return t[17]!==l.pinnedSessions||t[18]!==h||t[19]!==_?(v=(0,$.jsxs)(`section`,{className:`mb-3 flex flex-col gap-0.5`,"aria-label":p,children:[h,_]}),t[17]=l.pinnedSessions,t[18]=h,t[19]=_,t[20]=v):v=t[20],v}function Xx(e){return e.key}function Zx(e){let t=(0,Q.c)(3),{onNavigate:n}=e,r=Se(Qx),i;return t[0]!==r||t[1]!==n?(i=(0,$.jsx)($x,{gateway:r,onNavigate:n},r),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function Qx(e){return e.baseUrl}function $x({onNavigate:e,gateway:t}){let n=Ee(e=>e.language),r=xe(n),i=r.sidebar,a=r.sessions,o=r.projectsPage,s=r.chat.workingDirectory,c=Se(e=>e.conversationId),u=lg(t,c),d=i.sessionFilters,f=(0,Z.useRef)(null),p=(0,Z.useRef)(0);(0,Z.useLayoutEffect)(()=>{f.current&&(f.current.scrollTop=u.active?0:p.current)},[u.active]);let m=Se(e=>e.openTokenDialog),{data:h,mutate:g}=Zt(c?[`gateway-chat-agents`,c]:null,Mg,{revalidateOnFocus:!1}),_=h?.defaultId??`main`;(0,Z.useEffect)(()=>{let e=()=>void g();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[g]);let{pathname:v}=b(),y=l(),x=Px(v),S=(0,Z.useMemo)(()=>Date.now()-Ox*24*60*60*1e3,[]),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(``),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(``),[z,B]=(0,Z.useState)(``),[V,H]=(0,Z.useState)(null),[U,W]=(0,Z.useState)(!1),[G,ee]=(0,Z.useState)(!0),[te,ne]=(0,Z.useState)(()=>x),[re,ie]=(0,Z.useState)(!1),[ae,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(()=>new Set),[de,fe]=(0,Z.useState)(()=>new Set),[pe,me]=(0,Z.useState)({}),[he,_e]=(0,Z.useState)(()=>new Set),[ve,ye]=(0,Z.useState)([]),[be,q]=(0,Z.useState)(null),[Ce,we]=(0,Z.useState)(!1),[Te,De]=(0,Z.useState)({}),Oe=(0,Z.useRef)(new Set),J=fx({initialPath:z,onPicked:B}),{data:ke,size:Ae,setSize:je,isValidating:Me,mutate:Ne}=en((e,t)=>!c||t&&!t.projects.hasMore?null:[`sidebar-chat-list`,c,te??``,e],async([,,e,t])=>Xh({projectLimit:Ex,projectOffset:t*Ex,sessionPreviewLimit:Dx,inboxLimit:t===0?Tx:1,inboxOffset:0,staleDays:Ox,includeConversationId:e||void 0}),{keepPreviousData:!0,revalidateOnFocus:!1}),Pe=(0,Z.useMemo)(()=>{let e=ke??[],t=[],n=new Set;for(let r of e)for(let e of r.projects.items){if(n.has(e.project.id))continue;n.add(e.project.id);let r=pe[e.project.id],i=r?.sessions??e.sessions;t.push({project:e.project,sessions:i,sessionTotal:r?.sessionTotal??e.sessionTotal,sessionHasMore:r?.hasMore??e.sessionHasMore,sessionLoading:he.has(e.project.id)})}return jx(t.map(e=>({...e,sessions:jx(e.sessions,Te[`project:${e.project.id}`],e=>e.key)})),Te.projects,e=>e.project.id)},[ke,he,Te,pe]),Fe=ke?.[0]?.inbox,Ie=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of[...Fe?.items??[],...ve])t.has(n.key)||(t.add(n.key),e.push(n));return e.sort((e,t)=>Ix(t)-Ix(e)),jx(e,Te.inbox??ke?.[0]?.layouts.inbox?.itemIds,e=>e.key)},[ke,Fe?.items,ve,Te.inbox]),Le=be??Fe?.hasMore??!1,Re=(0,Z.useMemo)(()=>{let e=[],t=new Set;for(let n of Pe)for(let r of n.sessions)t.has(r.key)||(t.add(r.key),e.push(r));for(let n of Ie)t.has(n.key)||(t.add(n.key),e.push(n));return e},[Ie,Pe]),ze=(0,Z.useMemo)(()=>new Set(Re.map(e=>e.key)),[Re]),Be=Pe.length>0||Ie.length>0,Ve=(0,Z.useMemo)(()=>jx(ke?.[0]?.pinned??[],Te.pinned,e=>e.key),[ke,Te.pinned]),He=(0,Z.useMemo)(()=>new Set(Ve.map(e=>e.key)),[Ve]),Ue=!!(ke&&Ae>ke.length),We=(ke?.[ke.length-1])?.projects.hasMore??!1,Ge=!!(c&&!ke&&Me),Ke=(0,Z.useCallback)(()=>{me({}),ye([]),q(null),Ne()},[Ne]),qe=(0,Z.useCallback)((e,t)=>{if(Oe.current.has(e))return;let r=ke?.[0]?.layouts[e]?.revision??0;De(n=>({...n,[e]:t})),Oe.current.add(e),(async()=>{try{await Zh({containerId:e,itemIds:t,expectedRevision:r}),await Ne()}catch{Yl(`warning`,n===`zh`?`未能保存侧栏顺序,已恢复原位置`:`Could not save sidebar order; the previous order was restored`,void 0,{duration:3500})}finally{Oe.current.delete(e),De(t=>{let n={...t};return delete n[e],n})}})()},[ke,n,Ne]),Je=(0,Z.useCallback)(e=>{let t=e.currentTarget;if(u.active||(p.current=t.scrollTop,!We||Ue))return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t;r-n-i>100||je(e=>e+1)},[u.active,We,Ue,je]);(0,Z.useEffect)(()=>{if(!c)return;let e=()=>{Ke()},t=e=>{if(!e.detail?.key){Ke();return}Ke()},n=e=>{Ag(e.detail,ze)&&Ke()};return window.addEventListener(`session-updated`,t),window.addEventListener(`session-created`,e),window.addEventListener(`project-updated`,e),window.addEventListener(`session-transcript-updated`,n),()=>{window.removeEventListener(`session-updated`,t),window.removeEventListener(`session-created`,e),window.removeEventListener(`project-updated`,e),window.removeEventListener(`session-transcript-updated`,n)}},[c,Ke,ze]),(0,Z.useEffect)(()=>{!c||!x||!ke||Re.some(e=>e.key===x)||ne(e=>e===x?e:x)},[x,ke,Re,c]);let Xe=(0,Z.useCallback)(e=>{w(e.key),E(Nx(e,r.chat.newSession))},[r.chat.newSession]),rt=async()=>{if(!C)return;let e=T.trim();if(e)try{await ng(C,e),w(null),u.refresh(),Ke()}catch{}},it=async e=>{try{await tg(e),u.refresh(),x===e&&y(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),Ke()}catch{}},at=(0,Z.useCallback)(e=>{A(e.id),M(e.name.trim())},[]),ot=async()=>{if(!k||!mt)return;let e=j.trim();if(e)try{await Sh(k,e,mt.version),A(null),Ke(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:k}}))}catch{}},st=(0,Z.useCallback)(async e=>{try{await Ch(e.id,e.version),v===`/projects/${encodeURIComponent(e.id)}`&&y(`/projects`),Ke(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[y,v,Ke]),ct=(0,Z.useCallback)(async e=>{try{e.pinnedAt?await Eh(e.id,e.version):await Th(e.id,e.version),Ke(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch{}},[Ke]),lt=async e=>{let t=e.id;try{await Dh(t,e.version),v===`/projects/${encodeURIComponent(t)}`&&y(`/projects`),Ke(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:t}}))}catch{}},ut=(0,Z.useCallback)(e=>{let t=Pe.find(t=>t.project.id===e);if(t){if(de.has(e)&&!t.sessionHasMore){fe(t=>{let n=new Set(t);return n.delete(e),n});return}fe(t=>{let n=new Set(t);return n.add(e),n}),!(!t.sessionHasMore||he.has(e))&&(_e(t=>new Set(t).add(e)),(async()=>{try{let n=await Yh({projectId:e,limit:5e3,offset:0,updatedAfter:S,includePinned:!0,includeConversationId:x});me(r=>{let i=r[e]?.sessions??t.sessions,a=new Set(i.map(e=>e.key)),o=[...i];for(let e of n.items)a.has(e.key)||(a.add(e.key),o.push(e));let s=jx(o,Te[`project:${e}`]??ke?.[0]?.layouts[`project:${e}`]?.itemIds,e=>e.key);return{...r,[e]:{sessions:s,sessionTotal:n.total,hasMore:!1}}})}finally{_e(t=>{let n=new Set(t);return n.delete(e),n})}})())}},[x,ke,de,he,Te,Pe,S]),dt=(0,Z.useCallback)(e=>{le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Y=(0,Z.useCallback)(()=>{!Le||Ce||(we(!0),(async()=>{try{let e=await Yh({unassigned:!0,limit:5e3,offset:0,updatedAfter:S,includePinned:!0,includeConversationId:x});ye(t=>{let n=new Set([...Fe?.items??[],...t].map(e=>e.key)),r=[...t];for(let t of e.items)n.has(t.key)||(n.add(t.key),r.push(t));return jx(r,Te.inbox??ke?.[0]?.layouts.inbox?.itemIds,e=>e.key)}),q(!1)}finally{we(!1)}})())},[x,ke,Fe?.items,Le,Ce,Te.inbox,S]),ft=(0,Z.useCallback)(t=>{y(Gg(t.id),{state:{forceNewChat:!0,agentId:t.defaultAgentId??_}}),e?.()},[_,y,e]),pt=(0,Z.useCallback)(async e=>{e.preventDefault();let t=L.trim(),n=z.trim();if(!(!t||!n||U)){W(!0),H(null);try{let e=await yh({name:t,workspaceRoot:n,autoUnderstand:G});R(``),B(``),ee(!0),I(!1),Ke(),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}catch(e){H(e instanceof Error?e.message:String(e))}finally{W(!1)}}},[L,z,U,Ke,G]),mt=k?Pe.find(e=>e.project.id===k)?.project:void 0,ht=N?Pe.find(e=>e.project.id===N)?.project:void 0;return c?(0,$.jsx)(wx,{value:u.filters.details,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{ref:f,className:`app-sidebar-nav-scroll min-h-0 flex-1 overflow-y-auto overscroll-y-contain pt-3 pb-2`,onScroll:Je,children:[(0,$.jsx)(`div`,{hidden:u.active||Ge,className:`px-2`,children:(0,$.jsx)(Yx,{sessions:Ve,activeConversationId:x,onNavigate:e,mutate:Ke,onRequestRename:Xe,onRequestDelete:O,sb:i,sess:a,clipboard:r.clipboard,defaultUnnamedTitle:r.chat.newSession,onReorder:qe})}),(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsxs)(`div`,{className:`group flex min-w-0 items-center gap-1.5 px-2 pb-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:K(`flex shrink-0 items-center gap-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,zx),onClick:()=>ie(e=>!e),"aria-expanded":!re,children:[i.projectsHeading,(0,$.jsx)(cr,{className:K(`size-3.5 transition-transform duration-150 ease-out`,re&&`-rotate-90`),strokeWidth:1.75,"aria-hidden":!0})]}),(0,$.jsx)(Hh,{filters:u.filters,onChange:u.updateFilters,search:u.search,onSearch:u.setSearch,labels:d,gateway:t,agents:h?.items??[]}),(0,$.jsx)(`button`,{type:`button`,className:K(`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-subtle opacity-0 transition-[color,background-color,opacity] hover:bg-surface-hover hover:text-fg focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,F&&`opacity-100`),onClick:()=>I(!0),"aria-label":o.createTitle,title:o.createTitle,children:(0,$.jsx)(ge,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0})})]})}),u.active?(0,$.jsxs)(`div`,{className:`px-2 py-2`,children:[u.pendingUpdate?(0,$.jsx)(`button`,{type:`button`,className:`mb-2 w-full rounded-md px-2 py-1 text-xs text-accent-fg hover:bg-surface-hover`,onClick:u.refresh,children:d.refresh}):null,u.error?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:d.error}),(0,$.jsx)(X,{variant:`secondary`,onClick:u.refresh,children:d.retry})]}):u.loading?(0,$.jsx)(Vx,{}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs text-fg-muted`,"aria-live":`polite`,children:d.results.replace(`{{count}}`,String(u.total))}),u.items.length?null:(0,$.jsx)(`p`,{className:`px-2 py-4 text-xs text-fg-muted`,children:d.empty}),(0,$.jsx)(wx,{value:!0,children:u.items.map(t=>(0,$.jsx)(Hx,{session:t,isActive:t.key===x,contextLabel:t.projectId?u.projects?.find(e=>e.id===t.projectId)?.name??Pe.find(e=>e.project.id===t.projectId)?.project.name??t.projectId:d.unassigned,onNavigate:e,mutate:()=>{u.refresh(),Ke()},onRequestRename:Xe,onRequestDelete:O,sb:i,sess:a,clipboard:r.clipboard,defaultUnnamedTitle:r.chat.newSession},t.key))}),u.loadingMore?(0,$.jsx)(Bx,{}):u.hasMore?(0,$.jsx)(`button`,{type:`button`,className:`w-full rounded-md py-2 text-xs text-fg-muted hover:bg-surface-hover`,onClick:u.loadMore,children:d.more}):null]})]}):null,(0,$.jsxs)(`div`,{hidden:u.active,children:[Ge?(0,$.jsx)(Vx,{}):Be?(0,$.jsxs)(`div`,{className:`flex flex-col px-2`,children:[Pe.length>0?(0,$.jsx)(`div`,{className:`pb-1`,children:re?null:Pe.map(t=>(0,$.jsx)(Gx,{group:t,isExpanded:de.has(t.project.id),isCollapsed:ce.has(t.project.id),activeConversationId:x,onToggleExpanded:ut,onToggleCollapsed:dt,onCreateProjectChat:e=>void ft(e),onToggleProjectPin:e=>void ct(e),onRequestProjectRename:at,onArchiveProject:e=>void st(e),onRequestProjectRemove:e=>P(e.id),onNavigate:e,mutate:Ke,onRequestRename:Xe,onRequestDelete:O,sb:i,sess:a,clipboard:r.clipboard,defaultUnnamedTitle:r.chat.newSession,excludedConversationIds:He,projectSort:{containerId:`projects`,itemId:t.project.id,itemIds:Pe.map(e=>e.project.id),onReorder:qe},onReorder:qe},t.project.id))}):null,(0,$.jsx)(qx,{sessions:Ie.filter(e=>Oo(e).source!==`system`),hasMore:Le,loadingMore:Ce,isCollapsed:ae,onToggleCollapsed:()=>se(e=>!e),onCreateChat:()=>{y(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:Y,activeConversationId:x,onNavigate:e,mutate:Ke,onRequestRename:Xe,onRequestDelete:O,sb:i,sess:a,clipboard:r.clipboard,defaultUnnamedTitle:r.chat.newSession,excludedConversationIds:He,onReorder:qe}),Ie.some(e=>Oo(e).source===`system`)?(0,$.jsxs)(`details`,{className:`mt-3`,open:Ie.some(e=>e.key===x&&Oo(e).source===`system`),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-2 py-2 text-xs text-fg-muted`,children:n===`zh`?`系统活动`:`System activity`}),(0,$.jsx)(qx,{sessions:Ie.filter(e=>Oo(e).source===`system`),hasMore:!1,loadingMore:Ce,isCollapsed:!1,onToggleCollapsed:()=>void 0,onCreateChat:()=>{y(`/chat/new?projectScope=none`,{state:{forceNewChat:!0}}),e?.()},onLoadMore:Y,activeConversationId:x,onNavigate:e,mutate:Ke,onRequestRename:Xe,onRequestDelete:O,sb:i,sess:a,clipboard:r.clipboard,defaultUnnamedTitle:r.chat.newSession,excludedConversationIds:He,onReorder:qe,sortable:!1})]}):null]}):(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel p-3 text-xs leading-relaxed text-fg-muted`,children:i.taskListEmpty})}),Ue?(0,$.jsx)(`div`,{className:`flex justify-center py-2`,"aria-busy":!0,children:(0,$.jsx)(ue,{className:`size-4 animate-spin text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})}):null]})]}),(0,$.jsx)(nt,{open:F,onOpenChange:e=>{U||(I(e),e||H(null))},children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(30rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:o.createTitle}),(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:o.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:pt,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm font-medium text-fg`,children:[o.projectName,(0,$.jsx)(`input`,{autoFocus:!0,className:`h-10 rounded-lg border border-edge bg-surface-base px-3 font-normal outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`,value:L,onChange:e=>R(e.target.value),maxLength:160})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:o.workspaceRoot}),(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2 text-left outline-none transition-colors hover:bg-surface-hover focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent/20 disabled:cursor-not-allowed disabled:opacity-60`,onClick:J.pick,disabled:U||J.picking,children:[J.picking?(0,$.jsx)(ue,{className:`size-5 shrink-0 animate-spin text-accent`,"aria-hidden":!0}):(0,$.jsx)(oe,{className:`size-5 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:z?s.chooseFolder:s.selectWorkingDirectory}),(0,$.jsx)(`span`,{className:K(`mt-0.5 block truncate font-mono text-xs font-normal`,z?`text-fg-muted`:`text-fg-subtle`),title:z||void 0,children:z||o.workspaceSelectionPlaceholder})]})]}),(0,$.jsx)(`p`,{className:`text-xs font-normal text-fg-subtle`,children:o.workspaceSelectionHint})]}),(0,$.jsx)(Cg,{checked:G,onChange:ee,disabled:U}),V?(0,$.jsx)(`p`,{className:`rounded-lg bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:V}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:U,children:o.cancel})}),(0,$.jsx)(X,{type:`submit`,variant:`primary`,disabled:U||!L.trim()||!z.trim(),children:U?o.home.creating:o.create})]})]})]})]})}),J.hasNativePicker?null:(0,$.jsx)(Cx,{open:J.modalOpen,onOpenChange:J.setModalOpen,initialAbsolutePath:z||void 0,onConfirm:J.confirmPick,wd:s}),(0,$.jsx)(nt,{open:C!==null,onOpenChange:e=>!e&&w(null),children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:i.taskRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-rename-input`,children:i.taskRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-rename-input`,type:`text`,value:T,onChange:e=>E(e.target.value),className:K(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,bd,`dark:border-edge`),placeholder:r.chat.newSession,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),rt())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>w(null),children:i.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void rt(),disabled:!T.trim(),children:i.taskRenameSave})]})]})]})}),(0,$.jsx)(nt,{open:D!==null,onOpenChange:e=>!e&&O(null),children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:a.deleteSessionTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:D?Fx(a.deleteSessionMessage,{name:Re.find(e=>e.key===D)?.name?.trim()||r.chat.newSession}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>O(null),children:a.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{D&&it(D),O(null)},children:a.delete})]})]})]})}),(0,$.jsx)(nt,{open:k!==null,onOpenChange:e=>!e&&A(null),children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:i.projectRenameTitle}),(0,$.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg-subtle`,htmlFor:`sidebar-project-rename-input`,children:i.projectRenamePlaceholder}),(0,$.jsx)(`input`,{id:`sidebar-project-rename-input`,type:`text`,value:j,onChange:e=>M(e.target.value),className:K(`mt-1.5 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,bd,`dark:border-edge`),placeholder:mt?.name??``,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ot())}}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>A(null),children:i.taskRenameCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void ot(),disabled:!j.trim(),children:i.taskRenameSave})]})]})]})}),(0,$.jsx)(nt,{open:N!==null,onOpenChange:e=>!e&&P(null),children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:i.projectRemoveTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:ht?Fx(i.projectRemoveMessage,{name:ht.name}):``}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>P(null),children:a.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{ht&&lt(ht),P(null)},children:i.projectRemove})]})]})]})})]})}):(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 px-4 pt-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.taskListNeedToken}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-8 w-full text-xs font-medium`,onClick:()=>{m(),e?.()},children:i.taskListAddToken})]})})})}function eS(e){let t=(0,Q.c)(33),{onNavigate:n,collapsed:r}=e,i=r===void 0?!1:r,a=Ee(tS),o;t[0]===a?o=t[1]:(o=xe(a),t[0]=a,t[1]=o);let s=o,c=i?`px-1.5`:`px-4`,l;t[2]===c?l=t[3]:(l=K(`shrink-0 pt-4`,c),t[2]=c,t[3]=l);let u;t[4]!==i||t[5]!==s||t[6]!==n?(u=i?null:(0,$.jsxs)(y,{to:`/chat/new`,state:{forceNewChat:!0},className:K(`flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm font-medium leading-5 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`text-fg hover:bg-surface-hover`),title:s.sidebar.newTask,onClick:()=>n?.(),children:[(0,$.jsx)(ge,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:s.sidebar.newTask})]}),t[4]=i,t[5]=s,t[6]=n,t[7]=u):u=t[7];let d;t[8]!==i||t[9]!==n?(d=(0,$.jsx)($m,{collapsed:i,onNavigate:n}),t[8]=i,t[9]=n,t[10]=d):d=t[10];let f;t[11]!==u||t[12]!==d?(f=(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[u,d]}),t[11]=u,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==l||t[15]!==f?(p=(0,$.jsx)(`nav`,{className:l,"aria-label":`Main`,children:f}),t[14]=l,t[15]=f,t[16]=p):p=t[16];let m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`mx-4 my-3 h-px shrink-0 bg-edge-subtle`,"aria-hidden":!0}),t[17]=m):m=t[17];let h=i&&`hidden`,g;t[18]===h?g=t[19]:(g=K(`flex min-h-0 flex-1 flex-col overflow-hidden`,h),t[18]=h,t[19]=g);let _=i?!0:void 0,v;t[20]===n?v=t[21]:(v=(0,$.jsx)(Zx,{onNavigate:n}),t[20]=n,t[21]=v);let b;t[22]!==g||t[23]!==_||t[24]!==v?(b=(0,$.jsx)(`div`,{className:g,"aria-hidden":_,children:v}),t[22]=g,t[23]=_,t[24]=v,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n?(x=(0,$.jsx)(Zm,{collapsed:i,onNavigate:n}),t[26]=i,t[27]=n,t[28]=x):x=t[28];let S;return t[29]!==b||t[30]!==x||t[31]!==p?(S=(0,$.jsxs)(`div`,{className:`app-sidebar-content flex min-h-0 flex-1 flex-col`,children:[p,m,b,x]}),t[29]=b,t[30]=x,t[31]=p,t[32]=S):S=t[32],S}function tS(e){return e.language}var nS=`(min-width: 768px)`,rS=(0,Z.memo)(function(){let e=(0,Q.c)(42),t=Ee(iS),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n,i=Kf(aS),a=Kf(oS),o=Kf(sS),s=ep(cS),c=ep(lS),[l,u]=(0,Z.useState)(!1),d=Df({runtime:Ef(),sidebarCollapsed:i,mobileNavOpen:s}),f;e[2]!==o||e[3]!==i?(f=e=>{if(i)return;e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),u(!0);let r=e.clientX,a=Kf.getState().expandedWidthPx,s=e.pointerId,c=0,l=a,d=a,f=()=>{c=0,d=l,n?.style.setProperty(`--sidebar-expanded-px`,`${d}px`)},p=e=>{l=Uf(a+(e.clientX-r)),c===0&&(c=window.requestAnimationFrame(f))},m=()=>{c!==0&&(window.cancelAnimationFrame(c),f());try{t.releasePointerCapture(s)}catch{}u(!1),o(d),window.removeEventListener(`pointermove`,p),window.removeEventListener(`pointerup`,m),window.removeEventListener(`pointercancel`,m)};window.addEventListener(`pointermove`,p),window.addEventListener(`pointerup`,m),window.addEventListener(`pointercancel`,m)},e[2]=o,e[3]=i,e[4]=f):f=e[4];let p=f,m,h;e[5]===c?(m=e[6],h=e[7]):(m=()=>{let e=e=>{e.key===`Escape`&&c(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},h=[c],e[5]=c,e[6]=m,e[7]=h),(0,Z.useEffect)(m,h);let g,_;e[8]===c?(g=e[9],_=e[10]):(g=()=>{let e=window.matchMedia(nS),t=()=>{e.matches&&c(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},_=[c],e[8]=c,e[9]=g,e[10]=_),(0,Z.useEffect)(g,_);let v,y;e[11]===s?(v=e[12],y=e[13]):(v=()=>{if(!s||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},y=[s],e[11]=s,e[12]=v,e[13]=y),(0,Z.useEffect)(v,y);let b;e[14]!==r||e[15]!==s||e[16]!==c?(b=s?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 bg-scrim md:hidden`,"aria-label":r.closeMenu,onClick:()=>c(!1)}):null,e[14]=r,e[15]=s,e[16]=c,e[17]=b):b=e[17];let x=l&&`sidebar-width-resizing`,S=s?`max-md:translate-x-0`:`max-md:-translate-x-full`,C=i?`md:w-0 md:overflow-hidden md:border-0`:`app-sidebar-expanded-width`,w;e[18]!==x||e[19]!==S||e[20]!==C?(w=K(`app-sidebar-push app-chrome-sidebar flex min-h-0 shrink-0 flex-col overflow-hidden bg-transparent`,x,`max-md:fixed max-md:left-0 max-md:top-0 max-md:z-50 max-md:h-[100dvh] max-md:w-[min(16rem,85vw)]`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,S,`md:relative md:h-full md:translate-x-0`,C),e[18]=x,e[19]=S,e[20]=C,e[21]=w):w=e[21];let T=i&&!s?!0:void 0,E=i&&!s?!0:void 0,D;e[22]!==a||e[23]!==i?(D=i?void 0:{"--sidebar-expanded-px":`${a}px`},e[22]=a,e[23]=i,e[24]=D):D=e[24];let O=d.sidebarChromeVisible?(0,$.jsxs)(`div`,{className:K(`sidebar-chrome-row flex min-w-0`,hd,d.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,d.sidebarLeadingInsetClass,i?`justify-center gap-1 px-1.5 max-md:flex`:K(`justify-start gap-1`,d.sidebarLeadingInsetClass?`sidebar-chrome-row-darwin pr-3`:`px-3`),i&&`md:hidden`),children:[s?(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:K(`size-8 shrink-0 rounded-xl p-0 md:hidden`,md),"aria-label":r.closeMenu,title:r.closeMenu,onClick:()=>c(!1),children:(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,d.sidebarQuickActionsVisible&&!i?(0,$.jsx)(Zf,{sidebarToggleVariant:`sidebar`,className:`overflow-hidden`}):null]}):null,k;e[25]===c?k=e[26]:(k=(0,$.jsx)(eS,{collapsed:!1,onNavigate:()=>c(!1)}),e[25]=c,e[26]=k);let A;e[27]!==r||e[28]!==p||e[29]!==i?(A=i?null:(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r.sidebar.resizeHandleAria,onPointerDown:p,className:K(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`touch-none select-none`,md)}),e[27]=r,e[28]=p,e[29]=i,e[30]=A):A=e[30];let j;e[31]!==w||e[32]!==T||e[33]!==E||e[34]!==D||e[35]!==O||e[36]!==k||e[37]!==A?(j=(0,$.jsxs)(`aside`,{id:`app-sidebar`,className:w,"aria-hidden":T,"data-collapsed":E,style:D,children:[O,k,A]}),e[31]=w,e[32]=T,e[33]=E,e[34]=D,e[35]=O,e[36]=k,e[37]=A,e[38]=j):j=e[38];let M;return e[39]!==j||e[40]!==b?(M=(0,$.jsxs)($.Fragment,{children:[b,j]}),e[39]=j,e[40]=b,e[41]=M):M=e[41],M});function iS(e){return e.language}function aS(e){return e.collapsed}function oS(e){return e.expandedWidthPx}function sS(e){return e.setExpandedWidthPx}function cS(e){return e.mobileNavOpen}function lS(e){return e.setMobileNavOpen}function uS(e){let t=(0,Q.c)(42),{open:n,title:r,description:i,confirmLabel:a,cancelLabel:o,destructive:s,overlayClassName:c,contentClassName:l,checkboxLabel:u,checkboxChecked:d,onCheckboxCheckedChange:f,onConfirm:p,onCancel:m}=e,h=d===void 0?!1:d,g=(0,Z.useId)(),_;t[0]===m?_=t[1]:(_=e=>{e||m()},t[0]=m,t[1]=_);let v;t[2]===c?v=t[3]:(v=K(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,wn,c),t[2]=c,t[3]=v);let y;t[4]===v?y=t[5]:(y=(0,$.jsx)(Ye,{className:v}),t[4]=v,t[5]=y);let b;t[6]===l?b=t[7]:(b=K(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2`,Sn,`rounded-2xl border border-edge bg-surface-overlay p-5 sm:p-6 shadow-popover outline-none dark:border-edge`,l),t[6]=l,t[7]=b);let x;t[8]===r?x=t[9]:(x=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:r}),t[8]=r,t[9]=x);let S;t[10]===i?S=t[11]:(S=(0,$.jsx)(Ze,{className:`mt-2 max-h-[min(50vh,16rem)] overflow-y-auto text-sm text-fg-muted overscroll-contain whitespace-pre-wrap break-words`,children:i}),t[10]=i,t[11]=S);let C;t[12]!==h||t[13]!==g||t[14]!==u||t[15]!==f?(C=u?(0,$.jsxs)(`label`,{htmlFor:g,className:`touch-target mt-5 flex w-fit cursor-pointer items-center gap-2.5 text-sm text-fg`,children:[(0,$.jsx)(`input`,{id:g,type:`checkbox`,checked:h,onChange:e=>f?.(e.target.checked),className:`size-4 rounded border-edge accent-accent`}),(0,$.jsx)(`span`,{children:u})]}):null,t[12]=h,t[13]=g,t[14]=u,t[15]=f,t[16]=C):C=t[16];let w;t[17]!==o||t[18]!==m?(w=(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:m,children:o}),t[17]=o,t[18]=m,t[19]=w):w=t[19];let T=s&&`border-danger/40 bg-danger text-white hover:bg-danger/90 dark:border-danger/40`,E;t[20]===T?E=t[21]:(E=K(T),t[20]=T,t[21]=E);let D;t[22]!==a||t[23]!==p||t[24]!==E?(D=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:E,onClick:p,children:a}),t[22]=a,t[23]=p,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==D||t[27]!==w?(O=(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap justify-end gap-2`,children:[w,D]}),t[26]=D,t[27]=w,t[28]=O):O=t[28];let k;t[29]!==O||t[30]!==b||t[31]!==x||t[32]!==S||t[33]!==C?(k=(0,$.jsxs)(et,{className:b,children:[x,S,C,O]}),t[29]=O,t[30]=b,t[31]=x,t[32]=S,t[33]=C,t[34]=k):k=t[34];let A;t[35]!==k||t[36]!==y?(A=(0,$.jsxs)($e,{children:[y,k]}),t[35]=k,t[36]=y,t[37]=A):A=t[37];let j;return t[38]!==n||t[39]!==A||t[40]!==_?(j=(0,$.jsx)(nt,{open:n,onOpenChange:_,children:A}),t[38]=n,t[39]=A,t[40]=_,t[41]=j):j=t[41],j}var dS=450,fS=900;function pS(e){return new Promise(t=>window.setTimeout(t,e))}function mS({label:e,loading:t=!1,disabled:n=!1,className:r,iconClassName:i,strokeWidth:a=1.75,onClick:o,variant:s=`ghost`,type:c=`button`,title:l,"aria-label":u,...d}){let[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(!1),v=(0,Z.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),y=(0,Z.useCallback)(()=>{v(),h(!0),g.current=window.setTimeout(()=>{h(!1),g.current=null},fS)},[v]);(0,Z.useEffect)(()=>v,[v]),(0,Z.useEffect)(()=>{if(t){f&&(_.current=!0),h(!1);return}_.current&&(_.current=!1,y())},[f,t,y]);let b=t||f,x=async e=>{if(n||b){e.preventDefault();return}let t=Date.now();p(!0),h(!1);try{await o?.(e);let n=dS-(Date.now()-t);n>0&&await pS(n),y()}finally{p(!1)}};return(0,$.jsx)(X,{type:c,variant:s,className:K(`relative overflow-hidden`,b&&`bg-accent/10 text-accent hover:bg-accent/15 disabled:opacity-100`,m&&`bg-emerald-500/10 text-emerald-600 hover:bg-emerald-500/15 dark:text-emerald-300`,r),disabled:n,"aria-disabled":n||b,"aria-busy":b||void 0,title:l??e,"aria-label":u??e,onClick:e=>void x(e),...d,children:m&&!b?(0,$.jsx)(S,{className:K(`size-4 transition-transform duration-150 ease-out`,i),strokeWidth:a,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:K(`size-4 transition-transform duration-150 ease-out motion-reduce:transition-none`,b&&`animate-spin motion-reduce:animate-none`,i),strokeWidth:a,"aria-hidden":!0})})}function hS(e){let t=e.toLowerCase();return t.endsWith(`.md`)?`text-green-600 dark:text-green-400`:t.endsWith(`.json`)?`text-yellow-600 dark:text-yellow-400`:t.endsWith(`.ts`)||t.endsWith(`.js`)?`text-blue-600 dark:text-blue-400`:`text-fg-muted`}function gS(e){let t=(0,Q.c)(45),{entry:n,labels:r,onAction:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Z.useState)(s),u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>o(!1),t[1]=u):u=t[1];let d=u,f;t[2]!==n.fileId||t[3]!==a?(f=()=>{if(!a||!n.fileId||!An()||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){l([]);return}let e=!1;return window.electronAPI.shell.getOpenWithAppsForFileResource(n.fileId).then(t=>{e||l(t.recommended.map(CS))}).catch(()=>{e||l([])}),()=>{e=!0}},t[2]=n.fileId,t[3]=a,t[4]=f):f=t[4];let p;t[5]!==n.fileId||t[6]!==n.isDirectory||t[7]!==a?(p=[n.fileId,n.isDirectory,a],t[5]=n.fileId,t[6]=n.isDirectory,t[7]=a,t[8]=p):p=t[8],(0,Z.useEffect)(f,p);let m,h,g,_;if(t[9]!==n||t[10]!==r.copyPath||t[11]!==r.delete||t[12]!==r.desktopUpdateRequired||t[13]!==r.download||t[14]!==r.openDefault||t[15]!==r.openDirectory||t[16]!==r.openWith||t[17]!==r.preview||t[18]!==r.recommendedApps||t[19]!==r.revealInFolder||t[20]!==r.share||t[21]!==r.trash||t[22]!==a||t[23]!==i||t[24]!==c){let e=n.fileId?c.map(SS):[],s=An()?window.electronAPI?.shell:void 0,l=n.isDirectory?r.openDirectory:r.openDefault,u=n.fileId?[...!l||!s?.openFileResource?[]:[{action:`openDefault`,label:l}],...!r.openWith||!s?.chooseAppAndOpenFileResource?[]:[{action:`openWith`,label:r.openWith}],...r.revealInFolder&&s?.showFileResourceInFolder?[{action:`revealInFolder`,label:r.revealInFolder}]:[],...!n.isDirectory&&r.trash&&s?.trashFileResource?[{action:`trash`,label:r.trash}]:[]]:[],f=n.isDirectory?[...u,...r.share?[{action:`share`,label:r.share}]:[],{action:`copyPath`,label:r.copyPath}]:[...u,{action:`preview`,label:r.preview},{action:`download`,label:r.download},...r.share?[{action:`share`,label:r.share}]:[],{action:`copyPath`,label:r.copyPath},...r.delete?[{action:`delete`,label:r.delete}]:[]];t[29]===a?_=t[30]:(_=a?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),d()}}):null,t[29]=a,t[30]=_),m=`relative shrink-0`;let p=a&&`opacity-100`,v;t[31]===p?v=t[32]:(v=K(`rounded-md p-1 text-fg-muted opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg`,`group-hover:opacity-100`,p),t[31]=p,t[32]=v);let y,b;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{e.stopPropagation(),o(bS)},b=(0,$.jsx)(F,{className:`size-3.5`,"aria-hidden":!0}),t[33]=y,t[34]=b):(y=t[33],b=t[34]),t[35]!==a||t[36]!==v?(h=(0,$.jsx)(`button`,{type:`button`,className:v,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":`More`,onPointerDown:xS,onClick:y,children:b}),t[35]=a,t[36]=v,t[37]=h):h=t[37],g=a?(0,$.jsxs)(`div`,{role:`menu`,className:`absolute right-0 top-full z-50 mt-0.5 min-w-[9rem] rounded-md border border-edge bg-surface-panel py-1 shadow-popover`,onPointerDown:yS,children:[An()&&n.fileId&&!s?.openFileResource&&r.desktopUpdateRequired?(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!0,className:`block w-full cursor-not-allowed px-3 py-1.5 text-left text-sm text-fg-subtle opacity-70`,title:r.desktopUpdateRequired,children:(0,$.jsx)(`span`,{className:`block truncate`,children:r.desktopUpdateRequired})}):null,u.filter(vS).map(e=>{let{action:t,label:r,appPath:a}=e;return(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:a,onClick:()=>{i(t,n,a),d()},children:(0,$.jsx)(`span`,{className:`block truncate`,children:r})},a?`${t}:${a}`:t)}),r.recommendedApps&&e.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge-subtle px-3 pb-1 pt-2 text-[11px] font-medium uppercase tracking-normal text-fg-subtle dark:border-edge`,children:r.recommendedApps}),e.map(e=>{let{action:t,label:r,appPath:a}=e;return(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`block w-full min-w-0 px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,title:a,onClick:()=>{i(t,n,a),d()},children:(0,$.jsx)(`span`,{className:`block truncate`,children:r})},`${t}:${a}`)})]}):null,f.filter(_S).map(e=>{let{action:t,label:r,appPath:a}=e;return(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:K(`block w-full px-3 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,(t===`trash`||t===`delete`)&&`text-danger hover:bg-danger/10 hover:text-danger`),title:a,onClick:()=>{i(t,n,a),d()},children:(0,$.jsx)(`span`,{className:`block truncate`,children:r})},a?`${t}:${a}`:t)})]}):null,t[9]=n,t[10]=r.copyPath,t[11]=r.delete,t[12]=r.desktopUpdateRequired,t[13]=r.download,t[14]=r.openDefault,t[15]=r.openDirectory,t[16]=r.openWith,t[17]=r.preview,t[18]=r.recommendedApps,t[19]=r.revealInFolder,t[20]=r.share,t[21]=r.trash,t[22]=a,t[23]=i,t[24]=c,t[25]=m,t[26]=h,t[27]=g,t[28]=_}else m=t[25],h=t[26],g=t[27],_=t[28];let v;t[38]!==m||t[39]!==h||t[40]!==g?(v=(0,$.jsxs)(`div`,{className:m,children:[h,g]}),t[38]=m,t[39]=h,t[40]=g,t[41]=v):v=t[41];let y;return t[42]!==_||t[43]!==v?(y=(0,$.jsxs)($.Fragment,{children:[_,v]}),t[42]=_,t[43]=v,t[44]=y):y=t[44],y}function _S(e){return e.action!==`openDefault`}function vS(e){return e.action===`openDefault`}function yS(e){return e.stopPropagation()}function bS(e){return!e}function xS(e){return e.stopPropagation()}function SS(e){return{action:`openWithApp`,label:e.name,appPath:e.path}}function CS(e){return{name:e.name,path:e.path}}function wS(e){return Array.from(e.dataTransfer.types).includes(`Files`)}function TS(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function ES(e){let t=(0,Q.c)(109),{entry:n,depth:r,selectedPath:i,forceOpen:a,onSelect:o,onExpandDir:s,onAction:c,actionLabels:l,onFileDragStart:u,onUploadFiles:d,onUploadTargetEnter:f}=e,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),_=a||p,v=i===n.path;if(n.isDirectory){let e=n.path,p=v&&`bg-accent-soft text-accent-fg`,y=h&&`bg-accent-soft text-accent-fg ring-1 ring-inset ring-accent`,b;t[0]!==p||t[1]!==y?(b=K(`flex min-w-0 flex-1 items-center gap-1 rounded-md py-1 pr-2 text-left text-sm`,`hover:bg-surface-hover`,p,y),t[0]=p,t[1]=y,t[2]=b):b=t[2];let x=8+r*12,S;t[3]===x?S=t[4]:(S={paddingLeft:x},t[3]=x,t[4]=S);let C;t[5]!==n.path||t[6]!==s||t[7]!==o||t[8]!==_?(C=()=>{let e=!_;m(e),e&&s?.(n.path),o(n.path,!0)},t[5]=n.path,t[6]=s,t[7]=o,t[8]=_,t[9]=C):C=t[9];let w;t[10]!==d||t[11]!==f?(w=d?e=>{wS(e)&&(e.preventDefault(),e.stopPropagation(),f?.(),g(!0))}:void 0,t[10]=d,t[11]=f,t[12]=w):w=t[12];let T;t[13]===d?T=t[14]:(T=d?e=>{wS(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,g(!0))}:void 0,t[13]=d,t[14]=T);let E;t[15]===d?E=t[16]:(E=d?e=>{e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||g(!1)}:void 0,t[15]=d,t[16]=E);let D;t[17]!==n.path||t[18]!==d?(D=d?e=>{if(!wS(e))return;e.preventDefault(),e.stopPropagation(),g(!1);let t=Array.from(e.dataTransfer.files);t.length&&d(t,n.path)}:void 0,t[17]=n.path,t[18]=d,t[19]=D):D=t[19];let O=_&&`rotate-90`,k;t[20]===O?k=t[21]:(k=K(`size-3.5 shrink-0 transition-transform`,O),t[20]=O,t[21]=k);let A;t[22]===k?A=t[23]:(A=(0,$.jsx)(lr,{className:k,"aria-hidden":!0}),t[22]=k,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(Gr,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===n.name?M=t[26]:(M=(0,$.jsx)(`span`,{className:`truncate`,children:n.name}),t[25]=n.name,t[26]=M);let N;t[27]!==n.path||t[28]!==E||t[29]!==D||t[30]!==A||t[31]!==M||t[32]!==b||t[33]!==S||t[34]!==C||t[35]!==w||t[36]!==T||t[37]!==_?(N=(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":_,"data-file-drop-directory":e,className:b,style:S,onClick:C,onDragEnter:w,onDragOver:T,onDragLeave:E,onDrop:D,children:[A,j,M]}),t[27]=n.path,t[28]=E,t[29]=D,t[30]=A,t[31]=M,t[32]=b,t[33]=S,t[34]=C,t[35]=w,t[36]=T,t[37]=_,t[38]=N):N=t[38];let P;t[39]!==l||t[40]!==n||t[41]!==c?(P=c&&l?(0,$.jsx)(gS,{entry:n,labels:l,onAction:c}):null,t[39]=l,t[40]=n,t[41]=c,t[42]=P):P=t[42];let F;t[43]!==N||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`group flex w-full items-stretch gap-0.5`,children:[N,P]}),t[43]=N,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==l||t[47]!==r||t[48]!==n.children||t[49]!==a||t[50]!==c||t[51]!==s||t[52]!==u||t[53]!==o||t[54]!==d||t[55]!==f||t[56]!==i||t[57]!==_?(I=_&&n.children?.length?(0,$.jsx)(`div`,{children:n.children.map(e=>(0,$.jsx)(ES,{entry:e,depth:r+1,selectedPath:i,forceOpen:a,onSelect:o,onExpandDir:s,onAction:c,actionLabels:l,onFileDragStart:u,onUploadFiles:d,onUploadTargetEnter:f},e.path))}):null,t[46]=l,t[47]=r,t[48]=n.children,t[49]=a,t[50]=c,t[51]=s,t[52]=u,t[53]=o,t[54]=d,t[55]=f,t[56]=i,t[57]=_,t[58]=I):I=t[58];let L;return t[59]!==F||t[60]!==I?(L=(0,$.jsxs)(`div`,{className:`select-none`,children:[F,I]}),t[59]=F,t[60]=I,t[61]=L):L=t[61],L}let y=!!u,b=u&&`cursor-grab active:cursor-grabbing`,x=v&&`bg-accent-soft text-accent-fg`,S=h&&`bg-accent-soft text-accent-fg ring-1 ring-inset ring-accent`,C;t[62]!==b||t[63]!==x||t[64]!==S?(C=K(`flex min-w-0 flex-1 items-center gap-1.5 rounded-md py-1 pr-2 text-left text-sm`,`hover:bg-surface-hover`,b,x,S),t[62]=b,t[63]=x,t[64]=S,t[65]=C):C=t[65];let w=8+r*12,T;t[66]===w?T=t[67]:(T={paddingLeft:w},t[66]=w,t[67]=T);let E;t[68]!==n.path||t[69]!==o?(E=()=>o(n.path,!1),t[68]=n.path,t[69]=o,t[70]=E):E=t[70];let D;t[71]!==n||t[72]!==u?(D=u?e=>u(e,n):void 0,t[71]=n,t[72]=u,t[73]=D):D=t[73];let O;t[74]!==d||t[75]!==f?(O=d?e=>{wS(e)&&(e.preventDefault(),e.stopPropagation(),f?.(),g(!0))}:void 0,t[74]=d,t[75]=f,t[76]=O):O=t[76];let k;t[77]===d?k=t[78]:(k=d?e=>{wS(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,g(!0))}:void 0,t[77]=d,t[78]=k);let A;t[79]===d?A=t[80]:(A=d?e=>{e.stopPropagation(),e.currentTarget.contains(e.relatedTarget)||g(!1)}:void 0,t[79]=d,t[80]=A);let j;t[81]!==n.path||t[82]!==d?(j=d?e=>{if(!wS(e))return;e.preventDefault(),e.stopPropagation(),g(!1);let t=Array.from(e.dataTransfer.files);t.length&&d(t,TS(n.path))}:void 0,t[81]=n.path,t[82]=d,t[83]=j):j=t[83];let M;t[84]===n.name?M=t[85]:(M=K(`size-3.5 shrink-0`,hS(n.name)),t[84]=n.name,t[85]=M);let N;t[86]===M?N=t[87]:(N=(0,$.jsx)(zr,{className:M,"aria-hidden":!0}),t[86]=M,t[87]=N);let P;t[88]===n.name?P=t[89]:(P=(0,$.jsx)(`span`,{className:`truncate`,children:n.name}),t[88]=n.name,t[89]=P);let F;t[90]!==y||t[91]!==O||t[92]!==k||t[93]!==A||t[94]!==j||t[95]!==N||t[96]!==P||t[97]!==C||t[98]!==T||t[99]!==E||t[100]!==D?(F=(0,$.jsxs)(`button`,{type:`button`,draggable:y,className:C,style:T,onClick:E,onDragStart:D,onDragEnter:O,onDragOver:k,onDragLeave:A,onDrop:j,children:[N,P]}),t[90]=y,t[91]=O,t[92]=k,t[93]=A,t[94]=j,t[95]=N,t[96]=P,t[97]=C,t[98]=T,t[99]=E,t[100]=D,t[101]=F):F=t[101];let I;t[102]!==l||t[103]!==n||t[104]!==c?(I=c&&l?(0,$.jsx)(gS,{entry:n,labels:l,onAction:c}):null,t[102]=l,t[103]=n,t[104]=c,t[105]=I):I=t[105];let L;return t[106]!==F||t[107]!==I?(L=(0,$.jsxs)(`div`,{className:`group flex w-full items-stretch gap-0.5`,children:[F,I]}),t[106]=F,t[107]=I,t[108]=L):L=t[108],L}function DS(e,t){return e.name.toLocaleLowerCase().includes(t)||e.path.toLocaleLowerCase().includes(t)}function OS(e,t){return t?e.flatMap(e=>{let n=e.children?OS(e.children,t):void 0;return DS(e,t)||n?.length?[{...e,children:n}]:[]}):e}function kS(e){let t=(0,Q.c)(42),{tree:n,selectedPath:r,onSelectFile:i,onSelectEntry:a,onExpandDir:o,onAction:s,actionLabels:c,emptyHint:l,searchQuery:u,emptySearchHint:d,onFileDragStart:f,onUploadFiles:p,uploadDropHint:m}=e,[h,g]=(0,Z.useState)(!1),_=u??``,v;t[0]===_?v=t[1]:(v=_.trim().toLocaleLowerCase(),t[0]=_,t[1]=v);let y=v,b;t[2]!==y||t[3]!==n?(b=OS(n,y),t[2]=y,t[3]=n,t[4]=b):b=t[4];let x=b,S;t[5]!==a||t[6]!==i?(S=(e,t)=>{a?.(e,t),t||i(e)},t[5]=a,t[6]=i,t[7]=S):S=t[7];let C=S,w=h&&`bg-accent-soft/60 ring-1 ring-inset ring-accent`,T;t[8]===w?T=t[9]:(T=K(`relative min-h-0 flex-1 overflow-y-auto py-2`,w),t[8]=w,t[9]=T);let E;t[10]===p?E=t[11]:(E=p?e=>{wS(e)&&(e.preventDefault(),g(!0))}:void 0,t[10]=p,t[11]=E);let D;t[12]===p?D=t[13]:(D=p?e=>{wS(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,g(!0))}:void 0,t[12]=p,t[13]=D);let O;t[14]===p?O=t[15]:(O=p?e=>{e.currentTarget.contains(e.relatedTarget)||g(!1)}:void 0,t[14]=p,t[15]=O);let k;t[16]===p?k=t[17]:(k=p?e=>{if(!wS(e))return;e.preventDefault(),g(!1);let t=Array.from(e.dataTransfer.files);t.length&&p(t,``)}:void 0,t[16]=p,t[17]=k);let A;t[18]!==h||t[19]!==m?(A=h&&m?(0,$.jsx)(`div`,{className:`pointer-events-none sticky top-0 z-20 mx-2 mb-1 rounded-md border border-accent bg-surface-panel/95 px-3 py-2 text-center text-xs font-medium text-accent-fg shadow-sm`,children:m}):null,t[18]=h,t[19]=m,t[20]=A):A=t[20];let j;t[21]!==c||t[22]!==l||t[23]!==d||t[24]!==C||t[25]!==y||t[26]!==s||t[27]!==o||t[28]!==f||t[29]!==p||t[30]!==r||t[31]!==n.length||t[32]!==x?(j=n.length?x.length?x.map(e=>(0,$.jsx)(ES,{entry:e,depth:0,selectedPath:r,forceOpen:!!y,onSelect:C,onExpandDir:o,onAction:s,actionLabels:c,onFileDragStart:f,onUploadFiles:p,onUploadTargetEnter:()=>g(!1)},e.path)):(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:d??l}):(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:l}),t[21]=c,t[22]=l,t[23]=d,t[24]=C,t[25]=y,t[26]=s,t[27]=o,t[28]=f,t[29]=p,t[30]=r,t[31]=n.length,t[32]=x,t[33]=j):j=t[33];let M;return t[34]!==k||t[35]!==A||t[36]!==j||t[37]!==T||t[38]!==E||t[39]!==D||t[40]!==O?(M=(0,$.jsxs)(`div`,{className:T,"data-file-drop-directory":``,onDragEnter:E,onDragOver:D,onDragLeave:O,onDrop:k,children:[A,j]}),t[34]=k,t[35]=A,t[36]=j,t[37]=T,t[38]=E,t[39]=D,t[40]=O,t[41]=M):M=t[41],M}async function AS(e){let t=await e.json().catch(()=>null);return Error(t?.error?.message??`HTTP ${e.status}`)}async function jS(e,t){let n=await we(J(e),t);if(!n.ok)throw await AS(n);return n.json()}async function MS(e){let t=e?.projectId?{kind:`project`,id:e.projectId}:e?.conversationId?{kind:`session`,id:e.conversationId}:e?.agentId?{kind:`agent`,id:e.agentId}:null;if(t){let e=await jS(`/api/files/contexts/${t.kind}/${encodeURIComponent(t.id)}`);return Wt.parse(e.space)}let n=await jS(`/api/files/default-space`);return Wt.parse(n.space)}function NS(e){return{id:e.id,name:e.name,path:e.relativePath,isDirectory:e.kind===`directory`,mimeType:e.mimeType,revision:e.revision}}async function PS(e,t){let n=await MS(t),r=await jS(`/api/files/resolve`,{method:`POST`,body:JSON.stringify({spaceId:n.id,path:e})});return Gt.parse(r.resource)}async function FS(e,t){return PS(e,t)}async function IS(e=``,t){let n=await MS(t),r=new URLSearchParams;return e&&r.set(`path`,e),{entries:Kt.parse(await jS(`/api/files/spaces/${encodeURIComponent(n.id)}/children${r.size?`?${r}`:``}`)).items.map(NS)}}async function LS(e=``,t){return(await IS(e,t)).entries}async function RS(e){let t=await MS(e);return NS(qt.parse(await jS(`/api/files/spaces/${encodeURIComponent(t.id)}/root`)).resource)}async function zS(e,t,n=50){let r=await MS(t),i=new URLSearchParams({q:e.trim(),limit:String(n),spaceId:r.id});return Kt.parse(await jS(`/api/files/search?${i}`)).items.map(NS)}async function BS(e,t){let n=await PS(e,t),r=await we(J(`/api/files/${encodeURIComponent(n.id)}/content`));if(!r.ok)throw await AS(r);return{content:await r.text(),path:n.relativePath,mtimeMs:n.modifiedAt,revision:n.revision}}async function VS(e,t){let n;try{n=await MS(t)}catch{return null}try{let t=await jS(`/api/files/resolve`,{method:`POST`,body:JSON.stringify({spaceId:n.id,path:e})}),r=Gt.parse(t.resource);return{fileId:r.id,inputPath:e,displayName:r.name,scope:`workspace`,locationKind:`workspace`,exists:!0,isDirectory:r.kind===`directory`,workspaceRelativePath:r.relativePath,capabilities:r.capabilities.filter(e=>e===`preview`||e===`edit`),mtimeMs:r.modifiedAt}}catch{try{return(await jS(`/api/files/resolve-reference`,{method:`POST`,body:JSON.stringify({spaceId:n.id,path:e,conversationId:t?.conversationId})})).reference}catch{return null}}}async function HS(e,t,n){return await jS(`/api/files/references/${encodeURIComponent(e)}/action`,{method:`POST`,body:JSON.stringify({action:t,conversationId:n?.conversationId})})}async function US(e,t){let n=await PS(e,t),r=await we(J(`/api/files/${encodeURIComponent(n.id)}/content`),{headers:{Accept:`*/*`}});if(!r.ok)throw await AS(r);return r.blob()}async function WS(e,t,n){let r=await PS(e,n),i=await jS(`/api/files/${encodeURIComponent(r.id)}/content`,{method:`PUT`,body:JSON.stringify({content:t,revision:r.revision})}),a=Gt.parse(i.resource);return{path:a.relativePath,mtimeMs:a.modifiedAt,revision:a.revision}}async function GS(e,t=``,n){let r=await MS(n),i=new FormData;i.set(`directory`,t),i.set(`file`,e);let a=await we(J(`/api/files/spaces/${encodeURIComponent(r.id)}/upload`),{method:`POST`,body:i});if(!a.ok)throw await AS(a);return NS(qt.parse(await a.json()).resource)}async function KS(e){let t=await we(J(`/api/files/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw await AS(t)}function qS(e,t){let n=new Blob([t],{type:`text/plain;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function JS(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}var YS=5*1024*1024,XS=32*1024*1024,ZS=new Set(`.astro,.bat,.c,.cc,.clj,.cljs,.cljc,.cmd,.cpp,.cs,.cts,.cxx,.dart,.edn,.erl,.ex,.exs,.fish,.fs,.fsx,.go,.gql,.graphql,.groovy,.h,.hh,.hpp,.hrl,.hxx,.java,.ts,.tsx,.mts,.js,.jsx,.mjs,.cjs,.css,.scss,.sass,.less,.json,.jsonc,.json5,.yml,.yaml,.xml,.xsd,.xsl,.py,.pyw,.rb,.php,.rs,.kt,.kts,.scala,.swift,.m,.mm,.sh,.bash,.zsh,.ps1,.sql,.lua,.r,.pl,.pm,.sol,.tf,.tfvars,.nix,.proto,.vue,.svelte,.toml,.ini,.cfg,.conf,.properties`.split(`,`)),QS=new Set([`.txt`,`.log`,`.lock`,`.csv`,`.tsv`,`.env`,`.gitignore`,`.gitattributes`,`.editorconfig`,`.npmrc`,`.dockerignore`,`.eslintignore`,`.prettierignore`,`.stylelintignore`]),$S=new Set([`dockerfile`,`gemfile`,`jenkinsfile`,`makefile`,`procfile`,`rakefile`]),eC=new Set([`brewfile`,`changelog`,`codeowners`,`license`,`readme`]),tC=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.ico`,`.svg`,`.svgz`,`.tif`,`.tiff`,`.avif`,`.heic`,`.heif`,`.jxl`]),nC=new Set([`.mp3`,`.wav`,`.ogg`,`.oga`,`.aac`,`.m4a`,`.flac`,`.opus`,`.weba`]),rC=new Set([`.mp4`,`.webm`,`.mov`,`.m4v`,`.ogv`]),iC=new Set([`.zip`]),aC=new Map([[`.pdf`,`application/pdf`],[`.docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`.pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`.xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`.xls`,`application/vnd.ms-excel`],[`.md`,`text/markdown`],[`.markdown`,`text/markdown`],[`.html`,`text/html`],[`.htm`,`text/html`],[`.json`,`application/json`],[`.txt`,`text/plain`],[`.csv`,`text/csv`],[`.tsv`,`text/tab-separated-values`],[`.png`,`image/png`],[`.jpg`,`image/jpeg`],[`.jpeg`,`image/jpeg`],[`.gif`,`image/gif`],[`.webp`,`image/webp`],[`.svg`,`image/svg+xml`],[`.svgz`,`image/svg+xml`],[`.mp3`,`audio/mpeg`],[`.wav`,`audio/wav`],[`.ogg`,`audio/ogg`],[`.mp4`,`video/mp4`],[`.webm`,`video/webm`],[`.mov`,`video/quicktime`],[`.zip`,`application/zip`]]);function oC(e){let t=sC(e),n=t.lastIndexOf(`.`);return n<0||n===t.length-1?``:t.slice(n).toLowerCase()}function sC(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function cC(e,t){let n=t?.split(`;`)[0]?.trim().toLowerCase();return n&&n!==`application/octet-stream`?n:aC.get(oC(e))??n??`application/octet-stream`}function lC(e,t){let n=oC(e),r=sC(e).toLowerCase(),i=cC(e,t);return i===`text/markdown`||n===`.md`||n===`.markdown`?`markdown`:i===`text/html`||n===`.html`||n===`.htm`?`html`:i===`application/pdf`||n===`.pdf`?`pdf`:i===`application/vnd.openxmlformats-officedocument.wordprocessingml.document`||n===`.docx`?`docx`:i===`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`||i===`application/vnd.ms-excel`||n===`.xlsx`||n===`.xls`?`spreadsheet`:i===`application/vnd.openxmlformats-officedocument.presentationml.presentation`||n===`.pptx`?`pptx`:i.startsWith(`image/`)||tC.has(n)?`image`:i.startsWith(`audio/`)||nC.has(n)?`audio`:i.startsWith(`video/`)||rC.has(n)?`video`:i===`application/zip`||iC.has(n)?`archive`:ZS.has(n)||$S.has(r)||r.startsWith(`dockerfile.`)?`code`:i.startsWith(`text/`)||QS.has(n)||eC.has(r)||r.startsWith(`.env.`)||i===`application/json`?`text`:`unsupported`}function uC(e){switch(e){case`text`:case`markdown`:case`code`:case`html`:return`text`;case`unsupported`:return`metadata`;default:return`binary`}}async function dC(e){let{uri:t,conversationId:n,taskId:r}=e;try{let e=vt(t),i=await we(J(e?`/api/files/${encodeURIComponent(e)}/content`:l_(t,n,r)));return i.ok?{ok:!0,blob:await i.blob()}:{ok:!1,reason:`http`,status:i.status}}catch(e){return{ok:!1,reason:`network`,message:e instanceof Error?e.message:String(e)}}}async function fC(e){let t=await dC(e);return t.ok?{ok:!0,buffer:await t.blob.arrayBuffer()}:t}function pC(e){return e.id?String(e.id):`${e.name}:${e.uri??``}`}function mC(){return{id:`__empty__`,context:`attachment`,fileName:``,mimeType:`application/octet-stream`,type:`unsupported`,source:{kind:`inline`}}}function hC(e){let t=(0,Q.c)(65),{open:n,attachment:r,authToken:i,conversationId:a,language:o}=e,[s,c]=(0,Z.useState)(n?r:null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p;t[0]!==r||t[1]!==n?(p=n&&r?pC(r):null,t[0]=r,t[1]=n,t[2]=p):p=t[2];let m=p,h=(0,Z.useRef)(m);m!==h.current&&(h.current=m,c(n&&r?r:null),u(!1),f(!1));let g=s,_;bb0:{if(!g){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=mC(),t[3]=e):e=t[3],_=e;break bb0}let e=g.name??`attachment`,n,r;t[4]!==e||t[5]!==g.mimeType?(n=cC(e,g.mimeType),r=lC(e,n),t[4]=e,t[5]=g.mimeType,t[6]=n,t[7]=r):(n=t[6],r=t[7]);let i=r,o=g.id?String(g.id):`${e}:${g.uri??``}`,s;t[8]!==a||t[9]!==g.uri?(s=g.uri?{kind:`media-uri`,uri:g.uri,conversationId:a}:{kind:`inline`},t[8]=a,t[9]=g.uri,t[10]=s):s=t[10];let c;t[11]!==e||t[12]!==n||t[13]!==g.size||t[14]!==o||t[15]!==s||t[16]!==i?(c={id:o,context:`attachment`,fileName:e,mimeType:n,size:g.size,type:i,source:s},t[11]=e,t[12]=n,t[13]=g.size,t[14]=o,t[15]=s,t[16]=i,t[17]=c):c=t[17],_=c}let v=_,y;t[18]===g?y=t[19]:(y=g?u_(g):void 0,t[18]=g,t[19]=y);let b=y,x=g?.uri,S;t[20]===v.type?S=t[21]:(S=uC(v.type),t[20]=v.type,t[21]=S);let C=S,w=!!(n&&x&&!b&&i&&(C===`binary`||C===`text`)),T;t[22]!==a||t[23]!==o||t[24]!==x||t[25]!==g?.taskId?(T=async()=>{let e=xe(o).chat,t=await fC({uri:x,conversationId:a,taskId:g?.taskId});if(!t.ok)throw t.reason===`http`?Error(`${e.attachmentPreviewLoadError} (HTTP ${t.status})`):Error(t.message);return t.buffer},t[22]=a,t[23]=o,t[24]=x,t[25]=g?.taskId,t[26]=T):T=t[26];let E=g?.taskId,D;t[27]!==i||t[28]!==a||t[29]!==b||t[30]!==o||t[31]!==x||t[32]!==n||t[33]!==C||t[34]!==E?(D=[n,x,i,o,b,E,a,C],t[27]=i,t[28]=a,t[29]=b,t[30]=o,t[31]=x,t[32]=n,t[33]=C,t[34]=E,t[35]=D):D=t[35];let O;t[36]===w?O=t[37]:(O={enabled:w,initial:null,errorData:null},t[36]=w,t[37]=O);let k=Am(T,D,O),A;bb1:{if(b)try{let e;t[38]===b?e=t[39]:(e=p_(b),t[38]=b,t[39]=e),A=e;break bb1}catch{A=null;break bb1}if(w&&k.loading){A=null;break bb1}A=k.data??null}let j=A,M=C===`binary`?j:null,N=g?.extractedText??``,P;t[40]!==j||t[41]!==N||t[42]!==o||t[43]!==C?(P=C===`text`?N||(j?new TextDecoder(`utf-8`,{fatal:!1}).decode(new Uint8Array(j)):xe(o).chat.attachmentPreviewNoText):null,t[40]=j,t[41]=N,t[42]=o,t[43]=C,t[44]=P):P=t[44];let F=P,I=!!g?.extractedText,L=v.type===`pptx`&&N.length>3e5,R;t[45]!==i||t[46]!==b||t[47]!==o||t[48]!==x||t[49]!==n||t[50]!==C?(R=n&&x&&!b&&!i&&C===`binary`?xe(o).chat.attachmentPreviewMissingAuth:null,t[45]=i,t[46]=b,t[47]=o,t[48]=x,t[49]=n,t[50]=C,t[51]=R):R=t[51];let z=R,B=k.error?k.error instanceof Error?k.error.message:String(k.error):null,V=d?null:z??B,H=w?k.loading:!1,U;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>f(!0),t[52]=U):U=t[52];let W=N||null,G;return t[53]!==M||t[54]!==v||t[55]!==j||t[56]!==L||t[57]!==I||t[58]!==V||t[59]!==g||t[60]!==l||t[61]!==H||t[62]!==W||t[63]!==F?(G={preview:g,descriptor:v,fileType:v.type,fileName:v.fileName,loading:H,loadError:V,clearLoadError:U,textContent:F,binaryBuffer:M,downloadBuffer:j,hasExtractedText:I,extractedText:W,extractedTextTruncated:L,showExtractedText:l,setShowExtractedText:u},t[53]=M,t[54]=v,t[55]=j,t[56]=L,t[57]=I,t[58]=V,t[59]=g,t[60]=l,t[61]=H,t[62]=W,t[63]=F,t[64]=G):G=t[64],G}function gC(e){let t=(0,Q.c)(12),{projectId:n,conversationId:r,agentId:i}=e,a;bb0:{let e;t[0]===n?e=t[1]:(e=n?.trim(),t[0]=n,t[1]=e);let o=e;if(o){let e;t[2]===o?e=t[3]:(e={projectId:o},t[2]=o,t[3]=e),a=e;break bb0}let s;t[4]===r?s=t[5]:(s=r?.trim(),t[4]=r,t[5]=s);let c=s;if(c){let e;t[6]===c?e=t[7]:(e={conversationId:c},t[6]=c,t[7]=e),a=e;break bb0}let l;t[8]===i?l=t[9]:(l=i?.trim(),t[8]=i,t[9]=l);let u=l,d;t[10]===u?d=t[11]:(d=u?{agentId:u}:void 0,t[10]=u,t[11]=d),a=d}return a}function _C(e){return{descriptor:e,textContent:null,binaryBuffer:null,fileResourceId:null,mtimeMs:null,loadError:null,loading:!1,pptxText:null,pptxTruncated:!1,pptxError:null}}function vC(e,t){switch(t.type){case`clear`:return _C(t.descriptor);case`loadStart`:return{..._C(t.descriptor),loading:!0};case`loadSuccess`:return{...e,descriptor:t.payload.descriptor,textContent:t.payload.textContent??null,binaryBuffer:t.payload.binaryBuffer??null,fileResourceId:t.payload.fileResourceId??null,mtimeMs:t.payload.mtimeMs??null,loadError:null,loading:!1};case`loadError`:return{..._C(t.descriptor),loadError:t.error};case`patchMtime`:return{...e,mtimeMs:t.mtimeMs};case`patchText`:return{...e,textContent:t.text};case`pptxClear`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:null};case`pptxSuccess`:return{...e,pptxText:t.text,pptxTruncated:t.truncated,pptxError:null};case`pptxError`:return{...e,pptxText:null,pptxTruncated:!1,pptxError:t.error}}}function yC(e,t){switch(t.type){case`reset`:return{sourceEditMode:!1,saveStatus:`idle`};case`source`:return{...e,sourceEditMode:typeof t.value==`function`?t.value(e.sourceEditMode):t.value};case`saveStatus`:return{...e,saveStatus:t.value}}}function bC({filePath:e,projectId:t,conversationId:n,agentId:r}){let i=gC({projectId:t,conversationId:n,agentId:r}),a=(0,Z.useMemo)(()=>{let t=e?sC(e):``,i=cC(t,h_(t)),a=e?lC(t,i):`unsupported`;return{id:e||`__empty__`,context:`workspace`,fileName:t,mimeType:i,type:a,source:{kind:`workspace`,path:e||``,conversationId:n,agentId:r}}},[r,e,n]),[o,c]=(0,Z.useReducer)(vC,a,_C),[l,u]=(0,Z.useReducer)(yC,{sourceEditMode:!1,saveStatus:`idle`}),[d,f]=(0,Z.useState)([]),[p,m]=(0,Z.useState)([]),h=(0,Z.useRef)(void 0),g=(0,Z.useRef)(e);g.current!==e&&(g.current=e,u({type:`reset`})),(0,Z.useEffect)(()=>{if(!e){c({type:`clear`,descriptor:a});return}let t=!1;c({type:`loadStart`,descriptor:a});let n=uC(a.type),r=e=>{t||c({type:`loadError`,descriptor:a,error:e instanceof Error?e.message:String(e)})};return n===`metadata`?(Promise.all([FS(e,i).catch(()=>null),VS(e,i).catch(()=>null)]).then(async([n,r])=>{if(!n){t||c({type:`loadSuccess`,payload:{descriptor:a,fileResourceId:r?.fileId??null,mtimeMs:typeof r?.mtimeMs==`number`?r.mtimeMs:null}});return}let o={...a,mimeType:n.mimeType,type:lC(n.name,n.mimeType)};if(uC(o.type)===`text`){let{content:r,mtimeMs:a}=await BS(e,i);t||c({type:`loadSuccess`,payload:{descriptor:o,textContent:r,fileResourceId:n.id,mtimeMs:typeof a==`number`?a:n.modifiedAt}});return}t||c({type:`loadSuccess`,payload:{descriptor:o,fileResourceId:n.id,mtimeMs:n.modifiedAt}})}).catch(r),()=>{t=!0}):(n===`text`?Promise.all([BS(e,i),VS(e,i).catch(()=>null)]).then(([{content:e,mtimeMs:n},r])=>{t||c({type:`loadSuccess`,payload:{descriptor:a,textContent:e,fileResourceId:r?.fileId??null,mtimeMs:typeof n==`number`?n:null}})}).catch(r):Promise.all([US(e,i),VS(e,i).catch(()=>null)]).then(async([e,n])=>{let r=await e.arrayBuffer();t||c({type:`loadSuccess`,payload:{descriptor:a,binaryBuffer:r,fileResourceId:n?.fileId??null,mtimeMs:typeof n?.mtimeMs==`number`?n.mtimeMs:null}})}).catch(r),()=>{t=!0})},[a,e,i]),(0,Z.useEffect)(()=>{if(!o.binaryBuffer||o.descriptor.type!==`pptx`){c({type:`pptxClear`});return}let e=!1;return c({type:`pptxClear`}),s(()=>import(`./attachment-process-heavy-Db4nTY5N.js`).then(e=>e.processPptx(o.binaryBuffer,o.descriptor.fileName)),__vite__mapDeps([147,1,7,148])).then(({extractedText:t})=>{if(e)return;let n=t.length>c_;c({type:`pptxSuccess`,text:n?t.slice(0,c_):t,truncated:n})}).catch(t=>{e||c({type:`pptxError`,error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[o.binaryBuffer,o.descriptor.fileName,o.descriptor.type]);let _=(0,Z.useCallback)(async t=>{if(e){h.current!==void 0&&clearTimeout(h.current),u({type:`saveStatus`,value:`saving`});try{let{mtimeMs:n}=await WS(e,t,i);typeof n==`number`&&c({type:`patchMtime`,mtimeMs:n}),u({type:`saveStatus`,value:`saved`}),h.current=setTimeout(()=>u({type:`saveStatus`,value:`idle`}),2e3)}catch{u({type:`saveStatus`,value:`error`}),h.current=setTimeout(()=>u({type:`saveStatus`,value:`idle`}),4e3)}}},[e,i]),v=Gh(e=>void _(e),500),y=(0,Z.useCallback)(e=>{c({type:`patchText`,text:e}),v(e)},[v]);(0,Z.useEffect)(()=>()=>v.cancel(),[v,e]);let b=(0,Z.useCallback)(async()=>{if(!e)return;let t=sC(e);if(o.binaryBuffer){JS(t,o.binaryBuffer,o.descriptor.mimeType||`application/octet-stream`);return}if(o.textContent!=null){qS(t,o.textContent);return}let n=await US(e,i);JS(t,await n.arrayBuffer(),o.descriptor.mimeType||n.type||`application/octet-stream`)},[e,o.binaryBuffer,o.descriptor.mimeType,o.textContent,i]),x=(0,Z.useCallback)(async()=>{if(!e)throw Error(`No workspace file selected`);let t=sC(e),n=o.descriptor.mimeType||`application/octet-stream`,r;return r=o.binaryBuffer?new Blob([o.binaryBuffer],{type:n}):o.textContent==null?await US(e,i):new Blob([o.textContent],{type:n}),new File([r],t,{type:o.descriptor.mimeType||r.type||`application/octet-stream`,lastModified:o.mtimeMs??Date.now()})},[e,o.binaryBuffer,o.descriptor.mimeType,o.mtimeMs,o.textContent,i]),S=!o.loading&&!!e,C=An()&&(!!o.fileResourceId&&!!window.electronAPI?.shell?.openFileResource||o.descriptor.type===`spreadsheet`&&!!o.binaryBuffer&&!!window.electronAPI?.shell?.openTemporaryFile),w=An()&&!!o.fileResourceId&&!!window.electronAPI?.shell?.chooseAppAndOpenFileResource,T=(0,Z.useCallback)(async()=>{let e=o.fileResourceId;if(!An()||!e||!window.electronAPI?.shell?.getOpenWithAppsForFileResource){m([]),f([]);return}try{let t=await window.electronAPI.shell.getOpenWithAppsForFileResource(e);m(t.recommended.map(e=>({name:e.name,path:e.path}))),f(t.recent.map(e=>({name:e.name,path:e.path,lastUsedAt:e.lastUsedAt})))}catch{m([]),f([])}},[o.fileResourceId]);(0,Z.useEffect)(()=>{T()},[T]);let E=(0,Z.useCallback)(async()=>{let e=o.fileResourceId;if(e&&window.electronAPI?.shell?.openFileResource)return window.electronAPI.shell.openFileResource(e);if(o.descriptor.type===`spreadsheet`&&o.binaryBuffer&&window.electronAPI?.shell?.openTemporaryFile)return window.electronAPI.shell.openTemporaryFile({fileName:o.descriptor.fileName,data:new Uint8Array(o.binaryBuffer)})},[o.binaryBuffer,o.descriptor.fileName,o.descriptor.type,o.fileResourceId]),D=(0,Z.useCallback)(async()=>{let e=o.fileResourceId;if(!e||!window.electronAPI?.shell?.chooseAppAndOpenFileResource)return;let t=await window.electronAPI.shell.chooseAppAndOpenFileResource(e);return t.ok&&T(),t},[o.fileResourceId,T]),O=(0,Z.useCallback)(async e=>{let t=o.fileResourceId;if(!t||!e||!window.electronAPI?.shell?.openFileResourceWithApp)return;let n=await window.electronAPI.shell.openFileResourceWithApp(t,e);return n.ok&&T(),n},[o.fileResourceId,T]),k=An()&&!!o.fileResourceId&&!!window.electronAPI?.shell?.showFileResourceInFolder,A=(0,Z.useCallback)(async()=>{let e=o.fileResourceId;if(e&&window.electronAPI?.shell?.showFileResourceInFolder)return window.electronAPI.shell.showFileResourceInFolder(e)},[o.fileResourceId]);return{...o,extractedText:o.descriptor.type===`pptx`?o.pptxText:null,extractedTextTruncated:o.pptxTruncated,sourceEditMode:l.sourceEditMode,setSourceEditMode:e=>u({type:`source`,value:e}),saveStatus:l.saveStatus,onSourceChange:y,onDownload:b,createAttachmentFile:x,canDownload:S,canOpenWithSystemApp:C,onOpenWithSystemApp:E,canChooseOpenWithApp:w,onChooseOpenWithApp:D,recommendedOpenWithApps:p,recentOpenWithApps:d,onOpenWithRecentApp:O,canRevealInFolder:k,onRevealInFolder:A}}var xC=`!z-[10000] max-w-[min(28rem,90vw)] rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-snug text-fg shadow-lg`,SC=`block w-full min-w-0 truncate rounded border border-transparent bg-surface-hover px-2 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`,CC=`inline-flex w-[5.25rem] shrink-0 items-center justify-center gap-1 px-2 py-1 text-xs`;function wC(e){let t=(0,Q.c)(38),{label:n,text:r,compact:i,labels:a,monospace:o}=e,s=o===void 0?!0:o,c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p;t[0]===r?p=t[1]:(p=async()=>{if(f(!1),await Yt(r)){u(!0),window.setTimeout(()=>u(!1),2e3);return}Jt(c.current),f(!0),window.setTimeout(()=>f(!1),2500)},t[0]=r,t[1]=p);let m=p,h=i&&`gap-0.5`,g;t[2]===h?g=t[3]:(g=K(`flex min-w-0 flex-col gap-1`,h),t[2]=h,t[3]=g);let _;t[4]===n?_=t[5]:(_=n?(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}):null,t[4]=n,t[5]=_);let v=n??a.copy,y=!s&&`font-sans`,b;t[6]===y?b=t[7]:(b=K(SC,y),t[6]=y,t[7]=b);let x;t[8]!==v||t[9]!==b||t[10]!==r?(x=(0,$.jsx)(Mn,{asChild:!0,children:(0,$.jsx)(`input`,{ref:c,readOnly:!0,type:`text`,value:r,"aria-label":v,className:b,onFocus:TC})}),t[8]=v,t[9]=b,t[10]=r,t[11]=x):x=t[11];let C;t[12]===r?C=t[13]:(C=(0,$.jsx)(Pn,{children:(0,$.jsx)(In,{side:`top`,sideOffset:6,collisionPadding:12,className:xC,children:(0,$.jsx)(`span`,{className:`break-all`,children:r})})}),t[12]=r,t[13]=C);let w;t[14]!==C||t[15]!==x?(w=(0,$.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,$.jsxs)(Nn,{children:[x,C]})}),t[14]=C,t[15]=x,t[16]=w):w=t[16];let T;t[17]===m?T=t[18]:(T=()=>void m(),t[17]=m,t[18]=T);let E;t[19]===l?E=t[20]:(E=l?(0,$.jsx)(S,{className:`size-3.5 shrink-0`}):(0,$.jsx)(N,{className:`size-3.5 shrink-0`}),t[19]=l,t[20]=E);let D=l?a.copied:a.copy,O;t[21]===D?O=t[22]:(O=(0,$.jsx)(`span`,{className:`truncate`,children:D}),t[21]=D,t[22]=O);let k;t[23]!==T||t[24]!==E||t[25]!==O?(k=(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:CC,onClick:T,children:[E,O]}),t[23]=T,t[24]=E,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==w||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_5.25rem] items-center gap-2`,children:[w,k]}),t[27]=w,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==d||t[31]!==a.copyFailed?(j=d?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:a.copyFailed}):null,t[30]=d,t[31]=a.copyFailed,t[32]=j):j=t[32];let M;return t[33]!==A||t[34]!==j||t[35]!==g||t[36]!==_?(M=(0,$.jsx)(Fn,{delayDuration:300,children:(0,$.jsxs)(`div`,{className:g,children:[_,A,j]})}),t[33]=A,t[34]=j,t[35]=g,t[36]=_,t[37]=M):M=t[37],M}function TC(e){return e.currentTarget.select()}function EC(e){let t=(0,Q.c)(12),{rows:n,compact:r,labels:i}=e,a=r&&`gap-1.5`,o;t[0]===a?o=t[1]:(o=K(`flex min-w-0 flex-col gap-2`,a),t[0]=a,t[1]=o);let s;if(t[2]!==r||t[3]!==i||t[4]!==n){let e;t[6]!==r||t[7]!==i?(e=e=>(0,$.jsx)(wC,{label:e.label,text:e.text,compact:r,labels:i},e.key),t[6]=r,t[7]=i,t[8]=e):e=t[8],s=n.map(e),t[2]=r,t[3]=i,t[4]=n,t[5]=s}else s=t[5];let c;return t[9]!==o||t[10]!==s?(c=(0,$.jsx)(`div`,{className:o,children:s}),t[9]=o,t[10]=s,t[11]=c):c=t[11],c}var DC=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),OC=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function kC(e,t,n,r){if(n===`public`){let n=[{key:`public`,label:r.publicUrlLabel,url:e}];return t&&n.push({key:`lan`,label:r.lanUrlLabel,url:t}),n}return n===`lan`?[{key:`lan`,label:r.lanUrlLabel,url:e}]:[{key:`local`,label:r.localUrlLabel,url:e}]}function AC(e){let t=(0,Q.c)(17),{shareUrl:n,lanUrl:r,reachability:i,compact:a}=e,o=Ee(MC),s;t[0]===o?s=t[1]:(s=xe(o),t[0]=o,t[1]=s);let c=s.sharesSettings,l=r??null,u;t[2]!==i||t[3]!==n||t[4]!==c||t[5]!==l?(u=kC(n,l,i,c),t[2]=i,t[3]=n,t[4]=c,t[5]=l,t[6]=u):u=t[6];let d=u,f;t[7]!==c.copied||t[8]!==c.copy||t[9]!==c.copyFailed?(f={copy:c.copy,copied:c.copied,copyFailed:c.copyFailed},t[7]=c.copied,t[8]=c.copy,t[9]=c.copyFailed,t[10]=f):f=t[10];let p=f,m;t[11]===d?m=t[12]:(m=d.map(jC),t[11]=d,t[12]=m);let h;return t[13]!==a||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(EC,{rows:m,compact:a,labels:p}),t[13]=a,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function jC(e){return{key:e.key,label:e.label,text:e.url}}function MC(e){return e.language}function NC(e,t){return(t===`zh`?DC:OC).format(new Date(e))}function PC(e){let t=(0,Q.c)(23),{reachability:n,reachabilityHint:r}=e,i=Ee(FC),a;t[0]===i?a=t[1]:(a=xe(i),t[0]=i,t[1]=a);let o=a.sharesSettings;if(n===`public`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ce,{className:`size-3`}),t[2]=e):e=t[2];let n;return t[3]===o.reachPublic?n=t[4]:(n=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-emerald-600 dark:text-emerald-400`,children:[e,o.reachPublic]}),t[3]=o.reachPublic,t[4]=n),n}if(n===`lan`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ba,{className:`size-3`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r?(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[` — `,r]}):null,t[6]=r,t[7]=n);let i;return t[8]!==o.reachLan||t[9]!==n?(i=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400`,children:[e,o.reachLan,n]}),t[8]=o.reachLan,t[9]=n,t[10]=i):i=t[10],i}let s;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(ya,{className:`size-3`}),t[11]=s):s=t[11];let c;t[12]===o.reachLocal?c=t[13]:(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-subtle`,children:[s,o.reachLocal]}),t[12]=o.reachLocal,t[13]=c);let l=r??o.reachLocalHint,u;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(I,{className:`size-3`}),t[14]=u):u=t[14];let d;t[15]===o.openTunnel?d=t[16]:(d=(0,$.jsxs)(y,{to:`/settings/remote-access?tab=public`,className:`inline-flex items-center gap-0.5 text-accent hover:underline`,children:[o.openTunnel,u]}),t[15]=o.openTunnel,t[16]=d);let f;t[17]!==l||t[18]!==d?(f=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,children:[l,` `,d]}),t[17]=l,t[18]=d,t[19]=f):f=t[19];let p;return t[20]!==c||t[21]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c,f]}),t[20]=c,t[21]=f,t[22]=p):p=t[22],p}function FC(e){return e.language}function IC(e){let t=(0,Q.c)(24),{result:n}=e,r=Ee(LC),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i.sharesSettings,o;t[2]===n.fileName?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.fileName}),t[2]=n.fileName,t[3]=o);let s=a.expiresLabel,c;t[4]!==r||t[5]!==n.expiresAt?(c=NC(n.expiresAt,r),t[4]=r,t[5]=n.expiresAt,t[6]=c):c=t[6];let l;t[7]!==a.expiresLabel||t[8]!==c?(l=(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s,`: `,c]}),t[7]=a.expiresLabel,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==o||t[11]!==l?(u=(0,$.jsxs)(`div`,{children:[o,l]}),t[10]=o,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.lanUrl||t[14]!==n.reachability||t[15]!==n.shareUrl?(d=(0,$.jsx)(AC,{shareUrl:n.shareUrl,lanUrl:n.lanUrl,reachability:n.reachability}),t[13]=n.lanUrl,t[14]=n.reachability,t[15]=n.shareUrl,t[16]=d):d=t[16];let f;t[17]!==n.reachability||t[18]!==n.reachabilityHint?(f=(0,$.jsx)(PC,{reachability:n.reachability,reachabilityHint:n.reachabilityHint}),t[17]=n.reachability,t[18]=n.reachabilityHint,t[19]=f):f=t[19];let p;return t[20]!==u||t[21]!==d||t[22]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[u,d,f]}),t[20]=u,t[21]=d,t[22]=f,t[23]=p):p=t[23],p}function LC(e){return e.language}function RC(e){let t=(0,Q.c)(95),{params:n,loading:r,error:i,onConfirm:a,onCancel:o}=e,s=Ee(zC),c;t[0]===s?c=t[1]:(c=xe(s),t[0]=s,t[1]=c);let l=c.sharesSettings,[u,d]=(0,Z.useState)(n.ttlMs??864e5),[f,p]=(0,Z.useState)(n.maxViews??null),[m,h]=(0,Z.useState)(n.description??``),g;t[2]!==m||t[3]!==f||t[4]!==a||t[5]!==u?(g=e=>{e.preventDefault(),a({ttlMs:u,maxViews:f,description:m.trim()||void 0})},t[2]=m,t[3]=f,t[4]=a,t[5]=u,t[6]=g):g=t[6];let _=n.fileName??n.path??n.fileId??n.uri,v=n.fileName??n.path??n.fileId??n.uri,y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,title:_,children:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===l.shareConfirmHint?b=t[11]:(b=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.shareConfirmHint}),t[10]=l.shareConfirmHint,t[11]=b);let x;t[12]!==y||t[13]!==b?(x=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[y,b]}),t[12]=y,t[13]=b,t[14]=x):x=t[14];let S;t[15]===l.ttlLabel?S=t[16]:(S=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:l.ttlLabel}),t[15]=l.ttlLabel,t[16]=S);let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>d(Number(e.target.value)),t[17]=C):C=t[17];let w=l.ttlOptions[`1h`],T;t[18]===w?T=t[19]:(T=(0,$.jsx)(O,{value:36e5,children:w}),t[18]=w,t[19]=T);let D=l.ttlOptions[`6h`],k;t[20]===D?k=t[21]:(k=(0,$.jsx)(O,{value:216e5,children:D}),t[20]=D,t[21]=k);let A=l.ttlOptions[`24h`],j;t[22]===A?j=t[23]:(j=(0,$.jsx)(O,{value:864e5,children:A}),t[22]=A,t[23]=j);let M=l.ttlOptions[`3d`],N;t[24]===M?N=t[25]:(N=(0,$.jsx)(O,{value:2592e5,children:M}),t[24]=M,t[25]=N);let P=l.ttlOptions[`7d`],F;t[26]===P?F=t[27]:(F=(0,$.jsx)(O,{value:6048e5,children:P}),t[26]=P,t[27]=F);let I=l.ttlOptions[`30d`],L;t[28]===I?L=t[29]:(L=(0,$.jsx)(O,{value:2592e6,children:I}),t[28]=I,t[29]=L);let R;t[30]!==r||t[31]!==T||t[32]!==k||t[33]!==j||t[34]!==N||t[35]!==F||t[36]!==L||t[37]!==u?(R=(0,$.jsxs)(E,{value:u,disabled:r,onChange:C,children:[T,k,j,N,F,L]}),t[30]=r,t[31]=T,t[32]=k,t[33]=j,t[34]=N,t[35]=F,t[36]=L,t[37]=u,t[38]=R):R=t[38];let z;t[39]!==R||t[40]!==S?(z=(0,$.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[S,R]}),t[39]=R,t[40]=S,t[41]=z):z=t[41];let B;t[42]===l.maxViewsLabel?B=t[43]:(B=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:l.maxViewsLabel}),t[42]=l.maxViewsLabel,t[43]=B);let V=f??`unlimited`,H;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>p(e.target.value===`unlimited`?null:Number(e.target.value)),t[44]=H):H=t[44];let U;t[45]===l.maxViewsUnlimited?U=t[46]:(U=(0,$.jsx)(O,{value:`unlimited`,children:l.maxViewsUnlimited}),t[45]=l.maxViewsUnlimited,t[46]=U);let W,G,ee,te;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(O,{value:1,children:`1`}),G=(0,$.jsx)(O,{value:5,children:`5`}),ee=(0,$.jsx)(O,{value:10,children:`10`}),te=(0,$.jsx)(O,{value:50,children:`50`}),t[47]=W,t[48]=G,t[49]=ee,t[50]=te):(W=t[47],G=t[48],ee=t[49],te=t[50]);let ne;t[51]!==r||t[52]!==V||t[53]!==U?(ne=(0,$.jsxs)(E,{value:V,disabled:r,onChange:H,children:[U,W,G,ee,te]}),t[51]=r,t[52]=V,t[53]=U,t[54]=ne):ne=t[54];let re;t[55]!==B||t[56]!==ne?(re=(0,$.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[B,ne]}),t[55]=B,t[56]=ne,t[57]=re):re=t[57];let ie;t[58]!==z||t[59]!==re?(ie=(0,$.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[z,re]}),t[58]=z,t[59]=re,t[60]=ie):ie=t[60];let ae;t[61]===l.descriptionLabel?ae=t[62]:(ae=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:l.descriptionLabel}),t[61]=l.descriptionLabel,t[62]=ae);let oe;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>h(e.target.value),t[63]=oe):oe=t[63];let se;t[64]!==m||t[65]!==r||t[66]!==l.descriptionPlaceholder?(se=(0,$.jsx)(`input`,{type:`text`,value:m,disabled:r,onChange:oe,placeholder:l.descriptionPlaceholder,className:`h-10 rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-edge-strong disabled:opacity-60`}),t[64]=m,t[65]=r,t[66]=l.descriptionPlaceholder,t[67]=se):se=t[67];let ce;t[68]!==ae||t[69]!==se?(ce=(0,$.jsxs)(`label`,{className:`mt-3 flex flex-col gap-1.5`,children:[ae,se]}),t[68]=ae,t[69]=se,t[70]=ce):ce=t[70];let le;t[71]===i?le=t[72]:(le=i?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:i}):null,t[71]=i,t[72]=le);let de;t[73]!==ie||t[74]!==ce||t[75]!==le||t[76]!==x?(de=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:[x,ie,ce,le]}),t[73]=ie,t[74]=ce,t[75]=le,t[76]=x,t[77]=de):de=t[77];let fe;t[78]!==r||t[79]!==o||t[80]!==l.cancel?(fe=(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:r,onClick:o,children:l.cancel}),t[78]=r,t[79]=o,t[80]=l.cancel,t[81]=fe):fe=t[81];let pe;t[82]===r?pe=t[83]:(pe=r?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):null,t[82]=r,t[83]=pe);let me=r?l.creating:l.createButton,he;t[84]!==r||t[85]!==pe||t[86]!==me?(he=(0,$.jsxs)(X,{type:`submit`,disabled:r,children:[pe,me]}),t[84]=r,t[85]=pe,t[86]=me,t[87]=he):he=t[87];let ge;t[88]!==fe||t[89]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-4 py-3`,children:[fe,he]}),t[88]=fe,t[89]=he,t[90]=ge):ge=t[90];let _e;return t[91]!==g||t[92]!==de||t[93]!==ge?(_e=(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:g,children:[de,ge]}),t[91]=g,t[92]=de,t[93]=ge,t[94]=_e):_e=t[94],_e}function zC(e){return e.language}function BC(e){let t=(0,Q.c)(36),{open:n,onOpenChange:r,loading:i,error:a,result:o,pendingParams:s,onConfirm:c}=e,l=Ee(VC),u;t[0]===l?u=t[1]:(u=xe(l),t[0]=l,t[1]=u);let d=u.sharesSettings,f;t[2]===l?f=t[3]:(f=xe(l),t[2]=l,t[3]=f);let p=f,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[180] bg-scrim backdrop-blur-[2px]`}),t[4]=m):m=t[4];let h;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[181] flex h-[min(31rem,calc(100dvh-2rem))] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,`overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-popover outline-none`),t[5]=h):h=t[5];let g=o?d.shareCreated:d.shareConfirmTitle,_;t[6]===g?_=t[7]:(_=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==s||t[9]!==o||t[10]!==d.createHint?(v=!o&&s?(0,$.jsx)(Ze,{className:`mt-0.5 text-xs text-fg-muted`,children:d.createHint}):null,t[8]=s,t[9]=o,t[10]=d.createHint,t[11]=v):v=t[11];let y;t[12]!==_||t[13]!==v?(y=(0,$.jsxs)(`div`,{children:[_,v]}),t[12]=_,t[13]=v,t[14]=y):y=t[14];let b;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ye,{className:`size-4`}),t[15]=b):b=t[15];let x;t[16]===d.cancel?x=t[17]:(x=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":d.cancel,children:b})}),t[16]=d.cancel,t[17]=x);let S;t[18]!==x||t[19]!==y?(S=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-edge px-4 py-3`,children:[y,x]}),t[18]=x,t[19]=y,t[20]=S):S=t[20];let C;t[21]!==a||t[22]!==i||t[23]!==p||t[24]!==c||t[25]!==r||t[26]!==s||t[27]!==o?(C=o?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,$.jsx)(IC,{result:o})}):s&&c?(0,$.jsx)(RC,{params:s,loading:!!i,error:a,onConfirm:c,onCancel:()=>r(!1)},`${s.fileId??s.uri??s.path}:${s.conversationId??s.agentId??``}`):i?(0,$.jsxs)(`p`,{className:`flex items-center gap-2 p-4 text-sm text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-4 animate-spin`}),p.workspace.sharing]}):a?(0,$.jsx)(`p`,{className:`p-4 text-sm text-red-600 dark:text-red-400`,children:a}):null,t[21]=a,t[22]=i,t[23]=p,t[24]=c,t[25]=r,t[26]=s,t[27]=o,t[28]=C):C=t[28];let w;t[29]!==S||t[30]!==C?(w=(0,$.jsxs)($e,{children:[m,(0,$.jsxs)(et,{className:h,children:[S,C]})]}),t[29]=S,t[30]=C,t[31]=w):w=t[31];let T;return t[32]!==r||t[33]!==n||t[34]!==w?(T=(0,$.jsx)(nt,{open:n,onOpenChange:r,children:w}),t[32]=r,t[33]=n,t[34]=w,t[35]=T):T=t[35],T}function VC(e){return e.language}async function HC(){return q(J(`/api/shares`))}async function UC(){return(await q(J(`/api/hosted-publications/capabilities`))).payload}async function WC(){if(!await rw())return{connected:!1,publishingAllowed:!1,publications:[]};let[e,t]=await Promise.all([q(J(`/api/hosted-publications`)),UC()]);return{connected:!0,publishingAllowed:t.publishing.allowed,publications:e.payload.publications}}async function GC(e){await q(J(`/api/hosted-publications/${encodeURIComponent(e)}`),{method:`DELETE`})}async function KC(e){return(await q(J(`/api/hosted-publications/static-sites`),{method:`POST`,body:JSON.stringify(e)})).payload}async function qC(e){await q(J(`/api/hosted-publications/static-sites/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function JC(e){return(await q(J(`/api/hosted-publications/${encodeURIComponent(e)}/revisions`))).payload.revisions}async function YC(e,t,n){await q(J(`/api/hosted-publications/${encodeURIComponent(e)}/rollback`),{method:`POST`,body:JSON.stringify({expectedRevision:t,targetRevision:n})})}async function XC(e){return q(J(`/api/shares`),{method:`POST`,body:JSON.stringify(e)})}async function ZC(e){return q(J(`/api/shares/${e}`),{method:`DELETE`})}async function QC(){return q(J(`/api/shares`),{method:`DELETE`,body:JSON.stringify({expired:!0})})}async function $C(e,t){return q(J(`/api/shares/${e}`),{method:`PATCH`,body:JSON.stringify({extendTtlMs:t})})}async function ew(e){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/share-preview`))).payload}async function tw(e){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/shares`))).payload.shares}async function nw(e){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/hosted-shares`))).payload.shares}async function rw(){return(await q(J(`/api/auth/oauth/xopc-share`))).payload.authStatus===`connected`}async function iw(e,t){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/shares`),{method:`POST`,body:JSON.stringify(t)})).payload}async function aw(e,t){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/hosted-shares`),{method:`POST`,body:JSON.stringify(t)})).payload}async function ow(e,t,n){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/shares/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})).payload}async function sw(e,t,n){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/hosted-shares/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})).payload}async function cw(e,t){await q(J(`/api/sessions/${encodeURIComponent(e)}/hosted-shares/${encodeURIComponent(t)}`),{method:`DELETE`})}function lw(){let[e,t]=(0,Z.useState)(!1),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),u=(0,Z.useCallback)(e=>{t(!0),l(e),a(null),s(null)},[]),d=(0,Z.useCallback)(async e=>{if(!c||n)return null;r(!0),s(null);try{let t=await XC({...c,...e});return a(t.payload),t.payload}catch(e){return s(e instanceof Error?e.message:String(e)),null}finally{r(!1)}},[n,c]),f=(0,Z.useCallback)(()=>{a(null),s(null),r(!1),l(null)},[]);return{dialogOpen:e,loading:n,result:i,error:o,pendingParams:c,createShareLink:u,confirmShareLink:d,handleOpenChange:(0,Z.useCallback)(e=>{t(e),e||f()},[f])}}async function uw(e,t){try{let n=await e();return n&&`ok`in n&&n.code===`CANCELED`?!1:n&&(`ok`in n?n.ok:n.success)?!0:(Yl(`warning`,n?.error||t,void 0,{duration:4e3}),!1)}catch{return Yl(`warning`,t,void 0,{duration:4e3}),!1}}function dw(e){return e.map(e=>({fileId:e.id,name:e.name,path:e.path,isDirectory:e.isDirectory,children:e.isDirectory?[]:void 0}))}function fw(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:fw(e.children,t,n)}:e)}function pw(e,t,n){let[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(new Set),f=e.trim(),p=t?.trim()??``,m=n?.trim()??``,h=m?``:p,g=!m&&!p?f:``,_=(0,Z.useMemo)(()=>{if(m)return{projectId:m};if(h)return{conversationId:h};if(g)return{agentId:g}},[m,h,g]);return{tree:r,rootResource:a,loading:s,error:l,loadRoot:(0,Z.useCallback)(async()=>{c(!0),u(null),d.current.clear();try{let[e,t]=await Promise.all([IS(``,_),RS(_)]);i(dw(e.entries)),o(dw([t])[0]??null),d.current.add(``)}catch(e){o(null),u(e instanceof Error?e.message:String(e))}finally{c(!1)}},[_]),loadChildren:(0,Z.useCallback)(async e=>{if(!d.current.has(e)){d.current.add(e);try{let t=dw(await LS(e,_));i(n=>fw(n,e,t))}catch{d.current.delete(e)}}},[_]),refreshDirectory:(0,Z.useCallback)(async e=>{let t=dw(await LS(e,_));i(e?n=>fw(n,e,t):t),d.current.add(e)},[_]),reset:(0,Z.useCallback)(()=>{i([]),o(null),u(null),d.current.clear()},[])}}var mw=`application/x-xopc-workspace-file`;function hw(e,t){e.effectAllowed=`copy`,e.setData(mw,JSON.stringify(t))}function gw(e){return!!(e&&Array.from(e.types).includes(`application/x-xopc-workspace-file`))}function _w(e){if(!e)return null;try{let t=JSON.parse(e.getData(mw)),n=typeof t.path==`string`?t.path.trim():``,r=typeof t.name==`string`?t.name.trim():``;return!n||!r?null:{path:n,name:r,...typeof t.conversationId==`string`&&t.conversationId.trim()?{conversationId:t.conversationId.trim()}:{},...typeof t.agentId==`string`&&t.agentId.trim()?{agentId:t.agentId.trim()}:{},...typeof t.projectId==`string`&&t.projectId.trim()?{projectId:t.projectId.trim()}:{}}}catch{return null}}function vw({resourceId:e,displayName:t,className:n}){let r=xe(Ee(e=>e.language)).workspace,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(!1),f=An(),p=f?window.electronAPI?.shell:void 0,m=f&&!!e.trim(),h=!!p?.openFileResource,g=(0,Z.useCallback)(async()=>{if(!p?.getOpenWithAppsForFileResource||!e.trim()){s([]),l([]);return}try{let t=await p.getOpenWithAppsForFileResource(e);s(t.recommended.map(e=>({name:e.name,path:e.path}))),l(t.recent.map(e=>({name:e.name,path:e.path})))}catch{s([]),l([])}},[e,p]);(0,Z.useEffect)(()=>{g()},[g]);let _=(0,Z.useCallback)(e=>{Yl(`warning`,e||r.openLocationFailed,void 0,{duration:4e3})},[r.openLocationFailed]),v=(0,Z.useCallback)(async()=>{if(!(!p?.openFileResource||!e)){d(!0);try{let t=await p.openFileResource(e);t.ok===!1&&_(t.error)}finally{d(!1),a(!1)}}},[_,e,p]),y=(0,Z.useCallback)(async t=>{if(!(!p?.openFileResourceWithApp||!e)){d(!0);try{let n=await p.openFileResourceWithApp(e,t);n.ok===!1?_(n.error):g()}finally{d(!1),a(!1)}}},[g,_,e,p]),b=(0,Z.useCallback)(async()=>{if(!(!p?.chooseAppAndOpenFileResource||!e)){d(!0);try{let t=await p.chooseAppAndOpenFileResource(e);t.ok===!1&&t.code!==`CANCELED`&&_(t.error),t.ok&&g()}finally{d(!1),a(!1)}}},[g,_,e,p]),x=(0,Z.useCallback)(async()=>{if(!p?.copyFileResourcePath||!e)return;let t=await p.copyFileResourcePath(e);Yl(t.ok?`success`:`warning`,t.ok?r.pathCopied:t.error||r.copyPathFailed,void 0,{duration:t.ok?2500:4e3}),a(!1)},[r.copyPathFailed,r.pathCopied,e,p]);if(!m)return null;if(!h)return(0,$.jsxs)(X,{variant:`ghost`,className:K(`min-w-0 max-w-40 shrink rounded-md px-2 py-1.5 text-xs`,n),disabled:!0,title:r.desktopUpdateRequired,children:[(0,$.jsx)(vi,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:t||r.openLocation})]});let S=`flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-sm text-fg hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50`,C=o[0]??c[0],w=C?o.filter(e=>e.path!==C.path):o,T=C?c.filter(e=>e.path!==C.path):c;return(0,$.jsxs)(hn,{open:i,onOpenChange:e=>{a(e),e&&g()},children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,className:K(`min-w-0 max-w-40 shrink rounded-md px-2 py-1.5 text-xs`,n),"aria-label":r.openLocation,title:r.openLocation,children:[(0,$.jsx)(vi,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:C?.name??t??r.openLocation}),(0,$.jsx)(cr,{className:`size-3.5 shrink-0`,"aria-hidden":!0})]})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{align:`end`,side:`bottom`,sideOffset:6,className:`z-50 w-60 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,children:[C?(0,$.jsxs)(`button`,{type:`button`,disabled:u,className:S,title:C.path,onClick:()=>void y(C.path),children:[(0,$.jsx)(vi,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:C.name})]}):null,(0,$.jsx)(`div`,{className:K(C&&`border-t border-edge pt-1`),children:(0,$.jsxs)(`button`,{type:`button`,disabled:u,className:S,onClick:()=>void v(),children:[(0,$.jsx)(oe,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),r.openInFileManager]})}),w.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.recommendedApps}),w.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:u,className:S,title:e.path,onClick:()=>void y(e.path),children:[(0,$.jsx)(vi,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,T.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`border-t border-edge px-2.5 pb-1 pt-2 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:r.recentApps}),T.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:u,className:S,title:e.path,onClick:()=>void y(e.path),children:[(0,$.jsx)(vi,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))]}):null,(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge pt-1`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:u,className:S,onClick:()=>void b(),children:[(0,$.jsx)(vi,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),r.chooseApp]}),(0,$.jsxs)(`button`,{type:`button`,disabled:u||!p?.copyFileResourcePath,className:S,onClick:()=>void x(),children:[(0,$.jsx)(N,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),r.copyPath]})]})]})})]})}var yw=Oe(e=>({agentId:``,setAgentId:t=>e({agentId:t})})),bw=`xopc-web-workspace-panel-open`,xw=`xopc-web-workspace-panel-width-px`;function Sw(){try{return globalThis.localStorage?.getItem(bw)===`1`}catch{return!1}}function Cw(e){try{globalThis.localStorage?.setItem(bw,e?`1`:`0`)}catch{}}function ww(e){return Math.min(520,Math.max(200,Math.round(e)))}function Tw(){try{let e=globalThis.localStorage?.getItem(xw);if(e==null)return 320;let t=Number.parseInt(e,10);return Number.isFinite(t)?ww(t):320}catch{return 320}}function Ew(e){try{globalThis.localStorage?.setItem(xw,String(e))}catch{}}var Dw=Oe((e,t)=>({open:Sw(),setOpen:t=>{e(t?{open:t}:{open:t,conversationIdOverride:null}),queueMicrotask(()=>Cw(t))},toggleOpen:()=>{t().setOpen(!t().open)},conversationIdOverride:null,openForSession:t=>{e({open:!0,conversationIdOverride:t.trim()||null}),queueMicrotask(()=>Cw(!0))},widthPx:Tw(),setWidthPx:n=>{let r=ww(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>Ew(r)))}})),Ow=Oe(e=>({path:null,line:null,projectId:null,conversationId:null,setPath:(t,n,r,i)=>e({path:t,line:t&&typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):null,projectId:t&&r?.trim()||null,conversationId:t&&i?.trim()||null})})),kw=(0,Z.memo)(function({elevated:e=!1}){let t=xe(Ee(e=>e.language)),{pathname:n,search:r}=b(),{conversationId:i}=p(),a=n.startsWith(`/chat`)&&i&&i!==`new`?decodeURIComponent(i):null,o=Dw(e=>e.open),s=Dw(e=>e.setOpen),c=Dw(e=>e.conversationIdOverride),l=Dw(e=>e.widthPx),u=Dw(e=>e.setWidthPx),d=c??a,f=!d&&n.startsWith(`/chat`)?new URLSearchParams(r).get(`projectId`):null,[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(``),[x,S]=(0,Z.useState)([]),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),j=Ow(e=>e.path),M=Ow(e=>e.setPath),N=yw(e=>e.agentId),{tree:P,rootResource:F,loading:I,error:L,loadRoot:R,loadChildren:z,refreshDirectory:B,reset:V}=pw(N,d,f),H=d?`session:${d}`:f?`project:${f}`:`agent:${N}`,U=(0,Z.useMemo)(()=>f?{projectId:f}:d==null?N.trim()?{agentId:N.trim()}:void 0:{conversationId:d},[d,f,N]),W=v.trim(),G=An(),ee=(0,Z.useCallback)((e,t)=>{M(null),hw(e.dataTransfer,{name:t.name,path:t.path,...U})},[M,U]),{dialogOpen:te,loading:ne,result:re,error:ie,pendingParams:ae,createShareLink:oe,confirmShareLink:se,handleOpenChange:ce}=lw(),le=(0,Z.useCallback)(e=>{if(!o)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`#app-workspace-panel`);t.setPointerCapture(e.pointerId),h(!0);let r=e.clientX,i=Dw.getState().widthPx,a=e.pointerId,s=0,c=i,l=i,d=()=>{s=0,l=c,n?.style.setProperty(`--workspace-panel-px`,`${l}px`)},f=e=>{c=ww(i+(r-e.clientX)),s===0&&(s=window.requestAnimationFrame(d))},p=()=>{s!==0&&(window.cancelAnimationFrame(s),d());try{t.releasePointerCapture(a)}catch{}h(!1),u(l),window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)},[o,u]);(0,Z.useEffect)(()=>{n.startsWith(`/chat`)||s(!1)},[n,s]),(0,Z.useEffect)(()=>{if(!o){V(),M(null);return}M(null),R()},[o,H,R,V,M]),(0,Z.useEffect)(()=>{if(!o)return;let e=e=>{if(e.key===`Escape`){if(g){e.preventDefault(),e.stopPropagation(),y(``),_(!1);return}Ow.getState().path||s(!1)}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[g,o,s]),(0,Z.useEffect)(()=>{if(!o||!g||!W){S([]),w(!1),E(null);return}let e=!1;w(!0),E(null),S([]);let t=window.setTimeout(()=>{zS(W,U,50).then(t=>{e||S(t)}).catch(t=>{e||E(t instanceof Error?t.message:String(t))}).finally(()=>{e||w(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[g,W,o,U]),(0,Z.useEffect)(()=>{if(!o||!window.matchMedia(`(max-width: 767px)`).matches)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[o]);let ue=(0,Z.useCallback)(e=>{z(e)},[z]),de=(0,Z.useCallback)(async(e,n,r)=>{switch(e){case`preview`:if(n.isDirectory)return;M(n.path);break;case`download`:if(n.isDirectory)return;try{let e=sC(n.path);if(uC(lC(e))!==`text`)JS(e,await(await US(n.path,U)).arrayBuffer(),h_(e)??`application/octet-stream`);else{let{content:t}=await BS(n.path,U);qS(e,t)}}catch{}break;case`copyPath`:try{await Yt(n.path)&&Yl(`success`,t.workspace.pathCopied,void 0,{duration:2500})}catch{}break;case`openDefault`:await uw(()=>window.electronAPI?.shell?.openFileResource?.(n.fileId),t.workspace.openFileFailed);break;case`openWith`:await uw(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(n.fileId),t.workspace.openFileFailed);break;case`openWithApp`:if(!r)return;await uw(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(n.fileId,r),t.workspace.openFileFailed);break;case`revealInFolder`:await uw(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(n.fileId),t.workspace.revealFileFailed);break;case`trash`:O(n);break;case`delete`:n.isDirectory||A(n);break;case`share`:await oe({path:n.path,...n.isDirectory?{kind:`directory`,directoryMode:`browse`}:{},...U});break;default:break}},[oe,t.workspace.openFileFailed,t.workspace.pathCopied,t.workspace.revealFileFailed,M,U]),fe=(0,Z.useCallback)(async()=>{let e=D;if(!e)return;let n=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!n?.ok){Yl(`warning`,n?.error??t.workspace.trashFailed,void 0,{duration:4e3});return}j===e.path&&M(null),O(null),await R(),Yl(`success`,t.workspace.trashSuccess,void 0,{duration:2500})},[R,t.workspace.trashFailed,t.workspace.trashSuccess,D,j,M]),pe=(0,Z.useCallback)(async(e,n)=>{try{await Promise.all(e.map(e=>GS(e,n,U))),await B(n).catch(()=>void 0),Yl(`success`,t.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await B(n).catch(()=>void 0),Yl(`warning`,`${t.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t.workspace.uploadFailed,t.workspace.uploadSuccess,B,U]),me=(0,Z.useCallback)(async()=>{let e=k;if(e)try{await KS(e.fileId),j===e.path&&M(null),A(null);let n=e.path.lastIndexOf(`/`);await B(n<0?``:e.path.slice(0,n)).catch(()=>void 0),Yl(`success`,t.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Yl(`warning`,`${t.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[t.workspace.deleteFailed,t.workspace.deleteSuccess,k,j,B,M]);return(0,$.jsxs)($.Fragment,{children:[o?(0,$.jsx)(`button`,{type:`button`,className:K(`fixed inset-0 bg-scrim md:hidden`,e?`z-[109]`:`z-40`),"aria-label":t.closeMenu,onClick:()=>s(!1)}):null,(0,$.jsx)(`aside`,{id:`app-workspace-panel`,"aria-label":t.workspace.title,"aria-hidden":!o,className:K(`flex min-h-0 flex-col overflow-hidden bg-surface-base`,`max-md:fixed max-md:right-0 max-md:top-0 max-md:h-[100dvh] max-md:shadow-popover`,`max-md:transition-transform max-md:duration-200 max-md:ease-out`,`motion-reduce:max-md:transition-none`,`max-md:w-[min(20rem,92vw)]`,o?`max-md:translate-x-0`:`max-md:pointer-events-none max-md:translate-x-full`,`md:relative md:h-full md:translate-x-0`,e&&o?`pointer-events-auto z-[110]`:`max-md:z-50`,`motion-reduce:md:transition-none`,!o&&`md:pointer-events-none md:w-0 md:min-w-0 md:max-w-0 md:overflow-hidden`,o&&`app-workspace-panel-expanded-width md:shrink-0`,o&&m&&`workspace-panel-rail-resizing`),style:o?{"--workspace-panel-px":`${l}px`}:void 0,children:o?(0,$.jsxs)(`div`,{className:K(`relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-x-hidden overflow-y-hidden bg-surface-base`),children:[(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":t.workspace.resizeHandleAria,onPointerDown:le,className:K(`pointer-events-auto absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,m&&`bg-surface-hover/30 before:!bg-edge/80 dark:before:!bg-edge/85`,`transition-[background-color] duration-150`,`touch-none select-none`,md)}),(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4 dark:border-edge`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:t.workspace.title}),G?F?(0,$.jsx)(vw,{resourceId:F.fileId,displayName:F.name}):null:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(Gr,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:t.workspace.title})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:K(`size-9 shrink-0 rounded-md p-0`,g&&`bg-surface-hover text-fg`),"aria-label":t.workspace.search,title:t.workspace.search,"aria-pressed":g,onClick:()=>_(!0),children:(0,$.jsx)(ve,{className:`size-4`,strokeWidth:1.75})}),(0,$.jsx)(mS,{className:`size-9 shrink-0 rounded-md p-0`,loading:I,label:t.cron.refresh,onClick:R}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-md p-0`,"aria-label":t.workspace.close,title:t.workspace.close,onClick:()=>s(!1),children:(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.75})})]})]}),g?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-inset/40 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-md border border-edge bg-surface-panel px-2 focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/20`,children:[(0,$.jsx)(ve,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:v,onChange:e=>y(e.target.value),placeholder:t.workspace.searchPlaceholder,"aria-label":t.workspace.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle`}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":t.workspace.clearSearch,title:t.workspace.clearSearch,onClick:()=>{y(``),_(!1)},children:(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})]})}):null,L?(0,$.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[t.workspace.loadError,`: `,L]}):null,W?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:C?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(xn,{className:`h-11 w-full`}),(0,$.jsx)(xn,{className:`h-11 w-full`}),(0,$.jsx)(xn,{className:`h-11 w-full`})]}):T?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[t.workspace.loadError,`: `,T]}):x.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:t.workspace.noSearchResults}):x.map(e=>(0,$.jsxs)(`button`,{type:`button`,draggable:!0,className:K(`flex w-full min-w-0 cursor-grab items-center gap-2 px-3 py-2 text-left active:cursor-grabbing hover:bg-surface-hover`,j===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>M(e.path),onDragStart:t=>ee(t,e),title:e.path,children:[(0,$.jsx)(zr,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):(0,$.jsx)(kS,{tree:P,selectedPath:j,onSelectFile:e=>M(e),onExpandDir:ue,onAction:de,onFileDragStart:ee,onUploadFiles:(e,t)=>void pe(e,t),uploadDropHint:t.workspace.dropToUpload,actionLabels:{preview:t.workspace.preview,download:t.workspace.download,copyPath:t.workspace.copyPath,share:t.workspace.shareLink,delete:t.workspace.deleteFile,...G?{openDefault:t.workspace.openSystemApp,openDirectory:t.workspace.openInFileManager,openWith:t.workspace.chooseApp,revealInFolder:t.workspace.revealInFolder,trash:t.workspace.moveToTrash,recommendedApps:t.workspace.recommendedApps,desktopUpdateRequired:t.workspace.desktopUpdateRequired}:{}},emptyHint:t.workspace.emptyDir})]}):null}),(0,$.jsx)(BC,{open:te,onOpenChange:ce,loading:ne,error:ie,result:re,pendingParams:ae,onConfirm:e=>void se(e)}),(0,$.jsx)(uS,{open:!!D,title:t.workspace.trashConfirmTitle,description:t.workspace.trashConfirmDescription.replace(`{{name}}`,D?.name??``),confirmLabel:t.workspace.moveToTrash,cancelLabel:t.workspace.cancel,destructive:!0,onConfirm:()=>void fe(),onCancel:()=>O(null)}),(0,$.jsx)(uS,{open:!!k,title:t.workspace.deleteConfirmTitle,description:t.workspace.deleteConfirmDescription.replace(`{{name}}`,k?.name??``),confirmLabel:t.workspace.deleteFile,cancelLabel:t.workspace.cancel,destructive:!0,onConfirm:()=>void me(),onCancel:()=>A(null)})]})}),Aw=RegExp(`^\\/skill:(${Pg})`),jw=[],Mw=new Map;function Nw(e){let t=new Set;for(let n of e??[]){n?.name&&t.add(n.name);for(let e of n.aliases??[])typeof e==`string`&&e.length>0&&t.add(e)}jw=Array.from(t).toSorted((e,t)=>t.length-e.length).map(e=>({key:e})),Mw.clear()}function Pw(e,t){if(t>=e.length)return!0;let n=e[t];return!/[a-zA-Z0-9_-]/.test(n)}function Fw(e,t){return!(e[t]!==`/`||t>0&&!/\s/.test(e[t-1]))}function Iw(e,t){if(!Fw(e,t)||jw.length===0)return null;let n=e.slice(t);if(n.startsWith(`/skill:`))return null;for(let{key:e}of jw){let t=`/${e}`;if(n.startsWith(t)&&Pw(n,t.length))return{len:t.length,matchedKey:e}}return null}function Lw(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==`/`){n+=1;continue}let r=e.slice(n).match(Aw);if(r?.[0]){n+=r[0].length;continue}let i=Iw(e,n);i?(t.push({start:n,end:n+i.len}),n+=i.len):n+=1}return t}function Rw(e){for(let t=e.length-1;t>=0;--t){if(e[t]!==`/`||e.startsWith(`/skill:`,t))continue;let n=Iw(e,t);if(n&&t+n.len===e.length)return!0}return!1}function zw(e){if(!e.startsWith(`/`)||jw.length===0||e.startsWith(`/skill:`))return!1;let t=Iw(e,0);return t?e.length===t.len||!/[a-zA-Z0-9_-]/.test(e[t.len]):!1}function Bw(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Vw(e){let t=Mw.get(e);return t||(t=RegExp(`(${Bw(e)})([ \\t\\f\\v]*)$`),Mw.set(e,t)),t}function Hw(e){for(let{key:t}of jw){let n=`/${t}`;if(!e.endsWith(n))continue;let r=e.length-n.length;if(Iw(e,r))return{tokenStart:r}}return null}function Uw(e){for(let{key:t}of jw){let n=`/${t}`,r=e.match(Vw(n));if(!r)continue;let i=e.length-r[0].length;if(Iw(e,i))return{tokenStart:i}}return null}var Ww=`​`,Gw=`⁠`,Kw=RegExp(`^\\/skill:(${Pg})`);function qw(e){return!!e.dataset.skill}function Jw(e){return!!e.dataset.contextRefId}function Yw(e){return e.dataset.slashCommand!=null&&e.dataset.slashCommand!==``}var Xw=new WeakMap;function Zw(e){let t=as(),n,r=-1;for(;(n=t.exec(e))!==null;)r=n.index+n[0].length;return r===e.length}function Qw(e){let t=``;for(let n of e)if(n){if(t.length>0){let e=t[t.length-1],r=n[0];if(!/\s/.test(e)&&!/\s/.test(r)){let e=Zw(t)||/\/skill:\S+$/.test(t)||Rw(t),r=n.startsWith(`@xopc-ref:`)||n.startsWith(`/skill:`)||zw(n);(e||r)&&(t+=` `)}}t+=n}return t}function $w(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;let t=e.tagName;return t===`DIV`||t===`P`||t===`PRE`||t===`BLOCKQUOTE`}function eT(e,t){if(e.nodeType===Node.TEXT_NODE)t.push((e.textContent??``).replaceAll(Ww,``));else if(e.nodeType===Node.ELEMENT_NODE){let n=e;if(qw(n)){let e=n.dataset.skill??``;e&&t.push(`/skill:${e}`)}else if(Jw(n)){let e=n.dataset.contextRefId??``;e&&t.push(is(e))}else if(Yw(n)){let e=n.dataset.slashCommand??``;e&&t.push(`/${e}`)}else n.tagName===`BR`?t.push(`
22
- `):tT(n,t)}}function tT(e,t){let n=Array.from(e.childNodes);for(let e=0;e<n.length;e++){let r=n[e],i=n[e+1];eT(r,t),i!=null&&($w(r)||$w(i))&&t.push(`
23
- `)}}function nT(e,t){tT(e,t)}function rT(e){let t=[];return nT(e,t),Qw(t).replaceAll(Gw,``)}function iT(e){let t=window.getSelection();if(!t)return;let n=document.createRange(),r=e.firstChild;r&&r.nodeType===Node.TEXT_NODE?(n.setStart(r,0),n.collapse(!0)):(n.setStart(e,0),n.collapse(!0)),t.removeAllRanges(),t.addRange(n)}function aT(e){let t=rT(e);return t.length>0||e.childNodes.length===0?t:(bT(e,``),iT(e),``)}function oT(e){let t=new Set,n=Ig(),r;for(;(r=n.exec(e))!==null;){let e=r[1];e&&t.add(e)}return t}function sT(e){let t=window.getSelection();if(!t||t.rangeCount===0)return rT(e).length;let n=t.getRangeAt(0);if(!e.contains(n.startContainer))return rT(e).length;let r=document.createRange();r.selectNodeContents(e),r.setEnd(n.startContainer,n.startOffset);let i=document.createElement(`div`);return i.appendChild(r.cloneContents()),rT(i).length}var cT=new WeakMap;function lT(e,t){cT.set(e,t);for(let n of e.querySelectorAll(`[data-skill]`)){let e=`/${t(n.dataset.skill??``)}`;n.textContent!==e&&(n.textContent=e),n.title=`/${n.dataset.skill}`}}function uT(e,t){Xw.set(e,t);for(let n of e.querySelectorAll(`[data-context-ref-id]`)){let e=t(n.dataset.contextRefId??``);n.textContent=e?`@${e.title}`:`@reference`,n.title=e?.title??``,n.dataset.refKind=e?.kind??``,n.dataset.fileKind=e?.fileKind??``}}function dT(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.skill=t,n.className=`chat-skill-pill`,n.textContent=`/${cT.get(e)?.(t)??t}`,n.title=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Ww))}function fT(e,t){let n=Xw.get(e)?.(t),r=document.createElement(`span`);r.contentEditable=`false`,r.dataset.contextRefId=t,r.dataset.refKind=n?.kind??``,r.dataset.fileKind=n?.fileKind??``,r.className=`chat-context-ref-pill`,r.textContent=n?`@${n.title}`:`@reference`,r.title=n?.title??``,e.appendChild(r),e.appendChild(document.createTextNode(Ww))}function pT(e,t){let n=document.createElement(`span`);n.contentEditable=`false`,n.dataset.slashCommand=t,n.className=`chat-command-pill`,n.textContent=`/${t}`,e.appendChild(n),e.appendChild(document.createTextNode(Ww))}function mT(e){let t=[],n=n=>{let r,i=new RegExp(n.source,n.flags);for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length})};n(Ig()),n(as());for(let n of Lw(e))t.push(n);return t.sort((e,t)=>e.start-t.start),t}function hT(e,t){for(let{start:n,end:r}of mT(e))if(t>n&&t<=r)return{wire:e.slice(0,n)+e.slice(r),caret:n};return null}function gT(e,t){if(t<=0)return null;let n=e.slice(0,t),r=r=>{let i=n.match(r);if(i?.[1]){let r=i[1],a=n.length-r.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}return null},i=[Lg];for(let e of i){let t=r(e);if(t)return t}let a=Hw(n);if(a){let n=a.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}if(t===e.length){let r=[Rg];for(let i of r){let r=n.match(i);if(r?.[1]){let i=r[0],a=n.length-i.length;return{wire:e.slice(0,a)+e.slice(t),caret:a}}}let i=Uw(n);if(i){let n=i.tokenStart;return{wire:e.slice(0,n)+e.slice(t),caret:n}}}return null}function _T(e){let t=window.getSelection();if(!t||t.rangeCount===0||!t.isCollapsed)return!1;let n=t.getRangeAt(0),r=rT(e),i=sT(e);i===0&&r.length>0&&n.startContainer===e&&n.startOffset===e.childNodes.length&&(i=r.length);let a=hT(r,i);return a||=gT(r,i),a?(bT(e,a.wire,a.caret),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),!0):!1}function vT(e,t){let n=e.slice(t);return Kw.test(n)||as().exec(n)?.index===0?!0:Iw(e,t)!=null}function yT(e,t,n){let r=t.slice(n),i=[],a=r.match(Kw);a?.[0]&&i.push({len:a[0].length,apply:()=>dT(e,a[1]??``)});let o=as().exec(r);o?.index===0&&o[0]&&i.push({len:o[0].length,apply:()=>fT(e,o[1]??``)});let s=Iw(t,n);if(s&&i.push({len:s.len,apply:()=>pT(e,s.matchedKey)}),i.length===0){let r=n+1;for(;r<t.length&&!vT(t,r);)r+=1;let i=t.slice(n,r);return i&&e.appendChild(document.createTextNode(i)),r}return i.sort((e,t)=>t.len-e.len),i[0].apply(),n+i[0].len}function bT(e,t,n){e.replaceChildren();let r=t;if(n!==void 0){let e=Math.max(0,Math.min(n,t.length));r=t.slice(0,e)+Gw+t.slice(e)}let i=0;for(;i<r.length;)i=yT(e,r,i);if(n===void 0)return;let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o;for(;o=a.nextNode();){let e=o.textContent??``,t=-1;for(let n=0;n<e.length;n++)if(e[n]===Gw){t=n;break}if(t>=0){let n=o;n.textContent=e.slice(0,t)+e.slice(t+1);let r=window.getSelection(),i=document.createRange();i.setStart(n,t),i.collapse(!0),r?.removeAllRanges(),r?.addRange(i);return}}}function xT(e,t){for(let n of e)if(n.isActive()&&n.handleKey(t))return!0;return!1}function ST(e){return`${e.name}\0${e.size}`}function CT(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=ST(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var wT=8*1024,TT=80,ET=2*1024,DT=20;function OT(e){let t=e.trimStart().slice(0,8*1024);if(/^(?:<!doctype\s+html\b|<(?:html|head|body)\b)/i.test(t)||/^<(?:div|span|section|main|article|script|style)\b/i.test(t))return`html`;let n=e.trim();return(n.startsWith(`{`)&&n.endsWith(`}`)||n.startsWith(`[`)&&n.endsWith(`]`))&&/[\":,]/.test(t)?`json`:/(?:^|\n)\s*(?:(?:import|export|const|let|var|function|class|interface|type|def|SELECT|CREATE)\b|#!\/)/m.test(t)||/(?:=>|\{\s*$|;\s*$)/m.test(t)?`code`:`text`}function kT(e){let t=new TextEncoder().encode(e).byteLength,n=e.split(/\r\n|\n|\r/).length,r=OT(e);return t>=wT||n>=TT||r!==`text`&&(t>=ET||n>=DT)?{text:e,...r===`html`?{name:`pasted-text.html`,mimeType:`text/html`}:r===`json`?{name:`pasted-text.json`,mimeType:`application/json`}:r===`code`?{name:`pasted-code.txt`,mimeType:`text/plain`}:{name:`pasted-text.txt`,mimeType:`text/plain`},byteLength:t,lineCount:n}:null}function AT(e){if(!e)return null;let t=CT(e);if(t.length>0)return{kind:`files`,files:t};let n=e.getData(`text/plain`);if(!n)return null;let r=kT(n);return r?{kind:`text-attachment`,attachment:r}:{kind:`inline-text`,text:n}}async function jT(e,t){switch(e.kind){case`files`:await t.processFiles(e.files);return;case`unsupported-files`:t.onUnsupportedFiles();return;case`text-attachment`:await t.processPastedText(e.attachment);return;case`inline-text`:t.insertText(e.text)}}var MT=`fill-chat-composer`;function NT(e,t,n){window.dispatchEvent(new CustomEvent(MT,{detail:{text:e,attachments:t,contextRefs:n}}))}function PT(e,t){let n=t.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`,r=e.localizations?.[n]??e.localizations?.en,i=r?.displayName.trim()||e.name,a=r?.description.trim()||e.description,o=new Set([e.name]),s=new Set([e.description]);for(let t of Object.values(e.localizations??{}))t?.displayName.trim()&&o.add(t.displayName.trim()),t?.description.trim()&&s.add(t.description.trim());return o.delete(i),s.delete(a),{displayName:i,description:a,aliases:[...o],searchTerms:[...s]}}async function FT(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function IT(){let e=await we(J(`/api/skills`),{cache:`no-store`});if(!e.ok)throw Error(await FT(e));let t=await e.json();if(!t.payload)throw Error(`Invalid response`);return t.payload}async function LT(e){let t=await e.json().catch(()=>({}));if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;if(typeof e==`string`)return e}return`HTTP ${e.status}`}async function RT(){let e=await we(J(`/api/commands`));if(!e.ok)throw Error(await LT(e));return(await e.json()).payload?.commands??[]}var zT=6e4,BT=null,VT=0,HT=null,UT=null,WT=0,GT=null,KT=0,qT=new Map,JT=new Map,YT=0;function XT(e,t){let n=Se.getState();return`${e?.trim()||`main`}\u0000${JSON.stringify([n.baseUrl,n.conversationId,t?.trim()||``])}`}async function ZT(e=!1){return!e&&BT&&Date.now()<VT?(Nw(BT),BT):HT||(HT=RT().then(e=>(BT=e,VT=Date.now()+zT,Nw(e),e)).catch(e=>{throw Nw([]),e}).finally(()=>{HT=null}),HT)}async function QT(e,t,n=!1){let r=XT(e,t),i=Date.now(),a=qT.get(r);if(!n&&a&&i<a.expiry)return a.payload;let o=JT.get(r);if(o)return o;let s=YT,c=new URLSearchParams({agentId:e?.trim()||`main`});t?.trim()&&c.set(`conversationId`,t.trim());let l=we(J(`/api/chat/skills?${c.toString()}`)).then(async e=>{if(!e.ok)throw Error(await LT(e));let t=await e.json();if(!t.payload||!Array.isArray(t.payload.skills))throw Error(`Invalid /api/chat/skills response`);return s===YT&&qT.set(r,{payload:t.payload,expiry:Date.now()+zT}),t.payload}).finally(()=>{JT.delete(r)});return JT.set(r,l),l}async function $T(e,t,n){let r=e?.trim()||`main`,i=await QT(r,n,!0),a=new Set(i.effectiveAllowlist??i.agentAllowlist??[]);a.add(t);let o=await we(J(`/api/agents/${encodeURIComponent(r)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({skills:[...a].sort((e,t)=>e.localeCompare(t))})});if(!o.ok)throw Error(await LT(o));eE(r)}function eE(e){if(YT+=1,e){let t=`${e.trim()}\u0000`;for(let e of qT.keys())e.startsWith(t)&&qT.delete(e);for(let e of JT.keys())e.startsWith(t)&&JT.delete(e);return}qT.clear(),JT.clear()}async function tE(e){let t=await we(J(`/api/chat/workspace-trust?${new URLSearchParams({conversationId:e}).toString()}`));if(!t.ok)throw Error(await LT(t));let n=await t.json();if(!n.payload)throw Error(`Invalid /api/chat/workspace-trust response`);return n.payload}async function nE(e,t){let n=await we(J(`/api/chat/workspace-trust`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({conversationId:e,trusted:t})});if(!n.ok)throw Error(await LT(n));let r=await n.json();if(!r.payload)throw Error(`Invalid /api/chat/workspace-trust response`);return rE(),r.payload}function rE(e){eE(e),e||(KT+=1,UT=null,WT=0,GT=null)}async function iE(e=!1){if(!e&&UT&&Date.now()<WT)return UT;if(GT)return GT;let t=KT;return GT=IT().then(e=>(t===KT&&(UT=e,WT=Date.now()+zT),e)).finally(()=>{GT=null}),GT}function aE(e,t,n){let r=(0,Q.c)(20),i=n===void 0?!0:n,a=Ee(cE),o=Se(sE),s=Se(oE),c;r[0]!==e||r[1]!==s||r[2]!==t||r[3]!==i||r[4]!==o?(c=i&&o?[`chat-skill-labels`,s,o,e??`main`,t??``]:null,r[0]=e,r[1]=s,r[2]=t,r[3]=i,r[4]=o,r[5]=c):c=r[5];let l;r[6]!==e||r[7]!==t?(l=()=>QT(e,t),r[6]=e,r[7]=t,r[8]=l):l=r[8];let u;r[9]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1,shouldRetryOnError:!1},r[9]=u):u=r[9];let{data:d,mutate:f}=Zt(c,l,u),p,m;r[10]!==i||r[11]!==o||r[12]!==f?(p=()=>{if(!i||!o)return;let e=e=>{let t=e.detail?.section;(t===`skills`||t===`agents`)&&f()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},m=[i,o,f],r[10]=i,r[11]=o,r[12]=f,r[13]=p,r[14]=m):(p=r[13],m=r[14]),(0,Z.useEffect)(p,m);let h;r[15]!==d?.skills||r[16]!==a?(h=new Map(d?.skills.map(e=>[e.name,PT(e,a).displayName])),r[15]=d?.skills,r[16]=a,r[17]=h):h=r[17];let g=h,_;return r[18]===g?_=r[19]:(_=e=>g.get(e)??e,r[18]=g,r[19]=_),_}function oE(e){return e.baseUrl}function sE(e){return e.conversationId}function cE(e){return e.language}function lE(e,t){e.classList.toggle(`composer-input-empty`,t.length===0)}function uE(e){let{disabled:t,initialValue:n=``,onValueChange:r,autoFocusKey:i,welcomeDraftSeed:a,onExternalTextReplace:o,shouldSyncSelectionRef:s,resolveContextRef:c}=e,l=aE(e.agentId,e.conversationId),[u,d]=(0,Z.useState)(n),[f,p]=(0,Z.useState)(n.length),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(u),v=(0,Z.useRef)(f),y=(0,Z.useRef)(null),b=(0,Z.useRef)(0),x=(0,Z.useRef)(r),S=(0,Z.useRef)(!0),C=(0,Z.useRef)(null),w=(0,Z.useRef)(!1);_.current=u,v.current=f,x.current=r;let T=(0,Z.useCallback)(()=>{let e=g.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,128)}px`)},[]);(0,Z.useLayoutEffect)(()=>{let e=g.current;!e||m||(lT(e,l),c&&uT(e,c),T())},[l,c,m,T]),(0,Z.useLayoutEffect)(()=>{if(w.current)return;let e=g.current;e&&(w.current=!0,c&&uT(e,c),bT(e,n,n.length),lE(e,n),T())},[T,n,c]);let E=(0,Z.useCallback)(()=>{let e=g.current;if(!e)return;e.focus({preventScroll:!0});let t=window.getSelection(),n=y.current;if(t&&n?.startContainer.isConnected&&n.endContainer.isConnected&&e.contains(n.startContainer)&&e.contains(n.endContainer)){t.removeAllRanges(),t.addRange(n);return}bT(e,_.current,v.current)},[]),D=(0,Z.useCallback)(e=>{let t=e?.nextText??``,n=e?.caretOffset??t.length;d(t),x.current?.(t),_.current=t,p(n),v.current=n,y.current=null;let r=g.current;r&&(bT(r,t,n),lE(r,t),e?.focus&&r.focus({preventScroll:!0})),T()},[T]);(0,Z.useEffect)(()=>{T()},[u,T]);let O=(0,Z.useRef)(a?.id??0);return a&&a.id!==O.current&&(O.current=a.id,b.current=a.id,o?.(),D({nextText:a.text,focus:typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches})),(0,Z.useLayoutEffect)(()=>{if(t){S.current=!0;return}let e=i??null,n=S.current,r=e!=null&&e!==C.current;if(!n&&!r)return;S.current=!1,e!=null&&(C.current=e);let a=requestAnimationFrame(()=>{typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(`(hover: hover) and (pointer: fine)`).matches&&g.current?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(a)},[t,i]),(0,Z.useEffect)(()=>{let e=g.current;if(!e)return;let t=!1,n=null,r=!1,i=-1,a=()=>{let t=window.getSelection();if(!t?.rangeCount||!e.contains(t.anchorNode)||!e.contains(t.focusNode))return null;let n=sT(e);return v.current=n,y.current=t.getRangeAt(0).cloneRange(),n},o=()=>{if(n=null,r=!1,document.activeElement!==e)return;let t=a();t!==null&&t!==i&&(i=t,s.current&&p(t))},c=()=>{t&&(r||(r=!0,n=requestAnimationFrame(o)))},l=()=>{t||(t=!0,document.addEventListener(`selectionchange`,c),c())},u=()=>{t&&(t=!1,document.removeEventListener(`selectionchange`,c),n!=null&&cancelAnimationFrame(n),n=null,r=!1)},d=()=>l(),f=()=>{a(),u()};return e.addEventListener(`focus`,d),e.addEventListener(`blur`,f),document.activeElement===e&&l(),()=>{e.removeEventListener(`focus`,d),e.removeEventListener(`blur`,f),u()}},[s]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;typeof t?.text==`string`&&(o?.(t),D({nextText:t.text,focus:!0}))};return window.addEventListener(MT,e),()=>window.removeEventListener(MT,e)},[o,D]),{value:u,cursor:f,isComposing:m,setIsComposing:h,editorRef:g,valueRef:_,adjustHeight:T,focusForExternalPaste:E,resetEditor:D,onWireInput:(0,Z.useCallback)((e,t)=>{_.current=e,v.current=t,d(e),x.current?.(e),p(t)},[])}}var dE=(0,Z.memo)(function(e){let t=(0,Q.c)(33),{editorRef:n,disabled:r,hidden:i,placeholder:a,ariaLabel:o,onWireInput:s,adjustHeight:c,processFiles:l,processPastedText:u,setIsComposing:d,kbdRef:f,chatMessages:p}=e,m=(0,Z.useRef)(!1),h,g;t[0]!==r||t[1]!==n?(h=()=>{let e=n.current;if(!e||r)return;let t=t=>{t.inputType!==`deleteContentBackward`||!t.cancelable||t.isComposing||m.current||_T(e)&&t.preventDefault()};return e.addEventListener(`beforeinput`,t),()=>e.removeEventListener(`beforeinput`,t)},g=[r,n],t[0]=r,t[1]=n,t[2]=h,t[3]=g):(h=t[2],g=t[3]),(0,Z.useEffect)(h,g);let _=o??a,v=!r,y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=K(`composer-input box-border m-0 max-h-24 min-h-12 w-full overflow-y-auto border-0 bg-transparent px-0 py-1.5 text-[0.9375rem] leading-6 text-fg focus:outline-none focus:ring-0 disabled:opacity-50 sm:max-h-32 sm:min-h-16 sm:py-2`,`composer-input-empty`),t[4]=y):y=t[4];let b;t[5]!==c||t[6]!==s?(b=e=>{let t=e.currentTarget,n=m.current?rT(t):aT(t);lE(t,n),s(n,sT(t)),c()},t[5]=c,t[6]=s,t[7]=b):b=t[7];let x;t[8]===d?x=t[9]:(x=()=>{m.current=!0,d(!0)},t[8]=d,t[9]=x);let S;t[10]!==c||t[11]!==n||t[12]!==s||t[13]!==d?(S=()=>{m.current=!1,d(!1),queueMicrotask(()=>{let e=n.current;if(!e||m.current)return;let t=aT(e);lE(e,t),s(t,sT(e)),c()})},t[10]=c,t[11]=n,t[12]=s,t[13]=d,t[14]=S):S=t[14];let C;t[15]!==p||t[16]!==l||t[17]!==u?(C=async e=>{let t=AT(e.clipboardData);t&&(e.preventDefault(),await jT(t,{processFiles:l,processPastedText:u,insertText:fE,onUnsupportedFiles:()=>Yl(`warning`,p.clipboardFileTypeUnsupported)}))},t[15]=p,t[16]=l,t[17]=u,t[18]=C):C=t[18];let w;t[19]!==n||t[20]!==f?(w=e=>{let t=f.current;if(e.key===`Backspace`&&!t.isComposing&&!m.current&&!e.nativeEvent.isComposing&&n.current&&_T(n.current)){e.preventDefault();return}if(xT(t.adapters,e))return;if(e.key===`Tab`&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!t.isComposing&&!t.valueRef.current.trim()&&t.acceptEmptySuggestion?.()){e.preventDefault();return}if(!t.isComposing&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){let n=e.key===`ArrowUp`?`up`:`down`;if(t.tryInputHistoryArrow?.(n)){e.preventDefault(),t.adjustHeight();return}}if(e.key===`Escape`&&!t.isComposing&&t.editingFollowUpId){e.preventDefault(),t.onCancelEditFollowUp?.();return}if(e.key===`Enter`&&e.shiftKey&&!t.isComposing){e.preventDefault(),document.execCommand(`insertText`,!1,`
24
- `);return}let r=typeof KeyboardEvent<`u`&&e.nativeEvent instanceof KeyboardEvent&&e.nativeEvent.isComposing;if(e.key===`Enter`&&!e.shiftKey&&!t.isComposing&&!r){e.preventDefault();let n=!!(t.valueRef.current.trim()||t.attachmentsLen>0||t.contextRefsLen>0);if(t.runBusy||t.pendingFollowUpsCount>0){if((e.metaKey||e.ctrlKey)&&n){t.interruptDraft?.();return}if(!e.metaKey&&!e.ctrlKey&&!e.altKey&&n){t.flushSteeringDraft?.();return}return}n&&t.send()}},t[19]=n,t[20]=f,t[21]=w):w=t[21];let T;return t[22]!==n||t[23]!==i||t[24]!==a||t[25]!==w||t[26]!==_||t[27]!==v||t[28]!==b||t[29]!==x||t[30]!==S||t[31]!==C?(T=(0,$.jsx)(`div`,{ref:n,hidden:i,role:`textbox`,"aria-multiline":`true`,"aria-label":_,contentEditable:v,suppressContentEditableWarning:!0,spellCheck:!0,className:y,"data-placeholder":a,onInput:b,onCompositionStart:x,onCompositionEnd:S,onPaste:C,onKeyDown:w}),t[22]=n,t[23]=i,t[24]=a,t[25]=w,t[26]=_,t[27]=v,t[28]=b,t[29]=x,t[30]=S,t[31]=C,t[32]=T):T=t[32],T});function fE(e){return document.execCommand(`insertText`,!1,e)}var pE=120*1e3,mE=new Map;function hE(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function gE(e){for(let[t,n]of mE)n.expiresAt<=e&&mE.delete(t)}function _E(e,t=Date.now()){gE(t);let n=hE();return mE.set(n,{file:e,name:e.name,type:e.type,expiresAt:t+pE}),n}function vE(e,t=Date.now()){let n=mE.get(e);return n?n.expiresAt<=t?(mE.delete(e),null):{name:n.name,type:n.type}:null}function yE(e,t=Date.now()){let n=mE.get(e);if(!n)return null;if(n.expiresAt<=t)return mE.delete(e),null;if(!n.file)return null;let r=n.file;return n.file=null,r}var bE=`<base href="about:srcdoc">`;function xE(e){if(/<base(?:\s|>)/i.test(e))return e;let t=/<head(?:\s[^>]*)?>/i.exec(e);if(t?.index!==void 0){let n=t.index+t[0].length;return`${e.slice(0,n)}${bE}${e.slice(n)}`}let n=/<html(?:\s[^>]*)?>/i.exec(e);if(n?.index!==void 0){let t=n.index+n[0].length;return`${e.slice(0,t)}<head>${bE}</head>${e.slice(t)}`}let r=/^\s*<!doctype[^>]*>/i.exec(e);return r?`${r[0]}<head>${bE}</head>${e.slice(r[0].length)}`:`<head>${bE}</head>${e}`}function SE(e){let t=(0,Q.c)(8),{html:n,title:r}=e,i=(0,Z.useRef)(null),a;t[0]===n?a=t[1]:(a=()=>{i.current?.contentWindow?.postMessage({type:`xopc-html-preview`,html:xE(n)},`*`)},t[0]=n,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=[o],t[2]=o,t[3]=s),(0,Z.useEffect)(o,s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=J(`/api/preview/html`),t[4]=c):c=t[4];let l;return t[5]!==o||t[6]!==r?(l=(0,$.jsx)(`iframe`,{ref:i,title:r,className:`min-h-0 w-full flex-1 rounded-lg border border-edge-subtle bg-white dark:border-edge dark:bg-[#1e1e1e]`,src:c,sandbox:`allow-scripts allow-popups allow-popups-to-escape-sandbox allow-downloads allow-forms allow-modals`,referrerPolicy:`no-referrer`,onLoad:o}),t[5]=o,t[6]=r,t[7]=l):l=t[7],l}var CE=(0,Z.lazy)(()=>s(()=>import(`./source-workspace-editor-DunRD1gY.js`).then(e=>({default:e.SourceWorkspaceEditor})),__vite__mapDeps([149,1,93,4,97,150,7])));function wE(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col px-4 py-3`,"aria-busy":!0,children:[(0,$.jsx)(`div`,{className:`h-4 w-11/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-9/12 animate-pulse rounded bg-surface-hover`}),(0,$.jsx)(`div`,{className:`mt-3 h-4 w-10/12 animate-pulse rounded bg-surface-hover`})]}),e[0]=t):t=e[0],t}function TE(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t).toLowerCase():``}function EE(e){return{".ts":`typescript`,".tsx":`tsx`,".js":`javascript`,".jsx":`jsx`,".json":`json`,".css":`css`,".yml":`yaml`,".yaml":`yaml`,".py":`python`,".go":`go`,".rs":`rust`,".sh":`bash`}[TE(e)]??`plaintext`}function DE(e){let t=(0,Q.c)(12),{text:n,targetLine:r}=e,i=(0,Z.useRef)(null),a;if(t[0]!==n){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\r\n|\n|\r/,t[2]=e):e=t[2],a=n.split(e),t[0]=n,t[1]=a}else a=t[1];let o=a,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{i.current?.scrollIntoView({block:`center`})},t[3]=s):s=t[3];let c;t[4]!==r||t[5]!==n?(c=[r,n],t[4]=r,t[5]=n,t[6]=c):c=t[6],(0,Z.useEffect)(s,c);let l;t[7]!==o||t[8]!==r?(l=o.map((e,t)=>{let n=t+1,a=n===r;return(0,$.jsxs)(`div`,{ref:a?i:void 0,className:a?`flex bg-accent-soft/60 text-fg`:`flex`,"data-line":n,children:[(0,$.jsx)(`span`,{className:`w-12 shrink-0 select-none pr-3 text-right text-fg-subtle`,children:n}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap break-words`,children:e||` `})]},n)}),t[7]=o,t[8]=r,t[9]=l):l=t[9];let u;return t[10]===l?u=t[11]:(u=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto px-4 py-3`,children:(0,$.jsx)(`div`,{className:`min-w-max font-mono text-xs leading-relaxed text-fg`,children:l})}),t[10]=l,t[11]=u),u}function OE(e,t){let n=e.textContent??``,r=e.descriptor.context===`workspace`,i=e.workspaceEditing;return r&&i?.sourceEditMode?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(wE,{}),children:(0,$.jsx)(CE,{fileName:e.descriptor.fileName,initialContent:n,onChange:e=>i.onSourceChange?.(e),isDark:(i.isDark??e.resolvedTheme===`dark`)===!0,lineWrap:i.sourceWordWrap===!0},e.descriptor.id)})}):t===`markdown`?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(ie,{content:n})}):t===`html`?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:(0,$.jsx)(SE,{html:n,title:e.descriptor.fileName})}):e.targetLine&&e.targetLine>0?(0,$.jsx)(DE,{text:n,targetLine:e.targetLine}):t===`code`?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(ie,{content:`\`\`\`${EE(e.descriptor.fileName)}\n${n}\n\`\`\``})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs text-fg`,children:n})})}function kE(e){return OE(e,`text`)}function AE(e){return OE(e,`markdown`)}function jE(e){return OE(e,`code`)}function ME(e){return OE(e,`html`)}function NE(){return(0,Z.createElement)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`},`Loading preview...`)}function PE(e,t,n,r=`binary`){let i=(0,Z.lazy)(n);return{id:e,readMode:r,capabilities:t,render:e=>(0,Z.createElement)(Z.Suspense,{fallback:NE()},(0,Z.createElement)(i,e))}}var FE={text:{id:`text`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,Z.createElement)(kE,e)},markdown:{id:`markdown`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,Z.createElement)(AE,e)},code:{id:`code`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,Z.createElement)(jE,e)},html:{id:`html`,readMode:`text`,capabilities:[`download`,`edit`],render:e=>(0,Z.createElement)(ME,e)},image:PE(`image`,[`download`,`zoom`,`rotate`],()=>s(()=>import(`./binary-plugins-D3WB-tVn.js`).then(e=>({default:e.InteractiveImagePreview})),__vite__mapDeps([151,1,7,4,152,153,19,9,39,15,124,28]))),pdf:PE(`pdf`,[`download`,`zoom`,`rotate`,`pageNavigation`,`print`],()=>s(()=>import(`./binary-plugins-D3WB-tVn.js`).then(e=>({default:e.PdfPreviewPluginView})),__vite__mapDeps([151,1,7,4,152,153,19,9,39,15,124,28]))),docx:PE(`docx`,[`download`],()=>s(()=>import(`./binary-plugins-D3WB-tVn.js`).then(e=>({default:e.DocxPreviewPluginView})),__vite__mapDeps([151,1,7,4,152,153,19,9,39,15,124,28]))),spreadsheet:PE(`spreadsheet`,[`download`],()=>s(()=>import(`./binary-plugins-D3WB-tVn.js`).then(e=>({default:e.SpreadsheetPreviewPluginView})),__vite__mapDeps([151,1,7,4,152,153,19,9,39,15,124,28]))),pptx:PE(`pptx`,[`download`],()=>s(()=>import(`./binary-plugins-D3WB-tVn.js`).then(e=>({default:e.PptxPreviewPluginView})),__vite__mapDeps([151,1,7,4,152,153,19,9,39,15,124,28]))),audio:PE(`audio`,[`download`],()=>s(()=>import(`./media-plugins-DLJrmU9J.js`).then(e=>({default:e.AudioPreviewPluginView})),__vite__mapDeps([154,1,4,152,153,19,9,39,15,124,28]))),video:PE(`video`,[`download`],()=>s(()=>import(`./media-plugins-DLJrmU9J.js`).then(e=>({default:e.VideoPreviewPluginView})),__vite__mapDeps([154,1,4,152,153,19,9,39,15,124,28]))),archive:PE(`archive`,[`download`],()=>s(()=>import(`./archive-plugin-_EzRfBuI.js`).then(e=>({default:e.ArchivePreviewPluginView})),__vite__mapDeps([155,1,4,156,153,19,9,39,15,124,28]))),unsupported:PE(`unsupported`,[`download`],()=>s(()=>import(`./media-plugins-DLJrmU9J.js`).then(e=>({default:e.UnsupportedPreviewPluginView})),__vite__mapDeps([154,1,4,152,153,19,9,39,15,124,28])),`metadata`)};function IE(e){return FE[e]??FE.unsupported}function LE(e){let t=(0,Q.c)(63),{plugin:n,controls:r,onZoomIn:i,onZoomOut:a,onZoomReset:o,onRotate:s,onSearchChange:c}=e,l;t[0]===n.capabilities?l=t[1]:(l=n.capabilities.includes(`zoom`),t[0]=n.capabilities,t[1]=l);let u=l,d;t[2]===n.capabilities?d=t[3]:(d=n.capabilities.includes(`search`),t[2]=n.capabilities,t[3]=d);let f=d,p;t[4]===n.capabilities?p=t[5]:(p=n.capabilities.includes(`rotate`),t[4]=n.capabilities,t[5]=p);let m=p,h;t[6]!==r||t[7]!==n.capabilities?(h=n.capabilities.includes(`pageNavigation`)&&r.pageCount!=null&&r.pageCount>1,t[6]=r,t[7]=n.capabilities,t[8]=h):h=t[8];let g=h;if(!(u||f||m||g))return null;let _;if(t[9]!==g||t[10]!==m||t[11]!==f||t[12]!==u||t[13]!==r||t[14]!==s||t[15]!==c||t[16]!==i||t[17]!==a||t[18]!==o){let e=[];if(g){let n=r.page<=1,i;t[20]===r?i=t[21]:(i=()=>r.setPage(Math.max(1,r.page-1)),t[20]=r,t[21]=i);let a;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(aa,{className:`size-3.5`}),t[22]=a):a=t[22];let o;t[23]!==n||t[24]!==i?(o=(0,$.jsx)(RE,{label:`Previous page`,disabled:n,onClick:i,children:a}),t[23]=n,t[24]=i,t[25]=o):o=t[25];let s;t[26]!==r.page||t[27]!==r.pageCount?(s=(0,$.jsxs)(`span`,{className:`min-w-16 px-1 text-center text-xs text-fg-muted`,children:[r.page,` / `,r.pageCount]}),t[26]=r.page,t[27]=r.pageCount,t[28]=s):s=t[28];let c=r.page>=(r.pageCount??1),l;t[29]===r?l=t[30]:(l=()=>r.setPage(Math.min(r.pageCount??r.page,r.page+1)),t[29]=r,t[30]=l);let u;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(ia,{className:`size-3.5`}),t[31]=u):u=t[31];let d;t[32]!==c||t[33]!==l?(d=(0,$.jsx)(RE,{label:`Next page`,disabled:c,onClick:l,children:u}),t[32]=c,t[33]=l,t[34]=d):d=t[34];let f;t[35]!==s||t[36]!==d||t[37]!==o?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[o,s,d]},`page`),t[35]=s,t[36]=d,t[37]=o,t[38]=f):f=t[38],e.push(f)}if(u){let n;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(H,{className:`size-3.5`}),t[39]=n):n=t[39];let s;t[40]===a?s=t[41]:(s=(0,$.jsx)(RE,{label:`Zoom out`,onClick:a,children:n}),t[40]=a,t[41]=s);let c;t[42]===r.zoom?c=t[43]:(c=Math.round(r.zoom*100),t[42]=r.zoom,t[43]=c);let l;t[44]!==o||t[45]!==c?(l=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-14 rounded px-1.5 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:o,title:`Reset zoom`,children:[c,`%`]}),t[44]=o,t[45]=c,t[46]=l):l=t[46];let u;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(ge,{className:`size-3.5`}),t[47]=u):u=t[47];let d;t[48]===i?d=t[49]:(d=(0,$.jsx)(RE,{label:`Zoom in`,onClick:i,children:u}),t[48]=i,t[49]=d);let f;t[50]!==d||t[51]!==s||t[52]!==l?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-base p-0.5 dark:border-edge`,children:[s,l,d]},`zoom`),t[50]=d,t[51]=s,t[52]=l,t[53]=f):f=t[53],e.push(f)}if(m){let n;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(_e,{className:`size-3.5`}),t[54]=n):n=t[54];let r;t[55]===s?r=t[56]:(r=(0,$.jsx)(RE,{label:`Rotate`,onClick:s,children:n},`rotate`),t[55]=s,t[56]=r),e.push(r)}if(f){let n;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),t[57]=n):n=t[57];let i;t[58]===c?i=t[59]:(i=e=>c(e.target.value),t[58]=c,t[59]=i);let a;t[60]!==r.searchQuery||t[61]!==i?(a=(0,$.jsxs)(`label`,{className:`flex min-w-40 items-center gap-1 rounded-md border border-edge-subtle bg-surface-base px-2 py-1 text-xs text-fg-muted dark:border-edge`,children:[n,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:r.searchQuery,onChange:i,placeholder:`Search`})]},`search`),t[60]=r.searchQuery,t[61]=i,t[62]=a):a=t[62],e.push(a)}_=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:e}),t[9]=g,t[10]=m,t[11]=f,t[12]=u,t[13]=r,t[14]=s,t[15]=c,t[16]=i,t[17]=a,t[18]=o,t[19]=_}else _=t[19];return _}function RE(e){let t=(0,Q.c)(6),{label:n,disabled:r,onClick:i,children:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=K(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:opacity-40`),t[0]=o):o=t[0];let s;return t[1]!==a||t[2]!==r||t[3]!==n||t[4]!==i?(s=(0,$.jsx)(`button`,{type:`button`,className:o,title:n,"aria-label":n,disabled:r,onClick:i,children:a}),t[1]=a,t[2]=r,t[3]=n,t[4]=i,t[5]=s):s=t[5],s}function zE(e){let t=(0,Q.c)(22),n;t[0]===e.type?n=t[1]:(n=IE(e.type),t[0]=e.type,t[1]=n);let r=n,[i,a]=(0,Z.useState)(1),[o,s]=(0,Z.useState)(0),[c,l]=(0,Z.useState)(1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(``),m;t[2]===u?m=t[3]:(m=e=>{l(Math.max(1,Math.min(u??e,Math.floor(e))))},t[2]=u,t[3]=m);let h=m,g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{a(1),s(0),l(1),d(null),p(``)},t[4]=g):g=t[4];let _;t[5]!==e.id||t[6]!==e.type?(_=[e.id,e.type],t[5]=e.id,t[6]=e.type,t[7]=_):_=t[7],(0,Z.useEffect)(g,_);let v;t[8]!==c||t[9]!==u||t[10]!==o||t[11]!==f||t[12]!==h||t[13]!==i?(v={zoom:i,rotation:o,page:c,pageCount:u,searchQuery:f,setPageCount:d,setPage:h},t[8]=c,t[9]=u,t[10]=o,t[11]=f,t[12]=h,t[13]=i,t[14]=v):v=t[14];let y=v,b,x,S,C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>a(HE),x=()=>a(VE),S=()=>{a(1),s(0)},C=()=>s(BE),t[15]=b,t[16]=x,t[17]=S,t[18]=C):(b=t[15],x=t[16],S=t[17],C=t[18]);let w;return t[19]!==y||t[20]!==r?(w={plugin:r,controls:y,onZoomIn:b,onZoomOut:x,onZoomReset:S,onRotate:C,onSearchChange:p},t[19]=y,t[20]=r,t[21]=w):w=t[21],w}function BE(e){return(e+90)%360}function VE(e){return Math.max(.25,Number((e-.15).toFixed(2)))}function HE(e){return Math.min(4,Number((e+.15).toFixed(2)))}function UE(e){let t=(0,Q.c)(8),{controller:n}=e,r;return t[0]!==n.controls||t[1]!==n.onRotate||t[2]!==n.onSearchChange||t[3]!==n.onZoomIn||t[4]!==n.onZoomOut||t[5]!==n.onZoomReset||t[6]!==n.plugin?(r=(0,$.jsx)(LE,{plugin:n.plugin,controls:n.controls,onZoomIn:n.onZoomIn,onZoomOut:n.onZoomOut,onZoomReset:n.onZoomReset,onRotate:n.onRotate,onSearchChange:n.onSearchChange}),t[0]=n.controls,t[1]=n.onRotate,t[2]=n.onSearchChange,t[3]=n.onZoomIn,t[4]=n.onZoomOut,t[5]=n.onZoomReset,t[6]=n.plugin,t[7]=r):r=t[7],r}function WE(e){let t=(0,Q.c)(14),n;t[0]===e.language?n=t[1]:(n=xe(e.language),t[0]=e.language,t[1]=n);let r=n,{controller:i}=e;if(e.loading){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 px-4 py-6`,"aria-busy":`true`,children:[(0,$.jsx)(xn,{className:`h-5 w-48 max-w-full`}),(0,$.jsx)(xn,{className:`h-4 w-full`}),(0,$.jsx)(xn,{className:`h-4 w-11/12`}),(0,$.jsx)(xn,{className:`h-4 w-3/4`}),(0,$.jsx)(xn,{className:`mt-3 min-h-48 flex-1 rounded-lg`})]}),t[2]=e):e=t[2],e}if(e.loadError){let n=(e.descriptor.context===`workspace`?r.workspace.loadError:r.chat.attachmentPreviewLoadError)+`: `+e.loadError,i;return t[3]===n?i=t[4]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n})}),t[3]=n,t[4]=i),i}if(e.descriptor.context===`attachment`&&e.showExtractedText&&e.descriptor.type!==`image`){let n=e.extractedText||r.chat.attachmentPreviewNoText,i;return t[5]===n?i=t[6]:(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-hover/40 p-4 dark:border-edge`,children:(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted`,children:n})})}),t[5]=n,t[6]=i),i}let a=`${e.descriptor.id}:${i.plugin.id}`,o;t[7]!==i.controls||t[8]!==e?(o={...e,controls:i.controls},t[7]=i.controls,t[8]=e,t[9]=o):o=t[9];let s;return t[10]!==i.plugin.render||t[11]!==a||t[12]!==o?(s=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(GE,{pluginRender:i.plugin.render,props:o},a)}),t[10]=i.plugin.render,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function GE(e){let t=(0,Q.c)(5),{pluginRender:n,props:r}=e,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),t[3]=i,t[4]=a),a}function KE(e){let t=(0,Q.c)(9),{label:n,active:r,disabled:i,onClick:a,children:o}=e,s=r&&`bg-surface-active text-fg`,c;t[0]===s?c=t[1]:(c=K(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-40`,s,yc.focusRingPanel),t[0]=s,t[1]=c);let l;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n||t[6]!==a||t[7]!==c?(l=(0,$.jsx)(`button`,{type:`button`,className:c,title:n,"aria-label":n,"aria-pressed":r,disabled:i,onClick:a,children:o}),t[2]=r,t[3]=o,t[4]=i,t[5]=n,t[6]=a,t[7]=c,t[8]=l):l=t[8],l}function qE(e){let t=(0,Q.c)(9),{icon:n,label:r,disabled:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-fg-muted`,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,$.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`flex h-9 w-full min-w-0 items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-40`,disabled:i,onClick:a,children:[o,s]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function JE(e){let t=(0,Q.c)(36),{name:n,subtitle:r,controller:i,actions:a,expanded:o,onToggleExpanded:s,onClose:c,edit:l,wordWrap:u,editInNewChat:d,share:f,openWithSystemApp:p,chooseApp:m,recommendedApps:h,recentApps:g,onOpenWithApp:_,onRevealInFolder:v,copyPath:y,textView:b,openInBrowser:x}=e,C=h===void 0?[]:h,w=g===void 0?[]:g,T=xe(Ee(ZE)),E=T.workspace,D=i.plugin.id===`pdf`?T.chat.attachmentPreviewPdf:i.plugin.id===`docx`?T.chat.attachmentPreviewDocument:i.plugin.id===`spreadsheet`?T.chat.attachmentPreviewSpreadsheet:E.preview,O=An(),[k,A]=(0,Z.useState)(!1),j;t[0]===i.plugin.capabilities?j=t[1]:(j=i.plugin.capabilities.some(XE),t[0]=i.plugin.capabilities,t[1]=j);let M=j,R,z;t[2]===k?(R=t[3],z=t[4]):(R=()=>{if(!k)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),A(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},z=[k],t[2]=k,t[3]=R,t[4]=z),(0,Z.useEffect)(R,z);let B;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{A(!1),e()},t[5]=B):B=t[5];let H=B,U;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(U=K(`shrink-0 bg-surface-hover/20 px-3 py-2 sm:px-4`,md),t[6]=U):U=t[6];let W;t[7]===n?W=t[8]:(W=(0,$.jsx)(`h2`,{className:`truncate text-base font-semibold leading-tight tracking-tight text-fg`,title:n,children:n}),t[7]=n,t[8]=W);let G;t[9]===r?G=t[10]:(G=r?(0,$.jsx)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-2 text-xs leading-tight text-fg-muted`,children:r}):null,t[9]=r,t[10]=G);let ee;t[11]!==W||t[12]!==G?(ee=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 py-0.5`,children:[W,G]}),t[11]=W,t[12]=G,t[13]=ee):ee=t[13];let te;t[14]===o?te=t[15]:(te=o?(0,$.jsx)(me,{className:`size-4`,strokeWidth:1.75}):(0,$.jsx)(V,{className:`size-4`,strokeWidth:1.75}),t[14]=o,t[15]=te);let ne;t[16]===d?.loading?ne=t[17]:(ne=d?.loading?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(fe,{className:`size-4`}),t[16]=d?.loading,t[17]=ne);let re;t[18]===f?.loading?re=t[19]:(re=f?.loading?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(le,{className:`size-4`}),t[18]=f?.loading,t[19]=re);let ie;t[20]===k?ie=t[21]:(ie=k?(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-40 cursor-default bg-transparent`,"aria-hidden":!0,tabIndex:-1,onPointerDown:e=>{e.preventDefault(),A(!1)}}):null,t[20]=k,t[21]=ie);let ae;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(ae=K(`inline-flex size-9 shrink-0 items-center justify-center rounded-md text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel),t[22]=ae):ae=t[22];let se,ce;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>A(YE),ce=(0,$.jsx)(F,{className:`size-4`}),t[23]=se,t[24]=ce):(se=t[23],ce=t[24]);let de;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`div`,{className:`mx-0.5 h-5 w-px bg-edge-subtle`,"aria-hidden":!0}),t[25]=de):de=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.75}),t[26]=pe):pe=t[26];let ge;t[27]!==E.close||t[28]!==c?(ge=(0,$.jsx)(KE,{label:E.close,onClick:c,children:pe}),t[27]=E.close,t[28]=c,t[29]=ge):ge=t[29];let _e;return t[30]!==i||t[31]!==M||t[32]!==T||t[33]!==D||t[34]!==b?(_e=M||b?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 overflow-x-auto pb-0.5`,children:[b?(0,$.jsx)(`div`,{className:`mr-2 flex shrink-0 rounded-lg bg-surface-hover p-0.5`,role:`group`,"aria-label":T.chat.attachmentPreviewText,children:[{active:!1,label:D},{active:!0,label:T.chat.attachmentPreviewText}].map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":b.active===e.active,className:K(`rounded-md px-2.5 py-1 text-xs font-medium`,b.active===e.active?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),onClick:()=>b.onChange(e.active),children:e.label},e.label))}):null,M?(0,$.jsx)(UE,{controller:i}):null]}):null,t[30]=i,t[31]=M,t[32]=T,t[33]=D,t[34]=b,t[35]=_e):_e=t[35],(0,$.jsxs)(`div`,{className:U,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[ee,(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[i.plugin.capabilities.includes(`edit`)?(0,$.jsx)(KE,{label:l?.active?E.preview:E.edit,active:l?.active??!1,disabled:!l,onClick:l?.onToggle,children:l?.active?(0,$.jsx)(L,{className:`size-4`}):(0,$.jsx)(he,{className:`size-4`})}):null,u?(0,$.jsx)(KE,{label:E.wordWrap,active:u.active,onClick:u.onToggle,children:(0,$.jsx)(la,{className:`size-4`})}):null,(0,$.jsx)(KE,{label:o?E.collapsePreview:E.expandPreview,active:o,disabled:!s,onClick:s,children:te}),(0,$.jsx)(KE,{label:E.editInNewChat,disabled:!d||d.disabled||d.loading,onClick:d?.onClick,children:ne}),(0,$.jsx)(KE,{label:E.shareLink,disabled:!f||f.disabled||f.loading,onClick:f?.onClick,children:re}),(0,$.jsxs)(`div`,{className:`relative shrink-0`,children:[ie,(0,$.jsx)(`button`,{type:`button`,className:ae,title:E.moreActions,"aria-label":E.moreActions,"aria-haspopup":`menu`,"aria-expanded":k,onClick:se,children:ce}),k?(0,$.jsxs)(`div`,{role:`menu`,"data-file-preview-menu":!0,className:`absolute right-0 top-full z-50 mt-1 w-60 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[x?(0,$.jsxs)(`a`,{href:x.href,target:`_blank`,rel:`noopener noreferrer`,role:`menuitem`,className:`flex h-9 w-full items-center gap-2.5 rounded-md px-2.5 text-sm text-fg hover:bg-surface-hover`,onClick:()=>A(!1),children:[(0,$.jsx)(I,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),E.openInBrowser]}):null,p?(0,$.jsx)(qE,{icon:(0,$.jsx)(I,{className:`size-4`}),label:E.openSystemApp,disabled:p.disabled||p.loading,onClick:()=>H(p.onClick)}):null,m?(0,$.jsx)(qE,{icon:(0,$.jsx)(F,{className:`size-4`}),label:E.chooseApp,disabled:m.disabled,onClick:()=>H(m.onClick)}):null,_?[{label:E.recommendedApps,apps:C},{label:E.recentApps,apps:w}].map(e=>{let{label:t,apps:n}=e;return n.length>0?(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1 dark:border-edge`,children:[(0,$.jsx)(`p`,{className:`px-3 pb-1 pt-0.5 text-[11px] font-medium uppercase tracking-normal text-fg-subtle`,children:t}),n.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`menuitem`,className:`flex h-9 w-full min-w-0 items-center rounded-md px-2.5 text-left text-sm text-fg hover:bg-surface-hover`,title:e.path,onClick:()=>H(()=>_(e.path)),children:(0,$.jsx)(`span`,{className:`block truncate`,children:e.name})},e.path))]},t):null}):null,v?(0,$.jsx)(qE,{icon:(0,$.jsx)(oe,{className:`size-4`}),label:E.revealInFolder,onClick:()=>H(v)}):null,p||m||v?(0,$.jsx)(`div`,{className:`my-1 border-t border-edge-subtle dark:border-edge`}):null,(0,$.jsx)(qE,{icon:(0,$.jsx)(P,{className:`size-4`}),label:O?E.saveCopy:E.download,disabled:!a.canDownload,onClick:()=>H(()=>void a.onDownload())}),y?(0,$.jsx)(qE,{icon:y.copied?(0,$.jsx)(S,{className:`size-4 text-emerald-500`}):(0,$.jsx)(N,{className:`size-4`}),label:y.copied?E.pathCopied:O?E.copyFilePath:E.copyWorkspacePath,onClick:()=>H(y.onClick)}):null]}):null]}),de,ge]})]}),_e]})}function YE(e){return!e}function XE(e){return[`zoom`,`search`,`rotate`,`pageNavigation`].includes(e)}function ZE(e){return e.language}function QE({header:e,chat:t,...n}){let r=zE(n.descriptor),i=l(),a=xe(n.language),[o,s]=(0,Z.useState)(!1),c=async()=>{if(!(!t||o)){s(!0);try{let[n,r]=await Promise.all([t.createFile(),t.conversationId?$h(t.conversationId).catch(()=>null):Promise.resolve(null)]);if(n.size>33554432){Yl(`warning`,a.chat.attachmentFileTooLarge,{name:n.name,maxSize:m_(_v)});return}let o=new URLSearchParams({attachmentHandoff:_E(n)}),s=t.projectId?.trim()||r?.projectId?.trim(),c=t.agentId?.trim()||r?.routing?.agentId?.trim();s&&o.set(`projectId`,s),i({pathname:`/chat/new`,search:`?${o}`},{state:{forceNewChat:!0,agentId:c||void 0}}),e.onClose()}catch{Yl(`error`,a.workspace.editInNewChatFailed)}finally{s(!1)}}};return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsx)(JE,{...e,name:n.descriptor.fileName,controller:r,actions:n.actions,editInNewChat:t?{onClick:()=>void c(),loading:o,disabled:n.loading||!!n.loadError||t.disabled}:void 0},n.descriptor.id),(0,$.jsx)(WE,{...n,controller:r})]})}function $E(e,t){let n=(0,Q.c)(7),r=e===void 0?!0:e,i=t===void 0?!1:t,[a,o]=(0,Z.useState)(!1);!r&&a&&o(!1);let s,c;n[0]!==r||n[1]!==i||n[2]!==a?(s=()=>{if(!r||!a)return;let e=document.body.style.overflow;document.body.style.overflow=`hidden`;let t=e=>{i||e.key!==`Escape`||e.defaultPrevented||document.querySelector(`[data-file-preview-menu]`)||(e.preventDefault(),e.stopImmediatePropagation(),o(!1))};return window.addEventListener(`keydown`,t,!0),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,t,!0)}},c=[r,a,i],n[0]=r,n[1]=i,n[2]=a,n[3]=s,n[4]=c):(s=n[3],c=n[4]),(0,Z.useEffect)(s,c);let l;return n[5]===a?l=n[6]:(l={expanded:a,setExpanded:o},n[5]=a,n[6]=l),l}function eD(){return An()&&window.electronAPI?.platform===`darwin`}function tD(){return An()&&window.electronAPI?.platform===`win32`}function nD(){return tD()?`windows-preview-viewport`:``}function rD({open:e,attachment:t,authToken:n,conversationId:r,layerClassName:i=`z-[81]`,onClose:a}){let o=Ee(e=>e.language),s=xe(o).chat,c=hC({open:e,attachment:t,authToken:n,conversationId:r,language:o}),l=lw(),{expanded:u,setExpanded:d}=$E(e,l.dialogOpen),[f,p]=(0,Z.useState)(!1),{preview:m,fileType:h,hasExtractedText:g}=c,_=h!==`image`&&h!==`text`&&h!==`pptx`&&g,v=m?.uri?vt(m.uri):null,y=!!(v||m?.uri?.startsWith(`media://`)&&(r||m.taskId)),b=()=>{!m?.uri||!y||l.createShareLink(v?{fileId:v,fileName:m.name}:{uri:m.uri,conversationId:r??void 0,taskId:m.taskId,fileName:m.name})},x=!!(m&&!c.loading&&!c.loadError),S=()=>{d(!1),a()},C=()=>{if(!m||!c.downloadBuffer)return;let e=new Blob([c.downloadBuffer],{type:c.descriptor.mimeType}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=m.name??`download`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},w=!!c.downloadBuffer,T=An()&&h===`spreadsheet`&&/\.xlsx?$/i.test(c.fileName)&&!!c.downloadBuffer&&!!window.electronAPI?.shell?.openTemporaryFile,E=async()=>{let e=c.downloadBuffer,t=window.electronAPI?.shell?.openTemporaryFile;if(!(!e||!t||f)){p(!0);try{(await t({fileName:c.fileName,data:new Uint8Array(e)})).ok||Yl(`warning`,s.attachmentPreviewOpenLocalFailed)}catch{Yl(`warning`,s.attachmentPreviewOpenLocalFailed)}finally{p(!1)}}},D={onDownload:C,canDownload:w},O=K(`min-h-0 min-w-0 flex-1 cursor-pointer border-0 p-0`,`bg-surface-base transition-colors`,`hover:bg-surface-hover/90 dark:bg-black/60 dark:hover:bg-black/70`,yc.focusRingBase);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nt,{open:e,onOpenChange:e=>!e&&S(),children:(0,$.jsx)($e,{children:(0,$.jsxs)(et,{"aria-describedby":void 0,className:K(`xopc-dialog-content-fullscreen fixed inset-0 flex h-[100dvh] w-full flex-row overflow-hidden`,nD(),i,`border-0 bg-transparent p-0 shadow-none outline-none`),children:[(0,$.jsx)(tt,{className:`sr-only`,children:m?.name??``}),(0,$.jsx)(`button`,{type:`button`,className:O,onClick:S,"aria-label":s.attachmentPreviewClose}),(0,$.jsx)(`div`,{className:K(`flex h-full min-h-0 shrink-0 flex-col overflow-hidden`,u?`w-full`:`w-[min(100%,var(--max-width-app-main))]`,`bg-surface-panel sm:border-x sm:border-edge dark:sm:border-edge`,`shadow-float dark:shadow-elevated`),children:(0,$.jsx)(QE,{header:{expanded:u,onToggleExpanded:x?()=>d(e=>!e):void 0,onClose:S,share:y?{onClick:b,loading:l.loading}:void 0,openWithSystemApp:T?{onClick:()=>void E(),loading:f}:void 0,textView:_?{active:c.showExtractedText,onChange:e=>{c.setShowExtractedText(e),c.clearLoadError()}}:void 0},chat:c.downloadBuffer?{conversationId:r,createFile:async()=>new File([c.downloadBuffer],c.fileName,{type:c.descriptor.mimeType})}:void 0,language:o,descriptor:c.descriptor,loading:c.loading,loadError:c.loadError,textContent:c.textContent,binaryBuffer:c.binaryBuffer,showExtractedText:c.showExtractedText,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,actions:D})}),(0,$.jsx)(`button`,{type:`button`,className:O,onClick:S,"aria-label":s.attachmentPreviewClose})]})})}),(0,$.jsx)(BC,{open:l.dialogOpen,onOpenChange:l.handleOpenChange,loading:l.loading,error:l.error,result:l.result,pendingParams:l.pendingParams,onConfirm:e=>void l.confirmShareLink(e)})]})}function iD(e){let t=(0,Q.c)(23),{attachments:n,conversationId:r,topPadded:i,onRemove:a,className:o}=e,s=Ee(aD),c;t[0]===s?c=t[1]:(c=xe(s),t[0]=s,t[1]=c);let l=c.chat,[u,d]=(0,Z.useState)(null);if(n.length===0)return null;let f=i?`pt-2`:`pt-3`,p;t[2]!==o||t[3]!==f?(p=K(`flex flex-wrap gap-2 border-b border-edge-subtle/90 bg-surface-hover/20 px-4 pb-2 dark:border-edge-subtle`,f,o),t[2]=o,t[3]=f,t[4]=p):p=t[4];let m;if(t[5]!==n||t[6]!==l||t[7]!==a){let e;t[9]!==l||t[10]!==a?(e=(e,t)=>{let n=e.type===`pasted_text`?l.pastedText:e.name;return(0,$.jsxs)(`div`,{className:`flex max-w-[200px] items-center rounded-lg bg-surface-hover text-xs dark:bg-surface-hover/80`,children:[(0,$.jsxs)(`button`,{type:`button`,className:K(`flex min-w-0 flex-1 items-center gap-1.5 rounded-l-lg py-1 pl-2 pr-1 text-left hover:bg-surface-active`,yc.transition,yc.press,yc.focusRingPanel),onClick:()=>d(e),"aria-label":`${l.attachmentPreviewOpen}: ${n}`,title:`${l.attachmentPreviewOpen}: ${n}`,children:[e.mimeType?.startsWith(`image/`)&&e.content?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.content}`,alt:``,className:`size-6 shrink-0 rounded object-cover`}):e.type===`voice`||e.mimeType?.startsWith(`audio/`)?(0,$.jsx)(hi,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.type===`pasted_text`?(0,$.jsx)(Pr,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(Br,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-disabled`,children:m_(e.size)})]}),(0,$.jsx)(`button`,{type:`button`,className:K(`flex min-h-8 min-w-8 items-center justify-center rounded-r-lg text-fg-muted hover:bg-surface-active hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel),onClick:()=>a(t),"aria-label":`${l.attachmentPreviewRemove}: ${n}`,title:`${l.attachmentPreviewRemove}: ${n}`,children:(0,$.jsx)(`span`,{"aria-hidden":!0,children:`×`})})]},e.id??`${e.name}-${e.size}-${e.mimeType}-${e.content?.slice(0,16)??``}`)},t[9]=l,t[10]=a,t[11]=e):e=t[11],m=n.map(e),t[5]=n,t[6]=l,t[7]=a,t[8]=m}else m=t[8];let h;t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`div`,{className:p,children:m}),t[12]=p,t[13]=m,t[14]=h):h=t[14];let g=u!==null,_;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>d(null),t[15]=_):_=t[15];let v;t[16]!==r||t[17]!==u||t[18]!==g?(v=(0,$.jsx)(rD,{open:g,attachment:u,conversationId:r,onClose:_}),t[16]=r,t[17]=u,t[18]=g,t[19]=v):v=t[19];let y;return t[20]!==h||t[21]!==v?(y=(0,$.jsxs)($.Fragment,{children:[h,v]}),t[20]=h,t[21]=v,t[22]=y):y=t[22],y}function aD(e){return e.language}function oD(e){let t=(0,Q.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({children:n,dragging:a,className:r,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=(a===void 0?!1:a)&&`ring-2 ring-accent ring-inset`,s;t[5]!==r||t[6]!==o?(s=K(`relative flex min-h-0 w-full flex-col overflow-hidden rounded-2xl bg-surface-panel shadow-surface ring-1 ring-inset ring-edge dark:bg-surface-panel/60 dark:shadow-none`,o,r),t[5]=r,t[6]=o,t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==s?(c=(0,$.jsx)(`div`,{className:s,...i,children:n}),t[8]=n,t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function sD(e,t){return e.displayNames?.[t.toLowerCase().startsWith(`zh`)?`zh-CN`:`en`]||e.name}function cD(e,t,n){if(t===`computer-use`)return e.filter(e=>!!e.computerUse);let r=e=>e.computerUse?.profile!==void 0&&e.computerUse.profile!==`openai-responses-computer-v1`;if(t!==`vision`)return e.filter(e=>!r(e)||e.id===n);let i=e.filter(e=>e.vision===!0&&!r(e));if(!n||i.some(e=>e.id===n))return i;let a=e.find(e=>e.id===n);if(a)return[a,...i];let o=n.indexOf(`/`),s=o>=0?n.slice(0,o):``;return[{id:n,name:(o>=0?n.slice(o+1):n)||n,provider:s||`—`,vision:!1},...i]}function lD(e){return`${e.id} ${e.name} ${Object.values(e.displayNames??{}).join(` `)} ${e.provider}`.toLowerCase()}var uD=[];function dD(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=n.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=lD(e);return r.every(e=>t.includes(e))})}function fD(e){let t=(0,Q.c)(99),{value:n,disabled:r,placeholder:i,searchPlaceholder:a,noMatches:o,models:s,modelsLoading:c,modelsError:u,capabilitiesFilter:d,outOfFilterNote:f,registryEmptyHint:p,allowEmpty:m,emptyLabel:h,compact:g,showProviderInTrigger:_,contentSide:v,contentAlign:y,className:b,popoverContentClassName:x,showProviderSettingsFooter:T,settingsFooterLink:E,ariaLabel:D,onChange:O}=e,A=m===void 0?!1:m,j=_===void 0?!0:_,M=v===void 0?`bottom`:v,N=y===void 0?`end`:y,P=l(),F=Ee(mD),I;t[0]===F?I=t[1]:(I=xe(F),t[0]=F,t[1]=I);let L=I.chat,[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(null),W=On(),G=Dn(H),ee=k(W,G!==null),te;t[2]!==L||t[3]!==E||t[4]!==T?(te=E??(T?{label:L.modelProviderSettingsLink,path:`/settings/capabilities/models`}:void 0),t[2]=L,t[3]=E,t[4]=T,t[5]=te):te=t[5];let ne=te,re;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(re={revalidateOnFocus:!1},t[6]=re):re=t[6];let ie=Zt(s?null:zn,Ln,re),ae=s??ie.data??uD,oe=s?!!c:ie.isLoading,se=s?u:ie.error,ce;t[7]===n?ce=t[8]:(ce=n.trim(),t[7]=n,t[8]=ce);let le=ce,ue;t[9]!==d||t[10]!==ae||t[11]!==le?(ue=cD(ae,d,le),t[9]=d,t[10]=ae,t[11]=le,t[12]=ue):ue=t[12];let de=ue,fe=d===`computer-use`||de.length>10,pe=fe?B:``,me;t[13]!==de||t[14]!==pe?(me=dD(de,pe),t[13]=de,t[14]=pe,t[15]=me):me=t[15];let he=me,ge;t[16]!==ae||t[17]!==de||t[18]!==n?(ge=ae.find(e=>e.id===n)??de.find(e=>e.id===n),t[16]=ae,t[17]=de,t[18]=n,t[19]=ge):ge=t[19];let _e=ge,ve;t[20]!==F||t[21]!==i||t[22]!==_e||t[23]!==j||t[24]!==n?(ve=_e?j?`${sD(_e,F)} (${_e.provider})`:sD(_e,F):n||i,t[20]=F,t[21]=i,t[22]=_e,t[23]=j,t[24]=n,t[25]=ve):ve=t[25];let ye=ve,be=!se&&!!d&&de.length===0,q=bn,Se=r||oe,Ce;t[26]!==F||t[27]!==i||t[28]!==_e?(Ce=_e?`${sD(_e,F)} (${_e.provider})`:i,t[26]=F,t[27]=i,t[28]=_e,t[29]=Ce):Ce=t[29];let we=g&&`py-1.5 text-[13px]`,Te;t[30]!==b||t[31]!==we?(Te=K(Cd,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2 text-left text-sm font-normal text-fg`,yc.transition,`hover:border-edge hover:bg-surface-hover/45`,yd,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,we,b),t[30]=b,t[31]=we,t[32]=Te):Te=t[32];let De=oe?`…`:ye,Oe;t[33]===De?Oe=t[34]:(Oe=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:De}),t[33]=De,t[34]=Oe);let J;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(w,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[35]=J):J=t[35];let ke;t[36]!==D||t[37]!==Se||t[38]!==Ce||t[39]!==Te||t[40]!==Oe?(ke=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{ref:U,type:`button`,"aria-label":D,disabled:Se,title:Ce,className:Te,children:[Oe,J]})}),t[36]=D,t[37]=Se,t[38]=Ce,t[39]=Te,t[40]=Oe,t[41]=ke):ke=t[41];let Ae=bn,je=G??void 0,Me=bn,Ne=K(ee,C,`w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,x),Pe;t[42]!==B||t[43]!==a||t[44]!==fe?(Pe=fe?(0,$.jsx)(`input`,{type:`search`,"aria-label":a,className:K(`mb-1 w-full shrink-0 rounded-lg border border-edge-subtle bg-surface-base px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-disabled dark:bg-surface-hover/40`,bd),placeholder:a,value:B,onChange:e=>V(e.target.value)}):null,t[42]=B,t[43]=a,t[44]=fe,t[45]=Pe):Pe=t[45];let Fe;t[46]!==A||t[47]!==h||t[48]!==O||t[49]!==i||t[50]!==le?(Fe=A?(0,$.jsxs)(`button`,{type:`button`,className:K(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-hover`,le===``&&`bg-surface-hover/90 font-medium dark:bg-surface-hover/70`),onClick:()=>{O(``),z(!1),V(``)},children:[(0,$.jsx)(S,{className:K(`size-4 shrink-0`,le!==``&&`invisible`),"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:h??i})]}):null,t[46]=A,t[47]=h,t[48]=O,t[49]=i,t[50]=le,t[51]=Fe):Fe=t[51];let Ie;t[52]===se?Ie=t[53]:(Ie=se?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:se instanceof Error?se.message:`Failed to load models`}):null,t[52]=se,t[53]=Ie);let Le;t[54]!==se||t[55]!==o||t[56]!==p||t[57]!==be?(Le=!se&&be?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:p??o}):null,t[54]=se,t[55]=o,t[56]=p,t[57]=be,t[58]=Le):Le=t[58];let Re;t[59]!==se||t[60]!==he||t[61]!==o||t[62]!==be?(Re=!se&&!be&&he.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:o}):null,t[59]=se,t[60]=he,t[61]=o,t[62]=be,t[63]=Re):Re=t[63];let ze=d===`vision`?f:void 0,Be;t[64]===O?Be=t[65]:(Be=e=>{O(e),z(!1),V(``)},t[64]=O,t[65]=Be);let Ve;t[66]!==he||t[67]!==o||t[68]!==a||t[69]!==ze||t[70]!==Be||t[71]!==n?(Ve=(0,$.jsx)(hD,{models:he,value:n,searchPlaceholder:a,noMatches:o,showSearch:!1,outOfFilterNote:ze,onChange:Be}),t[66]=he,t[67]=o,t[68]=a,t[69]=ze,t[70]=Be,t[71]=n,t[72]=Ve):Ve=t[72];let He;t[73]!==Fe||t[74]!==Ie||t[75]!==Le||t[76]!==Re||t[77]!==Ve?(He=(0,$.jsxs)(`div`,{className:`flex min-h-0 max-h-60 flex-1 flex-col overflow-hidden`,children:[Fe,Ie,Le,Re,Ve]}),t[73]=Fe,t[74]=Ie,t[75]=Le,t[76]=Re,t[77]=Ve,t[78]=He):He=t[78];let Ue;t[79]!==ne||t[80]!==P?(Ue=ne?(0,$.jsx)(`div`,{className:`mt-1 shrink-0 border-t border-edge-subtle pt-1`,children:(0,$.jsxs)(`button`,{type:`button`,className:K(`flex w-full items-center gap-2 rounded-md p-2 text-left text-sm font-medium text-accent`,yc.transition,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),onClick:()=>{P(ne.path),z(!1),V(``)},children:[(0,$.jsx)(qi,{className:`size-4 shrink-0 opacity-90`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:ne.label})]})}):null,t[79]=ne,t[80]=P,t[81]=Ue):Ue=t[81];let We;t[82]!==N||t[83]!==M||t[84]!==Me.Content||t[85]!==Ne||t[86]!==Pe||t[87]!==He||t[88]!==Ue?(We=(0,$.jsxs)(Me.Content,{className:Ne,side:M,sideOffset:4,align:N,collisionPadding:8,onOpenAutoFocus:pD,children:[Pe,He,Ue]}),t[82]=N,t[83]=M,t[84]=Me.Content,t[85]=Ne,t[86]=Pe,t[87]=He,t[88]=Ue,t[89]=We):We=t[89];let Ge;t[90]!==Ae.Portal||t[91]!==je||t[92]!==We?(Ge=(0,$.jsx)(Ae.Portal,{container:je,children:We}),t[90]=Ae.Portal,t[91]=je,t[92]=We,t[93]=Ge):Ge=t[93];let Ke;return t[94]!==R||t[95]!==q.Root||t[96]!==ke||t[97]!==Ge?(Ke=(0,$.jsxs)(q.Root,{open:R,onOpenChange:z,children:[ke,Ge]}),t[94]=R,t[95]=q.Root,t[96]=ke,t[97]=Ge,t[98]=Ke):Ke=t[98],Ke}function pD(e){return e.preventDefault()}function mD(e){return e.language}function hD({models:e,value:t,onChange:n,searchPlaceholder:r,noMatches:i,disabled:a,showSearch:o=e.length>10,outOfFilterNote:s}){let c=Ee(e=>e.language),[l,u]=(0,Z.useState)(``),d=dD(e,o?l:``);return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[o&&(0,$.jsx)(`input`,{type:`search`,"aria-label":r,placeholder:r,value:l,onChange:e=>u(e.target.value),className:K(`mx-1 mb-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,`focus:outline-none focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:shadow-none focus-visible:border-edge`)}),(0,$.jsxs)(`div`,{"data-select-scroll-region":!0,className:D,children:[d.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-4 text-sm text-fg-muted`,children:i}),d.map(r=>(0,$.jsxs)(`button`,{type:`button`,disabled:a,title:r.id,"aria-pressed":r.id===t,style:e.length>50?{contentVisibility:`auto`,containIntrinsicSize:`auto 60px`}:void 0,className:K(`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,yc.focusRingPanel,r.id===t&&`bg-surface-hover`),onClick:()=>n(r.id),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium`,children:sD(r,c)}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:r.provider}),r.computerUse&&(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:`Computer Use`}),s&&!r.vision&&r.id===t&&(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:s})]}),(0,$.jsx)(S,{className:K(`size-4 shrink-0 text-accent-fg`,r.id!==t&&`invisible`),"aria-hidden":!0})]},r.id))]})]})}function gD({chat:e,sessionModel:t,modelDisabled:n,onModelChange:r,thinkingLevel:i,thinkingDisabled:a,onThinkingChange:o}){let s=Ee(e=>e.language),c=Zt(zn,Ln,{revalidateOnFocus:!1}),[l,u]=(0,Z.useState)(`config`),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{(l===`models`?f:d).current?.focus()},[l]);let[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),b=c.data??[],x=b.find(e=>e.id===t),S=!!(t&&c.data&&!x),C=x?sD(x,s):t.slice(t.indexOf(`/`)+1)||e.modelConfigure,w=C.split(`/`).at(-1)||C,T=x?.thinking,E=T?.mode===`levels`||T?.mode===`toggle`,D=T?Fs(T,i):i,O=t=>T?.mode===`toggle`&&t!==`off`?e.modelThinkingOn:e.thinkingLevels[t]??t,k=E?O(D):T?.mode===`fixed`?e.modelThinkingFixed:``,A=p||n;async function j(t,n=!1){m(!0),g(``),v(``);try{await t(),n&&u(`config`),v(e.modelConfigSaved)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}return(0,$.jsxs)(hn,{onOpenChange:e=>{e||(u(`config`),g(``),v(``))},children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":`${e.modelConfigLabel}: ${w}${k?` · ${k}`:``}`,title:w,className:K(`inline-flex h-8 min-w-0 max-w-[min(18rem,calc(100vw-10rem))] items-center gap-1.5 rounded-lg bg-surface-hover/70 px-2.5 text-[13px] text-fg hover:bg-surface-hover`,yc.focusRingPanel,yc.transition),children:[c.isLoading||!t&&b.length>0?(0,$.jsx)(xn,{className:`h-4 w-28`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:w}),S?(0,$.jsx)(`span`,{className:`shrink-0 text-fg-muted`,children:e.modelUnavailable}):k&&(0,$.jsxs)(`span`,{className:`shrink-0 text-fg-muted`,children:[`· `,k]})]}),(0,$.jsx)(cr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{side:`top`,align:`end`,sideOffset:8,collisionPadding:12,"aria-label":e.modelConfigLabel,className:K(En,`xopc-composer-config-popover flex max-h-[min(21rem,calc(100dvh-3rem))] w-[min(20rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel p-2 shadow-popover`),children:[l===`models`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{ref:f,type:`button`,onClick:()=>u(`config`),className:K(`mb-2 flex min-h-11 shrink-0 items-center gap-2 rounded-lg px-2 text-sm text-fg hover:bg-surface-hover`,yc.focusRingPanel),children:[(0,$.jsx)(Jn,{className:`size-4`,"aria-hidden":!0}),e.modelBack]}),(0,$.jsx)(hD,{models:b,value:t,disabled:A,searchPlaceholder:e.modelSearchPlaceholder,noMatches:e.modelNoMatches,onChange:e=>{let t=b.find(t=>t.id===e),n=t?.thinking?Fs(t.thinking,D):D;j(()=>r(e,n),!0)}})]}):(0,$.jsx)(`div`,{className:`min-h-0 overflow-y-auto overscroll-contain`,children:c.isLoading?(0,$.jsxs)(`div`,{className:`space-y-4 p-3`,children:[(0,$.jsx)(xn,{className:`h-6 w-40`}),(0,$.jsx)(xn,{className:`h-4 w-24`}),(0,$.jsx)(xn,{className:`h-11 w-full`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{ref:d,type:`button`,disabled:A||!b.length,onClick:()=>u(`models`),className:K(`flex min-h-14 w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover disabled:opacity-60`,yc.focusRingPanel),children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:C}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,title:t,children:x?.provider||t})]}),(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0})]}),S&&(0,$.jsx)(`p`,{className:`px-3 py-2 text-sm text-fg-muted`,children:e.modelUnavailable}),x&&(0,$.jsxs)(`div`,{className:`mb-2 mt-4 px-3`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:e.modelThinkingLabel}),E?(0,$.jsx)(`div`,{role:`group`,"aria-label":e.modelThinkingLabel,className:K(`grid gap-1 rounded-lg bg-surface-base p-1`,T.options.length>4?`grid-cols-3`:T.options.length===4?`grid-cols-4`:T.options.length===3?`grid-cols-3`:`grid-cols-2`),children:T.options.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":e===D,disabled:A||a,onClick:()=>void j(()=>o(e)),className:K(`min-h-11 min-w-11 flex-1 rounded-md px-2 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,yc.focusRingPanel,e===D&&`bg-accent-soft font-medium text-accent-fg`),children:O(e)},e))}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T?.mode===`none`?e.thinkingUnsupported:T?.mode===`fixed`?e.modelThinkingFixed:e.modelThinkingUnknown})]})]})}),(p||h||c.error||_)&&(0,$.jsx)(`div`,{className:`shrink-0 px-3 py-2 text-xs`,"aria-live":`polite`,children:p?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-3 animate-spin`,"aria-hidden":!0}),e.modelConfigSaving]}):h?(0,$.jsx)(`span`,{role:`alert`,className:`text-danger`,children:h}):c.error?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void c.mutate(),className:K(`text-accent-fg`,yc.focusRingPanel),children:e.modelRetry}):_?(0,$.jsxs)(`span`,{className:`text-fg-muted`,children:[_,` · `,w,k?` · ${k}`:``]}):null}),(0,$.jsx)(y,{to:`/settings/capabilities/models`,className:K(`shrink-0 rounded-lg border-t border-edge-subtle px-3 py-3 text-sm text-fg-muted hover:bg-surface-hover`,yc.focusRingPanel),children:b.length?e.modelManage:e.modelConfigure})]})})]})}function _D(){return typeof navigator>`u`?!1:navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)}function vD(e,t=_D()){return bD(e).split(`+`).map(e=>e===`control`?`Ctrl`:e===`meta`?t?`⌘`:`Win`:e===`alt`?t?`Option`:`Alt`:e===`shift`?`Shift`:e===`space`?`Space`:e.length===1?e.toUpperCase():e)}function yD(e=_D()){return e?`meta+.`:`control+.`}function bD(e){return e.split(`+`).map(wD).filter(Boolean).join(`+`)}function xD(e){if(e.key===`Escape`||[`Meta`,`Control`,`Alt`,`Shift`].includes(e.key))return null;let t=e.key===` `?`space`:wD(e.key);return t?[...[e.metaKey?`meta`:``,e.ctrlKey?`control`:``,e.altKey?`alt`:``,e.shiftKey?`shift`:``].filter(Boolean),t].join(`+`):null}var SD=Oe(sn(e=>({shortcut:yD(),setShortcut:t=>e({shortcut:bD(t)||yD()})}),{name:`xopc-quick-capture-shortcut`,version:2,migrate:e=>{let t=e;return!_D()&&t.shortcut===`meta+.`?{...t,shortcut:yD(!1)}:{...t,shortcut:bD(t.shortcut??``)||yD()}}})),CD={cmd:`meta`,command:`meta`,ctrl:`control`,ctl:`control`,opt:`alt`,option:`alt`};function wD(e){let t=e.toLowerCase().trim();return CD[t]??t}function TD(e,t){let n=bD(t).split(`+`),r=new Set(n.filter(e=>[`meta`,`control`,`alt`,`shift`].includes(e))),i=n.find(e=>!r.has(e));return!i||r.has(`meta`)!==e.metaKey||r.has(`control`)!==e.ctrlKey||r.has(`alt`)!==e.altKey||r.has(`shift`)!==e.shiftKey?!1:e.key.toLowerCase()===i||e.code.toLowerCase()===i}function ED(e=_D()){return e?`meta+shift+m`:`control+shift+m`}var DD=Oe(sn(e=>({shortcut:ED(),setShortcut:t=>e({shortcut:bD(t)||ED()})}),{name:`xopc-voice-input-shortcut`,version:1}));function OD(e){let t=(0,Q.c)(10),{disabled:n,chat:r,onStart:i}=e,a=DD(kD),o=r.voiceInput,s;t[0]===a?s=t[1]:(s=vD(a).join(`+`),t[0]=a,t[1]=s);let c=`${o} (${s})`,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=K(`relative inline-flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[2]=l):l=t[2];let u;t[3]===i?u=t[4]:(u=()=>void i(),t[3]=i,t[4]=u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(hi,{className:`size-4 stroke-[1.75]`}),t[5]=d):d=t[5];let f;return t[6]!==n||t[7]!==u||t[8]!==c?(f=(0,$.jsx)(`button`,{type:`button`,className:l,disabled:n,title:c,"aria-label":c,onClick:u,children:d}),t[6]=n,t[7]=u,t[8]=c,t[9]=f):f=t[9],f}function kD(e){return e.shortcut}function AD(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function jD(e){let t=(0,Q.c)(12),{disabled:n,runBusy:r,attachmentCount:i,maxAttachments:a,chat:o,onPickFiles:s}=e,c=i>=a,l;t[0]!==i||t[1]!==c||t[2]!==o.attachFile||t[3]!==o.maxAttachmentsReached||t[4]!==a?(l=c?AD(o.maxAttachmentsReached,{max:a}):`${o.attachFile} (${i}/${a})`,t[0]=i,t[1]=c,t[2]=o.attachFile,t[3]=o.maxAttachmentsReached,t[4]=a,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[6]=d):d=t[6];let f=c||n||r,p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ge,{className:`size-4`}),t[7]=p):p=t[7];let m;return t[8]!==s||t[9]!==f||t[10]!==u?(m=(0,$.jsx)(`button`,{type:`button`,className:d,disabled:f,title:u,"aria-label":u,onClick:s,children:p}),t[8]=s,t[9]=f,t[10]=u,t[11]=m):m=t[11],m}function MD(e){let t=(0,Q.c)(12),{disabled:n,voiceActive:r,runBusy:i,hasDraft:a,showSteeringInterrupt:o,chat:s,onSend:c,onAbort:l,onInterrupt:u}=e,d;return t[0]!==n||t[1]!==a||t[2]!==s.abort||t[3]!==s.sendMessage||t[4]!==s.steeringInterruptSend||t[5]!==l||t[6]!==u||t[7]!==c||t[8]!==i||t[9]!==o||t[10]!==r?(d=(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:i?(0,$.jsxs)($.Fragment,{children:[o&&u?(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-accent-fg hover:bg-accent-soft dark:hover:bg-accent-soft`,yc.transition,yc.press,yc.focusRingPanel),title:s.steeringInterruptSend,"aria-label":s.steeringInterruptSend,onClick:()=>void u(),children:(0,$.jsx)(Ki,{className:`size-4 stroke-[1.75]`})}):null,(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/70 text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/50`,yc.transition,yc.press,yc.focusRingPanel),title:s.abort,"aria-label":s.abort,onClick:l,children:(0,$.jsx)(ra,{className:`size-4 stroke-[1.75]`})})]}):(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border transition-colors duration-150 ease-out`,yc.press,yc.focusRingPanel,a?`border-transparent text-accent-fg hover:bg-accent-soft dark:text-accent-fg dark:hover:bg-accent-soft`:`border-transparent text-fg-disabled`),disabled:n||r||!a,title:s.sendMessage,"aria-label":s.sendMessage,onClick:c,children:(0,$.jsx)(Ki,{className:`size-4 stroke-[1.75]`})})}),t[0]=n,t[1]=a,t[2]=s.abort,t[3]=s.sendMessage,t[4]=s.steeringInterruptSend,t[5]=l,t[6]=u,t[7]=c,t[8]=i,t[9]=o,t[10]=r,t[11]=d):d=t[11],d}function ND(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=K(`flex flex-wrap items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,$.jsx)(`div`,{className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var PD=(0,Z.memo)(function(e){let t=(0,Q.c)(44),{disabled:n,sending:r,streaming:i,runBusy:a,chat:o,hasDraft:s,showSteeringInterrupt:c,attachmentCount:l,maxAttachments:u,onPickFiles:d,thinkingLevel:f,onThinkingChange:p,voiceActive:m,onStartVoiceInput:h,voiceConversationEnabled:g,onStartVoiceConversation:_,onSend:v,onAbort:y,onInterrupt:b,sessionModel:x,showModelSelector:S,onModelChange:C,modelDisabled:w}=e;if(m)return null;let T;t[0]!==l||t[1]!==n||t[2]!==o||t[3]!==u||t[4]!==d||t[5]!==a?(T=(0,$.jsx)(jD,{disabled:n,runBusy:a,attachmentCount:l,maxAttachments:u,chat:o,onPickFiles:d}),t[0]=l,t[1]=n,t[2]=o,t[3]=u,t[4]=d,t[5]=a,t[6]=T):T=t[6];let E;t[7]!==n||t[8]!==o||t[9]!==w||t[10]!==C||t[11]!==p||t[12]!==r||t[13]!==x||t[14]!==S||t[15]!==i||t[16]!==f?(E=S?(0,$.jsx)(gD,{chat:o,sessionModel:x,modelDisabled:w,onModelChange:C,thinkingLevel:f,thinkingDisabled:n||r||i,onThinkingChange:p}):null,t[7]=n,t[8]=o,t[9]=w,t[10]=C,t[11]=p,t[12]=r,t[13]=x,t[14]=S,t[15]=i,t[16]=f,t[17]=E):E=t[17];let D;t[18]!==n||t[19]!==o||t[20]!==_||t[21]!==h||t[22]!==m||t[23]!==g?(D=m?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(OD,{disabled:n,chat:o,onStart:h}),(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),disabled:n||!g,title:o.voiceConversation,"aria-label":o.voiceConversation,onClick:()=>void _(),children:(0,$.jsx)(Zn,{className:`size-4 stroke-[1.75]`})})]}),t[18]=n,t[19]=o,t[20]=_,t[21]=h,t[22]=m,t[23]=g,t[24]=D):D=t[24];let O;t[25]!==n||t[26]!==s||t[27]!==o||t[28]!==y||t[29]!==b||t[30]!==v||t[31]!==a||t[32]!==c||t[33]!==m?(O=(0,$.jsx)(MD,{disabled:n,voiceActive:m,runBusy:a,hasDraft:s,showSteeringInterrupt:c,chat:o,onSend:v,onAbort:y,onInterrupt:b}),t[25]=n,t[26]=s,t[27]=o,t[28]=y,t[29]=b,t[30]=v,t[31]=a,t[32]=c,t[33]=m,t[34]=O):O=t[34];let k;t[35]!==D||t[36]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[D,O]}),t[35]=D,t[36]=O,t[37]=k):k=t[37];let A;t[38]!==E||t[39]!==k?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-2`,children:[E,k]}),t[38]=E,t[39]=k,t[40]=A):A=t[40];let j;return t[41]!==T||t[42]!==A?(j=(0,$.jsxs)(ND,{children:[T,A]}),t[41]=T,t[42]=A,t[43]=j):j=t[43],j});function FD(e){let{chat:t,initialAttachments:n=[],onAttachmentsChange:r}=e,[i,a]=(0,Z.useState)(n),[o,c]=(0,Z.useState)(!1),l=(0,Z.useRef)(null),u=(0,Z.useRef)(i),d=(0,Z.useRef)(r);u.current=i,d.current=r;let f=(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(u.current):e;u.current=t,a(t),d.current?.(t)},[]),p=(0,Z.useCallback)(()=>{f([])},[]),m=(0,Z.useCallback)(e=>{f(t=>t.filter((t,n)=>n!==e))},[]),h=(0,Z.useCallback)(()=>u.current.map(e=>({type:e.type===`voice`?`voice`:e.type||`file`,mimeType:e.mimeType,data:e.content,name:e.name,size:e.size,...e.uri?{uri:e.uri}:{},...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}})),[]),g=(0,Z.useCallback)(async(e,n)=>{if(e.length===0)return;let r=10-u.current.length;if(r<=0){Yl(`warning`,t.maxAttachmentsReached,{max:10});return}let i=e.slice(0,r);e.length>i.length&&Yl(`warning`,t.maxAttachmentsTruncated,{max:10,dropped:e.length-i.length});let{loadAttachment:a}=await s(async()=>{let{loadAttachment:e}=await import(`./attachment-load-CHg7_XFl.js`);return{loadAttachment:e}},[]),o=(await Promise.all(i.map(async e=>{if(e.size>33554432)return Yl(`warning`,t.attachmentFileTooLarge,{name:e.name,maxSize:m_(_v)}),null;try{return await a(e,e.name)}catch{return Yl(`error`,t.attachmentLoadFailed,{name:e.name}),null}}))).filter(e=>e!==null).map(e=>n?{...e,type:n}:e);f(e=>[...e,...o])},[t.attachmentFileTooLarge,t.attachmentLoadFailed,t.maxAttachmentsReached,t.maxAttachmentsTruncated]);return{attachments:i,setAttachments:f,attachmentsRef:u,isDragging:o,setIsDragging:c,fileInputRef:l,processFiles:(0,Z.useCallback)(e=>g(e),[g]),processPastedText:(0,Z.useCallback)(e=>g([new File([e.text],e.name,{type:e.mimeType})],`pasted_text`),[g]),removeAttachment:m,clearAttachments:p,wireAttachmentsPayload:h}}function ID(e){return e.projectId||e.contextKind!==`empty`?`hidden`:e.projectCount>0?`choose_project`:e.workDiscovery?.enabled?e.workDiscovery.state.status===`in_progress`&&e.workDiscovery.state.activeRunId?`resume_discovery`:e.workDiscovery.state.status===`not_started`?`discover_folder`:`hidden`:`hidden`}async function LD(){return q(J(`/api/onboarding/work-discovery`))}async function RD(){await q(J(`/api/onboarding/work-discovery`),{method:`PATCH`,body:JSON.stringify({status:`dismissed`})})}async function zD(e){return(await q(J(`/api/work-discovery/preview`),{method:`POST`,body:JSON.stringify({rootPath:e})})).preview}async function BD(){let e=await q(J(`/api/work-discovery/candidates`),{method:`POST`});return{candidates:e.candidates,processingTarget:e.processingTarget}}async function VD(e,t){return(await q(J(`/api/context-sources/work-folders`),{method:`POST`,body:JSON.stringify({rootPath:e,processingPolicy:t})})).source}async function HD(e,t,n,r){return q(J(`/api/context-sources/bootstrap`),{method:`POST`,body:JSON.stringify({items:e,processingPolicy:n,...t?{workDiscoveryRunId:t}:{},sourceCheckpoints:r})})}async function UD(e){return(await q(J(`/api/work-discovery/runs`),{method:`POST`,body:JSON.stringify({rootPath:e,source:`onboarding_selected_directory`,idempotencyKey:crypto.randomUUID()})})).run}async function WD(e){return(await q(J(`/api/work-discovery/runs/${encodeURIComponent(e)}`))).run}async function GD(e){return(await q(J(`/api/work-discovery/runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})).run}async function KD(e){return(await q(J(`/api/work-discovery/runs/${encodeURIComponent(e)}/retry`),{method:`POST`})).run}async function qD(e,t,n){return(await q(J(`/api/work-discovery/runs/${encodeURIComponent(e)}/recognition-feedback`),{method:`POST`,body:JSON.stringify({decision:t,correctedIntent:n})})).run}async function JD(e,t){await q(J(`/api/work-discovery/runs/${encodeURIComponent(e)}/suggestions/${encodeURIComponent(t)}/select`),{method:`POST`})}var YD={code:Dr,review:Sr,note:Si,task:ai,target:sa,search:Gi,folder:oe,content:oa,documents:Mr,globe:ce};function XD(e){let t=(0,Q.c)(5),{name:n,className:r}=e,i=YD[n]??oe,a;t[0]===r?a=t[1]:(a=K(`size-[1.125rem] text-accent-fg sm:size-5`,r),t[0]=r,t[1]=a);let o;return t[2]!==i||t[3]!==a?(o=(0,$.jsx)(i,{className:a,strokeWidth:1.75,"aria-hidden":!0}),t[2]=i,t[3]=a,t[4]=o):o=t[4],o}var ZD=(0,Z.memo)(function({spotlight:e,projectId:t,onPickPrompt:n,onRetryContext:r,onRefreshExploration:i,onSelectProject:a,compact:o=!1}){let s=e,[c,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(s.contextKind!==`empty`),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(null),y=l(),b=Se(e=>e.conversationId),x=xe(Ee(e=>e.language)).onboarding.workDiscovery;(0,Z.useEffect)(()=>{if(!b||t||s.contextKind!==`empty`){m(!0),u([]),f(null);return}let e=!1;return m(!1),Promise.allSettled([hh({status:`active`,sortBy:`updatedAt`,sortOrder:`desc`,limit:5}),LD()]).then(([t,n])=>{e||(u(t.status===`fulfilled`?t.value.items:[]),f(n.status===`fulfilled`?n.value:null),m(!0))}),()=>{e=!0}},[t,s.contextKind,b]);let S=e=>{n({...e,contextKind:s.contextKind})},C=s.categories.flatMap(e=>{let t=e.scenarios[0];return t?[{category:e,scenario:t}]:[]}).slice(0,3),w=ID({contextKind:s.contextKind,projectId:t,projectCount:c.length,workDiscovery:d}),T=async e=>{if(!(!a||_)){v(e);try{await a(e),g(!1)}catch{Yl(`error`,x.projectStartFailed)}finally{v(null)}}},E=K(`mt-1 inline-flex min-h-9 items-center gap-2 rounded-lg px-3 text-sm font-medium text-accent-fg hover:bg-accent-soft`,yc.transition,yc.press,yc.focusRingBase);return(0,$.jsxs)(`div`,{className:K(`flex flex-col pb-2`,o?`gap-2 pt-1`:`gap-3.5 pt-6 sm:gap-4 sm:pb-3 sm:pt-8 [@media(max-height:800px)]:pt-3 sm:[@media(max-height:800px)]:pt-4`),children:[(0,$.jsxs)(`div`,{className:K(`flex flex-col items-center gap-1.5 px-1 text-center sm:gap-2`,o?`pt-3 [@media(max-height:800px)]:pt-1`:`pt-14 sm:pt-16 [@media(max-height:800px)]:pt-6 sm:[@media(max-height:800px)]:pt-7`),children:[(0,$.jsx)(gd,{className:`size-11 shrink-0 sm:size-12`,"aria-hidden":!0}),s.contextLabel?(0,$.jsx)(`div`,{className:`max-w-full truncate rounded-full border border-edge-subtle bg-surface-base px-2.5 py-1 text-xs text-fg-muted sm:max-w-md`,title:s.contextLabel,children:s.contextLabel}):null,(0,$.jsx)(`h1`,{className:`text-balance text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.headline}),(0,$.jsx)(`p`,{className:`max-w-md text-pretty text-sm leading-snug text-fg-muted sm:text-[0.9375rem]`,children:s.tagline}),(0,$.jsx)(`div`,{className:`min-h-7 text-xs text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:s.statusLabel?(0,$.jsxs)(`span`,{className:`inline-flex flex-wrap items-center justify-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:s.statusLabel}),s.contextStatus===`degraded`&&r?(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:K(`inline-flex min-h-7 items-center gap-1 rounded-md px-1.5 font-medium text-accent-fg hover:bg-accent-soft`,yc.transition,yc.focusRingBase),children:[(0,$.jsx)(Vi,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),s.retryLabel]}):null]}):null}),!t&&!p&&s.contextKind===`empty`?(0,$.jsx)(xn,{className:`mt-1 h-9 w-36 rounded-lg`}):w===`choose_project`&&a?(0,$.jsxs)(hn,{open:h,onOpenChange:g,children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:E,children:[(0,$.jsx)(oe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),x.selectProject]})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{align:`center`,side:`bottom`,sideOffset:6,collisionPadding:12,className:`z-50 w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-panel p-1.5 text-left shadow-popover outline-none`,children:[(0,$.jsx)(`p`,{className:`px-2.5 pb-1.5 pt-1 text-xs font-medium text-fg-muted`,children:x.recentProjects}),c.map(e=>(0,$.jsxs)(`button`,{type:`button`,disabled:_!==null,onClick:()=>void T(e.id),className:K(`flex min-h-11 w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left hover:bg-surface-hover disabled:cursor-wait disabled:opacity-60`,yc.transition,yc.focusRingPanel),children:[(0,$.jsx)(oe,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),e.description?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:e.description}):null]}),(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]},e.id)),d?.enabled?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{g(!1),y(`/onboarding/workspace?new=1`)},className:K(`mt-1 flex min-h-10 w-full items-center gap-2.5 border-t border-edge-subtle px-2.5 pt-2 text-left text-sm font-medium text-fg-muted hover:text-fg`,yc.transition,yc.focusRingPanel),children:[(0,$.jsx)(oe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),x.chooseAnotherFolder]}):null]})})]}):w===`discover_folder`?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>y(`/onboarding/workspace?new=1`),className:E,children:[(0,$.jsx)(oe,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),x.chooseWorkFolder]}):w===`resume_discovery`?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>y(`/onboarding/workspace`),className:E,children:[(0,$.jsx)(Vi,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),x.resumeAnalysis]}):null]}),(0,$.jsx)(`section`,{className:K(o?`mt-2`:`mt-7 sm:mt-8 [@media(max-height:800px)]:mt-4 sm:[@media(max-height:800px)]:mt-5`),"aria-label":s.otherSuggestionsLabel,children:(0,$.jsx)(`ul`,{className:`grid w-full grid-cols-1 divide-y divide-edge-subtle sm:grid-cols-3 sm:divide-x sm:divide-y-0`,children:C.map(({category:e,scenario:t},n)=>{let r=e.scope===`explore`&&!!i;return(0,$.jsxs)(`li`,{className:`relative min-w-0 px-1 py-1 sm:px-2.5`,"data-welcome-suggestion-scope":e.scope,children:[(0,$.jsxs)(`button`,{type:`button`,title:t.prompt,onClick:()=>S({suggestionId:t.id??`${e.id}:${n}`,categoryId:e.id,prompt:t.prompt}),className:K(`flex min-h-12 w-full items-start gap-2.5 rounded-lg px-2 py-2 text-left hover:bg-surface-hover/70`,r&&`pe-10`,yc.transition,yc.press,yc.focusRingPanel),children:[(0,$.jsx)(XD,{name:e.icon,className:`mt-0.5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium leading-snug text-fg sm:text-[0.9375rem]`,children:e.title}),(0,$.jsx)(`div`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:e.description})]})]}),r?(0,$.jsx)(`button`,{type:`button`,"aria-label":s.refreshExplorationLabel,title:s.refreshExplorationLabel,onClick:i,className:K(`absolute end-3 top-2.5 inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel),children:(0,$.jsx)(Vi,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]},e.id)})})})]})}),QD=(0,Z.memo)(function(e){let t=(0,Q.c)(32),{showSkeleton:n,compact:r}=e,i=n===void 0?!0:n,a=r===void 0?!1:r,o=i?``:`opacity-0`,s=a?`pt-1`:`pt-6 sm:gap-4 sm:pb-3 sm:pt-8`,c;t[0]===s?c=t[1]:(c=K(`flex flex-col gap-3.5 pb-2`,s),t[0]=s,t[1]=c);let l=a?`pt-3`:`pt-14 sm:pt-16`,u;t[2]===l?u=t[3]:(u=K(`flex flex-col items-center gap-1.5 px-1 text-center sm:gap-2`,l),t[2]=l,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(gd,{className:`size-11 shrink-0 opacity-80 sm:size-12`,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===o?f=t[6]:(f=K(`h-5 w-44 max-w-full`,o),t[5]=o,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,$.jsx)(xn,{className:f}),t[7]=f,t[8]=p);let m;t[9]===o?m=t[10]:(m=K(`h-4 w-[min(100%,24rem)]`,o),t[9]=o,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(xn,{className:m}),t[11]=m,t[12]=h);let g;t[13]===o?g=t[14]:(g=K(`h-3 w-32`,o),t[13]=o,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`div`,{className:`flex min-h-7 items-center`,children:(0,$.jsx)(xn,{className:g})}),t[15]=g,t[16]=_);let v;t[17]!==h||t[18]!==_||t[19]!==u||t[20]!==p?(v=(0,$.jsxs)(`div`,{className:u,children:[d,p,h,_]}),t[17]=h,t[18]=_,t[19]=u,t[20]=p,t[21]=v):v=t[21];let y=a?`mt-2`:`mt-7 sm:mt-8`,b;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(b=[0,1,2],t[22]=b):b=t[22];let x;t[23]===o?x=t[24]:(x=(0,$.jsx)(`div`,{className:`grid w-full grid-cols-1 divide-y divide-edge-subtle sm:grid-cols-3 sm:divide-x sm:divide-y-0`,children:b.map(e=>(0,$.jsxs)(`div`,{className:`flex min-h-14 w-full items-start gap-2.5 px-3 py-2.5`,children:[(0,$.jsx)(xn,{className:K(`mt-0.5 size-5 shrink-0 rounded-md`,o)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(xn,{className:K(`h-4 w-24`,o)}),(0,$.jsx)(xn,{className:K(`h-3 w-32 max-w-full`,o)})]})]},e))}),t[23]=o,t[24]=x);let S;t[25]!==y||t[26]!==x?(S=(0,$.jsx)(`section`,{className:y,"aria-hidden":`true`,children:x}),t[25]=y,t[26]=x,t[27]=S):S=t[27];let C;return t[28]!==v||t[29]!==S||t[30]!==c?(C=(0,$.jsxs)(`div`,{className:c,"aria-busy":`true`,children:[v,S]}),t[28]=v,t[29]=S,t[30]=c,t[31]=C):C=t[31],C});function $D(e,t){let n=t?.split(`;`)[0]?.trim();return!n?.startsWith(`image/`)||e.type===n?e:new Blob([e],{type:n})}function eO(e,t){let n=(0,Q.c)(29),r;n[0]!==e.mimeType||n[1]!==e.type?(r=e.type===`image`||e.mimeType?.startsWith(`image/`)===!0,n[0]=e.mimeType,n[1]=e.type,n[2]=r):r=n[2];let i=r,a;n[3]!==e||n[4]!==i?(a=i?u_(e):void 0,n[3]=e,n[4]=i,n[5]=a):a=n[5];let o=a,s;bb0:{if(!o){s=void 0;break bb0}let t=e.mimeType?.startsWith(`image/`)?e.mimeType:`image/png`,r;n[6]!==o||n[7]!==t?(r=f_(t,o),n[6]=o,n[7]=t,n[8]=r):r=n[8],s=r}let c=s,l=`${e.uri??``}\n${t.conversationId??``}\n${e.taskId??``}`,[u,d]=(0,Z.useState)(),f;n[9]!==e.mimeType||n[10]!==e.taskId||n[11]!==e.uri||n[12]!==c||n[13]!==i||n[14]!==t.authToken||n[15]!==t.conversationId||n[16]!==l?(f=()=>{if(c||!e.uri||!i){d(void 0);return}if(!String(t.authToken??``).trim()){d(void 0);return}let n,r=!1;return d({key:l,status:`loading`}),(async()=>{let i=await dC({uri:e.uri,conversationId:t.conversationId,taskId:e.taskId});if(r)return;if(!i.ok){d({key:l,status:`error`});return}let a=URL.createObjectURL($D(i.blob,e.mimeType));n=a,d({key:l,blobUrl:a,status:`loaded`})})(),()=>{r=!0,n&&URL.revokeObjectURL(n)}},n[9]=e.mimeType,n[10]=e.taskId,n[11]=e.uri,n[12]=c,n[13]=i,n[14]=t.authToken,n[15]=t.conversationId,n[16]=l,n[17]=f):f=n[17];let p;n[18]!==e.taskId||n[19]!==e.uri||n[20]!==c||n[21]!==i||n[22]!==t.authToken||n[23]!==t.conversationId||n[24]!==l?(p=[c,e.taskId,e.uri,i,t.authToken,t.conversationId,l],n[18]=e.taskId,n[19]=e.uri,n[20]=c,n[21]=i,n[22]=t.authToken,n[23]=t.conversationId,n[24]=l,n[25]=p):p=n[25],(0,Z.useEffect)(f,p);let m=u?.key===l?u:void 0,h=c??m?.blobUrl??``,g=!c&&m?.status===`error`,_;return n[26]!==h||n[27]!==g?(_={src:h,error:g},n[26]=h,n[27]=g,n[28]=_):_=n[28],_}function tO(e){let t=(0,Q.c)(51),{attachment:n,authToken:r,conversationId:i,showDelete:a,onDelete:o,imageSize:s,compact:c,className:l,overflowLabel:u,onOpen:d}=e,f=a===void 0?!1:a,p=s===void 0?`thumbnail`:s,m=c===void 0?!1:c,h=Ee(nO),g;t[0]===h?g=t[1]:(g=xe(h),t[0]=h,t[1]=g);let _=g,v=(0,Z.useId)(),y;t[2]!==n.mimeType||t[3]!==n.type?(y=n.mimeType?.startsWith(`image/`)||n.type===`image`,t[2]=n.mimeType,t[3]=n.type,t[4]=y):y=t[4];let b=y,x;t[5]!==r||t[6]!==i?(x={authToken:r,conversationId:i},t[5]=r,t[6]=i,t[7]=x):x=t[7];let S=eO(n,x),C;t[8]===n?C=t[9]:(C=!!n.uri&&!u_(n),t[8]=n,t[9]=C);let w=C,T;t[10]!==r||t[11]!==w?(T=w&&!String(r??``).trim(),t[10]=r,t[11]=w,t[12]=T):T=t[12];let E=T,D=n.mimeType===`application/pdf`,O;t[13]!==n.mimeType||t[14]!==n.name?(O=n.mimeType?.includes(`spreadsheetml`)||n.name?.toLowerCase().endsWith(`.xlsx`)||n.name?.toLowerCase().endsWith(`.xls`),t[13]=n.mimeType,t[14]=n.name,t[15]=O):O=t[15];let k=O,A=n.name??`file`,j=n.type===`pasted_text`,M=j&&!E,N=n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`text/html`?`HTML`:n.mimeType?.split(`;`,1)[0]?.trim().toLowerCase()===`application/json`?`JSON`:`TXT`,P;t[16]!==n.size||t[17]!==N?(P=typeof n.size==`number`?`${N} · ${m_(n.size)}`:N,t[16]=n.size,t[17]=N,t[18]=P):P=t[18];let F=P,I=E?`${A} — ${_.chat.attachmentPreviewMissingAuth}`:A,L=_.chat.attachmentPreviewMissingAuth,R=p===`single`?`size-full object-contain`:p===`grid-cell`?`size-full object-cover`:`max-h-16 w-full object-cover`,z=p===`single`?m?`w-36 max-w-full`:`w-44 max-w-full`:p===`grid-cell`?`min-h-0 w-full`:`max-w-[10rem]`,B=p===`grid-cell`?`relative block aspect-square w-full min-w-0 overflow-hidden rounded-md border border-edge dark:border-edge`:p===`single`?`relative block aspect-[4/3] w-full overflow-hidden rounded-md border border-edge bg-surface-hover dark:border-edge`:`block w-full overflow-hidden rounded-md border border-edge dark:border-edge`,V=p===`grid-cell`?`w-full min-h-0`:`inline-block`,H;t[19]!==l||t[20]!==V?(H=K(`group relative min-w-0`,V,l),t[19]=l,t[20]=V,t[21]=H):H=t[21];let U;t[22]!==n||t[23]!==A||t[24]!==B||t[25]!==S||t[26]!==R||t[27]!==z||t[28]!==k||t[29]!==b||t[30]!==j||t[31]!==D||t[32]!==_.chat.attachmentPreviewLoadError||t[33]!==_.chat.pastedText||t[34]!==I||t[35]!==v||t[36]!==L||t[37]!==d||t[38]!==u||t[39]!==F||t[40]!==E||t[41]!==M?(U=b?(0,$.jsxs)(`div`,{className:z,children:[(0,$.jsxs)(`div`,{className:`relative size-full min-h-0`,children:[(0,$.jsxs)(`button`,{type:`button`,className:K(B,yc.transition,yc.press,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:()=>d(n),title:I,"aria-label":I,"aria-describedby":E?v:void 0,children:[S.src?(0,$.jsx)(`img`,{src:S.src,alt:A,className:R,decoding:`async`}):S.error||E?(0,$.jsxs)(`span`,{className:`flex size-full flex-col items-center justify-center gap-1 bg-surface-hover px-2 text-center text-[10px] text-fg-muted`,title:E?L:_.chat.attachmentPreviewLoadError,children:[(0,$.jsx)(Qr,{className:`size-5`,strokeWidth:1.5,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:E?L:_.chat.attachmentPreviewLoadError})]}):(0,$.jsx)(`span`,{className:`block size-full animate-pulse bg-surface-active`,"aria-hidden":!0}),u?(0,$.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/55 text-lg font-semibold text-white`,children:u}):null]}),D?(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 right-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,"aria-hidden":!0,children:`PDF`}):null]}),E?(0,$.jsx)(`p`,{id:v,className:`mt-1 line-clamp-2 text-[10px] leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]}):(0,$.jsx)(`div`,{className:K(`max-w-[14rem]`,M&&`inline-flex max-w-full`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(n),title:I,"aria-label":I,"aria-describedby":E?v:void 0,className:K(`flex min-w-0 border border-edge bg-surface-hover text-left text-xs text-fg-muted hover:bg-surface-active dark:border-edge`,M?`w-auto max-w-full items-center gap-1.5 rounded-full px-2.5 py-1`:`w-full gap-2 rounded-md px-2 py-1.5`,E?`items-start`:`items-center`,yc.transition,yc.press,yc.focusRingPanel),children:[j?(0,$.jsx)(Pr,{className:K(`shrink-0 text-accent-fg`,M?`size-3.5`:`size-8`),"aria-hidden":!0}):k?(0,$.jsx)(Rr,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}):(0,$.jsx)(zr,{className:`size-8 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:K(`truncate text-fg`,M?`inline`:`block`),children:j?_.chat.pastedText:A}),M?(0,$.jsxs)(`span`,{className:`ml-1 whitespace-nowrap text-fg-subtle`,children:[`· `,F]}):null,E?(0,$.jsx)(`span`,{id:v,className:`mt-0.5 line-clamp-2 block text-[10px] font-normal leading-snug text-amber-600 dark:text-amber-500`,children:L}):null]})]})}),t[22]=n,t[23]=A,t[24]=B,t[25]=S,t[26]=R,t[27]=z,t[28]=k,t[29]=b,t[30]=j,t[31]=D,t[32]=_.chat.attachmentPreviewLoadError,t[33]=_.chat.pastedText,t[34]=I,t[35]=v,t[36]=L,t[37]=d,t[38]=u,t[39]=F,t[40]=E,t[41]=M,t[42]=U):U=t[42];let W;t[43]!==_.chat.attachmentPreviewRemove||t[44]!==o||t[45]!==f?(W=f?(0,$.jsx)(`button`,{type:`button`,className:K(`absolute -right-1 -top-1 flex size-5 items-center justify-center rounded-full border border-edge bg-surface-panel text-fg-muted shadow-surface hover:text-fg dark:border-edge`,yc.transition,yc.press,yc.focusRingPanel),onClick:e=>{e.stopPropagation(),o?.()},title:_.chat.attachmentPreviewRemove,"aria-label":_.chat.attachmentPreviewRemove,children:(0,$.jsx)(ye,{className:`size-3`})}):null,t[43]=_.chat.attachmentPreviewRemove,t[44]=o,t[45]=f,t[46]=W):W=t[46];let G;return t[47]!==H||t[48]!==U||t[49]!==W?(G=(0,$.jsxs)(`div`,{className:H,children:[U,W]}),t[47]=H,t[48]=U,t[49]=W,t[50]=G):G=t[50],G}function nO(e){return e.language}function rO(e){let t=(0,Q.c)(11),{layout:n,conversationId:r,workspaceConversationId:i,projectId:a}=e,[o,s]=(0,Z.useState)(null),c=Ow(iO),l;t[0]!==r||t[1]!==n||t[2]!==a||t[3]!==c||t[4]!==i?(l=e=>{let t=i??r;if(n===`assistant`&&e.workspaceRelativePath?.trim()&&(a?.trim()||t?.trim())){c(e.workspaceRelativePath.trim(),null,a,t);return}s(e)},t[0]=r,t[1]=n,t[2]=a,t[3]=c,t[4]=i,t[5]=l):l=t[5];let u=l,d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>s(null),t[6]=d):d=t[6];let f=d,p=o!==null,m;return t[7]!==o||t[8]!==u||t[9]!==p?(m={active:o,open:p,openAttachment:u,closePreview:f},t[7]=o,t[8]=u,t[9]=p,t[10]=m):m=t[10],m}function iO(e){return e.setPath}function aO(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function oO(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function sO(e){let t=(0,Q.c)(9),{att:n,conversationId:r}=e,i;t[0]!==n.content||t[1]!==n.data||t[2]!==n.taskId||t[3]!==n.uri||t[4]!==r?(i=JSON.stringify([n.uri,n.content,n.data,n.taskId,r]),t[0]=n.content,t[1]=n.data,t[2]=n.taskId,t[3]=n.uri,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e||t[7]!==i?(a=(0,$.jsx)(cO,{...e},i),t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function cO({att:e,align:t=`start`,embedded:n=!1,conversationId:r}){let i=Ee(e=>e.language),a=i===`zh`,o=xe(i).chat,s=(0,Z.useId)(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(0),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(1),[C,w]=(0,Z.useState)(0),T=C||(oO(e.durationSeconds)?e.durationSeconds:0),[E,D]=(0,Z.useState)(0),O=e.content??e.data;(0,Z.useEffect)(()=>{let t=new AbortController,n;return f(!1),u(void 0),(async()=>{try{if(O){u(`data:${e.mimeType||`audio/mpeg`};base64,${O.replace(/\s/g,``)}`);return}if(!e.uri)throw Error(`Missing audio source`);let i=await we(J(l_(e.uri,r,e.taskId)),{signal:t.signal});if(!i.ok)throw Error(`Audio unavailable`);let a=await i.blob();if(t.signal.aborted)return;n=URL.createObjectURL(a),u(n)}catch{t.signal.aborted||f(!0)}})(),()=>{t.abort(),n&&URL.revokeObjectURL(n)}},[O,e.mimeType,e.uri,e.taskId,r,p]),(0,Z.useEffect)(()=>{let e=c.current,t=()=>e?.pause(),n=e=>{let n=e.detail?.id;n&&n!==s&&t()};return window.addEventListener(`xopc-voice-recording-start`,t),window.addEventListener(`xopc-voice-playback-start`,n),()=>{t(),window.removeEventListener(`xopc-voice-recording-start`,t),window.removeEventListener(`xopc-voice-playback-start`,n)}},[s]);let k=()=>{let e=c.current;if(d){m(e=>e+1);return}!e||!l||(h?e.pause():e.play().catch(e=>{e instanceof DOMException&&e.name===`AbortError`||f(!0)}))},j=()=>{let e=c.current?.duration;oO(e)&&w(e)},M=a?`播放选项`:`Playback options`;return(0,$.jsx)(`div`,{className:K(`flex min-w-0`,t===`end`&&`justify-end`,t===`center`&&`justify-center`),children:(0,$.jsxs)(`div`,{className:K(`w-60 max-w-full rounded-xl`,!n&&`bg-surface-base px-1`),role:`group`,"aria-label":o.voiceAriaRegion,children:[!l&&!d?(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:o.voiceLoading}):null,(0,$.jsxs)(`div`,{className:`flex min-h-14 items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:k,disabled:!l&&!d,className:`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":d?a?`重试播放`:`Retry playback`:h?o.voicePause:o.voicePlay,children:d?(0,$.jsx)(Hi,{className:`size-5`,"aria-hidden":!0}):h?(0,$.jsx)(Ai,{className:`size-5`,"aria-hidden":!0}):(0,$.jsx)(Li,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,"aria-hidden":!0,children:!l&&!d?(0,$.jsx)(xn,{className:`h-1 w-full`}):(0,$.jsx)(`div`,{className:`h-1 overflow-hidden rounded-full bg-surface-active`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${T>0?Math.min(100,E/T*100):0}%`}})})}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>v(!_),"aria-label":M,"aria-expanded":_,"aria-controls":`${s}-options`,className:`flex min-h-11 shrink-0 items-center gap-1 rounded-lg px-2 text-[13px] tabular-nums text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[E>0||T>0?aO(E>0?E:T):`—`,(0,$.jsx)(cr,{className:K(`size-3`,_&&`rotate-180`),"aria-hidden":!0})]})]}),d?(0,$.jsx)(`p`,{role:`alert`,className:`px-2 pb-2 text-xs text-fg-muted`,children:a?`音频无法播放,请重试`:`Audio unavailable. Try again.`}):null,_?(0,$.jsxs)(`div`,{id:`${s}-options`,className:`space-y-2 px-2 pb-3`,children:[(0,$.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[a?`播放进度`:`Playback position`,(0,$.jsx)(`input`,{type:`range`,min:0,max:T||1,step:.1,value:Math.min(E,T),disabled:!l||!T||d,onChange:e=>{c.current&&(c.current.currentTime=Number(e.target.value),D(Number(e.target.value)))},className:`block h-11 w-full accent-accent`})]}),(0,$.jsx)(A,{contentClassName:`[&_button]:min-h-11`,value:String(x),allowEmpty:!1,placeholder:`1×`,ariaLabel:o.voicePlaybackSpeed,triggerClassName:`min-h-11`,options:[.75,1,1.25,1.5,2].map(e=>({value:String(e),label:`${e}×`})),onChange:e=>{let t=Number(e);S(t),c.current&&(c.current.playbackRate=t)}})]}):null,e.extractedText?.trim()?(0,$.jsxs)(`div`,{className:`px-2 pb-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`min-h-11 rounded-lg text-xs text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>b(!y),"aria-expanded":y,"aria-controls":`${s}-text`,children:y?a?`收起文字`:`Hide transcript`:a?`查看文字`:`Show transcript`}),y?(0,$.jsx)(`p`,{id:`${s}-text`,className:`whitespace-pre-wrap break-words pb-2 text-sm text-fg-muted`,children:e.extractedText}):null]}):null,(0,$.jsx)(`audio`,{ref:c,src:l,preload:`metadata`,className:`hidden`,onLoadedMetadata:j,onDurationChange:j,onTimeUpdate:e=>D(e.currentTarget.currentTime),onError:()=>{l&&(g(!1),f(!0))},onPlay:e=>{e.currentTarget.playbackRate=x,g(!0),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:s}}))},onPause:()=>g(!1),onEnded:()=>{g(!1),D(0)}})]})})}function lO(e){return e.type===`voice`||e.type===`audio`||e.mimeType?.startsWith(`audio/`)===!0}var uO=9;function dO(e,t){let n=t?`max-w-[11rem]`:`max-w-52`,r=`gap-1`;return e===1?{container:`grid grid-cols-1 ${n} ${r}`,tileSize:`single`}:e===2?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e===3?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:e===4?{container:`grid grid-cols-2 ${n} ${r}`,tileSize:`grid-cell`}:e<=uO?{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`}:{container:`grid grid-cols-3 ${n} ${r}`,tileSize:`grid-cell`,overflowCount:e-(uO-1)}}function fO(e){let t=(0,Q.c)(29),{attachments:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,layout:s,centerUserVoiceRow:c}=e,l=s===void 0?`assistant`:s,u=c===void 0?!1:c,d;t[0]!==i||t[1]!==l||t[2]!==o||t[3]!==a?(d={layout:l,conversationId:i,workspaceConversationId:a,projectId:o},t[0]=i,t[1]=l,t[2]=o,t[3]=a,t[4]=d):d=t[4];let f=rO(d);if(!n?.length)return null;let p,m,h,g;if(t[5]!==n||t[6]!==r||t[7]!==u||t[8]!==i||t[9]!==l||t[10]!==f.openAttachment){let e=n.filter(mO),a=n.filter(lO),o=n.filter(pO);p=`flex flex-col gap-2`,m=e.length>0?(()=>{let t=dO(e.length,l===`user`),n=t.overflowCount==null?e:e.slice(0,uO-1);return(0,$.jsxs)(`div`,{className:K(`w-full min-w-0`,t.container),children:[n.map((e,n)=>(0,$.jsx)(tO,{attachment:e,authToken:r,conversationId:i,imageSize:t.tileSize,compact:l===`user`,onOpen:f.openAttachment},e.id??`${e.name}-${n}`)),t.overflowCount==null?null:(0,$.jsx)(tO,{attachment:e[uO-1],authToken:r,conversationId:i,imageSize:`grid-cell`,compact:l===`user`,overflowLabel:`+${t.overflowCount}`,onOpen:f.openAttachment},e[uO-1]?.id??`overflow-${uO-1}`)]})})():null,h=a.length>0?(0,$.jsx)(`div`,{className:K(`flex flex-col gap-2`,l===`user`&&(u?`items-center`:`items-end`)),children:a.map((e,t)=>(0,$.jsx)(sO,{att:e,conversationId:i,align:l===`user`?u?`center`:`end`:`start`,embedded:l===`user`},e.id??`${e.name}-${t}`))}):null,g=o.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o.map((e,t)=>(0,$.jsx)(tO,{attachment:e,authToken:r,conversationId:i,onOpen:f.openAttachment},e.id??`${e.name}-${t}`))}):null,t[5]=n,t[6]=r,t[7]=u,t[8]=i,t[9]=l,t[10]=f.openAttachment,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else p=t[11],m=t[12],h=t[13],g=t[14];let _;t[15]!==p||t[16]!==m||t[17]!==h||t[18]!==g?(_=(0,$.jsxs)(`div`,{className:p,children:[m,h,g]}),t[15]=p,t[16]=m,t[17]=h,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==r||t[21]!==i||t[22]!==f.active||t[23]!==f.closePreview||t[24]!==f.open?(v=(0,$.jsx)(rD,{open:f.open,attachment:f.active,authToken:r,conversationId:i,onClose:f.closePreview}),t[20]=r,t[21]=i,t[22]=f.active,t[23]=f.closePreview,t[24]=f.open,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)($.Fragment,{children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function pO(e){return e.type!==`image`&&!e.mimeType?.startsWith(`image/`)&&!lO(e)}function mO(e){return e.type===`image`||e.mimeType?.startsWith(`image/`)}function hO(e,t){let n=e.source?.data?.trim();if(!n)return null;let r=n.match(/^data:([^;]+);base64,([\s\S]+)$/i);if(r?.[1]&&r[2]){let e=r[2].replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:r[1],type:`image`,content:e,data:e}}if(n.startsWith(`data:`))return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:n,data:n};let i=n.replace(/\s/g,``);return{name:`image-${t+1}`,mimeType:`image/png`,type:`image`,content:i,data:i}}function gO(e){return e?.length?e.flatMap((e,t)=>{let n=hO(e,t);return n?[n]:[]}):[]}function _O(e){let t=[];for(let n of e)if(n.type===`text`){if(n.presentation===`pending`||n.presentation===`narration`)continue;t.push(n.text)}else n.type===`image`&&t.push(`[image]`);return t.join(`
25
-
26
- `).trim()}function vO(e){if(!e.trim())return``;let t=ae.parse(e,{gfm:!0,breaks:!1});return new DOMParser().parseFromString(`<div>${t}</div>`,`text/html`).body.textContent?.trim()??``}function yO(e){let t=[];for(let n of e)if(n.type===`text`){if(n.presentation===`pending`||n.presentation===`narration`)continue;t.push(vO(n.text))}else n.type===`image`&&t.push(`[image]`);return t.join(`
27
-
28
- `).trim()}function bO(e){let t=[];((n,r)=>{let i=new RegExp(n.source,n.flags),a;for(;(a=i.exec(e))!==null;)t.push({start:a.index,end:a.index+a[0].length,seg:r(a)})})(Ig(),e=>({kind:`skill`,name:e[1]??``}));for(let n of Lw(e))t.push({start:n.start,end:n.end,seg:{kind:`command`,name:e.slice(n.start+1,n.end)}});t.sort((e,t)=>e.start===t.start?t.end-e.end:e.start-t.start);let n=[],r=0;for(let i of t)i.start<r||(i.start>r&&n.push({kind:`text`,text:e.slice(r,i.start)}),n.push(i.seg),r=i.end);return r<e.length&&n.push({kind:`text`,text:e.slice(r)}),n.length===0&&n.push({kind:`text`,text:e}),n}function xO(e){return e.kind===`text`?`t:${e.text}`:e.kind===`skill`?`s:${e.name}`:e.kind===`context_ref`?`r:${e.refId}`:`c:${e.name}`}function SO(e,t){let n=e[t-1],r=e[t-2],i=e[t+1],a=n?.kind===`text`&&n.text.trim()===``&&r!==void 0&&r.kind!==`text`;return K(n?.kind===`text`&&/\s$/u.test(n.text)&&!a&&`ms-1`,i?.kind===`text`&&/^\s/u.test(i.text)&&`me-1`)}function CO(e){let t=(0,Q.c)(6),{contextRef:n}=e;if(n?.kind===`file`&&n.fileKind===`directory`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gr,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[0]=e):e=t[0],e}if(n?.kind===`file`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(zr,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n?.kind===`session`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(pi,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[2]=e):e=t[2],e}if(n?.kind===`browser_tab`){let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Gn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=e):e=t[3],e}if(n?.kind===`mcp_resource`){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Or,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[4]=e):e=t[4],e}let r;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(xi,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=r):r=t[5],r}var wO=(0,Z.memo)(function(e){let t=(0,Q.c)(20),{text:n,conversationId:r,document:i,contextRefs:a}=e,o;bb0:{if(!i){let e;t[0]===n?e=t[1]:(e=bO(n),t[0]=n,t[1]=e),o=e;break bb0}let e;if(t[2]!==a||t[3]!==i.parts){let n=new Map(a?.flatMap(TO)??[]);e=i.parts.flatMap(e=>e.type===`text`?bO(e.text):[{kind:`context_ref`,refId:e.refId,ref:n.get(e.refId)}]),t[2]=a,t[3]=i.parts,t[4]=e}else e=t[4];o=e}let s=o,c;if(t[5]!==s){let e=new Map;c=s.map(t=>{let n=xO(t),r=e.get(n)??0;return e.set(n,r+1),{part:t,key:`${n}#${String(r)}`}}),t[5]=s,t[6]=c}else c=t[6];let l=c,u;t[7]===s?u=t[8]:(u=s.some(EO),t[7]=s,t[8]=u);let d=aE(void 0,r,u);if(!s.some(DO)){let e;return t[9]===n?e=t[10]:(e=(0,$.jsx)(`div`,{className:`markdown-content min-w-0`,children:(0,$.jsx)(ie,{content:n,compact:!0,breaks:!0})}),t[9]=n,t[10]=e),e}let f;if(t[11]!==s||t[12]!==l||t[13]!==d){let e;t[15]!==s||t[16]!==d?(e=(e,t)=>{let{part:n,key:r}=e;return n.kind===`skill`?(0,$.jsxs)(`span`,{className:`chat-skill-pill max-w-full shrink-0`,"data-skill":n.name,title:`/${n.name}`,children:[`/`,d(n.name)]},r):n.kind===`command`?(0,$.jsxs)(`span`,{className:`chat-command-pill max-w-full shrink-0`,"data-slash-command":n.name,children:[`/`,n.name]},r):n.kind===`context_ref`?(0,$.jsxs)(`span`,{className:K(`chat-context-ref-pill chat-context-ref-pill-message max-w-full shrink-0`,SO(s,t)),"data-context-ref-id":n.refId,"data-ref-kind":n.ref?.kind??``,"data-file-kind":n.ref?.fileKind??``,title:n.ref?.title,"aria-label":n.ref?.title??`reference`,children:[(0,$.jsx)(CO,{contextRef:n.ref}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:n.ref?.title??`reference`})]},r):n.text?(0,$.jsx)(`div`,{className:`chat-user-message-segment markdown-content inline-block min-w-0 max-w-full align-baseline text-fg`,children:(0,$.jsx)(ie,{content:n.text,compact:!0,breaks:!0})},r):null},t[15]=s,t[16]=d,t[17]=e):e=t[17],f=l.map(e),t[11]=s,t[12]=l,t[13]=d,t[14]=f}else f=t[14];let p;return t[18]===f?p=t[19]:(p=(0,$.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline gap-x-0 gap-y-1 [text-align:inherit]`,children:f}),t[18]=f,t[19]=p),p});function TO(e){return e.refId?[[e.refId,e]]:[]}function EO(e){return e.kind===`skill`}function DO(e){return e.kind!==`text`}function OO(e,t){switch(e.code){case`provider_setup_required`:return{title:t.providerSetupRequiredTitle,body:t.providerSetupRequiredBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.providerSetupRequiredCta,deepLink:`/settings/capabilities/models`};case`provider_auth_invalid`:return{title:t.agentRunErrorAuthInvalidTitle,body:t.agentRunErrorAuthInvalidBody.replace(`{{provider}}`,e.provider??t.agentRunErrorUnknownProvider),cta:t.agentRunErrorCtaProviders,deepLink:`/settings/capabilities/models`};case`rate_limit`:return{title:t.agentRunErrorRateLimitTitle,body:t.agentRunErrorRateLimitBody};case`timeout`:return{title:t.agentRunErrorTimeoutTitle,body:t.agentRunErrorTimeoutBody};case`billing`:return{title:t.agentRunErrorBillingTitle,body:t.agentRunErrorBillingBody};case`model_quota_exhausted`:return{title:t.xopcQuotaExhaustedTitle,body:t.xopcQuotaExhaustedBody};case`platform_token_limit_exceeded`:return{title:t.xopcPlatformLimitTitle,body:t.xopcPlatformLimitBody,cta:t.xopcPlatformLimitCta,deepLink:`/settings/capabilities/models?add=1`};case`send_failed`:return{title:t.agentRunErrorSendFailedTitle,body:t.agentRunErrorSendFailedBody};case`session_not_found`:return{title:t.sessionNotFoundTitle,body:t.sessionNotFoundBody,cta:t.sessionNotFoundCta,deepLink:`/chat/new`};default:return{title:t.agentRunErrorUnknownTitle,body:t.agentRunErrorUnknownBody}}}function kO(e){let t=(0,Q.c)(4),{code:n}=e;switch(n){case`provider_setup_required`:case`provider_auth_invalid`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ei,{className:`size-4`,strokeWidth:1.75}),t[0]=e):e=t[0],e}case`rate_limit`:case`timeout`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Tr,{className:`size-4`,strokeWidth:1.75}),t[1]=e):e=t[1],e}case`billing`:case`model_quota_exhausted`:case`platform_token_limit_exceeded`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(va,{className:`size-4`,strokeWidth:1.75}),t[2]=e):e=t[2],e}default:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(dr,{className:`size-4`,strokeWidth:1.75}),t[3]=e):e=t[3],e}}}function AO(e){return e===`provider_setup_required`||e===`provider_auth_invalid`||e===`rate_limit`||e===`timeout`||e===`billing`||e===`model_quota_exhausted`||e===`platform_token_limit_exceeded`||e===`session_not_found`?`amber`:`red`}function jO(e){let t=(0,Q.c)(46),{payload:n}=e,r=l(),i=Ee(NO),a,o;t[0]!==i||t[1]!==n?(a=xe(i).chat,o=OO(n,a),t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]);let s=o,c=AO(n.code),u=c===`amber`?`border-amber-300/60 bg-amber-50 dark:border-amber-500/30 dark:bg-amber-950`:`border-red-300/60 bg-red-50 dark:border-red-500/30 dark:bg-red-950`,d=c===`amber`?`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`:`bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-300`,f=c===`amber`?`text-amber-900 dark:text-amber-100`:`text-red-900 dark:text-red-100`,p=c===`amber`?`text-amber-900/85 dark:text-amber-100/80`:`text-red-900/85 dark:text-red-100/80`,m=c===`amber`?`text-amber-800/80 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`:`text-red-800/80 hover:text-red-900 dark:text-red-200/80 dark:hover:text-red-100`,h=c===`amber`?`bg-amber-100/60 text-amber-900 dark:bg-amber-500/15 dark:text-amber-100`:`bg-red-100/60 text-red-900 dark:bg-red-500/15 dark:text-red-100`,g=c===`amber`?`bg-amber-600 text-white hover:bg-amber-700 dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`:`bg-red-600 text-white hover:bg-red-700 dark:bg-red-500 dark:text-red-950 dark:hover:bg-red-400`,_=n.code===`model_quota_exhausted`,v=MO,y;t[4]===u?y=t[5]:(y=K(`flex flex-col gap-2 rounded-xl border p-3`,u),t[4]=u,t[5]=y);let b;t[6]===d?b=t[7]:(b=K(`flex size-8 shrink-0 items-center justify-center rounded-lg`,d),t[6]=d,t[7]=b);let x;t[8]===n.code?x=t[9]:(x=(0,$.jsx)(kO,{code:n.code}),t[8]=n.code,t[9]=x);let S;t[10]!==b||t[11]!==x?(S=(0,$.jsx)(`span`,{className:b,"aria-hidden":!0,children:x}),t[10]=b,t[11]=x,t[12]=S):S=t[12];let C;t[13]===f?C=t[14]:(C=K(`text-sm font-semibold`,f),t[13]=f,t[14]=C);let w;t[15]!==s.title||t[16]!==C?(w=(0,$.jsx)(`h3`,{className:C,children:s.title}),t[15]=s.title,t[16]=C,t[17]=w):w=t[17];let T;t[18]===p?T=t[19]:(T=K(`mt-1 text-xs leading-relaxed`,p),t[18]=p,t[19]=T);let E;t[20]!==s.body||t[21]!==T?(E=(0,$.jsx)(`p`,{className:T,children:s.body}),t[20]=s.body,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==w||t[24]!==E?(D=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,E]}),t[23]=w,t[24]=E,t[25]=D):D=t[25];let O;t[26]!==D||t[27]!==S?(O=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[S,D]}),t[26]=D,t[27]=S,t[28]=O):O=t[28];let k;t[29]!==s.cta||t[30]!==s.deepLink||t[31]!==g||t[32]!==a||t[33]!==r||t[34]!==_?(k=_?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,g),onClick:()=>v(`/models/credits/purchase`),children:a.xopcQuotaPurchaseCta}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>v(`/models/credits/request`),children:a.xopcQuotaRequestCta}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-lg border border-current px-3 py-1.5 text-xs font-medium transition-colors hover:bg-amber-500/10`,onClick:()=>r(`/settings/capabilities/models?add=1`),children:a.xopcQuotaOwnProviderCta})]}):s.cta&&s.deepLink?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`,g),onClick:()=>r(s.deepLink),children:s.cta})}):null,t[29]=s.cta,t[30]=s.deepLink,t[31]=g,t[32]=a,t[33]=r,t[34]=_,t[35]=k):k=t[35];let A;t[36]!==m||t[37]!==h||t[38]!==a||t[39]!==n.message?(A=n.message?(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,$.jsx)(`summary`,{className:K(`cursor-pointer select-none underline-offset-2`,m),children:a.agentRunErrorDetailToggle}),(0,$.jsx)(`pre`,{className:K(`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md p-2 font-mono text-[11px] [overflow-wrap:anywhere]`,h),children:n.message})]}):null,t[36]=m,t[37]=h,t[38]=a,t[39]=n.message,t[40]=A):A=t[40];let j;return t[41]!==O||t[42]!==k||t[43]!==A||t[44]!==y?(j=(0,$.jsxs)(`section`,{role:`alert`,"aria-live":`polite`,className:y,children:[O,k,A]}),t[41]=O,t[42]=k,t[43]=A,t[44]=y,t[45]=j):j=t[45],j}function MO(e){return window.open(`https://console.xopc.ai${e}`,`_blank`,`noopener,noreferrer`)}function NO(e){return e.language}function PO(e){let t=(0,Q.c)(8),{errorText:n}=e,r;t[0]===n?r=t[1]:(r=Qg(n),t[0]=n,t[1]=r);let i=r;if(!i)return null;let a;t[2]===i?a=t[3]:(a=$g(i),t[2]=i,t[3]=a);let o=a;if(o){let e;return t[4]===o?e=t[5]:(e=(0,$.jsx)(`div`,{className:`mb-4`,children:(0,$.jsx)(FO,{payload:o})}),t[4]=o,t[5]=e),e}let s;return t[6]===i?s=t[7]:(s=(0,$.jsx)(`div`,{className:`mb-4`,children:(0,$.jsx)(jO,{payload:i})}),t[6]=i,t[7]=s),s}function FO(e){let t=(0,Q.c)(32),{payload:n}=e,r=l(),i=Ee(IO),a,o,s,c;t[0]!==i||t[1]!==n.kind||t[2]!==n.provider?(o=xe(i).chat,a=n.kind===`provider_auth_invalid`,c=a?o.agentRunErrorAuthInvalidTitle:o.providerSetupRequiredTitle,s=(a?o.agentRunErrorAuthInvalidBody:o.providerSetupRequiredBody).replace(`{{provider}}`,n.provider),t[0]=i,t[1]=n.kind,t[2]=n.provider,t[3]=a,t[4]=o,t[5]=s,t[6]=c):(a=t[3],o=t[4],s=t[5],c=t[6]);let u=s,d=a?o.agentRunErrorCtaProviders:o.providerSetupRequiredCta,f=a?o.agentRunErrorDetailToggle:o.providerSetupRequiredDetailToggle,p=a?`alert`:`status`,m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=K(`flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50 p-3`,`dark:border-amber-500/30 dark:bg-amber-950`),t[7]=m):m=t[7];let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=K(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[8]=h):h=t[8];let g;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:h,"aria-hidden":!0,children:(0,$.jsx)(ei,{className:`size-4`,strokeWidth:1.75})}),t[9]=g):g=t[9];let _;t[10]===c?_=t[11]:(_=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[10]=c,t[11]=_);let v;t[12]===u?v=t[13]:(v=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:u}),t[12]=u,t[13]=v);let y;t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,v]})]}),t[14]=_,t[15]=v,t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=K(`inline-flex h-8 items-center rounded-lg px-3 py-1.5 text-xs font-medium`,`bg-amber-600 text-white hover:bg-amber-700`,`dark:bg-amber-500 dark:text-amber-950 dark:hover:bg-amber-400`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50`),t[17]=b):b=t[17];let x;t[18]!==r||t[19]!==n.deepLink?(x=()=>r(n.deepLink),t[18]=r,t[19]=n.deepLink,t[20]=x):x=t[20];let S;t[21]!==d||t[22]!==x?(S=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:(0,$.jsx)(`button`,{type:`button`,className:b,onClick:x,children:d})}),t[21]=d,t[22]=x,t[23]=S):S=t[23];let C;t[24]!==f||t[25]!==n.message?(C=n.message?(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:f}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.message})]}):null,t[24]=f,t[25]=n.message,t[26]=C):C=t[26];let w;return t[27]!==S||t[28]!==C||t[29]!==p||t[30]!==y?(w=(0,$.jsxs)(`section`,{role:p,"aria-live":`polite`,className:m,children:[y,S,C]}),t[27]=S,t[28]=C,t[29]=p,t[30]=y,t[31]=w):w=t[31],w}function IO(e){return e.language}var LO=/^No API key found for (\S+)/i;function RO(e){let t=e.trim();if(t.startsWith(`{`))try{let e=JSON.parse(t);return e.kind!==`provider_setup_required`||typeof e.provider!=`string`||!e.provider||typeof e.deepLink!=`string`||!e.deepLink.startsWith(`/settings/`)?null:{kind:`provider_setup_required`,provider:e.provider,deepLink:e.deepLink,message:typeof e.message==`string`?e.message:void 0}}catch{return null}let n=LO.exec(t);return n?{kind:`provider_setup_required`,provider:n[1].replace(/[.,]$/,``),deepLink:`/settings/capabilities/models`,message:t}:null}function zO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function BO(e){let t=e.match(/^ {0,3}(`{3,}|~{3,})(.*)$/),n=t?.[1];return!n||!t?null:{marker:n[0],length:n.length,rest:t[2]??``}}function VO(e){let t=null,n=null,r=0;for(let i of e.match(/[^\n]*(?:\n|$)/g)??[]){if(!i)continue;let e=i.endsWith(`
29
- `)?i.slice(0,-1):i;if(!n){let n=BO(e);if(n){if(!t){if(n.marker===`~`||!n.rest.includes("`")){t={marker:n.marker,length:n.length},r+=i.length;continue}}else if(n.marker===t.marker&&n.length>=t.length&&!n.rest.trim()){t=null,r+=i.length;continue}}}if(!t)for(let t=0;t<e.length;){if(e[t]!=="`"||zO(e,t)){t+=1;continue}let i=t+1;for(;e[i]==="`";)i+=1;let a=i-t;n?n.delimiterLength===a&&(n=null):n={start:r+t,delimiterLength:a},t=i}r+=i.length}return t?null:n}function HO(e){let t=e.replace(/\r$/,``),n=``,r=t,i=r.match(/^\s{0,3}/)?.[0]??``;for(n+=i,r=r.slice(i.length);r.startsWith(`>`);){n+=`>`,r=r.slice(1),r.startsWith(` `)&&(n+=` `,r=r.slice(1));let e=r.match(/^\s{0,3}/)?.[0]??``;n+=e,r=r.slice(e.length)}return n}function UO(e){let t=e.replace(/\r$/,``);return t.slice(HO(t).length)}function WO(e){return UO(e).trim().replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim())}function GO(e){return(UO(e).match(/\|/g)??[]).length}function KO(e){let t=UO(e).trim();return t?t.startsWith(`|`)?WO(e).length>=2:GO(e)>=2:!1}function qO(e){let t=UO(e).trim();return t.includes(`-`)&&/^[\s|:-]+$/.test(t)}function JO(e){let t=UO(e).trim();return t.length>0&&/^[\s|:]+$/.test(t)}function YO(e){return WO(e).filter(e=>e.includes(`-`)).length}function XO(e,t=``){return`${t}| ${Array.from({length:e},()=>`---`).join(` | `)} |`}function ZO(e,t){let n=WO(e);for(;n.length<t;)n.push(``);return`${HO(e)}| ${n.slice(0,t).join(` | `)} |`}function QO(e){return(e.match(/^\s*(```|~~~)/gm)??[]).length%2==1}function $O(e){let t=VO(e),n=t?e.slice(0,t.start):e;if(!n.includes(`|`)||QO(n))return n;let r=n.split(`
30
- `),i=r.length-1;for(;i>0&&r[i-1]?.trim();)i--;let a=r.slice(i).findIndex(e=>KO(e));if(a<0)return n;let o=i+a,s=r[o]??``,c=WO(s).length;if(c<2)return n;let l=HO(s),u=o+1,d=r[u];if(d===void 0)return`${n}${n.endsWith(`
31
- `)?``:`
32
- `}${XO(c,l)}`;if(!UO(d).trim()){let e=[...r];return e[u]=XO(c,l),e.join(`
33
- `)}if(qO(d)&&YO(d)<c||JO(d)){let e=[...r];return e[u]=XO(c,l),e.join(`
34
- `)}if(!qO(d))return n;let f=r.length-1,p=r[f]??``;if(f>u&&KO(p)&&!qO(p)&&!p.trim().endsWith(`|`)){let e=[...r];return e[f]=ZO(p,c),e.join(`
35
- `)}return n}function ek(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.type===`text`&&e?.type===`text`&&n.segmentId===e.segmentId&&n.presentation===e.presentation){e.text=`${e.text??``}${n.text??``}`;continue}t.push({...n})}return t}var tk=/^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/m,nk=/^\s{0,3}(?:[-+*]|\d+[.)])\s+/m,rk=/^\s{0,3}```/gm;function ik(e){return(e.match(rk)?.length??0)%2==1?`code`:tk.test(e)?`table`:nk.test(e)?`list`:e.length>=4096?`long_text`:`plain`}var ak={plain:32,long_text:48,list:40,table:72,code:64},ok=48,sk=16,ck=6,lk=512;function uk({tailKind:e,latestParseMs:t}){let n=ak[e];return!Number.isFinite(t)||t<=16?n:Math.min(120,Math.max(n,Math.ceil(t*2)))}function dk({intervalMs:e,elapsedMs:t,firstCommit:n}){return n?Math.max(ok,e):Math.max(0,e-t)}function fk({visibleLength:e,pendingContent:t}){if(e>=t.length)return t.length;let n=Math.min(lk,Math.max(ck,Math.ceil(t.length/sk))),r=Math.min(t.length,e+n),i=t.charCodeAt(r-1),a=t.charCodeAt(r);return i>=55296&&i<=56319&&a>=56320&&a<=57343&&(r+=1),r}function pk(e,t,n,r,i){let a=(0,Q.c)(11),o=r===void 0?!1:r,s;a[0]===e?s=a[1]:(s=()=>e,a[0]=e,a[1]=s);let[c,l]=(0,Z.useState)(s),u=(0,Z.useRef)(e),d=(0,Z.useRef)(c),f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(t||o),h=(0,Z.useRef)(!1),g,_;a[2]!==e||a[3]!==n||a[4]!==i||a[5]!==t||a[6]!==c?(g=()=>{if(u.current=e,t&&(m.current=!0,h.current=!1,z(n,e.length)),!m.current){d.current=e,l(e);return}if(!t&&c!==e){re(n,e.length-c.length),f.current!==null&&(window.clearTimeout(f.current),f.current=null),d.current=e,p.current=null,l(e);return}if(c===e){t||(m.current=!1,p.current=null,h.current||(h.current=!0,i?.()));return}if(!e.startsWith(c)){d.current=e,l(e);return}if(f.current!==null)return;let r=uk({tailKind:ik(e.slice(-8192)),latestParseMs:ne(n)}),a=performance.now(),o=p.current,s=dk({intervalMs:r,elapsedMs:o===null?0:a-o,firstCommit:o===null});f.current=window.setTimeout(()=>{f.current=null;let e=u.current,t=fk({visibleLength:d.current.length,pendingContent:e}),r=e.slice(0,t);d.current=r,p.current=performance.now(),U(n,r.length),l(r)},s)},_=[e,n,i,t,c],a[2]=e,a[3]=n,a[4]=i,a[5]=t,a[6]=c,a[7]=g,a[8]=_):(g=a[7],_=a[8]),(0,Z.useEffect)(g,_);let v,y;return a[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)},y=[],a[9]=v,a[10]=y):(v=a[9],y=a[10]),(0,Z.useEffect)(v,y),c}function mk(e){if(!e.filePath)return``;if(!e.lineStart)return e.filePath;let t=e.lineEnd&&e.lineEnd!==e.lineStart?`-${e.lineEnd}`:``;return`${e.filePath}:${e.lineStart}${t}`}function hk(e){let t=(0,Q.c)(37),{review:n}=e,r=n.status===`preparing`||n.status===`reviewing`,i=n.status===`preparing`,a=n.source===`local`&&n.overallCorrectness===`unknown`,o=n.overallCorrectness===`patch is incorrect`?`border-red-500/30 bg-red-500/5 text-red-700 dark:text-red-300`:n.overallCorrectness===`patch is correct`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700 dark:text-emerald-300`:`border-edge bg-surface-inset text-fg-secondary`,s;t[0]===r?s=t[1]:(s=r?(0,$.jsx)(ue,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}):null,t[0]=r,t[1]=s);let c=r?`Reviewing changes`:`Code review finished`,l;t[2]===c?l=t[3]:(l=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg-primary`,children:c}),t[2]=c,t[3]=l);let u;t[4]!==o||t[5]!==i||t[6]!==r||t[7]!==n.overallCorrectness?(u=r?(0,$.jsx)(`div`,{className:`rounded-md border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-medium text-fg-secondary`,children:i?`Collecting changes`:`Review assistant`}):(0,$.jsx)(`div`,{className:K(`rounded-md border px-1.5 py-0.5 text-[11px] font-medium`,o),children:n.overallCorrectness}),t[4]=o,t[5]=i,t[6]=r,t[7]=n.overallCorrectness,t[8]=u):u=t[8];let d;t[9]!==s||t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s,l,u]}),t[9]=s,t[10]=l,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.target?f=t[14]:(f=(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`Based on `,n.target]}),t[13]=n.target,t[14]=f);let p;t[15]!==i||t[16]!==r||t[17]!==n.analysisMarkdown?(p=r&&!n.analysisMarkdown?(0,$.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:i?`Preparing an isolated review context…`:`The review assistant is checking the changes…`}):null,t[15]=i,t[16]=r,t[17]=n.analysisMarkdown,t[18]=p):p=t[18];let m;t[19]===n.analysisMarkdown?m=t[20]:(m=n.analysisMarkdown?(0,$.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-secondary`,children:`Review assistant`}),(0,$.jsx)(ie,{content:n.analysisMarkdown,compact:!0})]}):null,t[19]=n.analysisMarkdown,t[20]=m);let h;t[21]!==n.errorMessage||t[22]!==n.status?(h=n.status===`error`&&n.errorMessage?(0,$.jsxs)(`div`,{className:`mt-3 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-2 text-sm text-warning`,children:[`The review assistant could not complete: `,n.errorMessage]}):null,t[21]=n.errorMessage,t[22]=n.status,t[23]=h):h=t[23];let g;t[24]!==r||t[25]!==a||t[26]!==n.findings||t[27]!==n.overallExplanation||t[28]!==n.summary?(g=r?null:(0,$.jsxs)($.Fragment,{children:[n.summary?(0,$.jsx)(`div`,{className:`mt-3 text-sm text-fg-secondary`,children:n.summary}):null,(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,children:n.findings.length===0?(0,$.jsx)(`div`,{className:`text-sm text-fg-secondary`,children:a?`No model findings were produced.`:`No findings.`}):n.findings.map(gk)}),n.overallExplanation?(0,$.jsx)(`div`,{className:`mt-3 whitespace-pre-wrap text-sm text-fg-secondary`,children:n.overallExplanation}):null]}),t[24]=r,t[25]=a,t[26]=n.findings,t[27]=n.overallExplanation,t[28]=n.summary,t[29]=g):g=t[29];let _;return t[30]!==g||t[31]!==d||t[32]!==f||t[33]!==p||t[34]!==m||t[35]!==h?(_=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-inset p-3`,children:[d,f,p,m,h,g]}),t[30]=g,t[31]=d,t[32]=f,t[33]=p,t[34]=m,t[35]=h,t[36]=_):_=t[36],_}function gk(e,t){let n=mk(e);return(0,$.jsxs)(`div`,{className:`rounded-md border border-edge bg-surface p-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`rounded border border-edge bg-surface-inset px-1.5 py-0.5 text-[11px] font-semibold text-fg-secondary`,children:[`P`,e.priority]}),(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg-primary`,children:e.title})]}),n?(0,$.jsx)(`div`,{className:`mt-1 break-all text-xs text-fg-tertiary`,children:n}):null,e.body?(0,$.jsx)(`div`,{className:`mt-1 text-sm text-fg-secondary`,children:e.body}):null]},`${e.title}-${t}`)}function _k({resolution:e,conversationId:t,onClose:n}){let r=Ee(e=>e.language),i=xe(r).chat.fileReference,[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),d=An()&&!!window.electronAPI?.shell,f=e.target.path,p=e.status===`ready`?e.ref:null,m=p?.displayName??f.split(/[\\/]/).pop()??f,h=p?.absolutePath??p?.workspaceRelativePath??f,g=(0,Z.useCallback)(()=>{Yt(h).then(e=>{e&&(o(!0),window.setTimeout(()=>o(!1),2e3))})},[h]),_=async e=>{let n=window.electronAPI?.shell;if(!(!p?.fileRefId||!d||!n||l)){c(``),u(!0);try{let r=await HS(p.fileRefId,e,{conversationId:t?.trim()||void 0});if(e===`openExternal`){let e=await n.openPath(r.absolutePath);e.ok||c(e.error)}else (await n.showItemInFolder(r.absolutePath)).success||c(i.resolveFailedDescription)}catch(e){c(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,$.jsxs)(`div`,{className:K(`mt-2 flex max-w-xl min-w-0 flex-col gap-1.5 rounded-lg border px-2.5 py-2 text-xs`,e.status===`ready`&&e.ref.exists&&e.ref.scope!==`missing`?`border-edge-subtle bg-surface-panel`:`border-warning/30 bg-warning/5`),children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.status===`loading`?(0,$.jsx)(ue,{className:`size-3.5 shrink-0 animate-spin text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):e.status===`error`||p?.scope===`missing`||p?.scope===`invalid`?(0,$.jsx)(dr,{className:`size-3.5 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Br,{className:`size-3.5 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:m}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:K(`ml-auto inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel),"aria-label":i.closeActions,children:(0,$.jsx)(ye,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0})})]}),(0,$.jsx)(`p`,{className:`line-clamp-2 break-all text-[11px] leading-snug text-fg-muted`,children:e.status===`loading`?i.resolvingDescription:e.status===`error`?e.message:p?.scope===`missing`?i.missingDescription:p?.scope===`invalid`?i.invalidDescription:d?i.externalDescription:i.browserExternalDescription}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-0.5`,children:[d&&p?.capabilities.includes(`openExternal`)?(0,$.jsxs)(`button`,{type:`button`,className:vk,disabled:l,onClick:()=>void _(`openExternal`),children:[(0,$.jsx)(I,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i.openExternal})]}):null,d&&p?.capabilities.includes(`revealInFolder`)?(0,$.jsxs)(`button`,{type:`button`,className:vk,disabled:l,onClick:()=>void _(`revealInFolder`),children:[(0,$.jsx)(oe,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i.revealInFolder})]}):null,p?.manageRoute?(0,$.jsxs)(`a`,{className:vk,href:`#${p.manageRoute}`,children:[(0,$.jsx)(Ji,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:xe(r).nav.settings})]}):null,(0,$.jsxs)(`button`,{type:`button`,className:vk,onClick:g,children:[(0,$.jsx)(N,{className:`size-3`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:a?xe(r).chat.messageCopied:i.copyPath})]})]}),s?(0,$.jsx)(`p`,{role:`alert`,className:`text-warning`,children:s}):null]})}var vk=K(`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel,yc.press);function yk(e){let t=(0,Q.c)(35),{content:n,compact:r,conversationId:i,projectId:a,streaming:o,animateInitialContent:s,onProgressiveRenderComplete:c}=e,l=o===void 0?!1:o,u=s===void 0?!1:s,d=`assistant-markdown-${(0,Z.useId)()}`,f=pk(n,l,d,u,c),[p,m]=(0,Z.useState)(l||u),h,g;t[0]===l?(h=t[1],g=t[2]):(h=()=>{l&&m(!0)},g=[l],t[0]=l,t[1]=h,t[2]=g),(0,Z.useEffect)(h,g);let _=l||f!==n,v=l||p,y=f,b;t[3]===y?b=t[4]:(b=W(y),t[3]=y,t[4]=b);let x=b,S,C;t[5]!==d||t[6]!==_?(S=()=>{if(_)return B(d),()=>G(d)},C=[d,_],t[5]=d,t[6]=_,t[7]=S,t[8]=C):(S=t[7],C=t[8]),(0,Z.useEffect)(S,C);let w,T;t[9]!==d||t[10]!==v||t[11]!==x?(w=()=>{if(!v)return;let e=x.at(-1);ee(d,Math.max(0,x.length-1),e?.content.length??0)},T=[d,v,x],t[9]=d,t[10]=v,t[11]=x,t[12]=w,t[13]=T):(w=t[12],T=t[13]),(0,Z.useEffect)(w,T);let E=Ow(xk),D=Ee(bk),O;t[14]===D?O=t[15]:(O=xe(D),t[14]=D,t[15]=O);let k=O.chat.fileReference,[A,j]=(0,Z.useState)(null),M;t[16]!==i||t[17]!==k.resolveFailedDescription||t[18]!==a||t[19]!==E?(M=e=>{if(e.kind===`workspace-relative`){E(e.path,e.line,a,i),j(null);return}j({status:`loading`,target:e}),VS(e.path,{projectId:a?.trim()||void 0,conversationId:i?.trim()||void 0}).then(t=>{if(!t){j({status:`error`,target:e,message:k.resolveFailedDescription});return}if(t.scope===`workspace`&&t.workspaceRelativePath){E(t.workspaceRelativePath,e.line,a,i),j(null);return}j({status:`ready`,target:e,ref:t})}).catch(t=>{j({status:`error`,target:e,message:t instanceof Error?t.message:String(t)})})},t[16]=i,t[17]=k.resolveFailedDescription,t[18]=a,t[19]=E,t[20]=M):M=t[20];let N=M,P;t[21]!==r||t[22]!==n||t[23]!==d||t[24]!==N||t[25]!==v||t[26]!==_||t[27]!==x?(P=v?(0,$.jsx)(`div`,{className:`markdown-stream-blocks`,children:x.map(e=>(0,$.jsx)(ie,{content:_&&e.isTail?$O(e.content):e.content,compact:r,className:K(`markdown-stream-block`,e.isTail&&`markdown-stream-tail`),onWorkspaceFileOpen:N,renderMermaid:!_||!e.isTail,mermaidActions:!0,streamingMetricsKey:d},e.key))}):(0,$.jsx)(ie,{content:n,compact:r,onWorkspaceFileOpen:N,mermaidActions:!0}),t[21]=r,t[22]=n,t[23]=d,t[24]=N,t[25]=v,t[26]=_,t[27]=x,t[28]=P):P=t[28];let F;t[29]!==i||t[30]!==A?(F=A?(0,$.jsx)(_k,{resolution:A,conversationId:i,onClose:()=>j(null)}):null,t[29]=i,t[30]=A,t[31]=F):F=t[31];let I;return t[32]!==P||t[33]!==F?(I=(0,$.jsxs)($.Fragment,{children:[P,F]}),t[32]=P,t[33]=F,t[34]=I):I=t[34],I}function bk(e){return e.language}function xk(e){return e.setPath}function Sk(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.type===`text`){if(n)return(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(wO,{text:j_(e.text??``),conversationId:s,document:f,contextRefs:p})},t);let i=RO(e.text??``);return i?(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(FO,{payload:i})},t):(0,$.jsx)(`div`,{className:`assistant-markdown-content markdown-content min-w-0`,children:(0,$.jsx)(yk,{content:e.text,compact:!0,conversationId:c??s,projectId:l,streaming:r,animateInitialContent:u,onProgressiveRenderComplete:d})},t)}if(e.type===`image`&&e.source?.data){let n=o??0;return a?(0,$.jsx)(`button`,{type:`button`,className:K(`inline-block max-w-full rounded-lg p-0 text-left`,yc.press,yc.focusRingPanel,`cursor-pointer`),onClick:()=>a(e,n),title:i,"aria-label":i,children:(0,$.jsx)(`img`,{src:e.source.data,className:`max-h-48 max-w-64 rounded-lg align-top object-contain`,alt:``})},t):(0,$.jsx)(`img`,{src:e.source.data,className:`max-h-48 max-w-64 rounded-lg object-contain`,alt:``},t)}return e.type===`review`?(0,$.jsx)(hk,{review:e},t):null}function Ck(e){let t=(0,Q.c)(16),{content:n,isUser:r,isAssistantMessageStreaming:i,imagePreviewLabel:a,onImagePreview:o,conversationId:s,workspaceConversationId:c,projectId:l,progressiveRender:u,onProgressiveRenderComplete:d,userTurnDocument:f,contextRefs:p}=e,m=u===void 0?!1:u,h;t[0]!==n||t[1]!==r?(h=r?n:ek(n),t[0]=n,t[1]=r,t[2]=h):h=t[2];let g=h,_=g.findLastIndex(wk),v=g.at(-1),y=_<0&&v?.type===`text`&&v.presentation===void 0?g.length-1:-1,b=i?Math.max(_,y):-1,x;if(t[3]!==p||t[4]!==s||t[5]!==a||t[6]!==r||t[7]!==o||t[8]!==d||t[9]!==m||t[10]!==l||t[11]!==g||t[12]!==b||t[13]!==f||t[14]!==c){let e=[],n=0,i=0;for(;n<g.length;){let t=g[n];if(t.type===`thinking`||t.type===`tool_use`)for(;n<g.length;){let e=g[n];if(e.type!==`thinking`&&e.type!==`tool_use`)break;n++}else{let u=t.type===`image`?i++:0,h=Sk(t,`block-${n}`,r,n===b,a,o,t.type===`image`?u:n,s,c,l,m,d,r&&n===0?f:void 0,r&&n===0?p:void 0);h&&e.push(h),n++}}x=(0,$.jsx)($.Fragment,{children:e}),t[3]=p,t[4]=s,t[5]=a,t[6]=r,t[7]=o,t[8]=d,t[9]=m,t[10]=l,t[11]=g,t[12]=b,t[13]=f,t[14]=c,t[15]=x}else x=t[15];return x}function wk(e){return e.type===`text`&&e.presentation===`pending`}var Tk=[`readFile`,`editFile`,`writeFile`,`runCommand`,`memorySearch`,`codeSearch`,`webSearch`,`search`,`fetchUrl`,`openUrl`,`listDir`,`other`];function Ek(e,t){return Gc(e,t)}function Dk(e){let t=new Map;for(let n of e){if(n.type!==`tool_use`)continue;let e=Ek(n.name,n.activity),r=t.get(e)??{total:0,running:0};r.total+=1,(n.status===`running`||n.activity?.status===`running`)&&(r.running+=1),t.set(e,r)}return t}function Ok(e,t){switch(e){case`webSearch`:return t.webSearch;case`memorySearch`:return t.memorySearch;case`codeSearch`:return t.codeSearch;case`search`:return t.search;case`readFile`:return t.readFile;case`editFile`:return t.editFile;case`writeFile`:return t.writeFile;case`runCommand`:return t.runCommand;case`listDir`:return t.listDir;case`openUrl`:return t.openUrl;case`fetchUrl`:return t.fetchUrl;case`other`:return t.other}}function kk(e,t){return Ok(e,t)}function Ak(e,t,n){let r=Dk(e),i=[];for(let e of Tk){let t=r.get(e);t&&t.running>0&&i.push(e)}if(i.length===1){let r=[...e].reverse().find(e=>e.type===`tool_use`&&(e.status===`running`||e.activity?.status===`running`));return(r?n?.(r):null)||Ok(i[0],t)}return i.length>1?t.mixed:e.some(e=>e.type===`thinking`&&e.streaming)?t.thinking:r.size>0?t.mixed:null}function jk(e){return e.filter(e=>e.type!==`thinking`||!!e.text?.trim()||!!e.streaming)}function Mk(e,t,n){return Ak(e,t,n)}function Nk(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Pk(e){if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}}function Fk(e){let t=Nk(Pk(e));if(!t)return[];let n=Nk(t.details)?.results??t.results;if(Array.isArray(n))return n.map(Nk).filter(e=>e!==null);let r=Array.isArray(t.content)?t.content:[];for(let e of r){let t=Nk(e)?.text,n=Nk(Pk(t));if(Array.isArray(n?.results))return n.results.map(Nk).filter(e=>e!==null)}return[]}function Ik(e,t){return e.replace(/\{\{count\}\}/g,String(t))}function Lk(e,t){if(e.status===`running`||e.activity?.status===`running`)return{title:t.running,purpose:t.purpose};if(e.status===`error`||e.activity?.status===`failed`)return{title:t.failed,purpose:t.purpose};let n=Fk(e.result),r=e.activity?.count??n.length;return{title:r===0?t.empty:Ik(r===1?t.found_one:t.found_other,r),purpose:t.purpose}}function Rk(e){if(e===void 0)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{try{return JSON.stringify(e,null,2)}catch{return String(e)}}}function zk(e){if(e==null)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function Bk(e){let t=zk(e),n=t?.path??t?.file_path??t?.filepath??t?.file??t?.qualified_name??t?.function_name;return typeof n==`string`?n:``}function Vk(e){let t=zk(e),n=t?.url??t?.href??t?.uri??t?.website;return typeof n==`string`?n:``}function Hk(e){let t=zk(e),n=t?.command??t?.cmd??t?.shell??t?.script;return typeof n==`string`?n:``}var Uk=120;function Wk(e){if(e==null)return``;let t=zk(e);if(!t)return typeof e==`string`?e.trim():``;let n=[t.command,t.cmd,t.shell,t.script,t.path,t.file_path,t.filepath,t.file,t.url,t.href,t.uri,t.website,t.query,t.q,t.query_string,t.search_term,t.searchQuery,t.qualified_name,t.function_name,t.name_pattern,t.qn_pattern,t.file_pattern];for(let e of n){if(typeof e==`string`&&e.trim()){let t=e.trim();return t.length>Uk?`${t.slice(0,Uk)}…`:t}if(typeof e==`number`&&Number.isFinite(e))return String(e)}return``}function Gk(e){return e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)||e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:e.startsWith(`+`)?`add`:e.startsWith(`-`)?`del`:`context`}function Kk(e){let t=e.details?.diff;if(typeof t!=`string`||t.length===0)return null;let n=t.split(`
36
- `),r=[],i=0,a=0;for(let e of n){let t=Gk(e);t===`add`&&!e.startsWith(`+++`)&&i++,t===`del`&&!e.startsWith(`---`)&&a++,r.push({kind:t,text:e})}return{raw:t,lines:r,added:i,removed:a}}function qk(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Jk(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`text`&&typeof e.text==`string`&&t.push(e.text)}return t.join(`
37
- `)}function Yk(e){if(e==null)return{details:null,text:``,isStructured:!1};if(typeof e==`object`&&!Array.isArray(e)){let t=e;return`content`in t||`details`in t?{details:qk(t.details),text:Jk(t.content),isStructured:!0}:{details:null,text:``,isStructured:!1}}if(typeof e==`string`){let t=e.trim();if(t.startsWith(`{`))try{let e=qk(JSON.parse(t));if(e&&(`content`in e||`details`in e))return{details:qk(e.details),text:Jk(e.content),isStructured:!0}}catch{}return{details:null,text:e,isStructured:!1}}return{details:null,text:String(e),isStructured:!1}}var Xk=`inline-flex max-w-full min-w-0 items-center gap-1 rounded-md bg-accent-soft/40 px-1.5 py-0.5 text-[11px] font-medium text-fg-muted [overflow-wrap:anywhere] dark:bg-accent-soft/25`,Zk=`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-fg [overflow-wrap:anywhere] dark:bg-surface-hover/35`,Qk=`max-h-72 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,$k=`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`;function eA(e){let t=(0,Q.c)(5),{children:n,tone:r}=e,i=r===void 0?`neutral`:r,a=i===`positive`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i===`negative`?`bg-red-500/15 text-red-700 dark:text-red-300`:i===`warning`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:i===`accent`?`bg-accent-soft/70 text-accent-fg dark:bg-accent-soft/50`:``,o;t[0]===a?o=t[1]:(o=K(Xk,a),t[0]=a,t[1]=o);let s;return t[2]!==n||t[3]!==o?(s=(0,$.jsx)(`span`,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s}function tA(e){let t=(0,Q.c)(3),{children:n,title:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(`code`,{className:Zk,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}var nA=(0,Z.memo)(function(e){let t=(0,Q.c)(11),{text:n,label:r,copiedLabel:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]===n?s=t[1]:(s=async e=>{e.preventDefault(),e.stopPropagation(),await Yt(n)&&(o(!0),window.setTimeout(()=>o(!1),1200))},t[0]=n,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=K(`inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),t[2]=c):c=t[2];let l;t[3]!==a||t[4]!==i||t[5]!==r?(l=a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(S,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{className:`size-3`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:r})]}),t[3]=a,t[4]=i,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==r||t[8]!==s||t[9]!==l?(u=(0,$.jsx)(`button`,{type:`button`,onClick:s,className:c,"aria-label":r,title:r,children:l}),t[7]=r,t[8]=s,t[9]=l,t[10]=u):u=t[10],u});function rA(e){let t=(0,Q.c)(8),{summary:n,children:r,defaultOpen:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(`summary`,{className:$k,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`div`,{className:`mt-1.5 min-w-0`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,open:a,children:[o,s]}),t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function iA(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`pre`,{className:Qk,children:n}),t[0]=n,t[1]=r),r}function aA(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r==null?``:String(r)})}function oA(e){return e.details??{}}var sA=/\[(\d+)\/(\d+) lines\]\s*$/;function cA(e){let t=e.match(sA);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return!Number.isFinite(n)||!Number.isFinite(r)?null:{shown:n,total:r}}function lA(e){return e.replace(sA,``).trimEnd()}var uA=(0,Z.memo)(function(e){let t=(0,Q.c)(32),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Bk(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Yk(n.result),t[2]=n.result,t[3]=o);let s=o.text,c;t[4]===s?c=t[5]:(c=cA(s),t[4]=s,t[5]=c);let l=c,u;t[6]===s?u=t[7]:(u=lA(s),t[6]=s,t[7]=u);let d=u,f;bb0:{if(l){f=l.total;break bb0}if(!d){f=0;break bb0}let e;t[8]===d?e=t[9]:(e=d.split(`
38
- `),t[8]=d,t[9]=e),f=e.length}let p=f,m;if(t[10]!==d){bb1:{if(!d){m=``;break bb1}let e=d.split(`
39
- `);if(e.length<=12){m=d;break bb1}m=`${e.slice(0,12).join(`
40
- `)}\n…`}t[10]=d,t[11]=m}else m=t[11];let h=m,g;t[12]===a?g=t[13]:(g=a?(0,$.jsx)(tA,{title:a,children:a}):null,t[12]=a,t[13]=g);let _;t[14]!==r||t[15]!==l||t[16]!==p?(_=p>0?(0,$.jsx)(eA,{children:l&&l.shown<l.total?aA(r.linesPartial,{shown:l.shown,total:l.total}):aA(r.linesBadge,{count:p})}):null,t[14]=r,t[15]=l,t[16]=p,t[17]=_):_=t[17];let v;t[18]!==r||t[19]!==a?(v=a?(0,$.jsx)(nA,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[18]=r,t[19]=a,t[20]=v):v=t[20];let y;t[21]!==g||t[22]!==_||t[23]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[g,_,v]}),t[21]=g,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==d||t[26]!==r||t[27]!==h?(b=d?(0,$.jsx)(rA,{summary:r.viewContent,children:(0,$.jsx)(iA,{children:h})}):null,t[25]=d,t[26]=r,t[27]=h,t[28]=b):b=t[28];let x;return t[29]!==y||t[30]!==b?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[y,b]}),t[29]=y,t[30]=b,t[31]=x):x=t[31],x});function dA(e){let t=(0,Q.c)(4),{lines:n}=e,r;t[0]===n?r=t[1]:(r=n.map(fA),t[0]=n,t[1]=r);let i;return t[2]===r?i=t[3]:(i=(0,$.jsx)(`pre`,{className:`max-h-80 w-full min-w-0 max-w-full overflow-auto rounded-md bg-surface-hover/60 p-2 font-mono text-xs leading-snug text-fg-muted dark:bg-surface-hover/35`,children:r}),t[2]=r,t[3]=i),i}function fA(e,t){return(0,$.jsx)(`div`,{className:K(`whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,e.kind===`add`&&`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,e.kind===`del`&&`bg-red-500/15 text-red-700 dark:text-red-300`,e.kind===`hunk`&&`text-fg-subtle`,e.kind===`meta`&&`text-fg-disabled`),children:e.text||`\xA0`},t)}var pA=(0,Z.memo)(function(e){let t=(0,Q.c)(25),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Bk(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Yk(n.result),t[2]=n.result,t[3]=o);let s=o,c;t[4]===s?c=t[5]:(c=Kk(s),t[4]=s,t[5]=c);let l=c,u;t[6]===a?u=t[7]:(u=a?(0,$.jsx)(tA,{title:a,children:a}):null,t[6]=a,t[7]=u);let d;t[8]!==l||t[9]!==r?(d=l?(0,$.jsx)(eA,{tone:`accent`,children:aA(r.diffStats,{added:l.added,removed:l.removed})}):null,t[8]=l,t[9]=r,t[10]=d):d=t[10];let f;t[11]!==r||t[12]!==a?(f=a?(0,$.jsx)(nA,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[11]=r,t[12]=a,t[13]=f):f=t[13];let p;t[14]!==u||t[15]!==d||t[16]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[u,d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=p):p=t[17];let m;t[18]!==l||t[19]!==r||t[20]!==s?(m=l?(0,$.jsx)(rA,{summary:r.viewDiff,defaultOpen:!0,children:(0,$.jsx)(dA,{lines:l.lines})}):s.text?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted [overflow-wrap:anywhere]`,children:s.text}):null,t[18]=l,t[19]=r,t[20]=s,t[21]=m):m=t[21];let h;return t[22]!==p||t[23]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[p,m]}),t[22]=p,t[23]=m,t[24]=h):h=t[24],h});function mA(e){return!Number.isFinite(e)||e<0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var hA=(0,Z.memo)(function(e){let t=(0,Q.c)(20),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Bk(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Yk(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=oA(s),n=typeof e.size==`number`?e.size:null;c=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[10]===a?l=t[11]:(l=a?(0,$.jsx)(tA,{title:a,children:a}):null,t[10]=a,t[11]=l),u=n==null?null:(0,$.jsx)(eA,{children:aA(r.sizeBadge,{size:mA(n)})}),t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u}else c=t[7],l=t[8],u=t[9];let d;t[12]!==r||t[13]!==a?(d=a?(0,$.jsx)(nA,{text:a,label:r.copyPath,copiedLabel:r.copied}):null,t[12]=r,t[13]=a,t[14]=d):d=t[14];let f;return t[15]!==c||t[16]!==l||t[17]!==u||t[18]!==d?(f=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[15]=c,t[16]=l,t[17]=u,t[18]=d,t[19]=f):f=t[19],f}),gA=12;function _A(e){if(!e)return{preview:``,truncated:!1};let t=e.split(`
41
- `);return t.length<=gA?{preview:e,truncated:!1}:{preview:`${t.slice(0,gA).join(`
42
- `)}\n…`,truncated:!0}}var vA=(0,Z.memo)(function(e){let t=(0,Q.c)(29),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Hk(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Yk(n.result),t[2]=n.result,t[3]=o);let s=o,c=n.details&&typeof n.details==`object`&&!Array.isArray(n.details)?n.details:null,l;t[4]!==c||t[5]!==s?(l=c??oA(s),t[4]=c,t[5]=s,t[6]=l):l=t[6];let u=l,d=!!u.truncated,f=typeof u.aggregatedOutput==`string`&&u.aggregatedOutput.length>0?u.aggregatedOutput:s.text,p;t[7]===f?p=t[8]:(p=_A(f),t[7]=f,t[8]=p);let{preview:m}=p,h;t[9]===a?h=t[10]:(h=a?(0,$.jsxs)(tA,{title:a,children:[(0,$.jsx)(`span`,{className:`mr-1 text-fg-disabled`,children:`$`}),a]}):null,t[9]=a,t[10]=h);let g;t[11]!==r||t[12]!==d?(g=d?(0,$.jsx)(eA,{children:r.truncatedBadge}):null,t[11]=r,t[12]=d,t[13]=g):g=t[13];let _;t[14]!==a||t[15]!==r?(_=a?(0,$.jsx)(nA,{text:a,label:r.copyCommand,copiedLabel:r.copied}):null,t[14]=a,t[15]=r,t[16]=_):_=t[16];let v;t[17]!==h||t[18]!==g||t[19]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:[h,g,_]}),t[17]=h,t[18]=g,t[19]=_,t[20]=v):v=t[20];let y;t[21]!==n.status||t[22]!==r||t[23]!==f||t[24]!==m?(y=f?(0,$.jsx)(rA,{summary:r.viewOutput,children:(0,$.jsx)(iA,{children:m})}):n.status===`running`?null:(0,$.jsx)(`p`,{className:`text-xs text-fg-disabled`,children:r.noOutput}),t[21]=n.status,t[22]=r,t[23]=f,t[24]=m,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}),yA=(0,Z.memo)(function(e){let t=(0,Q.c)(27),{block:n,labels:r}=e,i;t[0]===n.input?i=t[1]:(i=Vk(n.input),t[0]=n.input,t[1]=i);let a=i,o;t[2]===n.result?o=t[3]:(o=Yk(n.result),t[2]=n.result,t[3]=o);let s=o,c,l,u,d,f;if(t[4]!==r||t[5]!==s||t[6]!==a){let e=oA(s),n=typeof e.extractedLength==`number`?e.extractedLength:null,i;if(t[12]!==s.text){bb0:{if(!s.text){i=``;break bb0}let e=s.text.split(`
43
- `);if(e.length<=12){i=s.text;break bb0}i=`${e.slice(0,12).join(`
44
- `)}\n…`}t[12]=s.text,t[13]=i}else i=t[13];c=i,f=`space-y-1.5`,l=`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,t[14]===a?u=t[15]:(u=a?(0,$.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex max-w-full min-w-0 items-center break-words rounded-md bg-surface-hover/60 px-1.5 py-0.5 font-mono text-xs text-accent-fg underline-offset-2 hover:underline [overflow-wrap:anywhere] dark:bg-surface-hover/35`,title:a,children:a}):null,t[14]=a,t[15]=u),d=n!=null&&n>0?(0,$.jsx)(eA,{children:aA(r.linesBadge,{count:n})}):null,t[4]=r,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else c=t[7],l=t[8],u=t[9],d=t[10],f=t[11];let p;t[16]!==l||t[17]!==u||t[18]!==d?(p=(0,$.jsxs)(`div`,{className:l,children:[u,d]}),t[16]=l,t[17]=u,t[18]=d,t[19]=p):p=t[19];let m;t[20]!==r||t[21]!==c?(m=c?(0,$.jsx)(rA,{summary:r.viewContent,children:(0,$.jsx)(iA,{children:c})}):null,t[20]=r,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}),bA=Oe(sn(e=>({showRawToolData:!1,setShowRawToolData:t=>e({showRawToolData:t})}),{name:`xopc-web-dev-view`}));function xA(e,t){if(!Number.isFinite(e)||e<=0)return t===`zh`?`不到1秒`:`<1s`;let n=Math.floor(e/1e3);if(n===0)return t===`zh`?`不到1秒`:`<1s`;let r=Math.floor(n/60),i=n%60;return t===`zh`?r===0?`${i}秒`:i===0?`${r}分`:`${r}分${i}秒`:r===0?`${i}s`:i===0?`${r}m`:`${r}m ${i}s`}function SA(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.id!=`string`||!t.id||typeof t.conversationId!=`string`||typeof t.summary!=`string`||typeof t.expiresAt!=`string`||!Number.isFinite(Date.parse(t.expiresAt))||![`external_effect`,`destructive`,`sensitive`].includes(String(t.risk))||![`pending`,`approved`,`denied`,`consumed`,`expired`].includes(String(t.status))?null:t}function CA(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(t.kind!==`browser_approval_required`)return null;let n=t.error&&typeof t.error==`object`&&!Array.isArray(t.error)?t.error:null,r=n?.approval&&typeof n.approval==`object`&&!Array.isArray(n.approval)?n.approval:null;return!r||typeof r.id!=`string`||typeof r.summary!=`string`||typeof r.expiresAt!=`string`||![`external_effect`,`destructive`,`sensitive`].includes(String(r.risk))?null:r}function wA({approval:e,conversationId:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(!1),s=(0,Z.useRef)(0),c=Se(e=>e.conversationId),l=Se(e=>e.baseUrl);(0,Z.useEffect)(()=>(o.current=!1,r(!1),a(!1),()=>{s.current+=1}),[e.id,t,c,l]);let u=Ee(e=>e.language)===`zh`?{title:`浏览器操作需要确认`,risk:`风险`,deny:`拒绝`,approve:`仅批准本次`,approved:`已批准本次操作,请让助手继续。`,denied:`已拒绝。`,consumed:`本次批准已使用。`,expired:`本次请求已过期,请让助手重新发起。`,error:`无法确认当前审批状态,请重新检查。`,retry:`重新检查`}:{title:`Browser action needs approval`,risk:`Risk`,deny:`Deny`,approve:`Approve once`,approved:`Approved once. Ask the agent to continue.`,denied:`Denied.`,consumed:`This approval has been used.`,expired:`This request expired. Ask the agent to request approval again.`,error:`Could not verify approval status. Check again.`,retry:`Check again`},{data:d,error:f,isLoading:p,mutate:m}=Zt(t&&c?[`browser-approval`,l,c,t,e.id]:null,async()=>{let n=(await q(J(`/api/browser/approvals?conversationId=${encodeURIComponent(t)}`))).approvals.map(SA).find(n=>n?.id===e.id&&n.conversationId===t);if(!n)throw Error(`Approval unavailable`);return n},{refreshInterval:e=>e?.status===`pending`||e?.status===`approved`?1e4:0});(0,Z.useEffect)(()=>{if(!d||![`pending`,`approved`].includes(d.status))return;let e=Date.parse(d.expiresAt)-Date.now();if(e<=0)return;let t=window.setTimeout(()=>{m()},e+1);return()=>window.clearTimeout(t)},[d,m]);let h=d&&Date.parse(d.expiresAt)<=Date.now()&&[`pending`,`approved`].includes(d.status)?`expired`:d?.status;async function g(n){if(o.current||!d||h!==`pending`||Date.parse(d.expiresAt)<=Date.now())return;o.current=!0,r(!0),a(!1);let i=s.current,u=()=>i===s.current&&Se.getState().conversationId===c&&Se.getState().baseUrl===l;try{let r=SA((await q(J(`/api/browser/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e.id,decision:n})})).approval);if(!r||r.id!==e.id||r.conversationId!==t)throw Error(`Invalid approval response`);if(!u())return;await m(r,{revalidate:!1})}catch{if(!u())return;a(!0),m()}finally{u()&&(o.current=!1,r(!1))}}return(0,$.jsxs)(`section`,{className:`mt-2 rounded-xl border border-edge bg-surface-panel p-3 text-sm`,children:[(0,$.jsx)(`div`,{className:`font-medium text-fg`,children:u.title}),(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg`,children:d?.summary??e.summary}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[u.risk,`: `,(d?.risk??e.risk).replace(`_`,` `)]}),p?(0,$.jsx)(xn,{className:`mt-3 h-8 w-full`}):f||i||!d?(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:u.error}),(0,$.jsx)(X,{className:`mt-2 h-8 text-xs`,disabled:n||!t||!c,onClick:()=>{a(!1),m()},children:u.retry})]}):h===`pending`?(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(X,{className:`h-8 text-xs`,disabled:n,onClick:()=>void g(`denied`),children:u.deny}),(0,$.jsx)(X,{variant:`primary`,className:`h-8 text-xs`,disabled:n,onClick:()=>void g(`approved`),children:u.approve})]}):(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:h?u[h]:u.error})]})}function TA(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function EA(e,t){let n=TA(t);return J(`/api/extensions/${encodeURIComponent(e)}/assets/${n}`)}var DA={"capability:xopc.notes.create":`Create notes in this workspace`,"capability:xopc.notes.update":`Change notes in this workspace at an exact revision`,"capability:xopc.notes.append":`Append content to notes in this workspace`,"capability:xopc.notes.get":`Read notes in this workspace by ID`,"capability:xopc.notes.list":`Search and list notes in this workspace`,"capability:xopc.tasks.get":`Read tasks and their context in this workspace`,"capability:xopc.tasks.list":`Search and list tasks in this workspace`,theme:`Read theme (light / dark)`,"agent.send":`Send messages to the assistant`,"agent.subscribe":`Receive live agent stream events for a chat`,"session.read":`List and open chat sessions`,"config.read":`Read extension configuration`,"config.write":`Write extension configuration`,storage:`Read and write extension storage`,notification:`Show in-app notifications`},OA={"capability:xopc.notes.create":`在当前工作区创建笔记`,"capability:xopc.notes.update":`按精确版本修改当前工作区的笔记`,"capability:xopc.notes.append":`向当前工作区的笔记追加内容`,"capability:xopc.notes.get":`按 ID 读取当前工作区的笔记`,"capability:xopc.notes.list":`搜索和列出当前工作区的笔记`,"capability:xopc.tasks.get":`读取当前工作区的任务及其上下文`,"capability:xopc.tasks.list":`搜索和列出当前工作区的任务`,theme:`读取主题(浅色/深色)`,"agent.send":`向助手发送消息`,"agent.subscribe":`接收会话的实时助手流式事件`,"session.read":`列出并打开聊天会话`,"config.read":`读取扩展配置`,"config.write":`写入扩展配置`,storage:`读写扩展存储`,notification:`显示应用内通知`};function kA(e,t){let n=DA[e];return t===`zh`&&OA[e]?OA[e]:n??e}function AA(e){let t=(0,Q.c)(59),{open:n,onOpenChange:r,extensionId:i,extensionName:a,permissions:o,onConfirm:s,confirmDisabled:c}=e,l=Ee(MA),u,d,f,p,m,h,g,_,v,y,b,x;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==n?(m=xe(l).extensionUi,p=nt,b=n,x=r,f=$e,t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[16]=y):y=t[16],d=et,_=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-5`,v=jA,u=tt,h=`text-base font-semibold text-fg`,g=m.permissionTitle.replace(`{{name}}`,a),t[0]=a,t[1]=l,t[2]=r,t[3]=n,t[4]=u,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x):(u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14],x=t[15]);let S;t[17]!==u||t[18]!==h||t[19]!==g?(S=(0,$.jsx)(u,{className:h,children:g}),t[17]=u,t[18]=h,t[19]=g,t[20]=S):S=t[20];let C;t[21]===i?C=t[22]:(C=(0,$.jsxs)(`span`,{className:`font-mono text-xs text-fg-muted`,title:i,children:[`(`,i,`)`]}),t[21]=i,t[22]=C);let w;t[23]!==m.permissionSubtitle||t[24]!==C?(w=(0,$.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[m.permissionSubtitle,` `,C]}),t[23]=m.permissionSubtitle,t[24]=C,t[25]=w):w=t[25];let T;t[26]!==l||t[27]!==o||t[28]!==m.permissionsNone?(T=o.length===0?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:m.permissionsNone}):(0,$.jsx)(`ul`,{className:`mt-4 max-h-48 list-inside list-disc space-y-1 overflow-y-auto text-sm text-fg`,children:o.map(e=>(0,$.jsx)(`li`,{children:kA(e,l)},e))}),t[26]=l,t[27]=o,t[28]=m.permissionsNone,t[29]=T):T=t[29];let E;t[30]===m.deny?E=t[31]:(E=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge px-3 py-2 text-sm text-fg hover:bg-surface-inset`,children:m.deny})}),t[30]=m.deny,t[31]=E);let D;t[32]!==s||t[33]!==r?(D=()=>{s(),r(!1)},t[32]=s,t[33]=r,t[34]=D):D=t[34];let O;t[35]!==c||t[36]!==m.allow||t[37]!==D?(O=(0,$.jsx)(`button`,{type:`button`,disabled:c,className:`rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:opacity-90`,onClick:D,children:m.allow}),t[35]=c,t[36]=m.allow,t[37]=D,t[38]=O):O=t[38];let k;t[39]!==E||t[40]!==O?(k=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[E,O]}),t[39]=E,t[40]=O,t[41]=k):k=t[41];let A;t[42]!==d||t[43]!==w||t[44]!==T||t[45]!==k||t[46]!==_||t[47]!==v||t[48]!==S?(A=(0,$.jsxs)(d,{className:_,onOpenAutoFocus:v,children:[S,w,T,k]}),t[42]=d,t[43]=w,t[44]=T,t[45]=k,t[46]=_,t[47]=v,t[48]=S,t[49]=A):A=t[49];let j;t[50]!==f||t[51]!==A||t[52]!==y?(j=(0,$.jsxs)(f,{children:[y,A]}),t[50]=f,t[51]=A,t[52]=y,t[53]=j):j=t[53];let M;return t[54]!==p||t[55]!==j||t[56]!==b||t[57]!==x?(M=(0,$.jsx)(p,{open:b,onOpenChange:x,children:j}),t[54]=p,t[55]=j,t[56]=b,t[57]=x,t[58]=M):M=t[58],M}function jA(e){return e.preventDefault()}function MA(e){return e.language}async function NA(e){let{grant:t}=await q(J(`/api/extensions/${encodeURIComponent(e)}/ui-grant`));return t}async function PA(e,t){return(await q(J(`/api/extensions/${encodeURIComponent(e)}/ui-grant`),{method:`POST`,body:JSON.stringify({manifestDigest:t})})).grant}var FA=`agent-stream-event`;function IA(e){return e===`off`||e===`on`||e===`stream`}function LA(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function RA(e,t,n){return t&&typeof t==`object`&&!Array.isArray(t)?{...t,seq:n}:{type:e,seq:n,payload:t}}async function zA(e){try{let t=await we(J(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)return`on`;let n=await t.json(),r=n.payload?.activityDetail?.effective;if(IA(r))return r;let i=n.payload?.activityDetail?.default??n.payload?.reasoningLevel;return IA(i)?i:`on`}catch{return`on`}}function BA(e){window.dispatchEvent(new CustomEvent(FA,{detail:e}))}function VA(e={}){let t=e.subscribe??Fy,n=e.loadActivityDetailLevel??zA,r=e.dispatch??BA,i=new Map,a=!1,o=e=>{let o=LA(e.detail);if(!o||i.has(o.runId))return;let s=`on`,c=!1,l,u=!1,d=!1,f=()=>{},p=()=>{u||(u=!0,f(),i.get(o.runId)===p&&i.delete(o.runId))},m=e=>{a||u||r({conversationId:o.conversationId,event:e,activityDetailLevel:s})};n(o.conversationId).then(e=>{s=e,c=!0,e===`stream`&&l&&!d&&m(l),l=void 0}),f=t(`run:${o.runId}`,{onEvent:e=>{if(u||d)return;let t=RA(e.event,e.data,e.seq);e.event===`thinking_delta`&&!c?l=t:m(t),e.event===`run_end`&&(d=!0,l=void 0,queueMicrotask(p))},onGap:e=>{e.recoverable||p()}},0),i.set(o.runId,p)},s=e=>{let t=LA(e.detail);t&&i.get(t.runId)?.()};return window.addEventListener(`run-started`,o),window.addEventListener(`run-completed`,s),window.addEventListener(`agent-run-ended`,s),()=>{a=!0,window.removeEventListener(`run-started`,o),window.removeEventListener(`run-completed`,s),window.removeEventListener(`agent-run-ended`,s);for(let e of[...i.values()])e()}}var HA=function(e){return e[e.PermissionDenied=4001]=`PermissionDenied`,e[e.InvalidRequest=4002]=`InvalidRequest`,e[e.MethodNotFound=4003]=`MethodNotFound`,e[e.InternalError=4004]=`InternalError`,e[e.Timeout=4005]=`Timeout`,e[e.ExtensionNotFound=4006]=`ExtensionNotFound`,e[e.RateLimited=4007]=`RateLimited`,e}({}),UA=[`--color-surface-base`,`--color-surface-panel`,`--color-surface-hover`,`--color-fg`,`--color-fg-muted`,`--color-fg-subtle`,`--color-accent`,`--color-accent-hover`,`--color-accent-soft`,`--color-edge`,`--color-edge-subtle`,`--color-danger`,`--color-success`,`--color-warning`,`--radius-sm`,`--radius-lg`,`--radius-xl`];function WA(e){let t=getComputedStyle(document.documentElement),n={};for(let e of UA){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return{mode:e,tokens:n,fontFamily:t.getPropertyValue(`font-family`).trim(),fontFamilyMono:t.getPropertyValue(`--font-mono`).trim()}}var GA={"agent.sendMessage":`agent.send`,"session.list":`session.read`,"session.navigate":`session.read`,"config.get":`config.read`,"config.set":`config.write`,"storage.get":`storage`,"storage.set":`storage`,"storage.remove":`storage`,"storage.keys":`storage`,"ui.notification":`notification`,"theme.get":`theme`},KA=class{iframes=new Map;byContentWindow=new WeakMap;handlers=new Map;extensionPermissions=new Map;releaseBindings=new Map;eventSubscribers=new Map;agentStreamSubscriptions=new Map;boundListener=e=>{this.onWindowMessage(e)};constructor(){window.addEventListener(`message`,this.boundListener)}dispose(){window.removeEventListener(`message`,this.boundListener),this.iframes.clear(),this.handlers.clear(),this.extensionPermissions.clear(),this.releaseBindings.clear(),this.eventSubscribers.clear(),this.agentStreamSubscriptions.clear()}registerIframe(e,t,n,r){let i=this.iframes.get(e);if(i&&i!==t&&i.contentWindow&&this.byContentWindow.delete(i.contentWindow),this.iframes.set(e,t),this.extensionPermissions.set(e,new Set(n)),this.releaseBindings.delete(e),r){let t=Se.getState();this.releaseBindings.set(e,{digest:r,baseUrl:t.baseUrl,namespace:t.conversationId})}this.rememberIframeWindow(e,t)}unregisterIframe(e){let t=this.iframes.get(e);this.sendEvent(e,`panel.dispose`),t?.contentWindow&&this.byContentWindow.delete(t.contentWindow),this.iframes.delete(e),this.extensionPermissions.delete(e),this.releaseBindings.delete(e),this.agentStreamSubscriptions.delete(e)}rememberIframeWindow(e,t){let n=t.contentWindow;n&&this.byContentWindow.set(n,{extensionId:e,iframe:t})}subscribeAgentStream(e,t){let n=this.agentStreamSubscriptions.get(e);n||(n=new Set,this.agentStreamSubscriptions.set(e,n)),n.add(t)}unsubscribeAgentStream(e,t){this.agentStreamSubscriptions.get(e)?.delete(t)}forwardAgentStreamEvent(e,t){for(let[n,r]of this.agentStreamSubscriptions)r.has(e)&&this.sendEvent(n,`agent.stream.${e}`,t)}broadcastExtensionEvent(e,t,n){let r=t.startsWith(`ext.`)?t:`ext.${t}`;for(let[t]of this.iframes)t!==e&&this.sendEvent(t,r,n)}handleExtensionEvent(e,t,n){if(t.startsWith(`ext.`)){let r=t.slice(4);this.broadcastExtensionEvent(e,r,n);return}if(t===`agent.subscribe`||t===`agent.unsubscribe`){if(!(this.extensionPermissions.get(e)??new Set).has(`agent.subscribe`))return;let{conversationId:r}=n??{};if(typeof r!=`string`||!r.trim())return;let i=r.trim();t===`agent.subscribe`?this.subscribeAgentStream(e,i):this.unsubscribeAgentStream(e,i)}}registerMethod(e,t){this.handlers.set(e,t)}getReleaseDigest(e){let t=this.releaseBindings.get(e),n=Se.getState();if(!t||t.baseUrl!==n.baseUrl||t.namespace!==n.conversationId)throw Error(`Extension release authorization is unavailable`);return t.digest}subscribeExtensionEvents(e,t){let n=this.eventSubscribers.get(e);return n||(n=new Set,this.eventSubscribers.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&this.eventSubscribers.delete(e)}}sendInit(e,t,n){let r=this.iframes.get(e);if(!r?.contentWindow)return;this.rememberIframeWindow(e,r);let i=[...this.extensionPermissions.get(e)??[]];r.contentWindow.postMessage({source:`xopc-host`,type:`init`,extensionId:e,permissions:i,theme:t,locale:n},`*`)}sendEvent(e,t,n){let r=this.iframes.get(e);r?.contentWindow&&r.contentWindow.postMessage({source:`xopc-host`,type:`event`,event:t,data:n},`*`)}broadcastEvent(e,t){for(let[,n]of this.iframes)n.contentWindow?.postMessage({source:`xopc-host`,type:`event`,event:e,data:t},`*`)}postResponse(e,t,n,r,i){let a=e.contentWindow,o={source:`xopc-host`,type:`response`,requestId:n,result:r,error:i};!a||a!==t?.source||a.postMessage(o,`*`)}async onWindowMessage(e){let t=e.data;if(!t||t.source!==`xopc-extension`||!e.source)return;let n=this.byContentWindow.get(e.source);if(!n)return;let{iframe:r,extensionId:i}=n;if(this.iframes.get(i)!==r||r.contentWindow!==e.source)return;if(t.type===`event`){this.handleExtensionEvent(i,t.event,t.data);let e=this.eventSubscribers.get(i);if(e){let n={event:t.event,data:t.data};for(let t of e)try{t(n)}catch{}}return}if(t.type!==`request`)return;let{requestId:a,method:o,params:s}=t;if(typeof a!=`string`||a.length>200||typeof o!=`string`||o.length>200)return;let c=this.handlers.get(o);if(!c){this.postResponse(r,e,a,void 0,{code:HA.MethodNotFound,message:`Unknown method: ${o}`});return}let l=s&&typeof s==`object`&&`id`in s?s.id:void 0,u=o===`capability.describe`||o===`capability.call`?`capability:${typeof l==`string`?l:``}`:GA[o],d=this.extensionPermissions.get(i)??new Set;if(u&&!d.has(u)){this.postResponse(r,e,a,void 0,{code:HA.PermissionDenied,message:`Missing permission: ${u}`});return}let f=Se.getState(),p=()=>this.iframes.get(i)===r&&r.contentWindow===e.source&&this.extensionPermissions.get(i)===d&&Se.getState().baseUrl===f.baseUrl&&Se.getState().conversationId===f.conversationId;try{let t=await c(i,s);if(!p())return;this.postResponse(r,e,a,t)}catch(t){if(!p())return;let n=t instanceof Error?t.message:String(t);this.postResponse(r,e,a,void 0,{code:HA.InternalError,message:n})}}};function qA(e){let t=ot({id:zs.shape.id}),n=t.extend({call:Ht});e.registerMethod(`capability.describe`,async(n,r)=>{let{id:i}=t.parse(r),a=e.getReleaseDigest(n),o=(await q(J(`/api/local-app-capabilities/${encodeURIComponent(n)}?manifestDigest=${encodeURIComponent(a)}`))).capabilities.find(e=>e.id===i);if(!o)throw Error(`Capability is unavailable for this release`);return o}),e.registerMethod(`capability.call`,async(t,r)=>{let{id:i,call:a}=n.parse(r),o=e.getReleaseDigest(t);return q(J(`/api/local-app-capabilities/${encodeURIComponent(t)}/${encodeURIComponent(i)}/invocations`),{method:`POST`,body:JSON.stringify({manifestDigest:o,call:a})})}),e.registerMethod(`theme.get`,async()=>WA(Xd.getState().resolved)),e.registerMethod(`ui.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`path`in t?String(t.path??``):``;if(n){let e=n.startsWith(`/`)?n:`/${n}`;window.location.hash=`#${e}`}}),e.registerMethod(`ui.notification`,async(e,t)=>{if(!t||typeof t!=`object`)return;let n=t,r=typeof n.title==`string`?n.title.trim():``;r&&Jl({tone:n.type===`success`||n.type===`warning`||n.type===`error`||n.type===`info`?n.type:`info`,title:r,message:typeof n.message==`string`?n.message:void 0,source:e,dedupeKey:`extension:${e}:${r}`})}),e.registerMethod(`session.navigate`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`conversationId`in t?String(t.conversationId??``):``;n&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:n},bubbles:!0}))}),e.registerMethod(`session.list`,async()=>{let e=await we(J(`/api/sessions`));if(!e.ok)throw Error(`Failed to list sessions: ${e.status}`);return((await e.json()).items??[]).map(e=>({conversationId:e.key,title:e.name,lastMessageAt:e.updatedAt??e.lastAccessedAt,messageCount:e.messageCount}))}),e.registerMethod(`agent.sendMessage`,async(e,t)=>{let{message:n,conversationId:r,newSession:i}=t,a=r?.trim()||``;if(i||!a){let e=await we(J(`/api/sessions`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({channel:`webchat`})});if(!e.ok)throw Error(`Session create failed: ${e.status}`);if(a=(await e.json()).session?.key??``,!a)throw Error(`Session create did not return a session key`)}let o=await Cv(),s=await we(J(`/api/sessions/${encodeURIComponent(a)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientMessageId:crypto.randomUUID(),delivery:`next`,content:n,origin:o})});if(!s.ok)throw Error(`Agent request failed: ${s.status}`);return{conversationId:a}}),e.registerMethod(`config.get`,async e=>{let t=await we(J(`/api/extensions/${encodeURIComponent(e)}/config`));if(!t.ok)throw Error(`Failed to get config: ${t.status}`);return t.json()}),e.registerMethod(`config.set`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&!Array.isArray(t)?t:{},r=await we(J(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(n)});if(!r.ok)throw Error(`Failed to set config: ${r.status}`)}),e.registerMethod(`storage.get`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await we(J(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`));if(r.status!==404){if(!r.ok)throw Error(`Failed to get storage key: ${r.status}`);return(await r.json()).value}}),e.registerMethod(`storage.set`,async(e,t)=>{let n=t,r=n&&typeof n.key==`string`?n.key:``,i=await we(J(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(r)}`),{method:`PUT`,body:JSON.stringify({value:n?.value})});if(!i.ok)throw Error(`Failed to set storage key: ${i.status}`)}),e.registerMethod(`storage.remove`,async(e,t)=>{let n=t&&typeof t==`object`&&t&&`key`in t?String(t.key??``):``,r=await we(J(`/api/extensions/${encodeURIComponent(e)}/storage/${encodeURIComponent(n)}`),{method:`DELETE`});if(r.status!==404&&!r.ok)throw Error(`Failed to remove storage key: ${r.status}`)}),e.registerMethod(`storage.keys`,async e=>{let t=await we(J(`/api/extensions/${encodeURIComponent(e)}/storage`));if(!t.ok)throw Error(`Failed to list storage keys: ${t.status}`);return(await t.json()).keys??[]})}function JA(e){return e.active||e.activationEligible===!0}function YA(e){let t=e.ui?.contributions;return t?Array.isArray(t.pages)&&t.pages.length>0||Array.isArray(t.settingsPanels)&&t.settingsPanels.length>0||Array.isArray(t.chatWidgets)&&t.chatWidgets.length>0:!1}function XA(e){return e.source===`bundled`&&e.hasUi===!0&&YA(e)}function ZA(e){return e.kind===`image-generation`||e.kind===`media-provider`}function QA(e){return JA(e)?e.hasConfigSchema||ZA(e)?!0:e.hasUi?YA(e):!1:!1}function $A(e){return QA(e)||XA(e)}var ej=(0,Z.createContext)(null);function tj({children:e}){let t=(0,Z.useRef)(null);if(!t.current){let e=new KA;qA(e),t.current=e}let n=t.current,{data:r,isLoading:i,mutate:a}=Zt(Se(e=>!!e.conversationId)?`gateway-extensions-list`:null,()=>q(J(`/api/extensions`)),{revalidateOnFocus:!1}),o=r?.extensions??[],s=Xd(e=>e.resolved);(0,Z.useEffect)(()=>{let e=()=>{a()};return window.addEventListener(`config-reload`,e),window.addEventListener(`registry-updated`,e),()=>{window.removeEventListener(`config-reload`,e),window.removeEventListener(`registry-updated`,e)}},[a]);let c=(0,Z.useCallback)(e=>{let t=e.detail;t?.conversationId&&n.forwardAgentStreamEvent(t.conversationId,t.event??t)},[n]),l=(0,Z.useRef)(c);l.current=c,(0,Z.useEffect)(()=>{let e=e=>{l.current(e)};return window.addEventListener(FA,e),()=>{window.removeEventListener(FA,e)}},[]),(0,Z.useEffect)(()=>{let e=WA(s);n.broadcastEvent(`theme.changed`,e)},[s,n]);let u=(0,Z.useRef)(n);u.current=n,(0,Z.useEffect)(()=>()=>{u.current.dispose(),t.current=null},[]);let d=(0,Z.useMemo)(()=>({router:n,extensions:o,loading:i}),[n,o,i]);return(0,$.jsx)(ej.Provider,{value:d,children:e})}function nj(){let e=(0,Z.useContext)(ej);if(!e)throw Error(`useExtensionRouter must be used within ExtensionProvider`);return e.router}function rj(){let e=(0,Z.useContext)(ej);if(!e)throw Error(`useExtensions must be used within ExtensionProvider`);return e.extensions}function ij(){let e=(0,Q.c)(2),t=rj(),n;return e[0]===t?n=e[1]:(n=t.filter(QA),e[0]=t,e[1]=n),n}function aj(){let e=(0,Z.useContext)(ej);if(!e)throw Error(`useExtensionsLoading must be used within ExtensionProvider`);return e.loading}var oj=48,sj=2e3,cj=`allow-scripts allow-forms allow-popups`;function lj(e){let t=(0,Q.c)(98),{extensionId:n,extensionName:r,entrypoint:i,permissions:a,title:o,className:s,fixedHeight:c,maxHeight:l,minHeight:u,initialData:d}=e,f=l===void 0?sj:l,p=u===void 0?oj:u,m=Ee(pj),h;t[0]===m?h=t[1]:(h=xe(m),t[0]=m,t[1]=h);let g=h.extensionUi,_=nj(),v=Se(fj),y=Se(dj),b=(0,Z.useRef)(0),x=(0,Z.useRef)(!1),S=(0,Z.useRef)(null),C=Xd(uj),w;t[2]!==n||t[3]!==r?(w=r?.trim()||n,t[2]=n,t[3]=r,t[4]=w):w=t[4];let T=w,E;t[5]!==n||t[6]!==o?(E=o?.trim()||`Extension ${n}`,t[5]=n,t[6]=o,t[7]=E):E=t[7];let D=E,O;t[8]===a?O=t[9]:(O=JSON.stringify(Array.from(a??[]).toSorted()),t[8]=a,t[9]=O);let k=O,A;t[10]===k?A=t[11]:(A=JSON.parse(k),t[10]=k,t[11]=A);let j=A,M=c??Math.min(f,Math.max(p,320)),N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=[],t[12]=N):N=t[12];let P;t[13]===M?P=t[14]:(P={allowed:!1,dialogOpen:!1,reloadKey:0,loadError:!1,dynamicHeight:M,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:N},t[13]=M,t[14]=P);let[F,I]=(0,Z.useReducer)(mx,P),{allowed:L,dialogOpen:R,reloadKey:z,loadError:B,dynamicHeight:V,grantResolved:H,grantError:U}=F,W;t[15]===n?W=t[16]:(W=()=>{let e=!0;return x.current=!1,I({type:`patch`,patch:{allowed:!1,dialogOpen:!1,grantResolved:!1,grantError:null,manifestDigest:null,grantedPermissions:[]}}),NA(n).then(t=>{if(e){if(t.extensionId!==n||!t.manifestDigest)throw Error(`Could not verify extension permissions`);I({type:`patch`,patch:{allowed:t.granted,dialogOpen:!t.granted,grantResolved:!0,manifestDigest:t.manifestDigest,grantedPermissions:t.permissions}})}}).catch(t=>{e&&I({type:`patch`,patch:{allowed:!1,dialogOpen:!0,grantResolved:!0,grantError:t instanceof Error?t.message:String(t)}})}),()=>{e=!1,b.current+=1}},t[15]=n,t[16]=W);let G;t[17]!==n||t[18]!==v||t[19]!==y||t[20]!==j||t[21]!==z?(G=[n,j,v,y,z],t[17]=n,t[18]=v,t[19]=y,t[20]=j,t[21]=z,t[22]=G):G=t[22],(0,Z.useEffect)(W,G);let ee;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>I({type:`patch`,patch:{dialogOpen:e}}),t[23]=ee):ee=t[23];let te=ee,ne;t[24]!==i||t[25]!==n?(ne=EA(n,i),t[24]=i,t[25]=n,t[26]=ne):ne=t[26];let re=ne,ie;t[27]!==L||t[28]!==n||t[29]!==c||t[30]!==f||t[31]!==p||t[32]!==_||t[33]!==F.grantedPermissions||t[34]!==F.manifestDigest?(ie=()=>{if(!L)return;let e=S.current;if(!e)return;_.registerIframe(n,e,F.grantedPermissions,F.manifestDigest??void 0);let t=_.subscribeExtensionEvents(n,e=>{if(e.event!==`ui.resize`||!e.data||typeof e.data!=`object`||e.data===null)return;let t=Number(e.data.height);Number.isFinite(t)&&c===void 0&&I({type:`patch`,patch:{dynamicHeight:Math.min(f,Math.max(p,t))}})});return()=>{t(),_.unregisterIframe(n)}},t[27]=L,t[28]=n,t[29]=c,t[30]=f,t[31]=p,t[32]=_,t[33]=F.grantedPermissions,t[34]=F.manifestDigest,t[35]=ie):ie=t[35];let ae;t[36]!==L||t[37]!==n||t[38]!==c||t[39]!==f||t[40]!==p||t[41]!==z||t[42]!==_||t[43]!==F.grantedPermissions||t[44]!==F.manifestDigest?(ae=[L,n,c,f,p,F.grantedPermissions,F.manifestDigest,_,z],t[36]=L,t[37]=n,t[38]=c,t[39]=f,t[40]=p,t[41]=z,t[42]=_,t[43]=F.grantedPermissions,t[44]=F.manifestDigest,t[45]=ae):ae=t[45],(0,Z.useLayoutEffect)(ie,ae);let oe,se;t[46]!==L||t[47]!==n||t[48]!==C||t[49]!==_?(oe=()=>{if(!L)return;let e=WA(C);_.sendEvent(n,`theme.changed`,e)},se=[L,n,C,_],t[46]=L,t[47]=n,t[48]=C,t[49]=_,t[50]=oe,t[51]=se):(oe=t[50],se=t[51]),(0,Z.useEffect)(oe,se);let ce;t[52]!==V||t[53]!==c?(ce=c===void 0?{width:`100%`,height:V,border:`none`}:{width:`100%`,height:c,border:`none`},t[52]=V,t[53]=c,t[54]=ce):ce=t[54];let le=ce,ue;t[55]!==n||t[56]!==v||t[57]!==y||t[58]!==F.manifestDigest?(ue=()=>{if(x.current||!F.manifestDigest)return;x.current=!0;let e=b.current,t=()=>b.current===e&&Se.getState().baseUrl===v&&Se.getState().conversationId===y;PA(n,F.manifestDigest).then(e=>{if(t()){if(!e.granted||e.extensionId!==n||e.manifestDigest!==F.manifestDigest)throw Error(`Permission grant was not persisted`);I({type:`patch`,patch:{allowed:!0,grantError:null}})}}).catch(e=>{t()&&I({type:`patch`,patch:{allowed:!1,manifestDigest:null,grantError:e instanceof Error?e.message:String(e)}})}).finally(()=>{t()&&(x.current=!1)})},t[55]=n,t[56]=v,t[57]=y,t[58]=F.manifestDigest,t[59]=ue):ue=t[59];let de=ue;if(!H){let e=`${s??``} min-h-32 animate-pulse rounded-lg bg-surface-inset`,n;return t[60]===e?n=t[61]:(n=(0,$.jsx)(`div`,{className:e}),t[60]=e,t[61]=n),n}if(!L){let e=!F.manifestDigest,r;t[62]!==R||t[63]!==T||t[64]!==n||t[65]!==de||t[66]!==e||t[67]!==F.grantedPermissions?(r=(0,$.jsx)(AA,{open:R,onOpenChange:te,extensionId:n,extensionName:T,permissions:F.grantedPermissions,confirmDisabled:e,onConfirm:de}),t[62]=R,t[63]=T,t[64]=n,t[65]=de,t[66]=e,t[67]=F.grantedPermissions,t[68]=r):r=t[68];let i;t[69]!==s||t[70]!==R||t[71]!==U||t[72]!==z||t[73]!==g?(i=R?null:(0,$.jsxs)(`div`,{className:s?`${s} rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`:`rounded-lg border border-edge border-dashed bg-surface-base p-4 text-sm text-fg-muted`,children:[U?(0,$.jsx)(`p`,{className:`mb-2 text-danger`,children:U}):null,(0,$.jsx)(`p`,{children:g.deniedHint}),(0,$.jsx)(`button`,{type:`button`,className:`mt-2 text-sm font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>I({type:`patch`,patch:{reloadKey:z+1}}),children:g.reviewPermissions})]}),t[69]=s,t[70]=R,t[71]=U,t[72]=z,t[73]=g,t[74]=i):i=t[74];let a;return t[75]!==r||t[76]!==i?(a=(0,$.jsxs)($.Fragment,{children:[r,i]}),t[75]=r,t[76]=i,t[77]=a):a=t[77],a}let fe;t[78]!==B||t[79]!==z||t[80]!==g?(fe=B?(0,$.jsxs)(`div`,{className:`mb-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-fg`,children:[(0,$.jsx)(`p`,{children:g.loadFailed}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:g.loadFailedConnectionHint}),(0,$.jsx)(`button`,{type:`button`,className:`mt-2 font-medium text-accent underline-offset-2 hover:underline`,onClick:()=>{I({type:`patch`,patch:{loadError:!1,reloadKey:z+1}})},children:g.retryLoad})]}):null,t[78]=B,t[79]=z,t[80]=g,t[81]=fe):fe=t[81];let pe=`${n}-${i}-${z}`,me;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>I({type:`patch`,patch:{loadError:!0}}),t[82]=me):me=t[82];let he;t[83]!==n||t[84]!==d||t[85]!==m||t[86]!==_?(he=()=>{I({type:`patch`,patch:{loadError:!1}}),_.sendInit(n,WA(Xd.getState().resolved),m),d!==void 0&&_.sendEvent(n,`widget.data`,d)},t[83]=n,t[84]=d,t[85]=m,t[86]=_,t[87]=he):he=t[87];let ge;t[88]!==s||t[89]!==D||t[90]!==re||t[91]!==le||t[92]!==pe||t[93]!==he?(ge=(0,$.jsx)(`iframe`,{ref:S,className:s,title:D,src:re,style:le,sandbox:cj,referrerPolicy:`no-referrer`,onError:me,onLoad:he},pe),t[88]=s,t[89]=D,t[90]=re,t[91]=le,t[92]=pe,t[93]=he,t[94]=ge):ge=t[94];let _e;return t[95]!==fe||t[96]!==ge?(_e=(0,$.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col`,children:[fe,ge]}),t[95]=fe,t[96]=ge,t[97]=_e):_e=t[97],_e}function uj(e){return e.resolved}function dj(e){return e.conversationId}function fj(e){return e.baseUrl}function pj(e){return e.language}function mj(e){let t=(0,Q.c)(8),{extensionId:n,extensionName:r,entrypoint:i,title:a,toolResult:o,maxHeight:s,interactive:c,permissions:l}=e,u=s===void 0?400:s,d;return t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==u||t[4]!==l||t[5]!==a||t[6]!==o?(d=(0,$.jsx)(`div`,{className:`mt-2 w-full min-w-0 overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,$.jsx)(lj,{extensionId:n,extensionName:r,entrypoint:i,permissions:l,title:a,className:`w-full`,minHeight:80,maxHeight:u,initialData:o})}),t[0]=i,t[1]=n,t[2]=r,t[3]=u,t[4]=l,t[5]=a,t[6]=o,t[7]=d):d=t[7],d}function hj(e){let t=ij();return(0,Z.useMemo)(()=>{for(let n of t){let t=n.ui?.contributions?.chatWidgets;if(t){for(let r of t)if(r.match.toolName&&r.match.toolName===e)return{...r,extensionId:n.id}}}return null},[t,e])}function gj(e){if(e.scrollHeight<=e.clientHeight)return!1;let t=window.getComputedStyle(e).overflowY;return t===`auto`||t===`scroll`}function _j(e,t,n){let r=[],i=e instanceof HTMLElement?e:t;for(;i&&i!==t;)gj(i)&&r.push(i),i=i.parentElement;return t.scrollHeight>t.clientHeight&&r.push(t),n!==t&&r.push(n),r}function vj(e,t){let n=e;for(let e of t){let t=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.min(t,Math.max(0,e.scrollTop+n)),i=r-e.scrollTop;if(i!==0&&(e.scrollTop=r),n-=i,Math.abs(n)<.01)break}}function yj(e,t){if(e.defaultPrevented||e.ctrlKey||e.deltaY===0||Math.abs(e.deltaY)<=Math.abs(e.deltaX))return;let n=t.closest(`.chat-messages`);if(!n)return;let r=t.clientHeight||n.clientHeight,i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?r:1,a=_j(e.target,t,n);e.preventDefault(),vj(e.deltaY*i,a)}var bj=`workflow`;function xj(e){return e.name===bj}function Sj(e){if(e.result!=null){let t=Cj(Yk(e.result).details);if(t)return t}return Cj(e.details)}function Cj(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||!Array.isArray(t.agents)?null:e}function wj(e){return e.status===`running`?`running`:Tj(e)||e.status===`error`?`failed`:`completed`}function Tj(e){if(e.status===`error`)return!0;let t=jj(e).toLowerCase().trim();return!!(t.startsWith(`workflow failed`)||t.includes(`workflow graph validation failed`)||t.includes(`workflow aborted`)||t.includes(`timed out`)||Dj(e))}function Ej(e){let t=Sj(e),n=jj(e).trim(),r=Dj(e);return{headline:Oj(n,r),detailLines:kj(n,r,t),snapshot:t,logs:t?.logs??[],failedAgents:t?.agents.filter(e=>e.status===`error`||e.status===`skipped`||!!e.error?.trim())??[]}}function Dj(e){if(e.details!=null&&typeof e.details==`object`){let t=e.details.error;if(typeof t==`string`&&t.trim())return t.trim()}if(e.result!=null){let t=Yk(e.result).details?.error;if(typeof t==`string`&&t.trim())return t.trim()}return``}function Oj(e,t){let n=t||e;if(!n)return`workflow failed`;let r=n.replace(/^workflow failed:\s*/i,``).trim();return r&&r!==n?r:n.length>140?`${n.slice(0,137)}…`:n}function kj(e,t,n){let r=[],i=e=>{let t=e.trim();t&&!r.includes(t)&&r.push(t)};e&&i(e),t&&t!==e&&i(t);for(let e of n?.logs??[])i(e);for(let e of n?.agents??[])e.error?.trim()?i(`${e.label}: ${e.error.trim()}`):e.status===`error`?i(`${e.label}: subagent failed`):e.status===`skipped`&&i(`${e.label}: skipped`);return r}function Aj(e){let t=jj(e);if(!t)return`runtime_error`;let n=t.toLowerCase();return n.includes(`workflow graph`)||n.includes(`workflow definition`)||n.includes(`validation`)?`validation_error`:n.includes(`abort`)?`aborted`:n.includes(`timed out`)||n.includes(`timeout`)?`timeout`:`runtime_error`}function jj(e){let t=Dj(e);if(t)return t;if(e.result==null)return``;let n=Yk(e.result);return n.text?n.text:typeof e.result==`string`?e.result:``}function Mj(e){let t=e.agents.map(e=>e.phase).filter(e=>!!e),n=[],r=new Set;for(let i of[e.phases,t,e.currentPhase?[e.currentPhase]:[]])for(let e of i)r.has(e)||(r.add(e),n.push(e));let i=[],a=new Set;for(let t of n){let n=e.agents.filter(e=>e.phase===t);if(!(n.length===0&&e.currentPhase!==t)){for(let e of n)a.add(e.id);i.push(Nj(t,n))}}let o=e.agents.filter(e=>!a.has(e.id));return{phases:i,unphased:o.length>0?Nj(`unphased`,o):null}}function Nj(e,t){let n=0,r=0,i=0,a=0;for(let e of t)e.status===`done`?n++:e.status===`running`?r++:e.status===`error`?i++:e.status===`skipped`&&a++;let o=t.length>0&&n+i+a===t.length;return{title:e,agents:t,done:n,running:r,errored:i,skipped:a,complete:o}}function Pj(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h ${a}m`:`${i}h`}function Fj(e,t=Date.now()){return e.durationMs!=null&&Number.isFinite(e.durationMs)?e.durationMs:e.status===`running`&&e.startedAtMs!=null?Math.max(0,t-e.startedAtMs):null}function Ij(e,t=Date.now()){let n=Fj(e,t);return n==null?``:Pj(n)}function Lj(e){let t=String(e??``).toLowerCase();return t===`high`||t===`critical`||t===`h`?`high`:t===`med`||t===`medium`||t===`m`?`med`:t===`low`||t===`l`?`low`:`neutral`}function Rj(e,t){switch(e.status){case`queued`:return t.statusQueued;case`running`:return t.statusRunning;case`done`:return t.statusDone;case`error`:return t.statusError;case`skipped`:return t.statusSkipped;default:return e.status}}function zj(e){return e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-rose-500/10 text-rose-700 dark:text-rose-300`:e===`running`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-subtle`}var Bj=(0,Z.memo)(function(e){let t=(0,Q.c)(96),{agent:n,snapshot:r,labels:i,className:a,onClose:o}=e;if(!n)return null;let s,c,l,u,d,f,p,m,h,g,_,v,y,b;if(t[0]!==n||t[1]!==a||t[2]!==i||t[3]!==r?.logs){let e=Ij(n);l=n.error||n.resultPreview||n.currentStep||i.runningPlaceholder;let o;t[18]===r?.logs?o=t[19]:(o=r?.logs??[],t[18]=r?.logs,t[19]=o),c=o;let x;t[20]!==n.prompt||t[21]!==c?(x=!!n.prompt?.trim()||c.length>0,t[20]=n.prompt,t[21]=c,t[22]=x):x=t[22],s=x,d=!0,t[23]===a?f=t[24]:(f=K(`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/55 p-3`,a),t[23]=a,t[24]=f),b=`flex min-w-0 items-start justify-between gap-3`,v=`min-w-0`;let S;t[25]===n.label?S=t[26]:(S=(0,$.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.label}),t[25]=n.label,t[26]=S);let C;t[27]===n.status?C=t[28]:(C=K(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium`,zj(n.status)),t[27]=n.status,t[28]=C);let w;t[29]!==n||t[30]!==i?(w=Rj(n,i),t[29]=n,t[30]=i,t[31]=w):w=t[31];let T;t[32]!==C||t[33]!==w?(T=(0,$.jsx)(`span`,{className:C,children:w}),t[32]=C,t[33]=w,t[34]=T):T=t[34],t[35]!==S||t[36]!==T?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[S,T]}),t[35]=S,t[36]=T,t[37]=y):y=t[37],g=`mt-1 flex min-w-0 flex-wrap gap-x-3 gap-y-1 text-xs text-fg-subtle`;let E=n.phase||`-`,D;t[38]===E?D=t[39]:(D=(0,$.jsx)(`span`,{className:`text-fg-muted`,children:E}),t[38]=E,t[39]=D),t[40]!==i.phaseHeading||t[41]!==D?(_=(0,$.jsxs)(`span`,{children:[i.phaseHeading,`: `,D]}),t[40]=i.phaseHeading,t[41]=D,t[42]=_):_=t[42],m=i.elapsedHeading,h=`: `,u=`tabular-nums text-fg-muted`,p=e?i.workedFor(e):`-`,t[0]=n,t[1]=a,t[2]=i,t[3]=r?.logs,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b}else s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17];let x;t[43]!==u||t[44]!==p?(x=(0,$.jsx)(`span`,{className:u,children:p}),t[43]=u,t[44]=p,t[45]=x):x=t[45];let S;t[46]!==x||t[47]!==m||t[48]!==h?(S=(0,$.jsxs)(`span`,{children:[m,h,x]}),t[46]=x,t[47]=m,t[48]=h,t[49]=S):S=t[49];let C;t[50]!==S||t[51]!==g||t[52]!==_?(C=(0,$.jsxs)(`div`,{className:g,children:[_,S]}),t[50]=S,t[51]=g,t[52]=_,t[53]=C):C=t[53];let w;t[54]!==C||t[55]!==v||t[56]!==y?(w=(0,$.jsxs)(`div`,{className:v,children:[y,C]}),t[54]=C,t[55]=v,t[56]=y,t[57]=w):w=t[57];let T;t[58]!==i.close||t[59]!==o?(T=o?(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),"aria-label":i.close,onClick:o,children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})}):null,t[58]=i.close,t[59]=o,t[60]=T):T=t[60];let E;t[61]!==w||t[62]!==T||t[63]!==b?(E=(0,$.jsxs)(`div`,{className:b,children:[w,T]}),t[61]=w,t[62]=T,t[63]=b,t[64]=E):E=t[64];let D;t[65]!==n.currentStep||t[66]!==i.currentStepHeading?(D=n.currentStep?(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.currentStepHeading}),(0,$.jsx)(`div`,{className:`mt-1 wrap-break-word text-sm text-fg-muted`,children:n.currentStep})]}):null,t[65]=n.currentStep,t[66]=i.currentStepHeading,t[67]=D):D=t[67];let O;t[68]===i.outputHeading?O=t[69]:(O=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.outputHeading}),t[68]=i.outputHeading,t[69]=O);let k=n.error?`font-mono text-rose-600 dark:text-rose-400`:`text-fg-muted`,A;t[70]===k?A=t[71]:(A=K(`mt-1 max-h-44 overflow-y-auto whitespace-pre-wrap wrap-break-word text-sm leading-6`,k),t[70]=k,t[71]=A);let j;t[72]!==l||t[73]!==A?(j=(0,$.jsx)(`div`,{className:A,children:l}),t[72]=l,t[73]=A,t[74]=j):j=t[74];let M;t[75]!==O||t[76]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2`,children:[O,j]}),t[75]=O,t[76]=j,t[77]=M):M=t[77];let N;t[78]!==n.steps||t[79]!==i.stepsHeading?(N=n.steps?.length?(0,$.jsxs)(`div`,{className:`mt-3 space-y-1.5`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.stepsHeading}),n.steps.map(Vj)]}):null,t[78]=n.steps,t[79]=i.stepsHeading,t[80]=N):N=t[80];let P;t[81]!==n.prompt||t[82]!==s||t[83]!==i.executionHeading||t[84]!==i.logsHeading||t[85]!==i.promptHeading||t[86]!==c?(P=s?(0,$.jsxs)(`details`,{className:`group mt-3 rounded-lg border border-edge-subtle bg-surface-panel`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted`,children:[i.executionHeading,(0,$.jsx)(cr,{className:`size-3.5 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,$.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle p-2.5`,children:[n.prompt?.trim()?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.promptHeading}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-40 min-w-0 overflow-y-auto whitespace-pre-wrap wrap-break-word rounded-md bg-surface-hover/45 p-2 font-mono text-xs leading-5 text-fg-muted`,children:n.prompt})]}):null,c.length>0?(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.logsHeading}),(0,$.jsx)(`div`,{className:`mt-1 max-h-36 space-y-0.5 overflow-y-auto rounded-md bg-surface-hover/45 p-2 font-mono text-xs leading-5 text-fg-subtle`,children:c.map(Hj)})]}):null]})]}):null,t[81]=n.prompt,t[82]=s,t[83]=i.executionHeading,t[84]=i.logsHeading,t[85]=i.promptHeading,t[86]=c,t[87]=P):P=t[87];let F;return t[88]!==d||t[89]!==f||t[90]!==E||t[91]!==D||t[92]!==M||t[93]!==N||t[94]!==P?(F=(0,$.jsxs)(`section`,{"data-workflow-inline-detail":d,className:f,children:[E,D,M,N,P]}),t[88]=d,t[89]=f,t[90]=E,t[91]=D,t[92]=M,t[93]=N,t[94]=P,t[95]=F):F=t[95],F});function Vj(e){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-subtle`,children:e.status})]}),e.detail||e.resultPreview||e.error?(0,$.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap wrap-break-word text-xs leading-5 text-fg-muted`,children:e.error||e.resultPreview||e.detail}):null]},e.id)}function Hj(e){return(0,$.jsx)(`div`,{className:`wrap-break-word`,children:e},e)}var Uj=(0,Z.memo)(function(e){let t=(0,Q.c)(38),{name:n,description:r,status:i,doneCount:a,totalCount:o,durationText:s,metaText:c,collapsed:l,onToggleCollapsed:u,actions:d,labels:f}=e,p=o>0?`${a}/${o}`:i===`running`?`…`:`0`,m;t[0]!==p||t[1]!==s||t[2]!==f||t[3]!==c||t[4]!==i?(m=c??(i===`running`?f.runningMeta(p,s):i===`completed`?f.completedMeta(p,s):f.failedMeta),t[0]=p,t[1]=s,t[2]=f,t[3]=c,t[4]=i,t[5]=m):m=t[5];let h=m,g=i===`failed`&&`border-rose-300/40`,_;t[6]===g?_=t[7]:(_=K(`flex min-w-0 items-center gap-2 border-b border-edge-subtle px-3 py-2`,g),t[6]=g,t[7]=_);let v;t[8]===i?v=t[9]:(v=(0,$.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-fg-subtle`,children:i===`running`?(0,$.jsx)(ue,{className:`size-4 animate-spin text-accent-fg`}):(0,$.jsx)(Xr,{className:`size-4`})}),t[8]=i,t[9]=v);let y;t[10]===n?y=t[11]:(y=(0,$.jsx)(`div`,{className:`min-w-0 shrink truncate text-base font-semibold tracking-tight text-fg`,children:n}),t[10]=n,t[11]=y);let b;t[12]===h?b=t[13]:(b=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs tabular-nums text-fg-subtle`,children:h}),t[12]=h,t[13]=b);let x;t[14]!==y||t[15]!==b?(x=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[y,b]}),t[14]=y,t[15]=b,t[16]=x):x=t[16];let S;t[17]===r?S=t[18]:(S=r?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-1 text-xs text-fg-subtle`,children:r}):null,t[17]=r,t[18]=S);let C;t[19]!==x||t[20]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S]}),t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=K(`inline-flex size-7 items-center justify-center rounded-md`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),t[22]=w):w=t[22];let T=l?f.expand:f.collapse,E=l?f.expand:f.collapse,D;t[23]===l?D=t[24]:(D=l?(0,$.jsx)(cr,{className:`size-4`}):(0,$.jsx)(ur,{className:`size-4`}),t[23]=l,t[24]=D);let O;t[25]!==u||t[26]!==T||t[27]!==E||t[28]!==D?(O=(0,$.jsx)(`button`,{type:`button`,onClick:u,className:w,"aria-label":T,title:E,children:D}),t[25]=u,t[26]=T,t[27]=E,t[28]=D,t[29]=O):O=t[29];let k;t[30]!==d||t[31]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[d,O]}),t[30]=d,t[31]=O,t[32]=k):k=t[32];let A;return t[33]!==k||t[34]!==_||t[35]!==v||t[36]!==C?(A=(0,$.jsxs)(`div`,{className:_,children:[v,C,k]}),t[33]=k,t[34]=_,t[35]=v,t[36]=C,t[37]=A):A=t[37],A}),Wj={queued:(0,$.jsx)(pr,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),running:(0,$.jsx)(ue,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}),done:(0,$.jsx)(j,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),error:(0,$.jsx)(dr,{className:`size-3.5 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),skipped:(0,$.jsx)(vr,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0})},Gj=(0,Z.memo)(function(e){let t=(0,Q.c)(39),{agent:n,labels:r,selected:i,onSelect:a}=e,[,o]=(0,Z.useState)(0),s;t[0]!==n.status||t[1]!==o?(s=()=>{if(n.status!==`running`)return;let e=window.setInterval(()=>o(Kj),1e3);return()=>window.clearInterval(e)},t[0]=n.status,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.startedAtMs||t[4]!==n.status?(c=[n.status,n.startedAtMs],t[3]=n.startedAtMs,t[4]=n.status,t[5]=c):c=t[5],(0,Z.useEffect)(s,c);let l;t[6]===n.status?l=t[7]:(l=Wj[n.status]??(0,$.jsx)(hr,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[6]=n.status,t[7]=l);let u=l,d;t[8]===n?d=t[9]:(d=Ij(n),t[8]=n,t[9]=d);let f=d,p=n.status===`queued`?r.queued:n.status===`running`&&!n.currentStep?r.running:n.currentStep,m;t[10]!==n||t[11]!==a?(m=()=>a?.(n),t[10]=n,t[11]=a,t[12]=m):m=t[12];let h=`${r.openDetail}: ${n.label}`,g=i?`true`:void 0,_=i&&`bg-surface-hover/80 ring-1 ring-edge-subtle`,v;t[13]===_?v=t[14]:(v=K(`flex w-full min-w-0 flex-col gap-0.5 rounded-md px-1.5 py-0.5 text-left`,`text-sm leading-6 text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,_,yc.transition,yc.focusRingPanel),t[13]=_,t[14]=v);let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(lr,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[15]=y):y=t[15];let b;t[16]!==n.id||t[17]!==r?(b=r.agentNumber(n.id),t[16]=n.id,t[17]=r,t[18]=b):b=t[18];let x;t[19]===b?x=t[20]:(x=(0,$.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-disabled`,children:b}),t[19]=b,t[20]=x);let S;t[21]===n.label?S=t[22]:(S=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg`,children:n.label}),t[21]=n.label,t[22]=S);let C;t[23]===f?C=t[24]:(C=f?(0,$.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-fg-disabled`,children:f}):null,t[23]=f,t[24]=C);let w;t[25]!==u||t[26]!==x||t[27]!==S||t[28]!==C?(w=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[y,u,x,S,C]}),t[25]=u,t[26]=x,t[27]=S,t[28]=C,t[29]=w):w=t[29];let T;t[30]===p?T=t[31]:(T=p?(0,$.jsx)(`span`,{className:`ml-7 truncate text-xs text-fg-subtle`,children:p}):null,t[30]=p,t[31]=T);let E;return t[32]!==w||t[33]!==T||t[34]!==m||t[35]!==h||t[36]!==g||t[37]!==v?(E=(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsxs)(`button`,{type:`button`,onClick:m,"aria-label":h,"aria-current":g,className:v,children:[w,T]})}),t[32]=w,t[33]=T,t[34]=m,t[35]=h,t[36]=g,t[37]=v,t[38]=E):E=t[38],E});function Kj(e){return e+1}var qj=(0,Z.memo)(function(e){let t=(0,Q.c)(69),{kind:n,reason:r,detailLines:i,logs:a,failedAgents:o,snapshot:s,selectedAgentId:c,onSelectAgent:l,labels:u,className:d}=e,f=n===`validation_error`?u.titleValidation:n===`aborted`?u.titleAbort:n===`timeout`?u.titleTimeout:u.titleRuntime,p;t[0]===r?p=t[1]:(p=r.trim()||`workflow failed`,t[0]=r,t[1]=p);let m=p,h;t[2]===a?h=t[3]:(h=a??[],t[2]=a,t[3]=h);let g=h,_;t[4]===o?_=t[5]:(_=o??[],t[4]=o,t[5]=_);let v=_;s?.agents;let y;t[6]===s?.agents?y=t[7]:(y=s?.agents??[],t[6]=s?.agents,t[7]=y);let b=y,x;if(t[8]!==i||t[9]!==m){x=[];let e=e=>{let t=e.trim();t&&!x.includes(t)&&x.push(t)};e(m);for(let t of i??[])e(t);t[8]=i,t[9]=m,t[10]=x}else x=t[10];let C=x.join(`
45
- `),w;t[11]!==n||t[12]!==u.recoveryActions?(w=u.recoveryActions[n]??[],t[11]=n,t[12]=u.recoveryActions,t[13]=w):w=t[13];let T=w,E=s?.doneCount??0,D=s?.agentCount??0,O=v.length||s?.errorCount||0,k=!!C||T.length>0||g.length>0||b.length>0,[A,j]=(0,Z.useState)(!1),[M,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(!1),L=!A,R;t[14]!==C||t[15]!==m?(R=async()=>{await Yt(C||m)&&(I(!0),window.setTimeout(()=>I(!1),1500))},t[14]=C,t[15]=m,t[16]=R):R=t[16];let z=R,B=Jj[n],V;t[17]===f?V=t[18]:(V=(0,$.jsx)(`span`,{className:`shrink-0 text-sm font-semibold tracking-tight text-fg`,children:f}),t[17]=f,t[18]=V);let H;t[19]===m?H=t[20]:(H=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg-muted`,children:m}),t[19]=m,t[20]=H);let U;t[21]!==V||t[22]!==H?(U=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[V,H]}),t[21]=V,t[22]=H,t[23]=U):U=t[23];let W;t[24]!==k||t[25]!==A||t[26]!==u.expandHint?(W=A&&k?(0,$.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:u.expandHint}):null,t[24]=k,t[25]=A,t[26]=u.expandHint,t[27]=W):W=t[27];let G;t[28]!==U||t[29]!==W?(G=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[U,W]}),t[28]=U,t[29]=W,t[30]=G):G=t[30];let ee;t[31]===L?ee=t[32]:(ee=(0,$.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted`,"aria-hidden":!0,children:L?(0,$.jsx)(ur,{className:`size-4`}):(0,$.jsx)(cr,{className:`size-4`})}),t[31]=L,t[32]=ee);let te;t[33]!==G||t[34]!==ee||t[35]!==B?(te=(0,$.jsxs)($.Fragment,{children:[B,G,ee]}),t[33]=G,t[34]=ee,t[35]=B,t[36]=te):te=t[36];let ne=te,re;t[37]===d?re=t[38]:(re=K(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,d),t[37]=d,t[38]=re);let ie;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ie=()=>j(Yj),t[39]=ie):ie=t[39];let ae=L?u.collapse:u.expand,oe=L?`rounded-t-xl border-b border-edge-subtle`:`rounded-xl`,se;t[40]===oe?se=t[41]:(se=K(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left`,oe,`hover:bg-surface-hover`,yc.transition,yc.focusRingPanel),t[40]=oe,t[41]=se);let ce;t[42]!==ne||t[43]!==L||t[44]!==ae||t[45]!==se?(ce=(0,$.jsx)(`button`,{type:`button`,onClick:ie,"aria-expanded":L,"aria-label":ae,className:se,children:ne}),t[42]=ne,t[43]=L,t[44]=ae,t[45]=se,t[46]=ce):ce=t[46];let le;t[47]!==k||t[48]!==F||t[49]!==C||t[50]!==E||t[51]!==O||t[52]!==z||t[53]!==L||t[54]!==u||t[55]!==g||t[56]!==l||t[57]!==M||t[58]!==T||t[59]!==c||t[60]!==D||t[61]!==m||t[62]!==b?(le=L?(0,$.jsxs)(`div`,{className:`space-y-3 px-3 py-2.5`,children:[(0,$.jsxs)(`section`,{className:`min-w-0 rounded-lg bg-surface-hover/35 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>P(Xj),"aria-expanded":M,className:K(`inline-flex min-w-0 flex-1 items-center gap-1 text-left text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,`hover:text-fg-muted`,yc.transition,yc.focusRingPanel),children:[(0,$.jsx)(`span`,{className:`truncate`,children:u.detailsHeading}),M?(0,$.jsx)(ur,{className:`size-3`}):(0,$.jsx)(cr,{className:`size-3`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:z,className:K(`inline-flex h-6 shrink-0 items-center gap-1 rounded-md px-1.5 text-xs text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),"aria-label":F?u.copyReasonDone:u.copyReason,title:F?u.copyReasonDone:u.copyReason,children:[F?(0,$.jsx)(S,{className:`size-3.5`}):(0,$.jsx)(N,{className:`size-3.5`}),(0,$.jsx)(`span`,{children:F?u.copyReasonDone:u.copyReason})]})]}),M?(0,$.jsx)(`pre`,{className:`max-h-36 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-panel/60 p-2 font-sans text-sm leading-6 text-fg-muted`,children:C||m}):(0,$.jsx)(`div`,{className:`truncate text-sm text-fg-muted`,title:m,children:m})]}),D>0?(0,$.jsxs)(`section`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:u.impactHeading}),(0,$.jsx)(`div`,{className:`text-sm text-fg-muted`,children:u.impactTpl(E,D,O)})]}):null,T.length>0?(0,$.jsxs)(`section`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:u.recoveryHeading}),(0,$.jsx)(`ul`,{className:`space-y-0.5 text-sm text-fg-muted`,children:T.map(Zj)})]}):null,b.length>0?(0,$.jsxs)(`section`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:u.executedAgentsHeading}),(0,$.jsx)(`div`,{className:`space-y-0.5`,children:b.map(e=>(0,$.jsx)(Gj,{agent:e,labels:u.phase,selected:c===e.id,onSelect:l},e.id))})]}):null,g.length>0?(0,$.jsxs)(`section`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:u.logsHeading}),(0,$.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md bg-surface-hover/60 p-2 font-mono text-xs text-fg-muted dark:bg-surface-hover/35`,children:g.join(`
46
- `)})]}):null,k?null:(0,$.jsx)(`div`,{className:`text-xs text-fg-disabled`,children:u.noExtraDetails})]}):null,t[47]=k,t[48]=F,t[49]=C,t[50]=E,t[51]=O,t[52]=z,t[53]=L,t[54]=u,t[55]=g,t[56]=l,t[57]=M,t[58]=T,t[59]=c,t[60]=D,t[61]=m,t[62]=b,t[63]=le):le=t[63];let ue;return t[64]!==re||t[65]!==ce||t[66]!==le||t[67]!==f?(ue=(0,$.jsxs)(`div`,{className:re,role:`group`,"aria-label":f,children:[ce,le]}),t[64]=re,t[65]=ce,t[66]=le,t[67]=f,t[68]=ue):ue=t[68],ue}),Jj={validation_error:(0,$.jsx)(Ci,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0}),aborted:(0,$.jsx)(br,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),timeout:(0,$.jsx)(fa,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),runtime_error:(0,$.jsx)(ma,{className:`size-4 shrink-0 text-rose-600 dark:text-rose-400`,"aria-hidden":!0})};function Yj(e){return!e}function Xj(e){return!e}function Zj(e){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`•`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},e)}var Qj=(0,Z.memo)(function(e){let t=(0,Q.c)(49),{rollup:n,isCurrent:r,labels:i,selectedAgentId:a,onSelectAgent:o}=e,[s,c]=(0,Z.useState)(r||n.running>0||n.errored>0||n.skipped>0||!n.complete),l,u;t[0]===r?(l=t[1],u=t[2]):(l=()=>{r&&c(!0)},u=[r],t[0]=r,t[1]=l,t[2]=u),(0,Z.useEffect)(l,u);let d=n.agents.length,f;t[3]!==n.complete||t[4]!==n.running?(f=n.running>0?(0,$.jsx)(ue,{className:`size-3.5 shrink-0 animate-spin text-accent-fg`,"aria-hidden":!0}):n.complete?(0,$.jsx)(j,{className:`size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,$.jsx)(xr,{className:`size-3.5 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[3]=n.complete,t[4]=n.running,t[5]=f):f=t[5];let p=f,m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>c($j),t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=K(`flex w-full min-w-0 items-center gap-2 rounded-md p-1 text-left`,`text-sm font-medium text-fg`,`hover:bg-surface-hover`,yc.transition,yc.focusRingPanel),t[7]=h):h=t[7];let g=s&&`rotate-90`,_;t[8]===g?_=t[9]:(_=K(`size-3.5 shrink-0 text-fg-subtle transition-transform duration-150`,g),t[8]=g,t[9]=_);let v;t[10]===_?v=t[11]:(v=(0,$.jsx)(lr,{className:_,"aria-hidden":!0}),t[10]=_,t[11]=v);let y;t[12]===n.title?y=t[13]:(y=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.title}),t[12]=n.title,t[13]=y);let b;t[14]!==i||t[15]!==n.done||t[16]!==d?(b=i.countTpl(n.done,d),t[14]=i,t[15]=n.done,t[16]=d,t[17]=b):b=t[17];let x;t[18]===b?x=t[19]:(x=(0,$.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:b}),t[18]=b,t[19]=x);let S;t[20]!==i||t[21]!==n.running?(S=n.running>0?(0,$.jsx)(`span`,{className:`text-accent-fg`,children:i.runningTag(n.running)}):null,t[20]=i,t[21]=n.running,t[22]=S):S=t[22];let C;t[23]!==i||t[24]!==n.errored?(C=n.errored>0?(0,$.jsx)(`span`,{className:`text-rose-600 dark:text-rose-400`,children:i.errorsTag(n.errored)}):null,t[23]=i,t[24]=n.errored,t[25]=C):C=t[25];let w;t[26]!==i||t[27]!==n.skipped?(w=n.skipped>0?(0,$.jsx)(`span`,{children:i.skippedTag(n.skipped)}):null,t[26]=i,t[27]=n.skipped,t[28]=w):w=t[28];let T;t[29]!==S||t[30]!==C||t[31]!==w?(T=(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-disabled`,children:[S,C,w]}),t[29]=S,t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]!==s||t[34]!==p||t[35]!==x||t[36]!==T||t[37]!==v||t[38]!==y?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:m,"aria-expanded":s,className:h,children:[v,p,y,x,T]}),t[33]=s,t[34]=p,t[35]=x,t[36]=T,t[37]=v,t[38]=y,t[39]=E):E=t[39];let D;t[40]!==i||t[41]!==o||t[42]!==s||t[43]!==n.agents||t[44]!==a?(D=s?(0,$.jsxs)(`div`,{className:`ml-4 mt-0.5 space-y-0.5 border-l border-edge-subtle pl-2`,children:[n.agents.map(e=>(0,$.jsx)(Gj,{agent:e,labels:i,selected:a===e.id,onSelect:o},e.id)),n.agents.length===0?(0,$.jsx)(`div`,{className:`px-1.5 py-0.5 text-xs text-fg-disabled`,children:`…`}):null]}):null,t[40]=i,t[41]=o,t[42]=s,t[43]=n.agents,t[44]=a,t[45]=D):D=t[45];let O;return t[46]!==E||t[47]!==D?(O=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[E,D]}),t[46]=E,t[47]=D,t[48]=O):O=t[48],O});function $j(e){return!e}function eM(e){let t=(0,Q.c)(44),{snapshot:n,labels:r,logsExpanded:i,onToggleLogs:a,selectedAgentId:o,onSelectAgent:s}=e,c;t[0]===n.agents?c=t[1]:(c=n.agents.filter(iM),t[0]=n.agents,t[1]=c);let l=c,u;t[2]===n.agents?u=t[3]:(u=n.agents.filter(rM),t[2]=n.agents,t[3]=u);let d=u,f;t[4]===n.agents?f=t[5]:(f=n.agents.filter(nM),t[4]=n.agents,t[5]=f);let p=f,m;t[6]===n.agents?m=t[7]:(m=n.agents.filter(tM),t[6]=n.agents,t[7]=m);let h=m,g;t[8]!==r.phase||t[9]!==r.runningAgentsHeading||t[10]!==s||t[11]!==l||t[12]!==o?(g=(0,$.jsx)(aM,{heading:r.runningAgentsHeading,agents:l,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[8]=r.phase,t[9]=r.runningAgentsHeading,t[10]=s,t[11]=l,t[12]=o,t[13]=g):g=t[13];let _;t[14]!==d||t[15]!==r.failedAgentsHeading||t[16]!==r.phase||t[17]!==s||t[18]!==o?(_=(0,$.jsx)(aM,{heading:r.failedAgentsHeading,agents:d,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[14]=d,t[15]=r.failedAgentsHeading,t[16]=r.phase,t[17]=s,t[18]=o,t[19]=_):_=t[19];let v;t[20]!==p||t[21]!==r.completedAgentsHeading||t[22]!==r.phase||t[23]!==s||t[24]!==o?(v=(0,$.jsx)(aM,{heading:r.completedAgentsHeading,agents:p,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[20]=p,t[21]=r.completedAgentsHeading,t[22]=r.phase,t[23]=s,t[24]=o,t[25]=v):v=t[25];let y;t[26]!==r.phase||t[27]!==r.queuedAgentsHeading||t[28]!==s||t[29]!==h||t[30]!==o?(y=(0,$.jsx)(aM,{heading:r.queuedAgentsHeading,agents:h,labels:r.phase,selectedAgentId:o,onSelectAgent:s}),t[26]=r.phase,t[27]=r.queuedAgentsHeading,t[28]=s,t[29]=h,t[30]=o,t[31]=y):y=t[31];let b;t[32]!==r.recentLogsHeading||t[33]!==r.showAllLogs||t[34]!==i||t[35]!==a||t[36]!==n.logs?(b=(0,$.jsx)(oM,{recentLogs:n.logs,recentLogsHeading:r.recentLogsHeading,showAllLogsLabel:r.showAllLogs,logsExpanded:i,onToggleLogs:a}),t[32]=r.recentLogsHeading,t[33]=r.showAllLogs,t[34]=i,t[35]=a,t[36]=n.logs,t[37]=b):b=t[37];let x;return t[38]!==g||t[39]!==_||t[40]!==v||t[41]!==y||t[42]!==b?(x=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[g,_,v,y,b]}),t[38]=g,t[39]=_,t[40]=v,t[41]=y,t[42]=b,t[43]=x):x=t[43],x}function tM(e){return e.status===`queued`}function nM(e){return e.status===`done`}function rM(e){return e.status===`error`||e.status===`skipped`}function iM(e){return e.status===`running`}function aM(e){let t=(0,Q.c)(16),{heading:n,agents:r,labels:i,selectedAgentId:a,onSelectAgent:o}=e;if(r.length===0)return null;let s;t[0]===n?s=t[1]:(s=(0,$.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=s);let c;if(t[2]!==r||t[3]!==i||t[4]!==o||t[5]!==a){let e;t[7]!==i||t[8]!==o||t[9]!==a?(e=e=>(0,$.jsx)(Gj,{agent:e,labels:i,selected:a===e.id,onSelect:o},e.id),t[7]=i,t[8]=o,t[9]=a,t[10]=e):e=t[10],c=r.map(e),t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=c}else c=t[6];let l;t[11]===c?l=t[12]:(l=(0,$.jsx)(`div`,{className:`space-y-0.5`,children:c}),t[11]=c,t[12]=l);let u;return t[13]!==s||t[14]!==l?(u=(0,$.jsxs)(`section`,{className:`min-w-0`,children:[s,l]}),t[13]=s,t[14]=l,t[15]=u):u=t[15],u}function oM(e){let t=(0,Q.c)(19),{recentLogs:n,recentLogsHeading:r,showAllLogsLabel:i,logsExpanded:a,onToggleLogs:o}=e,s;t[0]!==a||t[1]!==n?(s=a||n.length<=2?n:n.slice(-2),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:r}),t[3]=r,t[4]=l);let u;t[5]!==o||t[6]!==n.length||t[7]!==i?(u=n.length>2?(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`text-[10px] text-accent-fg hover:underline`,children:i}):null,t[5]=o,t[6]=n.length,t[7]=i,t[8]=u):u=t[8];let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f;t[12]===c?f=t[13]:(f=c.map(sM),t[12]=c,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,$.jsx)(`div`,{className:`space-y-0.5`,children:f}),t[14]=f,t[15]=p);let m;return t[16]!==d||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2`,children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18],m}function sM(e){return(0,$.jsx)(`div`,{className:`break-words font-mono text-xs text-fg-subtle`,children:e},e)}function cM(e){let t=(0,Q.c)(29),{rollup:n,currentPhase:r,labels:i,recentLogs:a,recentLogsHeading:o,showAllLogsLabel:s,logsExpanded:c,onToggleLogs:l,selectedAgentId:u,onSelectAgent:d}=e,f;t[0]!==c||t[1]!==a?(f=c||a.length<=2?a:a.slice(-2),t[0]=c,t[1]=a,t[2]=f):f=t[2];let p=f,m;if(t[3]!==r||t[4]!==i||t[5]!==d||t[6]!==n.phases||t[7]!==u){let e;t[9]!==r||t[10]!==i||t[11]!==d||t[12]!==u?(e=e=>(0,$.jsx)(Qj,{rollup:e,isCurrent:e.title===r,labels:i,selectedAgentId:u,onSelectAgent:d},e.title),t[9]=r,t[10]=i,t[11]=d,t[12]=u,t[13]=e):e=t[13],m=n.phases.map(e),t[3]=r,t[4]=i,t[5]=d,t[6]=n.phases,t[7]=u,t[8]=m}else m=t[8];let h;t[14]!==i||t[15]!==d||t[16]!==n.unphased||t[17]!==u?(h=n.unphased?(0,$.jsx)(Qj,{rollup:n.unphased,isCurrent:!1,labels:i,selectedAgentId:u,onSelectAgent:d}):null,t[14]=i,t[15]=d,t[16]=n.unphased,t[17]=u,t[18]=h):h=t[18];let g;t[19]!==l||t[20]!==a.length||t[21]!==o||t[22]!==s||t[23]!==p?(g=a.length>0?(0,$.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle pt-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:o}),a.length>2?(0,$.jsx)(`button`,{type:`button`,onClick:l,className:`text-[10px] text-accent-fg hover:underline`,children:s}):null]}),(0,$.jsx)(`div`,{className:`space-y-0.5`,children:p.map(lM)})]}):null,t[19]=l,t[20]=a.length,t[21]=o,t[22]=s,t[23]=p,t[24]=g):g=t[24];let _;return t[25]!==m||t[26]!==h||t[27]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[m,h,g]}),t[25]=m,t[26]=h,t[27]=g,t[28]=_):_=t[28],_}function lM(e){return(0,$.jsx)(`div`,{className:`break-words font-mono text-xs text-fg-subtle`,children:e},e)}var uM=5,dM=(0,Z.memo)(function(e){let t=(0,Q.c)(17),{result:n,labels:r}=e;if(!n){let e;return t[0]===r.emptyResult?e=t[1]:(e=(0,$.jsx)(`div`,{className:`text-sm text-fg-disabled`,children:r.emptyResult}),t[0]=r.emptyResult,t[1]=e),e}let i;t[2]===n.title?i=t[3]:(i=n.title?(0,$.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:n.title}):null,t[2]=n.title,t[3]=i);let a;t[4]===n.summary?a=t[5]:(a=(0,$.jsx)(ie,{content:n.summary,className:`workflow-result-markdown`}),t[4]=n.summary,t[5]=a);let o;t[6]===n.sections?o=t[7]:(o=n.sections??[],t[6]=n.sections,t[7]=o);let s;if(t[8]!==r||t[9]!==o){let e;t[11]===r?e=t[12]:(e=(e,t)=>(0,$.jsx)(fM,{section:e,labels:r},`${e.kind}:${e.title}:${t}`),t[11]=r,t[12]=e),s=o.map(e),t[8]=r,t[9]=o,t[10]=s}else s=t[10];let c;return t[13]!==i||t[14]!==a||t[15]!==s?(c=(0,$.jsxs)(`article`,{className:`min-w-0 space-y-6`,children:[i,a,s]}),t[13]=i,t[14]=a,t[15]=s,t[16]=c):c=t[16],c});function fM(e){let t=(0,Q.c)(23),{section:n,labels:r}=e;if(n.kind===`text`){let e;return t[0]!==n.content||t[1]!==n.title?(e=(0,$.jsx)(pM,{heading:n.title,text:n.content}),t[0]=n.content,t[1]=n.title,t[2]=e):e=t[2],e}if(n.kind===`findings`){let e;t[3]!==r||t[4]!==n.items||t[5]!==n.title?(e=n.title||r.topFindingsHeading(n.items.length),t[3]=r,t[4]=n.items,t[5]=n.title,t[6]=e):e=t[6];let i;return t[7]!==r.moreSuffix||t[8]!==n.items||t[9]!==e?(i=(0,$.jsx)(gM,{heading:e,items:n.items,moreSuffix:r.moreSuffix}),t[7]=r.moreSuffix,t[8]=n.items,t[9]=e,t[10]=i):i=t[10],i}if(n.kind===`risks`){let e;t[11]!==r||t[12]!==n.items||t[13]!==n.title?(e=n.title||r.topRisksHeading(n.items.length),t[11]=r,t[12]=n.items,t[13]=n.title,t[14]=e):e=t[14];let i;return t[15]!==r.moreSuffix||t[16]!==n.items||t[17]!==e?(i=(0,$.jsx)(vM,{heading:e,items:n.items,moreSuffix:r.moreSuffix}),t[15]=r.moreSuffix,t[16]=n.items,t[17]=e,t[18]=i):i=t[18],i}if(n.kind===`questions`){let e=n.title||r.openQuestionsHeading,i;return t[19]!==r.moreSuffix||t[20]!==n.items||t[21]!==e?(i=(0,$.jsx)(mM,{heading:e,items:n.items,moreSuffix:r.moreSuffix}),t[19]=r.moreSuffix,t[20]=n.items,t[21]=e,t[22]=i):i=t[22],i}}function pM(e){let t=(0,Q.c)(7),{heading:n,text:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(ie,{content:r,compact:!0,className:`mt-2`}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`section`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function mM(e){let t=(0,Q.c)(21),{heading:n,items:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==n||t[1]!==r?(l=r.slice(0,uM),s=`min-w-0`,t[7]===n?c=t[8]:(c=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[7]=n,t[8]=c),a=`mt-1 space-y-1 text-sm text-fg-muted`,o=l.map(hM),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,$.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==r.length||t[13]!==i||t[14]!==l.length?(d=r.length>l.length?(0,$.jsx)(`div`,{className:`mt-1 pl-4 text-xs text-fg-disabled`,children:i(r.length-l.length)}):null,t[12]=r.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,$.jsxs)(`section`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function hM(e,t){return(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`-`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]},`${e}:${t}`)}function gM(e){let t=(0,Q.c)(21),{heading:n,items:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==n||t[1]!==r?(l=r.slice(0,uM),s=`min-w-0`,t[7]===n?c=t[8]:(c=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[7]=n,t[8]=c),a=`mt-2 space-y-2`,o=l.map(_M),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,$.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==r.length||t[13]!==i||t[14]!==l.length?(d=r.length>l.length?(0,$.jsx)(`div`,{className:`mt-2 pl-1 text-xs text-fg-disabled`,children:i(r.length-l.length)}):null,t[12]=r.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,$.jsxs)(`section`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function _M(e,t){return(0,$.jsx)(bM,{item:e},`${e.title}:${e.file??``}:${t}`)}function vM(e){let t=(0,Q.c)(21),{heading:n,items:r,moreSuffix:i}=e,a,o,s,c,l;t[0]!==n||t[1]!==r?(l=r.slice(0,uM),s=`min-w-0`,t[7]===n?c=t[8]:(c=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n}),t[7]=n,t[8]=c),a=`mt-2 space-y-2`,o=l.map(yM),t[0]=n,t[1]=r,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l):(a=t[2],o=t[3],s=t[4],c=t[5],l=t[6]);let u;t[9]!==a||t[10]!==o?(u=(0,$.jsx)(`ul`,{className:a,children:o}),t[9]=a,t[10]=o,t[11]=u):u=t[11];let d;t[12]!==r.length||t[13]!==i||t[14]!==l.length?(d=r.length>l.length?(0,$.jsx)(`div`,{className:`mt-2 pl-1 text-xs text-fg-disabled`,children:i(r.length-l.length)}):null,t[12]=r.length,t[13]=i,t[14]=l.length,t[15]=d):d=t[15];let f;return t[16]!==s||t[17]!==c||t[18]!==u||t[19]!==d?(f=(0,$.jsxs)(`section`,{className:s,children:[c,u,d]}),t[16]=s,t[17]=c,t[18]=u,t[19]=d,t[20]=f):f=t[20],f}function yM(e,t){return(0,$.jsx)(bM,{item:{title:e.title,severity:e.severity,detail:e.impact,recommendation:e.mitigation}},`${e.title}:${t}`)}function bM(e){let t=(0,Q.c)(19),{item:n}=e,r=Lj(n.severity),i=r===`high`?`bg-rose-500/15 text-rose-700 dark:text-rose-300`:r===`med`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`,a=n.file?n.line==null?n.file:`${n.file}:${n.line}`:``,o;t[0]!==n.severity||t[1]!==i?(o=n.severity?(0,$.jsx)(`span`,{className:K(`rounded px-1.5 py-0.5 text-[10px] font-medium uppercase`,i),children:n.severity}):null,t[0]=n.severity,t[1]=i,t[2]=o):o=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-sm font-medium text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[o,s]}),t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;t[8]===a?l=t[9]:(l=a?(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:a}):null,t[8]=a,t[9]=l);let u;t[10]===n.detail?u=t[11]:(u=n.detail?(0,$.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[10]=n.detail,t[11]=u);let d;t[12]===n.recommendation?d=t[13]:(d=n.recommendation?(0,$.jsx)(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-fg-muted`,children:n.recommendation}):null,t[12]=n.recommendation,t[13]=d);let f;return t[14]!==c||t[15]!==l||t[16]!==u||t[17]!==d?(f=(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge-subtle bg-surface-base/45 px-3 py-2`,children:[c,l,u,d]}),t[14]=c,t[15]=l,t[16]=u,t[17]=d,t[18]=f):f=t[18],f}function xM(e){return e?e.toLowerCase().startsWith(`zh`)?`zh`:`en`:`default`}var SM={default:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),en:new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`,timeStyle:`short`}),zh:new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`})},CM={default:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),en:new Intl.DateTimeFormat(`en-US`,{dateStyle:`medium`}),zh:new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`})},wM={default:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),en:new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})},TM={default:new Intl.DateTimeFormat(void 0,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}),en:new Intl.DateTimeFormat(`en-US`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}),zh:new Intl.DateTimeFormat(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})},EM={en:new Intl.RelativeTimeFormat(`en-US`,{numeric:`auto`}),zh:new Intl.RelativeTimeFormat(`zh-CN`,{numeric:`auto`})};function DM(e,t){return SM[xM(t)].format(e)}function OM(e,t){return CM[xM(t)].format(e)}function kM(e,t){return wM[xM(t)].format(e)}function AM(e,t){return TM[xM(t)].format(e)}function jM(e,t,n){return EM[xM(n)===`zh`?`zh`:`en`].format(e,t)}function MM(e){return e===`zh`?`zh`:`en`}function NM(e,t){let n=MM(t),r=n===`en`?void 0:e.metadata.i18n?.[n],i=r?.examplePrompts&&r.examplePrompts.length>0?r.examplePrompts:e.metadata.examplePrompts??[];return{description:FM(r?.description,e.description),whenToUse:IM(r?.whenToUse,e.metadata.whenToUse),examplePrompts:i}}function PM(e){return[e.name,e.title,e.description,e.metadata.whenToUse??``,...(e.metadata.examplePrompts??[]).map(e=>e.text),...Object.values(e.metadata.i18n??{}).flatMap(e=>[e.description??``,e.whenToUse??``,...(e.examplePrompts??[]).map(e=>e.text)]),...e.metadata.tags].join(` `).toLowerCase()}function FM(e,t){return e?.trim()||t}function IM(e,t){return e?.trim()||t?.trim()||void 0}function LM(e,t,n){if(e.field===`goal`){t(e.text);return}n(t=>({...t,[e.field]:e.text}))}var RM=[`all`,`code-review`,`planning`,`research`,`writing`,`productivity`];new Set(RM);var zM=[`all`,`builtin`,`user`];new Set(zM);var BM=`agent`,VM=`layout`,HM=`status`,UM=`trigger`,WM=new Set([`runs`,`library`]),GM=new Set([`list`,`board`]),KM=new Set([`all`,`attention`,`running`,`queued`,`succeeded`]);new Set([`result`,`process`,`artifacts`,`source`]);var qM={"code-review":[`code-review`,`pr`,`release`],planning:[`planning`,`implementation`,`architecture`,`decision`,`review`],research:[`research`,`investigation`,`debug`,`incident`,`troubleshooting`],writing:[`writing`,`content`,`communication`,`email`,`document`],productivity:[`productivity`,`meeting`,`comparison`,`brainstorm`,`decision-making`]},JM={research:[{key:`question`,labelKey:`argQuestion`,placeholderKey:`argQuestionPlaceholder`,required:!0,multiline:!0}],multi_perspective_review:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argTargetPlaceholder`,multiline:!0}],pr_review:[{key:`target`,labelKey:`argDiff`,placeholderKey:`argDiffPlaceholder`,multiline:!0}],debug_incident:[{key:`error`,labelKey:`argError`,placeholderKey:`argErrorPlaceholder`,required:!0,multiline:!0},{key:`context`,labelKey:`argContext`,placeholderKey:`argContextPlaceholder`,multiline:!0}],implementation_plan:[{key:`request`,labelKey:`argRequest`,placeholderKey:`argRequestPlaceholder`,required:!0,multiline:!0},{key:`scope`,labelKey:`argScope`,placeholderKey:`argScopePlaceholder`}],release_check:[{key:`target`,labelKey:`argTarget`,placeholderKey:`argReleaseTargetPlaceholder`,multiline:!0}],content_draft:[{key:`topic`,labelKey:`argTopic`,placeholderKey:`argTopicPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argAudience`,placeholderKey:`argAudiencePlaceholder`},{key:`format`,labelKey:`argFormat`,placeholderKey:`argFormatPlaceholder`}],decision_compare:[{key:`question`,labelKey:`argDecisionQuestion`,placeholderKey:`argDecisionQuestionPlaceholder`,required:!0,multiline:!0},{key:`options`,labelKey:`argOptions`,placeholderKey:`argOptionsPlaceholder`,multiline:!0},{key:`criteria`,labelKey:`argCriteria`,placeholderKey:`argCriteriaPlaceholder`,multiline:!0}],meeting_prep:[{key:`meeting_topic`,labelKey:`argMeetingTopic`,placeholderKey:`argMeetingTopicPlaceholder`,required:!0,multiline:!0},{key:`attendees`,labelKey:`argAttendees`,placeholderKey:`argAttendeesPlaceholder`},{key:`goal`,labelKey:`argMeetingGoal`,placeholderKey:`argMeetingGoalPlaceholder`,multiline:!0}],weekly_review:[{key:`wins`,labelKey:`argWins`,placeholderKey:`argWinsPlaceholder`,required:!0,multiline:!0},{key:`blockers`,labelKey:`argBlockers`,placeholderKey:`argBlockersPlaceholder`,multiline:!0},{key:`carryover`,labelKey:`argCarryover`,placeholderKey:`argCarryoverPlaceholder`,multiline:!0}],client_proposal:[{key:`client_brief`,labelKey:`argClientBrief`,placeholderKey:`argClientBriefPlaceholder`,required:!0,multiline:!0},{key:`offer`,labelKey:`argOffer`,placeholderKey:`argOfferPlaceholder`,multiline:!0},{key:`budget_hint`,labelKey:`argBudgetHint`,placeholderKey:`argBudgetHintPlaceholder`}],content_repurpose:[{key:`source`,labelKey:`argSource`,placeholderKey:`argSourcePlaceholder`,required:!0,multiline:!0},{key:`platforms`,labelKey:`argPlatforms`,placeholderKey:`argPlatformsPlaceholder`,multiline:!0}],competitor_scan:[{key:`market`,labelKey:`argMarket`,placeholderKey:`argMarketPlaceholder`,required:!0,multiline:!0},{key:`competitors`,labelKey:`argCompetitors`,placeholderKey:`argCompetitorsPlaceholder`,multiline:!0},{key:`focus`,labelKey:`argFocus`,placeholderKey:`argFocusPlaceholder`}],offer_design:[{key:`skills`,labelKey:`argSkills`,placeholderKey:`argSkillsPlaceholder`,required:!0,multiline:!0},{key:`audience`,labelKey:`argOfferAudience`,placeholderKey:`argOfferAudiencePlaceholder`,multiline:!0},{key:`constraints`,labelKey:`argConstraints`,placeholderKey:`argConstraintsPlaceholder`,multiline:!0}],inbox_triage:[{key:`inbox`,labelKey:`argInbox`,placeholderKey:`argInboxPlaceholder`,required:!0,multiline:!0},{key:`priorities`,labelKey:`argPriorities`,placeholderKey:`argPrioritiesPlaceholder`,multiline:!0}]},YM=new Set([`queued`,`running`]);function XM(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function ZM(e,t){return e?AM(e,t):`—`}function QM(e){if(!e||!Number.isFinite(e))return`—`;let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h ${a}m`:`${i}h`}function $M(e){return e===`succeeded`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/15 text-red-700 dark:text-red-300`:e===`cancelled`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-accent-soft text-accent-fg`}function eN(e,t){if(t===`all`)return!0;let n=e.metadata.tags.map(e=>e.toLowerCase());return qM[t].some(e=>n.includes(e))}function tN(e,t){return t===`all`?!0:t===`builtin`?e.metadata.builtIn:e.metadata.source===`user`}function nN(e,t,n,r){let i=t.trim().toLowerCase();return e.filter(e=>!eN(e,n)||!tN(e,r)?!1:i?PM(e).includes(i):!0)}function rN(e){let t=[e.summary.trim()];for(let n of e.sections??[]){let e=n.title.trim()?`## ${n.title.trim()}`:``;if(n.kind===`text`){t.push([e,n.content.trim()].filter(Boolean).join(`
47
-
48
- `));continue}if(n.kind===`questions`){t.push([e,...n.items.map(e=>`- ${e}`)].filter(Boolean).join(`
49
- `));continue}if(n.kind===`findings`){t.push([e,...n.items.map(e=>[`### ${e.title}`,e.severity?`**Severity:** ${e.severity}`:``,e.file?`**Location:** \`${e.file}${e.line==null?``:`:${e.line}`}\``:``,e.detail??``,e.recommendation??``].filter(Boolean).join(`
50
-
51
- `))].filter(Boolean).join(`
52
-
53
- `));continue}t.push([e,...n.items.map(e=>[`### ${e.title}`,e.severity?`**Severity:** ${e.severity}`:``,e.impact??``,e.mitigation??``].filter(Boolean).join(`
54
-
55
- `))].filter(Boolean).join(`
56
-
57
- `))}return t.filter(Boolean).join(`
58
-
59
- `)}function iN(e){return!e||typeof e!=`object`||Array.isArray(e)?!1:typeof e.summary==`string`}function aN(e){return iN(e)?e:null}function oN(e){let t=e.run.metadata?.conversationId?.trim();return t&&Ft.safeParse(t).success?t:null}function sN(e,t){let n=`/chat/${encodeURIComponent(e)}`,r=t?.trim();return r?`${n}?${new URLSearchParams({draft:r}).toString()}`:n}function cN(e,t){let n=e.trim(),r=new URLSearchParams({run:n}),i=t?.ownerAgentId?.trim();return i&&r.set(`agent`,i),`/workflows?${r.toString()}`}function lN(e){let t=e.source;return t&&typeof t==`object`&&`kind`in t&&typeof t.kind==`string`?t.kind:e.metadata?.triggerSource?.trim()||`unknown`}function uN(e,t){let n=t.trim();return!n||n===`all`?!0:lN(e)===n}function dN(e){let t={};for(let[n,r]of Object.entries(e)){let e=r.trim();e&&(t[n]=e)}return Object.keys(t).length>0?t:void 0}function fN(e){let t=[];e.run.error&&t.push({key:`run-error`,kind:`run_error`,severity:e.run.error.recoverable?`warning`:`error`,code:e.run.error.code,message:e.run.error.message,detail:e.run.error.detail});for(let n of e.agents){n.status===`error`?t.push({key:`agent-error:${n.id}`,kind:`agent_error`,severity:`error`,agentId:n.id,agentLabel:n.label,message:n.error,detail:n.resultPreview}):n.status===`skipped`&&t.push({key:`agent-skipped:${n.id}`,kind:`agent_skipped`,severity:`warning`,agentId:n.id,agentLabel:n.label,message:n.error});for(let e of n.steps??[])e.status===`error`&&t.push({key:`step-error:${n.id}:${e.id}`,kind:`step_error`,severity:`error`,agentId:n.id,agentLabel:n.label,stepId:e.id,stepLabel:e.label,message:e.error,detail:e.resultPreview??e.detail})}return t}var pN=(0,Z.memo)(function({block:e,startedAt:t,labels:n,className:r}){let i=wj(e),a=(0,Z.useMemo)(()=>Sj(e),[e]),o=l(),s=i===`failed`?Aj(e):null,c=i===`failed`?jj(e):``,[u,d]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{i===`completed`&&d(!0),(i===`running`||i===`failed`)&&d(!1)},[i]);let[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),g=(0,Z.useMemo)(()=>m==null||!a?null:a.agents.find(e=>e.id===m)??null,[m,a]),_=(0,Z.useCallback)(e=>{h(e.id)},[]),v=(0,Z.useCallback)(()=>{h(null)},[]);(0,Z.useEffect)(()=>{h(null)},[a?.runId,i]);let[,y]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{if(i!==`running`)return;let e=window.setInterval(()=>y(e=>e+1),1e3);return()=>window.clearInterval(e)},[i]);let b=(0,Z.useMemo)(()=>i===`running`?t?Pj(Date.now()-t):``:a?.durationMs==null?``:Pj(a.durationMs),[i,t,a?.durationMs]),[x,C]=(0,Z.useState)(!1),w=(0,Z.useCallback)(async()=>{!a||!iN(a.result)||await Yt(rN(a.result))&&(C(!0),window.setTimeout(()=>C(!1),1500))},[a]),T=(0,Z.useCallback)(()=>{let e=a?.runId?.trim();if(e){o(cN(e));return}let t=a?.name?.trim();t&&o(`/workflows?def=${encodeURIComponent(t)}`)},[o,a?.name,a?.runId]),E=(0,Z.useCallback)(()=>{let e=a?.name?.trim();e&&o(`/workflows?def=${encodeURIComponent(e)}&copy=1`)},[o,a?.name]),D=(0,Z.useCallback)(e=>{let t=a?.runId?.trim();if(!t)return;let n=e.target;n instanceof Element&&n.closest(`button,a,input,textarea,select,summary,[role="button"],[data-workflow-inline-detail]`)||o(cN(t))},[o,a?.runId]);if(Tj(e)||i===`completed`&&!a){let t=s??Aj(e),i=Ej(e),a=i.snapshot,o=m==null||!a?null:a.agents.find(e=>e.id===m)??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qj,{kind:t,reason:i.headline||c||`workflow failed`,detailLines:i.detailLines,logs:i.logs,failedAgents:i.failedAgents,snapshot:a,selectedAgentId:m,onSelectAgent:_,labels:n.error,className:r}),(0,$.jsx)(Bj,{agent:o,snapshot:a,labels:n.checkDetail,className:`mt-2`,onClose:v})]})}let O=a?.agentCount??0,k=a?.doneCount??0,A=a?Mj(a):{phases:[],unphased:null},j=i===`running`&&a?n.currentProgressTpl(a.currentPhase,a.runningCount,a.doneCount,a.agentCount):void 0,M=(0,$.jsx)($.Fragment,{children:i===`completed`&&a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:w,className:K(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),"aria-label":x?n.copyDoneAria:n.copyAria,title:x?n.copyDoneAria:n.copyAria,children:x?(0,$.jsx)(S,{className:`size-4 text-emerald-600 dark:text-emerald-400`}):(0,$.jsx)(N,{className:`size-4`})}),a?.name?(0,$.jsx)(`button`,{type:`button`,onClick:E,className:K(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),"aria-label":n.saveAria,title:n.saveTitle,children:(0,$.jsx)(Ui,{className:`size-4`})}):null,a?.name?(0,$.jsx)(`button`,{type:`button`,onClick:T,className:K(`inline-flex size-7 items-center justify-center rounded-md text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.focusRingPanel),"aria-label":n.openInWorkflowsAria,title:n.openInWorkflowsTitle,children:(0,$.jsx)(se,{className:`size-4`})}):null]}):null});return(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`div`,{onClick:D,className:K(`min-w-0 rounded-xl border border-edge bg-surface-panel shadow-surface`,a?.runId&&`cursor-pointer hover:bg-surface-hover/35`,r),role:`group`,"aria-label":a?`Workflow ${a.name}`:`Workflow`,children:[(0,$.jsx)(Uj,{name:a?.name??e.name,description:a?.description,status:i,doneCount:k,totalCount:O,durationText:b,metaText:j,collapsed:u,onToggleCollapsed:()=>d(e=>!e),actions:M,labels:n.header}),u?null:(0,$.jsxs)(`div`,{className:`space-y-3 px-3 py-2.5`,children:[i===`completed`&&a?(0,$.jsx)(dM,{result:iN(a.result)?a.result:null,labels:n.result}):null,i===`running`&&a?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-base/45 px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:a.currentPhase??n.live.activeFallback}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n.live.progress(a.doneCount,a.agentCount)})]}),a.agentCount>0?(0,$.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${Math.round(a.doneCount/a.agentCount*100)}%`}})}):null,(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`button`,{type:`button`,className:K(`rounded-md px-2 py-1 text-xs font-medium text-accent-fg hover:bg-accent-soft`,yc.focusRingPanel),onClick:T,children:n.live.details})})]}):null,i===`running`&&!a?(0,$.jsxs)(`div`,{className:`py-1 text-sm text-fg-subtle`,children:[(0,$.jsx)(`span`,{className:`inline-block size-2 animate-pulse rounded-full bg-accent align-middle`}),(0,$.jsx)(`span`,{className:`ml-2 align-middle`,children:n.viewSubagentsHeading})]}):null,i===`completed`&&a&&(A.phases.length>0||A.unphased)?(0,$.jsxs)(`details`,{className:`group`,open:f,onToggle:e=>p(e.target.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-xs text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:n.viewSubagentsHeading}),(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(cM,{rollup:A,currentPhase:void 0,labels:n.phase,recentLogs:[],recentLogsHeading:n.recentLogsHeading,showAllLogsLabel:n.showAllLogs,logsExpanded:!1,onToggleLogs:()=>{},selectedAgentId:m,onSelectAgent:_}),(0,$.jsx)(Bj,{agent:g,snapshot:a,labels:n.checkDetail,className:`mt-2`,onClose:v})]})]}):null]})]})})}),mN=(0,Z.memo)(function(e){let t=(0,Q.c)(14),{active:n,startedAt:r,frozenMs:i,language:a,className:o}=e,[,s]=(0,Z.useState)(0),c;t[0]!==n||t[1]!==s?(c=()=>{if(!n)return;let e=window.setInterval(()=>s(ON),500);return()=>window.clearInterval(e)},t[0]=n,t[1]=s,t[2]=c):c=t[2];let l;t[3]===n?l=t[4]:(l=[n],t[3]=n,t[4]=l),(0,Z.useEffect)(c,l);let u=n&&r!=null?Math.max(0,Date.now()-r):0,d;t[5]!==n||t[6]!==u||t[7]!==i||t[8]!==a||t[9]!==r?(d=n&&r!=null?xA(u,a):i==null?null:xA(i,a),t[5]=n,t[6]=u,t[7]=i,t[8]=a,t[9]=r,t[10]=d):d=t[10];let f=d;if(!f)return null;let p;return t[11]!==o||t[12]!==f?(p=(0,$.jsx)(`span`,{className:o,children:f}),t[11]=o,t[12]=f,t[13]=p):p=t[13],p});function hN(e){let t=(0,Q.c)(104),{workLog:n,toolLabels:r,stepLabels:i,clusterLabels:a,cardLabels:o,conversationId:s,workflowOptions:c}=e,l=Ee(yN),u=bA(vN),d;if(t[0]!==u||t[1]!==n.items){let e;t[3]===u?e=t[4]:(e=e=>e.type!==`thinking`||u,t[3]=u,t[4]=e),d=n.items.filter(e),t[0]=u,t[1]=n.items,t[2]=d}else d=t[2];let f=d,p;t[5]===n.items?p=t[6]:(p=n.items.filter(_N),t[5]=n.items,t[6]=p);let m=p,h=f.length,g=n.active,_=n.expandedByDefault&&g,[v,y]=(0,Z.useState)(null),b=!n.compact&&(v??_),x=n.startedAt??null,S=n.durationMs??null,C;t[7]!==i.editFile||t[8]!==i.fetchUrl||t[9]!==i.listDirectory||t[10]!==i.openUrl||t[11]!==i.readFile||t[12]!==i.runCommand||t[13]!==i.searched||t[14]!==i.searchedCode||t[15]!==i.searchedMemory||t[16]!==i.searchedWeb||t[17]!==i.unknownTool||t[18]!==i.writeFile?(C={searchedWeb:i.searchedWeb,searchedMemory:i.searchedMemory,searchedCode:i.searchedCode,searched:i.searched,readFile:i.readFile,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool},t[7]=i.editFile,t[8]=i.fetchUrl,t[9]=i.listDirectory,t[10]=i.openUrl,t[11]=i.readFile,t[12]=i.runCommand,t[13]=i.searched,t[14]=i.searchedCode,t[15]=i.searchedMemory,t[16]=i.searchedWeb,t[17]=i.unknownTool,t[18]=i.writeFile,t[19]=C):C=t[19];let w=C,T;t[20]!==a.ing||t[21]!==w||t[22]!==i.toolActivity?(T=(e,t)=>{let n=Ek(e.name,e.activity);if(n!==`other`&&!kc(e.name)){let t=Wk(e.input),r=kk(n,a.ing);return t?`${r.replace(/[…]+$/,``)} · ${t}`:r}return Wc(e.name,e.input,t,i.toolActivity,w,e.activity)},t[20]=a.ing,t[21]=w,t[22]=i.toolActivity,t[23]=T):T=t[23];let E=T,D;bb0:{if(!g){D=null;break bb0}let e;t[24]===E?e=t[25]:(e=e=>E(e,`running`),t[24]=E,t[25]=e);let n;t[26]!==m||t[27]!==a.ing||t[28]!==e?(n=Mk(m,a.ing,e),t[26]=m,t[27]=a.ing,t[28]=e,t[29]=n):n=t[29],D=n}let O=D;if(h===0&&!g)return null;let k;t[30]!==a.ing||t[31]!==i.editFile||t[32]!==i.fetchUrl||t[33]!==i.listDirectory||t[34]!==i.memoryActivity||t[35]!==i.openUrl||t[36]!==i.rawThinking||t[37]!==i.readFile||t[38]!==i.runCommand||t[39]!==i.searched||t[40]!==i.searchedCode||t[41]!==i.searchedMemory||t[42]!==i.searchedWeb||t[43]!==i.stepDetails||t[44]!==i.thoughts||t[45]!==i.thoughtsStreaming||t[46]!==i.toolActivity||t[47]!==i.toolError||t[48]!==i.unknownTool||t[49]!==i.writeFile?(k={thoughts:i.thoughts,thoughtsStreaming:i.thoughtsStreaming,searchedWeb:i.searchedWeb,searchedMemory:i.searchedMemory,searchedCode:i.searchedCode,searched:i.searched,readFile:i.readFile,stepDetails:i.stepDetails,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool,rawThinking:i.rawThinking,toolError:i.toolError,toolActivity:i.toolActivity,runningActions:a.ing,memoryActivity:i.memoryActivity},t[30]=a.ing,t[31]=i.editFile,t[32]=i.fetchUrl,t[33]=i.listDirectory,t[34]=i.memoryActivity,t[35]=i.openUrl,t[36]=i.rawThinking,t[37]=i.readFile,t[38]=i.runCommand,t[39]=i.searched,t[40]=i.searchedCode,t[41]=i.searchedMemory,t[42]=i.searchedWeb,t[43]=i.stepDetails,t[44]=i.thoughts,t[45]=i.thoughtsStreaming,t[46]=i.toolActivity,t[47]=i.toolError,t[48]=i.unknownTool,t[49]=i.writeFile,t[50]=k):k=t[50];let A=k,j;t[51]!==g||t[52]!==S||t[53]!==x||t[54]!==l||t[55]!==i.workLogComplete||t[56]!==i.workLogFailed||t[57]!==i.workLogPartial||t[58]!==i.workLogRunning||t[59]!==i.workLogTitle||t[60]!==O||t[61]!==n.status?(j=g?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:O??i.workLogRunning}),(0,$.jsx)(mN,{active:g,startedAt:x,frozenMs:null,language:l,className:`ml-1.5 tabular-nums text-fg-muted`})]}):(0,$.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:n.status===`failed`?i.workLogFailed:n.status===`partial`?i.workLogPartial:S==null?i.workLogTitle:i.workLogComplete}),t[51]=g,t[52]=S,t[53]=x,t[54]=l,t[55]=i.workLogComplete,t[56]=i.workLogFailed,t[57]=i.workLogPartial,t[58]=i.workLogRunning,t[59]=i.workLogTitle,t[60]=O,t[61]=n.status,t[62]=j):j=t[62];let M=j,N;t[63]!==g||t[64]!==S||t[65]!==x||t[66]!==l?(N=g?null:(0,$.jsx)(mN,{active:!1,startedAt:x,frozenMs:S,language:l,className:`mt-0.5 tabular-nums text-xs text-fg-muted`}),t[63]=g,t[64]=S,t[65]=x,t[66]=l,t[67]=N):N=t[67];let P=N,F=!n.compact&&h>0,I=F?`button`:`div`,L=b?`w-full`:`w-fit max-w-full`,R;t[68]===L?R=t[69]:(R=K(`my-1 min-w-0`,L),t[68]=L,t[69]=R);let z;t[70]!==I||t[71]!==g||t[72]!==b||t[73]!==P||t[74]!==M||t[75]!==F||t[76]!==_?(z=g||F?(0,$.jsxs)(I,{type:F?`button`:void 0,className:K(`flex min-h-11 w-fit max-w-full min-w-0 items-center gap-2 rounded-lg px-1 py-1.5 text-left text-sm text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),onClick:F?()=>y(e=>!(e??_)):void 0,"aria-expanded":F?b:void 0,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(`span`,{className:`inline-flex max-w-full flex-wrap items-baseline`,children:M})}),(0,$.jsx)(`span`,{className:`flex shrink-0 items-start justify-end`,children:P}),F?(0,$.jsx)(cr,{className:K(`size-4 shrink-0 text-fg-muted transition-transform motion-reduce:transition-none`,b&&`rotate-180`),"aria-hidden":!0}):null]}):null,t[70]=I,t[71]=g,t[72]=b,t[73]=P,t[74]=M,t[75]=F,t[76]=_,t[77]=z):z=t[77];let B;if(t[78]!==o||t[79]!==s||t[80]!==A||t[81]!==r||t[82]!==n.items||t[83]!==c){let e;t[85]!==o||t[86]!==s||t[87]!==A||t[88]!==r||t[89]!==c?(e=e=>(0,$.jsx)(EN,{block:e,toolLabels:r,stepLabels:A,cardLabels:o,conversationId:s,workflowOptions:c,surfaceOnly:!0},e.id),t[85]=o,t[86]=s,t[87]=A,t[88]=r,t[89]=c,t[90]=e):e=t[90],B=n.items.filter(gN).map(e),t[78]=o,t[79]=s,t[80]=A,t[81]=r,t[82]=n.items,t[83]=c,t[84]=B}else B=t[84];let V;t[91]!==o||t[92]!==s||t[93]!==b||t[94]!==A||t[95]!==r||t[96]!==f||t[97]!==c?(V=b?(0,$.jsx)(`div`,{className:`mt-1 w-full min-w-0 pb-1 pl-1`,children:(0,$.jsx)(bN,{blocks:f,toolLabels:r,stepLabels:A,cardLabels:o,conversationId:s,workflowOptions:c,className:`assistant-steps-scroll max-h-[min(60vh,28rem)] overflow-y-auto pr-1 [scrollbar-gutter:stable]`})}):null,t[91]=o,t[92]=s,t[93]=b,t[94]=A,t[95]=r,t[96]=f,t[97]=c,t[98]=V):V=t[98];let H;return t[99]!==R||t[100]!==z||t[101]!==B||t[102]!==V?(H=(0,$.jsxs)(`div`,{className:R,children:[z,B,V]}),t[99]=R,t[100]=z,t[101]=B,t[102]=V,t[103]=H):H=t[103],H}function gN(e){return e.type===`tool_use`}function _N(e){return e.type!==`text`}function vN(e){return e.showRawToolData}function yN(e){return e.language}function bN(e){let t=(0,Q.c)(23),{blocks:n,toolLabels:r,stepLabels:i,cardLabels:a,className:o,conversationId:s,workflowOptions:c}=e,l=(0,Z.useRef)(null),u=n.length>0,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=l.current;if(!e)return;let t=t=>{yj(t,e)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},t[0]=d):d=t[0];let f;if(t[1]===u?f=t[2]:(f=[u],t[1]=u,t[2]=f),(0,Z.useEffect)(d,f),!u)return null;let p;t[3]===o?p=t[4]:(p=K(`min-w-0 overflow-x-hidden`,o),t[3]=o,t[4]=p);let m;if(t[5]!==n||t[6]!==a||t[7]!==s||t[8]!==i||t[9]!==r||t[10]!==c){let e;t[12]!==a||t[13]!==s||t[14]!==i||t[15]!==r||t[16]!==c?(e=(e,t)=>(0,$.jsx)(EN,{block:e,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:s,workflowOptions:c},e.type===`tool_use`?e.id:e.type===`text`?e.segmentId??`narration-${t}`:`thinking-${t}`),t[12]=a,t[13]=s,t[14]=i,t[15]=r,t[16]=c,t[17]=e):e=t[17],m=n.map(e),t[5]=n,t[6]=a,t[7]=s,t[8]=i,t[9]=r,t[10]=c,t[11]=m}else m=t[11];let h;t[18]===m?h=t[19]:(h=(0,$.jsx)(`div`,{className:`min-w-0 space-y-2.5 pl-1`,children:m}),t[18]=m,t[19]=h);let g;return t[20]!==p||t[21]!==h?(g=(0,$.jsx)(`div`,{ref:l,className:p,children:h}),t[20]=p,t[21]=h,t[22]=g):g=t[22],g}function xN(e){let t=(0,Q.c)(15),{toolName:n,toolResult:r}=e,i=ij(),a=hj(n);if(!a||i.length===0)return null;let o;if(t[0]!==i||t[1]!==a.extensionId){let e;t[3]===a.extensionId?e=t[4]:(e=e=>e.id===a.extensionId,t[3]=a.extensionId,t[4]=e),o=i.find(e),t[0]=i,t[1]=a.extensionId,t[2]=o}else o=t[2];let s=o,c=s?.name??a.extensionId,l=a.maxHeight??400,u=a.interactive??!1,d=s?.ui?.permissions,f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d||t[9]!==r||t[10]!==a.entrypoint||t[11]!==a.extensionId||t[12]!==a.id||t[13]!==a.title?(f=(0,$.jsx)(mj,{extensionId:a.extensionId,extensionName:c,widgetId:a.id,entrypoint:a.entrypoint,title:a.title,toolResult:r,maxHeight:l,interactive:u,permissions:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=r,t[10]=a.entrypoint,t[11]=a.extensionId,t[12]=a.id,t[13]=a.title,t[14]=f):f=t[14],f}var SN=new Set([`readFile`,`editFile`,`writeFile`,`runCommand`,`fetchUrl`]),CN=240;function wN(e){let t=e.split(`
60
- `).map(e=>e.trim()).find(Boolean)??``;return t.length<=CN?t:`${t.slice(0,CN)}…`}function TN(e,t,n){let r=Yk(e.result),i=(e.details&&typeof e.details==`object`&&!Array.isArray(e.details)?e.details:null)??r.details;if(i?.timedOut===!0)return n.timedOut;if(typeof i?.exitCode==`number`&&i.exitCode!==0)return n.exitCodeNonZero.replace(/\{\{code\}\}/g,String(i.exitCode));for(let e of[`errorMessage`,`error`,`message`,`reason`]){let t=i?.[e];if(typeof t==`string`&&t.trim())return wN(t)}return wN(r.text)||t}function EN(e){let t=(0,Q.c)(106),{block:n,toolLabels:r,stepLabels:i,cardLabels:a,conversationId:o,workflowOptions:s,surfaceOnly:c}=e,l=c===void 0?!1:c,u=bA(DN),d;bb0:{if(n.type!==`tool_use`){d=``;break bb0}if(n.status===`running`){d=``;break bb0}let e=n.result;if(e==null){d=``;break bb0}if(typeof e==`string`){let n;t[0]===e?n=t[1]:(n=e.trim(),t[0]=e,t[1]=n),d=n;break bb0}try{let n;t[2]===e?n=t[3]:(n=JSON.stringify(e,null,2),t[2]=e,t[3]=n),d=n}catch{d=String(e)}}let f=d,p;bb1:{if(n.type!==`tool_use`||n.status===`running`||n.name!==`browser_use`){p=null;break bb1}let e;t[4]===n.details?e=t[5]:(e=CA(n.details),t[4]=n.details,t[5]=e),p=e}let m=p;if(n.type===`text`){let e;t[6]===n.text?e=t[7]:(e=n.text.trim(),t[6]=n.text,t[7]=e);let r=e;if(!r)return null;let i;return t[8]===r?i=t[9]:(i=(0,$.jsx)(`div`,{className:`min-w-0 text-sm leading-relaxed text-fg-muted`,children:(0,$.jsx)(ie,{content:r,compact:!0})}),t[8]=r,t[9]=i),i}if(n.type===`thinking`){let e=!!n.streaming,r;t[10]===n.text?r=t[11]:(r=n.text?.trim()??``,t[10]=n.text,t[11]=r);let a=r;if(!u||!a)return null;let o=e?i.thoughtsStreaming:i.thoughts,s;t[12]===o?s=t[13]:(s=(0,$.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-sm text-fg-muted [overflow-wrap:anywhere]`,children:o}),t[12]=o,t[13]=s);let c;t[14]!==u||t[15]!==i.rawThinking||t[16]!==e||t[17]!==a?(c=u&&a?(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted`,children:i.rawThinking}),(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere]`,children:a})]}):e?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`…`}):null,t[14]=u,t[15]=i.rawThinking,t[16]=e,t[17]=a,t[18]=c):c=t[18];let l;return t[19]!==s||t[20]!==c?(l=(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[s,c]})}),t[19]=s,t[20]=c,t[21]=l):l=t[21],l}if(xj(n)){if(!l)return null;let e;return t[22]!==n||t[23]!==o||t[24]!==s.labels?(e=(0,$.jsx)(pN,{block:n,startedAt:n.startedAt,conversationId:o,labels:s.labels}),t[22]=n,t[23]=o,t[24]=s.labels,t[25]=e):e=t[25],e}let h=n.status===`running`||n.activity?.status===`running`,g=n.status===`error`||n.activity?.status===`failed`,_;t[26]!==n||t[27]!==a||t[28]!==g||t[29]!==i.toolError?(_=g?TN(n,i.toolError,a):``,t[26]=n,t[27]=a,t[28]=g,t[29]=i.toolError,t[30]=_):_=t[30];let v=_,b=f,x=h&&n.details&&typeof n.details==`object`&&!Array.isArray(n.details)&&typeof n.details.text==`string`?n.details.text:``,S=b??``;if(S)try{let e;t[31]===S?e=t[32]:(e=JSON.stringify(JSON.parse(S),null,2),t[31]=S,t[32]=e),S=e}catch{}let C,w,T,E;if(t[33]!==n||t[34]!==g||t[35]!==h||t[36]!==i.editFile||t[37]!==i.fetchUrl||t[38]!==i.listDirectory||t[39]!==i.memoryActivity||t[40]!==i.openUrl||t[41]!==i.readFile||t[42]!==i.runCommand||t[43]!==i.runningActions||t[44]!==i.searched||t[45]!==i.searchedCode||t[46]!==i.searchedMemory||t[47]!==i.searchedWeb||t[48]!==i.toolActivity||t[49]!==i.toolError||t[50]!==i.unknownTool||t[51]!==i.writeFile){w=Ek(n.name,n.activity),C=SN.has(w),T=w===`memorySearch`?Lk(n,i.memoryActivity):null;let e={searchedWeb:i.searchedWeb,searchedMemory:i.searchedMemory,searchedCode:i.searchedCode,searched:i.searched,readFile:i.readFile,runCommand:i.runCommand,listDirectory:i.listDirectory,writeFile:i.writeFile,editFile:i.editFile,openUrl:i.openUrl,fetchUrl:i.fetchUrl,unknownTool:i.unknownTool},r=w===`other`||kc(n.name);E=g?i.toolError:T?.title??(h&&!r?kk(w,i.runningActions):Wc(n.name,n.input,h?`running`:`completed`,i.toolActivity,e,n.activity)),t[33]=n,t[34]=g,t[35]=h,t[36]=i.editFile,t[37]=i.fetchUrl,t[38]=i.listDirectory,t[39]=i.memoryActivity,t[40]=i.openUrl,t[41]=i.readFile,t[42]=i.runCommand,t[43]=i.runningActions,t[44]=i.searched,t[45]=i.searchedCode,t[46]=i.searchedMemory,t[47]=i.searchedWeb,t[48]=i.toolActivity,t[49]=i.toolError,t[50]=i.unknownTool,t[51]=i.writeFile,t[52]=C,t[53]=w,t[54]=T,t[55]=E}else C=t[52],w=t[53],T=t[54],E=t[55];let D=E,O;t[56]!==n.input||t[57]!==T?(O=T?``:Wk(n.input),t[56]=n.input,t[57]=T,t[58]=O):O=t[58];let k=O,A;t[59]===n.input?A=t[60]:(A=n.input===void 0?``:Rk(n.input),t[59]=n.input,t[60]=A);let j=A,M;t[61]!==n||t[62]!==a||t[63]!==C||t[64]!==w?(M=C?w===`readFile`?(0,$.jsx)(uA,{block:n,labels:a}):w===`editFile`?(0,$.jsx)(pA,{block:n,labels:a}):w===`writeFile`?(0,$.jsx)(hA,{block:n,labels:a}):w===`runCommand`?(0,$.jsx)(vA,{block:n,labels:a}):w===`fetchUrl`?(0,$.jsx)(yA,{block:n,labels:a}):null:null,t[61]=n,t[62]=a,t[63]=C,t[64]=w,t[65]=M):M=t[65];let N=M;if(l){let e;t[66]!==n.name||t[67]!==n.result||t[68]!==g||t[69]!==h?(e=!h&&!g?(0,$.jsx)(xN,{toolName:n.name,toolResult:n.result}):null,t[66]=n.name,t[67]=n.result,t[68]=g,t[69]=h,t[70]=e):e=t[70];let r;t[71]!==m||t[72]!==o||t[73]!==h?(r=!h&&m?(0,$.jsx)(wA,{approval:m,conversationId:o},m.id):null,t[71]=m,t[72]=o,t[73]=h,t[74]=r):r=t[74];let i;return t[75]!==r||t[76]!==e?(i=(0,$.jsxs)($.Fragment,{children:[e,r]}),t[75]=r,t[76]=e,t[77]=i):i=t[77],i}let P=!h&&u,F;t[78]===D?F=t[79]:(F=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1`,children:(0,$.jsx)(`span`,{className:`inline-flex max-w-full min-w-0 break-words text-sm text-fg-muted [overflow-wrap:anywhere]`,children:D})}),t[78]=D,t[79]=F);let I;t[80]!==T||t[81]!==i.memoryActivity?(I=T?(0,$.jsxs)(`div`,{className:`space-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:T.purpose}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[(0,$.jsx)(y,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.manage}),(0,$.jsx)(y,{className:`font-medium text-accent-fg hover:underline`,to:`/user-model`,children:i.memoryActivity.privacy})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle hover:text-fg-muted`,children:i.memoryActivity.why}),(0,$.jsx)(`div`,{className:`mt-1.5 rounded-md bg-surface-hover/60 px-2 py-1.5 dark:bg-surface-hover/35`,children:(0,$.jsx)(`p`,{children:i.memoryActivity.explanation})})]})]}):null,t[80]=T,t[81]=i.memoryActivity,t[82]=I):I=t[82];let L;t[83]===v?L=t[84]:(L=v?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:v}):null,t[83]=v,t[84]=L);let R;t[85]!==k||t[86]!==C?(R=!C&&k?(0,$.jsx)(`p`,{className:`min-w-0 break-words text-xs text-fg-muted [overflow-wrap:anywhere]`,children:k}):null,t[85]=k,t[86]=C,t[87]=R):R=t[87];let z;t[88]===x?z=t[89]:(z=x?(0,$.jsx)(`pre`,{className:`max-h-48 min-w-0 overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg-muted [overflow-wrap:anywhere] dark:bg-surface-hover/35`,children:x}):null,t[88]=x,t[89]=z);let B;t[90]!==a||t[91]!==C||t[92]!==S||t[93]!==j||t[94]!==P||t[95]!==i.stepDetails||t[96]!==r?(B=P?(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-fg-subtle underline-offset-2 hover:text-fg-muted group-open:text-fg-muted`,children:C?a.rawDetails:i.stepDetails}),(0,$.jsxs)(`div`,{className:`mt-2 max-h-48 w-full min-w-0 max-w-full overflow-y-auto overflow-x-hidden rounded-md bg-surface-hover/60 p-2 font-mono dark:bg-surface-hover/35`,children:[j?(0,$.jsxs)(`div`,{className:`mb-2 min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.input}),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:j})]}):null,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-0.5 text-[10px] uppercase tracking-wide text-fg-disabled`,children:r.output}),(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-fg-muted [overflow-wrap:anywhere]`,children:S||r.noOutput})]})]})]}):null,t[90]=a,t[91]=C,t[92]=S,t[93]=j,t[94]=P,t[95]=i.stepDetails,t[96]=r,t[97]=B):B=t[97];let V;return t[98]!==N||t[99]!==I||t[100]!==L||t[101]!==R||t[102]!==z||t[103]!==B||t[104]!==F?(V=(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[F,N,I,L,R,z,B]})}),t[98]=N,t[99]=I,t[100]=L,t[101]=R,t[102]=z,t[103]=B,t[104]=F,t[105]=V):V=t[105],V}function DN(e){return e.showRawToolData}function ON(e){return e+1}function kN(e){return e===`zh`?NN():MN()}function AN(){return{close:`Close`,statusQueued:`Queued`,statusRunning:`Running`,statusDone:`Completed`,statusError:`Failed`,statusSkipped:`Skipped`,workedFor:e=>`Worked for ${e}`,statusHeading:`Status`,phaseHeading:`Phase`,elapsedHeading:`Elapsed`,currentStepHeading:`Current step`,executionHeading:`Execution process`,outputHeading:`Output`,stepsHeading:`Steps`,transcriptHeading:`Transcript`,promptHeading:`Prompt`,logsHeading:`Workflow logs`,runningPlaceholder:`Waiting for check updates…`}}function jN(){return{close:`关闭`,statusQueued:`排队中`,statusRunning:`运行中`,statusDone:`已完成`,statusError:`失败`,statusSkipped:`已跳过`,workedFor:e=>`已运行 ${e}`,statusHeading:`状态`,phaseHeading:`阶段`,elapsedHeading:`耗时`,currentStepHeading:`当前步骤`,executionHeading:`执行过程`,outputHeading:`产出`,stepsHeading:`步骤`,transcriptHeading:`Transcript`,promptHeading:`输入`,logsHeading:`工作流日志`,runningPlaceholder:`等待检查项更新…`}}function MN(){return{header:{collapse:`Collapse`,expand:`Expand`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`failed`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`Check ${e}`,queued:`Queued`,running:`Running…`,openDetail:`View check details`},checkDetail:AN(),result:{topFindingsHeading:e=>`Top findings (${e})`,topRisksHeading:e=>`Top risks (${e})`,openQuestionsHeading:`Open questions`,moreSuffix:e=>`${e} more…`,emptyResult:`(no result)`},error:{titleValidation:`Workflow setup needs attention`,titleAbort:`Workflow aborted`,titleTimeout:`Workflow timed out`,titleRuntime:`Workflow failed`,expand:`Expand details`,collapse:`Collapse details`,expandHint:`Click to see error details`,detailsHeading:`Failure reason`,impactHeading:`Impact`,recoveryHeading:`Recommended actions`,recoveryActions:{validation_error:[`Open the workflow and review the highlighted steps.`,`Reconnect any step that cannot reach the final result.`],aborted:[`The run was stopped. Start it again if you still need the result.`],timeout:[`Retry the workflow.`,`If it times out again, reduce concurrency or check model/API availability.`],runtime_error:[`Review the failed check first.`,`Use completed check results if they are still relevant.`,`Copy the error details if you want to continue diagnosis.`]},logsHeading:`Technical logs`,failedAgentsHeading:`Check status`,executedAgentsHeading:`Check status`,progressHeading:`Execution process`,noExtraDetails:`No additional details recorded.`,copyReason:`Copy`,copyReasonDone:`Copied`,impactTpl:(e,t,n)=>`${e}/${t} checks completed · ${n} need attention`,phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} running`,errorsTag:e=>`· ${e} errors`,skippedTag:e=>`· ${e} skipped`,showPrompt:`Show prompt`,hidePrompt:`Hide prompt`,promptHeading:`Prompt`,resultPreviewHeading:`Result`,errorHeading:`Error`,emptyPreview:`(no preview)`,agentNumber:e=>`Check ${e}`,queued:`Queued`,running:`Running…`,openDetail:`View check details`}},saveAria:`Copy and edit workflow…`,saveTitle:`Open a copied workflow draft in the Workflows center`,copyAria:`Copy result`,copyDoneAria:`Copied`,openInWorkflowsAria:`Open task details`,openInWorkflowsTitle:`Open this task in the task center`,viewSubagentsHeading:`View checks`,runningProgressHeading:`Current progress`,runningAgentsHeading:`Running checks`,completedAgentsHeading:`Completed checks`,queuedAgentsHeading:`Queued checks`,failedAgentsHeading:`Needs attention`,currentProgressTpl:(e,t,n,r)=>`${e?`Step: ${e}`:`Task is running`} · ${t} running · ${n}/${r} completed`,recentLogsHeading:`Recent updates`,showAllLogs:`Show all`,live:{details:`Details`,openRun:`Open run`,stop:`Stop`,close:`Close workflow details`,title:`Task`,overview:`Overview`,agents:`Checks`,logs:`Logs`,result:`Result`,currentState:`Current state`,runId:`Run ID`,elapsed:`Elapsed`,progress:(e,t)=>`${e}/${t} checks`,activeFallback:`Task is running`,noResult:`No result recorded yet.`,status:{queued:`Queued`,running:`Running`,succeeded:`Completed`,failed:`Failed`,cancelled:`Cancelled`,timeout:`Timed out`}}}}function NN(){return{header:{collapse:`收起`,expand:`展开`,runningMeta:(e,t)=>t?`${e} · ${t}`:`${e}`,completedMeta:(e,t)=>t?`✓ ${e} · ${t}`:`✓ ${e}`,failedMeta:`失败`},phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`检查 ${e}`,queued:`排队中`,running:`运行中…`,openDetail:`查看检查项详情`},checkDetail:jN(),result:{topFindingsHeading:e=>`主要发现(${e})`,topRisksHeading:e=>`主要风险(${e})`,openQuestionsHeading:`待解决的问题`,moreSuffix:e=>`还有 ${e} 条…`,emptyResult:`(无结果)`},error:{titleValidation:`工作流配置需要处理`,titleAbort:`工作流已中止`,titleTimeout:`工作流超时`,titleRuntime:`工作流执行失败`,expand:`展开详情`,collapse:`收起详情`,expandHint:`点击查看错误详情`,detailsHeading:`失败原因`,impactHeading:`影响范围`,recoveryHeading:`建议处理`,recoveryActions:{validation_error:[`打开工作流并查看高亮的问题步骤。`,`重新连接无法到达最终结果的步骤。`],aborted:[`本次执行已停止。如仍需要结果,可以重新运行。`],timeout:[`重新运行工作流。`,`如果仍然超时,建议降低并发或检查模型/API 可用性。`],runtime_error:[`优先查看失败检查项。`,`已完成检查项的结果仍可按需参考。`,`需要继续诊断时,可以复制错误详情。`]},logsHeading:`技术日志`,failedAgentsHeading:`检查项状态`,executedAgentsHeading:`检查项状态`,progressHeading:`执行过程`,noExtraDetails:`没有更多诊断信息。`,copyReason:`复制`,copyReasonDone:`已复制`,impactTpl:(e,t,n)=>`已完成 ${e}/${t} 个检查项 · ${n} 个需要关注`,phase:{countTpl:(e,t)=>`${e}/${t}`,runningTag:e=>`· ${e} 运行中`,errorsTag:e=>`· ${e} 失败`,skippedTag:e=>`· ${e} 已跳过`,showPrompt:`查看 prompt`,hidePrompt:`收起 prompt`,promptHeading:`Prompt`,resultPreviewHeading:`结果预览`,errorHeading:`错误`,emptyPreview:`(暂无预览)`,agentNumber:e=>`检查 ${e}`,queued:`排队中`,running:`运行中…`,openDetail:`查看检查项详情`}},saveAria:`复制并编辑工作流…`,saveTitle:`在工作流中心打开复制草案`,copyAria:`复制结果`,copyDoneAria:`已复制`,openInWorkflowsAria:`打开任务详情`,openInWorkflowsTitle:`在任务中心查看此任务`,viewSubagentsHeading:`查看检查项`,runningProgressHeading:`当前进展`,runningAgentsHeading:`正在检查`,completedAgentsHeading:`已完成检查`,queuedAgentsHeading:`等待检查`,failedAgentsHeading:`需要关注`,currentProgressTpl:(e,t,n,r)=>`${e?`正在执行 ${e}`:`任务正在执行`} · ${t} 个运行中 · 已完成 ${n}/${r}`,recentLogsHeading:`最近更新`,showAllLogs:`显示全部`,live:{details:`详情`,openRun:`打开运行`,stop:`停止`,close:`关闭工作流详情`,title:`任务`,overview:`概览`,agents:`检查项`,logs:`日志`,result:`结果`,currentState:`当前状态`,runId:`运行 ID`,elapsed:`耗时`,progress:(e,t)=>`${e}/${t} 个检查项`,activeFallback:`任务正在执行`,noResult:`暂无结果。`,status:{queued:`排队中`,running:`运行中`,succeeded:`已完成`,failed:`失败`,cancelled:`已取消`,timeout:`超时`}}}}var PN=`xopc-attachment`,FN=/^xopc-attachment:\/\/notes\/([^/]+)\/([^/?#]+)$/i,IN=/^\/api\/notes\/([^/]+)\/media\/([^/?#]+)$/i;function LN(e,t){return`${PN}://notes/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function RN(e,t){let n=e.trim();if(!n)return null;let r=n.split(`?`)[0],i=r.match(FN),a=r.match(IN),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 zN(e,t){return`/api/notes/${encodeURIComponent(e)}/media/${encodeURIComponent(t)}`}var BN=new Map,VN=``;function HN(e,t,n){return`${n}:${e}:${t}`}function UN(){let e=Se.getState().conversationId??``;if(e!==VN){for(let e of BN.values())e.objectUrl&&URL.revokeObjectURL(e.objectUrl);BN.clear(),VN=e}}async function WN(e,t){UN();let n=HN(e,t,Se.getState().conversationId??``),r=BN.get(n);return r||(r={blob:(async()=>{let n=await we(J(zN(e,t)));if(n.status===401&&Se.getState().onUnauthorized(),!n.ok)throw Error(`HTTP ${n.status}`);return n.blob()})(),objectUrl:null,refCount:0},BN.set(n,r)),r.blob}async function GN(e,t){UN();let n=HN(e,t,Se.getState().conversationId??``),r=BN.get(n);if(r||(r={blob:WN(e,t),objectUrl:null,refCount:0},BN.set(n,r)),!r.objectUrl){let e=await r.blob;r.objectUrl=URL.createObjectURL(e)}return r.refCount+=1,r.objectUrl}function KN(e,t){UN();let n=HN(e,t,Se.getState().conversationId??``),r=BN.get(n);r&&(r.refCount=Math.max(0,r.refCount-1),r.refCount===0&&r.objectUrl&&(URL.revokeObjectURL(r.objectUrl),r.objectUrl=null,BN.delete(n)))}var qN={noteId:null,attachmentId:null,playing:!1,currentTime:0,duration:0,loading:!1},JN=null,YN=null,XN=null,ZN=null;function QN(){return JN||(JN=new Audio,JN.addEventListener(`timeupdate`,()=>{eP.setState({currentTime:JN.currentTime})}),JN.addEventListener(`loadedmetadata`,()=>{let e=JN.duration;Number.isFinite(e)&&eP.setState({duration:e})}),JN.addEventListener(`ended`,()=>{eP.setState({playing:!1,currentTime:0}),JN.currentTime=0}),JN.addEventListener(`pause`,()=>{eP.setState({playing:!1})}),JN.addEventListener(`play`,()=>{eP.setState({playing:!0})})),JN}function $N(){XN&&ZN&&KN(XN,ZN),YN=null,XN=null,ZN=null}var eP=Oe()((e,t)=>({...qN,play:async(n,r,i)=>{let a=QN(),o=t();if(o.noteId===n&&o.attachmentId===r&&YN){a.play();return}a.pause(),$N(),e({noteId:n,attachmentId:r,playing:!1,currentTime:0,duration:i??0,loading:!0});try{let t=await GN(n,r);YN=t,XN=n,ZN=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}),$N()}},pause:()=>{QN().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=QN();n.currentTime=t,e({currentTime:t})},reset:()=>{QN().pause(),QN().src=``,$N(),e(qN)}})),tP=!1,nP=[`play`,`pause`,`stop`,`seekto`,`seekbackward`,`seekforward`];function rP(){return typeof navigator>`u`?void 0:navigator.mediaSession}function iP(e){let t=rP();if(!t)return;tP=!0;let n={play:e.resume,pause:e.pause,stop:e.stop,seekto:({seekTime:t})=>{t!==void 0&&e.seek(t)},seekbackward:({seekOffset:t})=>e.seek(e.position()-(t??10)),seekforward:({seekOffset:t})=>e.seek(e.position()+(t??10))};for(let e of nP)try{t.setActionHandler(e,n[e])}catch{}}function aP(e){let t=rP();if(!(!tP||!t)){typeof MediaMetadata<`u`&&t.metadata?.title!==e.source?.title&&(t.metadata=e.source?new MediaMetadata({title:e.source.title,artist:`xopc`}):null),t.playbackState=e.status===`playing`?`playing`:`paused`;try{t.setPositionState(e.durationComplete&&e.duration>0?{duration:e.duration,playbackRate:e.rate,position:Math.min(e.duration,Math.max(0,e.currentTime))}:void 0)}catch{}}}function oP(){let e=rP();if(!(!tP||!e)){tP=!1,e.metadata=null,e.playbackState=`none`;for(let t of nP)try{e.setActionHandler(t,null)}catch{}try{e.setPositionState()}catch{}}}var sP=/```[\s\S]*?```|~~~[\s\S]*?~~~/g,cP=/[^。!?!?\.\n]+[。!?!?\.]?|\n+/g;function lP(e){return e.replace(sP,`
61
- `).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/^\s*\d+[.)]\s+/gm,``).replace(/[|`*_~>]/g,` `).replace(/<[^>]+>/g,` `)}function uP(e){if(!e.trim())return``;let t=e.replace(sP,`
62
- `),n;if(typeof DOMParser>`u`)n=lP(t);else{let e=ae.parse(t,{gfm:!0,breaks:!1}),r=new DOMParser().parseFromString(`<main>${e}</main>`,`text/html`);r.querySelectorAll(`pre, script, style`).forEach(e=>e.remove()),r.querySelectorAll(`img`).forEach(e=>e.replaceWith(e.alt||``)),r.querySelectorAll(`br, p, h1, h2, h3, h4, h5, h6, li, tr`).forEach(e=>{e.append(r.createTextNode(`
63
- `))}),n=r.body.textContent??``}return n.replace(/https?:\/\/\S+/gi,``).replace(/[\t ]+/g,` `).replace(/ *\n */g,`
64
- `).replace(/\n{3,}/g,`
65
-
66
- `).trim()}function dP(e,t=420){let n=e.trim();if(!n)return[];let r=Math.max(20,t),i=n.match(cP)??[n],a=[],o=``,s=()=>{let e=o.trim();e&&a.push(e),o=``};for(let e of i){let t=e.trim();if(t){if(t.length>r){s();for(let e=0;e<t.length;e+=r)a.push(t.slice(e,e+r).trim());continue}o&&o.length+t.length>r&&s(),o+=t}}return s(),a}function fP(e,t){let n=(e.match(/[\u3400-\u9fff]/g)??[]).length,r=(e.match(/[A-Za-z]/g)??[]).length;return n===0&&r===0?t===`zh`?`zh-CN`:`en-US`:n*2>=r?`zh-CN`:`en-US`}var pP=`xopc:read-aloud-online-consent:v1`,mP=`read-aloud`,hP={source:null,status:`idle`,currentChunkIndex:0,chunkCount:0,currentTime:0,duration:0,durationComplete:!1,currentText:``,rate:1,error:null,consentRequired:!1},gP=null,_P=null,vP=null,yP=[],bP=[],xP=[],SP=new Map,CP=null,wP=0,TP=0,EP=null,DP=null,OP=!1;function kP(){if(OP)return!0;try{return localStorage.getItem(pP)===`accepted`}catch{return!1}}function AP(){for(let e of bP)e&&URL.revokeObjectURL(e);bP=[],xP=[],SP.clear()}function jP(e){return xP.slice(0,e).reduce((e,t)=>e+(t||0),0)}async function MP(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:t.error?.message||`Speech request failed (${e.status})`}async function NP(e,t){let n=bP[e];if(n)return n;let r=SP.get(e);if(r)return r;let i=_P;if(!i||!yP[e])throw Error(`Speech chunk is unavailable`);let a=(async()=>{let n=await we(J(`/api/voice/speech`),{method:`POST`,signal:CP?.signal,body:JSON.stringify({text:yP[e],language:i.language})});if(!n.ok)throw Error(await MP(n));let r=await n.blob();if(!r.size)throw Error(`Speech service returned empty audio`);if(t!==wP)throw new DOMException(`Stale speech request`,`AbortError`);let a=URL.createObjectURL(r);return bP[e]=a,a})();SP.set(e,a);try{return await a}finally{SP.get(e)===a&&SP.delete(e)}}async function PP(e,t=0,n=!0){let r=wP,i=++TP,a=FP();RP.setState({status:`preparing`,currentChunkIndex:e,currentText:yP[e]??``,currentTime:jP(e)+t,error:null}),a.pause();try{let o=await NP(e,r);if(r!==wP||i!==TP||(EP!==e||a.getAttribute(`src`)!==o?(EP=e,DP=t,a.src=o):a.readyState===0?DP=t:(DP=null,a.currentTime=t),a.playbackRate=RP.getState().rate,n&&await a.play(),r!==wP||i!==TP))return;RP.setState({status:n?`playing`:`paused`}),n&&(eP.getState().pause(),window.dispatchEvent(new CustomEvent(`xopc-voice-playback-start`,{detail:{id:mP}})),iP({...RP.getState(),position:()=>RP.getState().currentTime}),aP(RP.getState())),e+1<yP.length&&NP(e+1,r).catch(()=>void 0)}catch(e){if(r!==wP||i!==TP||e instanceof DOMException&&e.name===`AbortError`)return;RP.setState({status:`error`,error:e instanceof Error?e.message:String(e)})}}function FP(){return gP||(gP=new Audio,gP.preload=`metadata`,gP.addEventListener(`loadedmetadata`,()=>{!gP||EP===null||!_P||(Number.isFinite(gP.duration)&&gP.duration>0&&(xP[EP]=gP.duration),DP!==null&&(gP.currentTime=DP,DP=null),RP.setState({duration:xP.reduce((e,t)=>e+t,0),durationComplete:xP.length>0&&xP.every(e=>e>0)}))}),gP.addEventListener(`timeupdate`,()=>{if(!gP||EP===null||DP!==null)return;let e=RP.getState();e.status!==`playing`&&e.status!==`paused`||RP.setState({currentTime:jP(EP)+gP.currentTime})}),gP.addEventListener(`pause`,()=>{RP.getState().status===`playing`&&RP.setState({status:`paused`})}),gP.addEventListener(`ended`,()=>{let e=RP.getState().status;if(!_P||e!==`playing`&&e!==`paused`)return;let t=RP.getState().currentChunkIndex+1;t<yP.length?PP(t):RP.setState({status:`ended`,currentTime:RP.getState().duration})}),gP.addEventListener(`error`,()=>{if(RP.getState().status!==`idle`){if(EP!==null){let e=bP[EP];e&&URL.revokeObjectURL(e),bP[EP]=null,xP[EP]=0,EP=null}TP+=1,RP.setState({status:`error`,error:`Audio playback failed`,durationComplete:!1})}}),window.addEventListener(`xopc-voice-recording-start`,()=>RP.getState().pause()),window.addEventListener(`xopc-voice-playback-start`,e=>{let t=e.detail?.id;t&&t!==mP&&(oP(),RP.getState().pause())}),gP)}function IP(){oP(),wP+=1,TP+=1,EP=null,DP=null,RP.setState({...hP,rate:RP.getState().rate}),CP?.abort(),CP=null,gP&&(gP.pause(),gP.removeAttribute(`src`),gP.load()),AP(),yP=[],_P=null}function LP(e){IP();let t=dP(e.text);if(!t.length){RP.setState({source:e.source,status:`error`,error:`There is no readable text`});return}_P=e,yP=t,bP=Array.from({length:yP.length},()=>null),xP=Array.from({length:yP.length},()=>0),CP=new AbortController,eP.getState().pause(),RP.setState({source:e.source,status:`preparing`,currentChunkIndex:0,chunkCount:yP.length,currentTime:0,duration:0,error:null,consentRequired:!1}),PP(0)}var RP=Oe()((e,t)=>({...hP,requestStart:n=>{let r=t(),i=r.source?.type===n.source.type&&r.source.id===n.source.id;if(i&&(r.status===`playing`||r.status===`preparing`)&&_P?.text===n.text){t().pause();return}if(i&&(r.status===`paused`||r.status===`ended`||r.status===`error`)&&_P?.text===n.text){t().resume();return}if(!kP()){vP=n,e({consentRequired:!0});return}LP(n)},acceptConsent:()=>{OP=!0;try{localStorage.setItem(pP,`accepted`)}catch{}let t=vP;vP=null,e({consentRequired:!1}),t&&LP(t)},declineConsent:()=>{vP=null,e({consentRequired:!1})},pause:()=>{let n=t();n.status!==`playing`&&n.status!==`preparing`||(TP+=1,gP?.pause(),e({status:`paused`}))},resume:()=>{let e=t();if(!e.source||!_P||e.status===`preparing`||e.status===`playing`)return;let n=e.status===`ended`?0:e.currentChunkIndex;PP(n,e.status===`ended`?0:Math.max(0,e.currentTime-jP(n)))},seek:n=>{let r=t();if(!r.durationComplete||!Number.isFinite(n)||!_P)return;let i=Math.max(0,Math.min(n,r.duration));if(i===r.duration){TP+=1,gP?.pause(),e({status:`ended`,currentTime:i});return}let a=0,o=i;for(;a<xP.length-1&&o>=xP[a];)o-=xP[a],a+=1;PP(a,o,r.status===`playing`)},stop:IP,setRate:t=>{let n=[.75,1,1.25,1.5,2].includes(t)?t:1;gP&&(gP.playbackRate=n),e({rate:n})}}));RP.subscribe(aP);function zP(e){let t=(0,Q.c)(25),{input:n,labels:r,className:i,showLabel:a,disabled:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l;t[0]===n?l=t[1]:(l=typeof n==`function`?n():n,t[0]=n,t[1]=l);let u=l,d=RP(HP),f=RP(VP),p=RP(BP),m=d?.type===u.source.type&&d.id===u.source.id,h=m?f:`idle`,g=h===`preparing`?r.preparing:h===`playing`?r.pause:h===`paused`?r.resume:h===`error`?r.retry:r.read,_;t[2]!==n||t[3]!==p?(_=()=>p(typeof n==`function`?n():n),t[2]=n,t[3]=p,t[4]=_):_=t[4];let v;t[5]!==c||t[6]!==u.text?(v=c||!u.text.trim(),t[5]=c,t[6]=u.text,t[7]=v):v=t[7];let y=m&&(h===`playing`||h===`paused`),b=s?`min-h-11 gap-1.5 px-2.5 text-sm font-medium sm:min-h-8 sm:text-xs`:`size-11 sm:size-9`,x=m&&`bg-surface-active text-accent`,S;t[8]!==i||t[9]!==b||t[10]!==x?(S=K(`inline-flex shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,b,x,i),t[8]=i,t[9]=b,t[10]=x,t[11]=S):S=t[11];let C;t[12]===h?C=t[13]:(C=h===`preparing`?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):h===`playing`?(0,$.jsx)(Ai,{className:`size-4`,"aria-hidden":!0}):h===`paused`?(0,$.jsx)(Li,{className:`size-4`,"aria-hidden":!0}):h===`error`?(0,$.jsx)(Hi,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(_a,{className:`size-4`,"aria-hidden":!0}),t[12]=h,t[13]=C);let w;t[14]!==g||t[15]!==s?(w=s?(0,$.jsx)(`span`,{children:g}):null,t[14]=g,t[15]=s,t[16]=w):w=t[16];let T;return t[17]!==g||t[18]!==C||t[19]!==w||t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==S?(T=(0,$.jsxs)(`button`,{type:`button`,onClick:_,disabled:v,title:g,"aria-label":g,"aria-pressed":y,className:S,children:[C,w]}),t[17]=g,t[18]=C,t[19]=w,t[20]=_,t[21]=v,t[22]=y,t[23]=S,t[24]=T):T=t[24],T}function BP(e){return e.requestStart}function VP(e){return e.status}function HP(e){return e.source}function UP(e,t){let n=e.filter(e=>e.type===`tool_use`),r=n.map(e=>e.startedAt).filter(e=>Number.isFinite(e)),i=n.map(e=>e.completedAt).filter(e=>Number.isFinite(e)),a=r.length>0?Math.min(...r):void 0,o=[...i,...Number.isFinite(t)?[t]:[]],s=o.length>0?Math.max(...o):void 0;return{startedAt:a,completedAt:s,durationMs:a!=null&&s!=null?Math.max(0,s-a):void 0}}function WP(e){return e.filter(e=>e.type===`thinking`||e.type===`tool_use`)}function GP(e){return e.some(e=>e.type===`text`&&e.presentation!==`pending`&&e.presentation!==`narration`&&!!e.text?.trim())}function KP(e){let t=Ut(e,`running`);return t.category===`web`&&t.action===`search`}function qP(e){let t=[];for(let n of e)if(!(!KP(n.name)||n.result==null))try{let e=typeof n.result==`string`?JSON.parse(n.result):n.result,r=Array.isArray(e)?e:e?.results??[];for(let e of r)e.url&&t.push({url:e.url,title:e.title??e.url,snippet:e.snippet})}catch{}return t}function JP(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function YP(e){let t=JP(e);return t?Mt(t.delivery)??Mt(JP(t.details)?.delivery)??Mt(e):null}function XP(e){let t=YP(e.details);if(t)return t;let n=Yk(e.result),r=YP(n.details);if(r)return r;let i=kt(n.text);if(i)return i;if(typeof e.result==`string`)try{return YP(JSON.parse(e.result))}catch{return null}return YP(e.result)}function ZP(e){return e.operation===`opened`?e.presentation?.kind===`diff`||e.presentation?.kind===`inline_app`||e.presentation?.kind===`inline_preview`:!0}function QP(e){return e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`diff`?[{key:e,presentation:t.presentation}]:[])}function $P(e){return{truncated:e.flatMap(({delivery:e})=>e.presentation?.kind===`table`?[e.presentation]:[]).some(e=>e.truncated)}}function eF(e){let t=e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`inline_app`?[{key:e,delivery:t,presentation:t.presentation}]:[]);return[...new Map(t.map(e=>[`${e.presentation.reference.id}:${e.presentation.snapshot.sourceHash}`,e])).values()]}function tF(e){let t=e.flatMap(({key:e,delivery:t})=>t.presentation?.kind===`inline_preview`?[{key:e,delivery:t,presentation:t.presentation}]:[]);return[...new Map(t.map(e=>[`${e.presentation.reference.id}:${e.presentation.sourceHash}`,e])).values()]}function nF(e,t){let n=e.flatMap(({key:e,delivery:n})=>(n.presentation?.kind===`table`?n.presentation.items:n.presentation?[]:[n.primary,...n.related??[]]).flatMap((r,i)=>{if(!r)return[];let a=`${r.kind}:${r.id}`;return t?.has(a)?[]:[{key:`${e}:${i}:${a}`,delivery:n,reference:r}]}));return[...new Map(n.map(e=>[`${e.reference.kind}:${e.reference.id}`,e])).values()]}function rF(e){return ZP(e)?e.presentation||e.related?.length?!0:e.primary?e.primary.kind!==`note`||e.operation===`created`||e.operation===`updated`:!1:!1}function iF({message:e,isStreaming:t,reasoningLevel:n}){let r=(e.content??[]).filter(e=>e.type===`review`||e.type===`text`&&e.presentation!==`pending`&&e.presentation!==`narration`),i=jk(WP(e.content??[])),a=(e.content??[]).filter(e=>e.type===`tool_use`?!0:n===`off`?!1:e.type===`thinking`?!!e.text?.trim()||!!e.streaming:e.type===`text`&&(e.presentation===`pending`||e.presentation===`narration`)&&!!e.text?.trim()),o=GP(r),s=i.filter(e=>e.type===`tool_use`),c=[...s].reverse().find(e=>e.status===`running`||e.activity?.status===`running`),l=new Map;for(let e of s){let t=XP(e);t&&rF(t)&&l.set(e.id,t)}let u=[...l].map(([e,t])=>({key:e,delivery:t})),d=UP(i,t?void 0:e.completedAt??e.timestamp),f=[e.timestamp,d.startedAt].filter(e=>Number.isFinite(e)),p=f.length>0?Math.min(...f):void 0,m=p!=null&&d.completedAt!=null?Math.max(0,d.completedAt-p):void 0,h=t?`running`:e.outcome?.status===`failed`?`failed`:e.outcome?.status===`partial`?`partial`:`completed`,g=(e.content??[]).filter(e=>e.type===`image`&&!!e.source?.data),_=new Set(e.outcome?.deliverables.map(e=>e.artifactId)),v=new Set(e.outcome?.deliverables.flatMap(e=>e.uri?[e.uri]:[])),y=[...gO(g),...e.attachments??[]].filter(e=>!(e.id&&_.has(e.id)||e.uri&&v.has(e.uri))),b;return b=t?c?`using_tool`:i.some(e=>e.type===`thinking`&&!!e.streaming)?`reasoning`:o?`answering`:`starting`:e.outcome?.status===`partial`||e.outcome?.status===`failed`?`partial`:`completed`,{answerContent:r,workLog:{items:a,active:t&&a.length>0,status:h,compact:n===`off`,expandedByDefault:n===`stream`&&t&&!o,startedAt:p,durationMs:m},answer:{started:o,showStreamingCursor:t&&(a.length===0||b===`answering`)},lifecycle:{state:b,activeTool:b===`using_tool`?c:void 0},outcome:e.outcome,deliveries:u,attachments:y,sources:qP(s)}}function aF(e){let t=(0,Q.c)(10),{blocks:n,sources:r,className:i}=e,a=n===void 0?[]:n,o=i===void 0?`mt-6`:i,s=xe(Ee(cF)),c=a.filter(sF),l=r??qP(c);if(l.length===0)return null;let u=s.chat.searchSourcesHeading.replace(`{{count}}`,String(l.length)),d;t[0]===u?d=t[1]:(d=(0,$.jsx)(`p`,{className:`mb-3 text-xs font-medium text-fg-muted`,children:u}),t[0]=u,t[1]=d);let f;t[2]===l?f=t[3]:(f=l.map(oF),t[2]=l,t[3]=f);let p;t[4]===f?p=t[5]:(p=(0,$.jsx)(`ol`,{className:`space-y-3`,children:f}),t[4]=f,t[5]=p);let m;return t[6]!==o||t[7]!==d||t[8]!==p?(m=(0,$.jsxs)(`div`,{className:o,children:[d,p]}),t[6]=o,t[7]=d,t[8]=p,t[9]=m):m=t[9],m}function oF(e,t){let n=(()=>{try{return new URL(e.url).hostname}catch{return``}})(),r=n?`https://www.google.com/s2/favicons?domain=${n}&sz=16`:void 0;return(0,$.jsxs)(`li`,{className:`flex min-w-0 gap-2.5`,children:[(0,$.jsxs)(`span`,{className:`mt-0.5 shrink-0 text-xs text-fg-disabled`,children:[t+1,`.`]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-1.5`,children:[r?(0,$.jsx)(`img`,{src:r,alt:``,className:`mt-0.5 size-3.5 shrink-0 rounded-sm`,"aria-hidden":!0}):null,(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`min-w-0 flex-1 break-words text-xs font-medium text-accent-fg [overflow-wrap:anywhere] hover:underline`,children:e.title})]}),e.snippet?(0,$.jsx)(`p`,{className:`mt-0.5 line-clamp-4 text-xs break-words text-fg-muted [overflow-wrap:anywhere]`,children:e.snippet}):null]})]},e.url)}function sF(e){return e.type===`tool_use`}function cF(e){return e.language}var lF={task:sa,project:Ur,note:xi,workflow_definition:xa,workflow_run:Li,automation:tr,scene:mr,local_app:Gn,chat_preview:ii,file:zr,session:di,settings:Ji},uF={task:{en:`Task`,zh:`任务`},project:{en:`Project`,zh:`项目`},note:{en:`Note`,zh:`笔记`},workflow_definition:{en:`Workflow`,zh:`工作流`},workflow_run:{en:`Workflow run`,zh:`工作流运行`},automation:{en:`Automation`,zh:`自动化`},scene:{en:`Scene`,zh:`场景`},local_app:{en:`Local app`,zh:`本地应用`},chat_preview:{en:`Chat preview`,zh:`对话预览`},file:{en:`File`,zh:`文件`},session:{en:`Conversation`,zh:`对话`},settings:{en:`Settings`,zh:`设置`}},dF={created:{en:`Created`,zh:`已创建`},updated:{en:`Updated`,zh:`已更新`},opened:{en:`Ready`,zh:`已就绪`},started:{en:`Started`,zh:`已启动`},completed:{en:`Completed`,zh:`已完成`},failed:{en:`Failed`,zh:`失败`}},fF={active:{en:`Active`,zh:`运行中`},completed:{en:`Completed`,zh:`已完成`},disabled:{en:`Disabled`,zh:`已停用`},enabled:{en:`Enabled`,zh:`已启用`},failed:{en:`Failed`,zh:`失败`},inbox:{en:`Inbox`,zh:`收件箱`},paused:{en:`Paused`,zh:`已暂停`},ready:{en:`Ready`,zh:`已就绪`},running:{en:`Running`,zh:`运行中`}};function pF(e,t){let n=e?.trim();return n?fF[n.toLowerCase()]?.[t]??n:null}function mF(e,t,n){let r=uF[t.kind][n],i=dF[e.operation][n],a=pF(t.status,n);return`${r} · ${a&&e.operation===`opened`?a:a&&a.toLowerCase()!==i.toLowerCase()?`${i} · ${a}`:a??i}`}function hF(e,t){return t===`zh`?`继续处理${uF[e.kind].zh}「${e.title}」(ID: ${e.id}):`:`Continue working on ${uF[e.kind].en.toLowerCase()} "${e.title}" (ID: ${e.id}): `}function gF(e){let t=(0,Q.c)(55),{delivery:n,reference:r,language:i}=e,a=l(),o=b(),s=lF[r.kind],c;t[0]===r?c=t[1]:(c=Ot(r),t[0]=r,t[1]=c);let u=c,d;t[2]!==r.capabilities||t[3]!==u?(d=u&&r.capabilities.includes(`open`),t[2]=r.capabilities,t[3]=u,t[4]=d):d=t[4];let f=!!d,p;t[5]!==r.capabilities||t[6]!==r.kind?(p=r.kind!==`note`&&r.capabilities.includes(`continue_in_chat`),t[5]=r.capabilities,t[6]=r.kind,t[7]=p):p=t[7];let m=p,h=n.operation===`failed`,g;t[8]!==n||t[9]!==i||t[10]!==r?(g=mF(n,r,i),t[8]=n,t[9]=i,t[10]=r,t[11]=g):g=t[11];let _;t[12]===r.summary?_=t[13]:(_=r.summary?.trim(),t[12]=r.summary,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=[g,_].filter(Boolean),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y=v.join(` · `),x;t[17]!==o||t[18]!==a||t[19]!==u?(x=()=>{u&&a(te(u,`${o.pathname}${o.search}`))},t[17]=o,t[18]=a,t[19]=u,t[20]=x):x=t[20];let S=x,C=r.kind,w=f?S:void 0,T=!f,E=f&&`cursor-pointer hover:bg-surface-hover/65 active:bg-surface-active/70`,D=!f&&`cursor-default`,O;t[21]!==E||t[22]!==D?(O=K(`flex min-h-14 min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left`,E,yc.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,D),t[21]=E,t[22]=D,t[23]=O):O=t[23];let k=h?`bg-danger-soft text-danger`:`bg-accent-soft/70 text-accent-fg`,A;t[24]===k?A=t[25]:(A=K(`flex size-8 shrink-0 items-center justify-center rounded-lg`,k),t[24]=k,t[25]=A);let j;t[26]===s?j=t[27]:(j=(0,$.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[26]=s,t[27]=j);let M;t[28]!==A||t[29]!==j?(M=(0,$.jsx)(`span`,{className:A,"aria-hidden":!0,children:j}),t[28]=A,t[29]=j,t[30]=M):M=t[30];let N;t[31]===r.title?N=t[32]:(N=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,title:r.title,children:r.title}),t[31]=r.title,t[32]=N);let P;t[33]===y?P=t[34]:(P=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-5 text-fg-muted`,title:y,children:y}),t[33]=y,t[34]=P);let F;t[35]!==N||t[36]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[N,P]}),t[35]=N,t[36]=P,t[37]=F):F=t[37];let I;t[38]===f?I=t[39]:(I=f?(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,t[38]=f,t[39]=I);let L;t[40]!==T||t[41]!==O||t[42]!==M||t[43]!==F||t[44]!==I||t[45]!==w?(L=(0,$.jsxs)(`button`,{type:`button`,onClick:w,disabled:T,className:O,children:[M,F,I]}),t[40]=T,t[41]=O,t[42]=M,t[43]=F,t[44]=I,t[45]=w,t[46]=L):L=t[46];let R;t[47]!==m||t[48]!==i||t[49]!==r?(R=m?(0,$.jsx)(`button`,{type:`button`,className:K(`m-2 inline-flex min-h-11 shrink-0 cursor-pointer items-center rounded-lg px-2.5 text-xs font-medium text-accent-fg`,`hover:bg-accent-soft active:bg-accent-soft/70`,yc.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),onClick:()=>NT(hF(r,i)),children:i===`zh`?`继续`:`Continue`}):null,t[47]=m,t[48]=i,t[49]=r,t[50]=R):R=t[50];let z;return t[51]!==r.kind||t[52]!==L||t[53]!==R?(z=(0,$.jsxs)(`li`,{className:`flex min-w-0 items-stretch`,"data-product-delivery":C,children:[L,R]}),t[51]=r.kind,t[52]=L,t[53]=R,t[54]=z):z=t[54],z}function _F(e){let t=(0,Q.c)(20),{entries:n,language:r}=e,i;t[0]!==n.length||t[1]!==r?(i=xe(r).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=r,t[2]=i):i=t[2];let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=K(`flex min-h-14 cursor-pointer list-none items-center gap-3 px-3 py-2 text-left`,`hover:bg-surface-hover/65 active:bg-surface-active/70`,yc.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),t[3]=o):o=t[3];let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft/70 text-accent-fg`,"aria-hidden":!0,children:(0,$.jsx)(Vr,{className:`size-4`,strokeWidth:1.75})}),t[4]=s):s=t[4];let c;t[5]===a?c=t[6]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-medium text-fg`,children:a}),t[5]=a,t[6]=c);let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle transition-transform duration-150 ease-out group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=(0,$.jsxs)(`summary`,{className:o,children:[s,c,l]}),t[8]=c,t[9]=u);let d;if(t[10]!==n||t[11]!==r){let e;t[13]===r?e=t[14]:(e=e=>{let{key:t,delivery:n,reference:i}=e;return(0,$.jsx)(gF,{delivery:n,reference:i,language:r},t)},t[13]=r,t[14]=e),d=n.map(e),t[10]=n,t[11]=r,t[12]=d}else d=t[12];let f;t[15]===d?f=t[16]:(f=(0,$.jsx)(`ul`,{className:`m-0 list-none divide-y divide-edge-subtle border-t border-edge-subtle p-0`,children:d}),t[15]=d,t[16]=f);let p;return t[17]!==u||t[18]!==f?(p=(0,$.jsx)(`li`,{"data-product-file-group":!0,children:(0,$.jsxs)(`details`,{className:`group`,children:[u,f]})}),t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function vF(e){let t=(0,Q.c)(7),{deliveries:n,language:r,excludedReferenceKeys:i}=e,a,o;if(t[0]!==n||t[1]!==i||t[2]!==r){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=nF(n,i),t=e.filter(bF),s=e.findIndex(yF);if(e.length===0){o=null;break bb0}a=e.map((e,n)=>{let{key:i,delivery:a,reference:o}=e;return o.kind!==`file`||t.length===1?(0,$.jsx)(gF,{delivery:a,reference:o,language:r},i):n===s?(0,$.jsx)(_F,{entries:t,language:r},`file-delivery-group`):null})}t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o}else a=t[3],o=t[4];if(o!==Symbol.for(`react.early_return_sentinel`))return o;let s;return t[5]===a?s=t[6]:(s=(0,$.jsx)($.Fragment,{children:a}),t[5]=a,t[6]=s),s}function yF(e){let{reference:t}=e;return t.kind===`file`}function bF(e){let{reference:t}=e;return t.kind===`file`}function xF(e){let t=(0,Q.c)(20),{presentation:n}=e,r=Ee(SF)===`zh`,i=r?`编辑预览`:`Edit preview`,a=r?`建议修改(尚未应用)`:`Proposed changes (not applied)`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s;t[2]===n.title?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.title}),t[2]=n.title,t[3]=s);let c;if(t[4]!==n.edits||t[5]!==r){let e;t[7]===r?e=t[8]:(e=(e,t)=>(0,$.jsxs)(`details`,{className:`rounded border border-edge-subtle p-2`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer rounded text-xs text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r?`替换范围`:`Replace range`,` `,e.from,`–`,e.to]}),(0,$.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] font-mono text-xs text-fg`,children:e.text})]},t),t[7]=r,t[8]=e),c=n.edits.map(e),t[4]=n.edits,t[5]=r,t[6]=c}else c=t[6];let l;t[9]===c?l=t[10]:(l=(0,$.jsx)(`div`,{className:`mt-2 max-h-80 space-y-2 overflow-y-auto`,children:c}),t[9]=c,t[10]=l);let u;t[11]!==n.truncated||t[12]!==r?(u=n.truncated?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:r?`仅显示部分内容,请查看完整工具结果。`:`Partial content shown. Inspect the full tool result.`}):null,t[11]=n.truncated,t[12]=r,t[13]=u):u=t[13];let d;return t[14]!==i||t[15]!==o||t[16]!==s||t[17]!==l||t[18]!==u?(d=(0,$.jsxs)(`section`,{className:`mt-2 rounded-lg border border-edge bg-surface-panel p-3`,"aria-label":i,children:[o,s,l,u]}),t[14]=i,t[15]=o,t[16]=s,t[17]=l,t[18]=u,t[19]=d):d=t[19],d}function SF(e){return e.language}var CF=2,wF=(0,Z.createContext)(null);function TF(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function EF(e){let t=(0,Q.c)(14),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=(0,Z.useRef)(r),a=(0,Z.useRef)(0),o=(0,Z.useRef)(null),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=new Set,t[1]=s):s=t[1];let[c,l]=(0,Z.useState)(s),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Set,t[2]=u):u=t[2];let[d,f]=(0,Z.useState)(u),p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{if(document.visibilityState===`hidden`){l(jF);return}let e=[...i.current.entries()].filter(AF).sort(kF),t=new Set(e.slice(0,CF).map(OF)),n=new Set(e.map(DF));l(e=>TF(e,t)?e:t),f(e=>TF(e,n)?e:n)},t[3]=p):p=t[3];let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{let n=i.current.get(e);if(n&&o.current?.unobserve(n.element),!t){i.current.delete(e),m();return}i.current.set(e,{element:t,near:!1,visible:!1,manualPriority:n?.manualPriority??0,distance:1/0}),o.current?.observe(t)},t[4]=h):h=t[4];let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=e=>{let t=i.current.get(e);t&&(a.current+=1,t.manualPriority=a.current,t.near=!0,t.visible=!0,t.distance=0,m())},t[5]=_):_=t[5];let v=_,y,b;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{if(typeof IntersectionObserver>`u`)return;o.current=new IntersectionObserver(e=>{for(let t of e){let e=[...i.current.values()].find(e=>e.element===t.target);if(!e)continue;let n=t.boundingClientRect;e.near=t.isIntersecting,e.visible=t.isIntersecting&&n.bottom>0&&n.top<window.innerHeight,e.distance=Math.abs((n.top+n.bottom)/2-window.innerHeight/2),e.near||(e.manualPriority=0)}m()},{rootMargin:`480px 0px`,threshold:0});for(let e of i.current.values())o.current.observe(e.element);let e=()=>m();return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),o.current?.disconnect(),o.current=null}},b=[m],t[6]=y,t[7]=b):(y=t[6],b=t[7]),(0,Z.useEffect)(y,b);let x;t[8]!==c||t[9]!==d?(x={activeIds:c,nearIds:d,register:g,activate:v},t[8]=c,t[9]=d,t[10]=x):x=t[10];let S=x,C;return t[11]!==n||t[12]!==S?(C=(0,$.jsx)(wF.Provider,{value:S,children:n}),t[11]=n,t[12]=S,t[13]=C):C=t[13],C}function DF(e){let[t]=e;return t}function OF(e){let[t]=e;return t}function kF(e,t){let[,n]=e,[,r]=t;return r.manualPriority-n.manualPriority||Number(r.visible)-Number(n.visible)||n.distance-r.distance}function AF(e){let[,t]=e;return t.near||t.manualPriority>0}function jF(e){return e.size?new Set:e}function MF(e){let t=(0,Q.c)(16),n=(0,Z.useContext)(wF),r=n?.register,i=n?.activate,a;t[0]!==e||t[1]!==r?(a=t=>r?.(e,t),t[0]=e,t[1]=r,t[2]=a):a=t[2];let o=a;if(!n){let e;return t[3]===o?e=t[4]:(e={active:!0,state:`active`,containerRef:o,activate:NF},t[3]=o,t[4]=e),e}let s;t[5]!==e||t[6]!==n.activeIds?(s=n.activeIds.has(e),t[5]=e,t[6]=n.activeIds,t[7]=s):s=t[7];let c=s,l=c?`active`:n.nearIds.has(e)?`queued`:`dormant`,u;t[8]!==e||t[9]!==i?(u=()=>i?.(e),t[8]=e,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==o||t[13]!==l||t[14]!==u?(d={active:c,state:l,containerRef:o,activate:u},t[11]=c,t[12]=o,t[13]=l,t[14]=u,t[15]=d):d=t[15],d}function NF(){}async function PF(){return(await q(J(`/api/local-apps`))).apps}async function FF(e){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}`))).app}async function IF(e){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/validate`),{method:`POST`})).validation}async function LF(e,t){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/snapshots/${encodeURIComponent(t)}`))).snapshot}async function RF(e,t){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function zF(e,t,n){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/acceptance-runs`),{method:`POST`,body:JSON.stringify({sourceHash:t,...n})})).acceptance}async function BF(e){return(await q(J(`/api/local-apps`),{method:`POST`,body:JSON.stringify(e)})).app}async function VF(e){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/install`),{method:`POST`})).app}async function HF(e,t){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/releases/${encodeURIComponent(t)}/rollback`),{method:`POST`})).app}async function UF(e,t){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/${t?`enable`:`disable`}`),{method:`POST`})).app}async function WF(e){return(await q(J(`/api/local-apps/${encodeURIComponent(e)}/install`),{method:`DELETE`})).app}var GF=Object.freeze({source:`xopc-local-app-host`,version:1,type:`connect`});function KF(e,t){let n=null,r=()=>{n?.close();let r=new MessageChannel;n=r.port1,n.onmessage=e=>t(e.data),n.start(),e.contentWindow?.postMessage(GF,`*`,[r.port2])};return e.addEventListener(`load`,r),r(),()=>{e.removeEventListener(`load`,r),n?.close()}}function qF(e){return e?.checks.filter(e=>e.status===`failed`).map(e=>e.message)??[]}function JF(e){let t=e.filename?` (${e.filename}${e.line?`:${e.line}${e.column?`:${e.column}`:``}`:``})`:``;return`${e.message}${t}`}function YF({previewId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=l(),o=b(),s=(0,Z.useRef)(null),[c,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)(`booting`),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)([]),[_,v]=(0,Z.useState)(!1),[y,x]=(0,Z.useState)(null),S=Math.min(720,Math.max(240,r)),C=MF(e),w=Zt(C.active?[`inline-local-app-snapshot`,t.id,n]:null,()=>LF(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1});(0,Z.useEffect)(()=>{let e=s.current;if(!e||!w.data?.previewUrl)return;f(`booting`),m(null),g([]);let t=window.setTimeout(()=>{f(e=>e===`booting`?`timeout`:e)},7e3),n=KF(e,e=>{let t=Nt(e);if(t){if(t.type===`ready`){f(`healthy`);return}if(t.type===`error`){m(t.detail),f(`failed`),g(e=>[...e,{phase:`runtime`,message:JF(t.detail),code:t.detail.kind}].slice(-20));return}if(t.type===`acceptance`&&t.detail.status===`failed`){f(`failed`),g(e=>[...e,...t.detail.checks.filter(e=>e.status===`failed`).map(e=>({phase:`acceptance`,code:e.id,message:e.message}))].slice(-20));return}t.type===`criteria`&&t.detail.status===`failed`&&(f(`failed`),g(e=>[...e,...t.detail.scenarios.filter(e=>e.status===`failed`).map(e=>({phase:e.failureKind===`runner`?`runner`:`acceptance`,code:e.id,message:`${e.name}: ${e.message}`}))].slice(-20)))}});return()=>{window.clearTimeout(t),n()}},[c,w.data?.previewUrl]);let T=()=>{let e=Ot(t);e&&a(te(e,`${o.pathname}${o.search}`))};if(!C.active)return(0,$.jsxs)(`section`,{ref:C.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:C.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`min-h-9 px-2.5 text-xs`,onClick:T,children:[(0,$.jsx)(I,{className:`size-4`}),i===`zh`?`打开`:`Open`]})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:S},children:(0,$.jsx)(X,{variant:`secondary`,onClick:C.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(w.isLoading)return(0,$.jsxs)(`section`,{ref:C.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"aria-label":`Loading app preview`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(xn,{className:`h-5 w-40`}),(0,$.jsx)(xn,{className:`h-9 w-24`})]}),(0,$.jsx)(xn,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:S}})]});let E=w.data;if(!E){let e=w.error,t=e instanceof Error?e.message:i===`zh`?`无法加载应用预览`:`Unable to load app preview`;return(0,$.jsx)(`section`,{ref:C.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ma,{className:`size-4`}),t]})})}let D=E.validation.issues.map(e=>({phase:`build`,code:e.code,message:e.message}))??[],O=d===`timeout`?[{phase:`boot`,code:`boot_timeout`,message:`Preview did not report ready within 7 seconds.`}]:[],k=[...D,...h,...O],A=E.status===`invalid`||E.validation.status===`failed`,j=A||d===`failed`||d===`timeout`,M=A?i===`zh`?`校验失败`:`Validation failed`:d===`healthy`?i===`zh`?`运行正常`:`Running`:d===`booting`?i===`zh`?`正在启动`:`Starting`:d===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`,N=()=>{x(null),u(e=>e+1)},P=async()=>{if(k.length){v(!0),x(null);try{NT((await RF(t.id,{sourceHash:E.sourceHash,locale:i,diagnostics:k})).prompt)}catch(e){x(e instanceof Error?e.message:String(e))}finally{v(!1)}}};return(0,$.jsxs)(`section`,{ref:C.containerRef,className:`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`,"data-inline-local-app":t.id,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:t.title,children:t.title}),(0,$.jsx)(`p`,{className:K(`mt-0.5 text-xs`,j?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:M})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`min-h-9 px-2.5 text-xs`,onClick:N,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:[(0,$.jsx)(Vi,{className:`size-4`}),i===`zh`?`重试`:`Retry`]}),(0,$.jsxs)(X,{variant:`ghost`,className:`min-h-9 px-2.5 text-xs`,onClick:T,children:[(0,$.jsx)(I,{className:`size-4`}),i===`zh`?`打开`:`Open`]})]}),(0,$.jsxs)(`div`,{className:`relative bg-surface-base`,style:{height:S},children:[E.previewUrl?(0,$.jsx)(`iframe`,{ref:s,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,src:J(E.previewUrl),sandbox:`allow-scripts allow-forms`,className:`h-full w-full border-0 bg-white`},c):null,E.previewUrl&&d===`booting`?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,$.jsx)(xn,{className:`h-10 w-40`})}):null]}),j?(0,$.jsxs)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,children:p?.message??k[0]?.message??(i===`zh`?`预览校验失败`:`Preview validation failed`)}),(0,$.jsxs)(X,{variant:`secondary`,className:`min-h-9 px-3 text-xs`,disabled:_||k.length===0,onClick:()=>void P(),children:[(0,$.jsx)(Sa,{className:`size-4`}),_?i===`zh`?`生成修复建议…`:`Preparing fix…`:i===`zh`?`让 Coder 修复`:`Ask Coder to fix`]})]}),y?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-danger`,role:`alert`,children:y}):null]}):null]})}async function XF(e,t){return(await q(J(`/api/chat-previews/${encodeURIComponent(e)}/revisions/${encodeURIComponent(t)}`))).revision}async function ZF(e,t){return(await q(J(`/api/chat-previews/${encodeURIComponent(e)}/fix-guidance`),{method:`POST`,body:JSON.stringify(t)})).guidance}async function QF(e,t){return(await q(J(`/api/chat-previews/${encodeURIComponent(e)}/promote`),{method:`POST`,body:JSON.stringify({sourceHash:t})})).app}function $F(e,t){return e.replace(RegExp(`</${t}`,`gi`),`<\\/${t}`)}function eI(e){let t=jt.safeParse(e);return t.success?t.data:null}function tI(e,t){let n=`(() => {
67
- const channel = ${JSON.stringify(t)};
68
- const bufferedErrors = [];
69
- const send = (type, detail = {}) => parent.postMessage({
70
- source: ${JSON.stringify(At)},
71
- version: 1, channel, type, ...detail
72
- }, '*');
73
- const resize = () => send('resize', { height: Math.max(120, Math.min(2000,
74
- Math.ceil(document.documentElement.getBoundingClientRect().height))) });
75
- const report = (diagnostic) => { bufferedErrors.push(diagnostic); send('error', { diagnostic }); };
76
- addEventListener('error', (event) => report({
77
- kind: 'script_error', message: String(event.message || 'Script error'),
78
- filename: event.filename || undefined, line: event.lineno || undefined,
79
- column: event.colno || undefined
80
- }));
81
- addEventListener('unhandledrejection', (event) => report({
82
- kind: 'unhandled_rejection', message: String(event.reason?.message || event.reason || 'Unhandled rejection')
83
- }));
84
- addEventListener('DOMContentLoaded', () => {
85
- resize(); new ResizeObserver(resize).observe(document.documentElement);
86
- setTimeout(() => {
87
- send('ready');
88
- bufferedErrors.forEach((diagnostic) => send('error', { diagnostic }));
89
- }, 100);
90
- });
91
- })();`;return`<!doctype html>
92
- <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
93
- <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'">
94
- <style>html,body{margin:0;min-height:100%;background:#fff;color:#111827;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}*{box-sizing:border-box}${$F(e.styles,`style`)}</style>
95
- </head><body>${e.markup}
96
- <script>${$F(n,`script`)}<\/script>
97
- <script>${$F(e.script,`script`)}<\/script>
98
- </body></html>`}function nI(e,t,n){let r=r=>{if(r.source!==e.contentWindow)return;let i=eI(r.data);!i||i.channel!==t||n(i)};return window.addEventListener(`message`,r),()=>window.removeEventListener(`message`,r)}function rI({leaseId:e,reference:t,sourceHash:n,preferredHeight:r,language:i}){let a=l(),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(`booting`),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),v=MF(e),y=Math.min(720,Math.max(240,r)),b=(0,Z.useMemo)(()=>crypto.randomUUID(),[s,n]),x=Zt(v.active?[`chat-preview-revision`,t.id,n]:null,()=>XF(t.id,n),{revalidateOnFocus:!1,shouldRetryOnError:!1}),S=x.data?tI(x.data,b):void 0;(0,Z.useEffect)(()=>{let e=o.current;if(!e||!S)return;d(`booting`),p([]);let t=window.setTimeout(()=>{d(e=>e===`booting`?`timeout`:e)},7e3),n=nI(e,b,t=>{t.type===`ready`&&d(`healthy`),t.type===`resize`&&(e.style.height=`${Math.min(720,Math.max(240,t.height))}px`),t.type===`error`&&(d(`failed`),p(e=>[...e,t.diagnostic].slice(-20)))});return()=>{window.clearTimeout(t),n()}},[b,S]);let C=()=>{_(null),c(e=>e+1)},w=async()=>{if(f.length){h(`fix`),_(null);try{NT((await ZF(t.id,{sourceHash:n,diagnostics:f,locale:i})).prompt)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}}},T=async()=>{h(`promote`),_(null);try{let e=await QF(t.id,n);a(`/local-apps/${encodeURIComponent(e.id)}`)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(null)}},E=`mt-3 overflow-hidden rounded-2xl border border-edge bg-surface-panel`;if(!v.active)return(0,$.jsxs)(`section`,{ref:v.containerRef,className:E,"data-inline-chat-preview":t.id,children:[(0,$.jsxs)(`header`,{className:`border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v.state===`queued`?i===`zh`?`正在等待预览资源`:`Waiting for a preview slot`:i===`zh`?`预览尚未加载`:`Preview not loaded`})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-surface-base`,style:{height:y},children:(0,$.jsx)(X,{variant:`secondary`,className:`min-h-11`,onClick:v.activate,children:i===`zh`?`加载交互预览`:`Load interactive preview`})})]});if(x.isLoading)return(0,$.jsxs)(`section`,{ref:v.containerRef,className:E,"aria-busy":`true`,"aria-label":i===`zh`?`正在加载预览`:`Loading preview`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,$.jsx)(xn,{className:`h-5 w-40`})}),(0,$.jsx)(xn,{className:`m-3 w-[calc(100%-1.5rem)]`,style:{height:y}})]});if(!x.data||!S){let e=x.error instanceof Error?x.error.message:i===`zh`?`无法加载预览`:`Unable to load preview`;return(0,$.jsx)(`section`,{ref:v.containerRef,className:`mt-3 rounded-2xl border border-danger/30 bg-danger-soft p-4 text-sm text-danger`,role:`alert`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ma,{className:`size-4`}),e]})})}let D=u===`failed`||u===`timeout`,O=u===`healthy`?i===`zh`?`运行正常`:`Running`:u===`booting`?i===`zh`?`正在启动`:`Starting`:u===`timeout`?i===`zh`?`启动超时`:`Start timed out`:i===`zh`?`运行错误`:`Runtime error`;return(0,$.jsxs)(`section`,{ref:v.containerRef,className:E,"data-inline-chat-preview":t.id,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:K(`mt-0.5 text-xs`,D?`text-danger`:`text-fg-muted`),"aria-live":`polite`,children:O})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`min-h-11 px-3 text-xs`,onClick:C,"aria-label":i===`zh`?`重新加载预览`:`Reload preview`,children:[(0,$.jsx)(Vi,{className:`size-4`}),i===`zh`?`重试`:`Retry`]}),(0,$.jsxs)(X,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:m!==null,onClick:()=>void T(),children:[(0,$.jsx)(Ui,{className:`size-4`}),m===`promote`?i===`zh`?`保存中…`:`Saving…`:i===`zh`?`保存为应用`:`Save as app`]})]}),(0,$.jsxs)(`div`,{className:`relative bg-surface-base`,style:{minHeight:y},children:[(0,$.jsx)(`iframe`,{ref:o,title:i===`zh`?`${t.title} 交互预览`:`${t.title} interactive preview`,srcDoc:S,sandbox:`allow-scripts allow-forms`,className:`block w-full border-0 bg-white`,style:{height:y}},s),u===`booting`?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 grid place-items-center bg-surface-base/75`,children:(0,$.jsx)(xn,{className:`h-10 w-40`})}):null]}),D?(0,$.jsx)(`footer`,{className:`border-t border-danger/20 bg-danger-soft/60 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-danger`,role:`alert`,children:f.at(-1)?.message??(i===`zh`?`预览未能正常启动`:`The preview did not start correctly`)}),(0,$.jsxs)(X,{variant:`secondary`,className:`min-h-11 px-3 text-xs`,disabled:!f.length||m!==null,onClick:()=>void w(),children:[(0,$.jsx)(Sa,{className:`size-4`}),m===`fix`?i===`zh`?`生成中…`:`Preparing…`:i===`zh`?`让 AI 修复`:`Ask AI to fix`]})]})}):null,g?(0,$.jsx)(`p`,{className:`border-t border-danger/20 px-4 py-2 text-xs text-danger`,role:`alert`,children:g}):null]})}function iI(e){let t=(0,Q.c)(8),{children:n,label:r,className:i}=e,a;t[0]===i?a=t[1]:(a=K(`mt-2 w-full max-w-[28rem] self-start`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,$.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-inset shadow-surface`,children:n}),t[2]=n,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsx)(`section`,{className:a,"aria-label":r,"data-turn-tail":!0,children:o}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function aI(e){return{id:e.artifactId,name:e.title,type:e.kind,mimeType:e.mimeType,size:e.sizeBytes,uri:e.uri,workspaceRelativePath:e.workspaceRelativePath}}function oI(e){let t=e.mimeType?.toLowerCase()??``,n=e.type?.toLowerCase()??``;return t.startsWith(`image/`)||n===`image`?R:t.startsWith(`audio/`)||n===`audio`||n===`voice`?Fr:t.startsWith(`video/`)||n===`video`?Ir:t.includes(`spreadsheet`)||[`spreadsheet`,`csv`,`xlsx`,`xls`].includes(n)?Rr:t.includes(`zip`)||[`archive`,`zip`].includes(n)?Kn:n===`site`?kr:zr}function sI(e,t,n){return!!(e.uri||u_(e)||e.workspaceRelativePath?.trim()&&(t?.trim()||n?.trim()))}function cI(e){let t=(0,Q.c)(46),{item:n,authToken:r,conversationId:i,projectId:a,onOpen:o}=e,s;t[0]!==r||t[1]!==i?(s={authToken:r,conversationId:i},t[0]=r,t[1]=i,t[2]=s):s=t[2];let c=eO(n.attachment,s),l;t[3]===n.attachment?l=t[4]:(l=oI(n.attachment),t[3]=n.attachment,t[4]=l);let u=l,d,f,p;if(t[5]!==u||t[6]!==i||t[7]!==c.src||t[8]!==n.attachment||t[9]!==n.failed||t[10]!==n.href||t[11]!==n.meta||t[12]!==a){d=sI(n.attachment,i,a);let e=d||!!n.href,r;t[16]!==u||t[17]!==c.src||t[18]!==n.failed?(r=c.src?(0,$.jsx)(`img`,{src:c.src,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`,decoding:`async`,loading:`lazy`}):(0,$.jsx)(`span`,{className:K(`flex size-8 shrink-0 items-center justify-center rounded-lg`,n.failed?`bg-danger-soft text-danger`:`bg-accent-soft/70 text-accent-fg`),"aria-hidden":!0,children:(0,$.jsx)(u,{className:`size-4`,strokeWidth:1.75})}),t[16]=u,t[17]=c.src,t[18]=n.failed,t[19]=r):r=t[19];let o=n.attachment.name??`File`,s=n.attachment.name??`File`,l;t[20]!==o||t[21]!==s?(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,title:o,children:s}),t[20]=o,t[21]=s,t[22]=l):l=t[22];let m;t[23]===n.meta?m=t[24]:(m=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-5 text-fg-muted`,title:n.meta,children:n.meta}),t[23]=n.meta,t[24]=m);let h;t[25]!==l||t[26]!==m?(h=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,m]}),t[25]=l,t[26]=m,t[27]=h):h=t[27];let g=e?(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}):null,_;t[28]!==g||t[29]!==r||t[30]!==h?(_=(0,$.jsxs)($.Fragment,{children:[r,h,g]}),t[28]=g,t[29]=r,t[30]=h,t[31]=_):_=t[31],f=_,p=K(`flex min-h-14 w-full min-w-0 items-center gap-3 px-3 py-2 text-left`,e&&`cursor-pointer hover:bg-surface-hover/65 active:bg-surface-active/70`,yc.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,!e&&`cursor-default`),t[5]=u,t[6]=i,t[7]=c.src,t[8]=n.attachment,t[9]=n.failed,t[10]=n.href,t[11]=n.meta,t[12]=a,t[13]=d,t[14]=f,t[15]=p}else d=t[13],f=t[14],p=t[15];let m=p;if(!d&&n.href){let e;return t[32]!==m||t[33]!==f||t[34]!==n.href?(e=(0,$.jsx)(`li`,{"data-result-attachment":!0,children:(0,$.jsx)(`a`,{href:n.href,target:`_blank`,rel:`noreferrer`,className:m,children:f})}),t[32]=m,t[33]=f,t[34]=n.href,t[35]=e):e=t[35],e}if(!d){let e;return t[36]!==m||t[37]!==f?(e=(0,$.jsx)(`li`,{className:m,"data-result-attachment":!0,children:f}),t[36]=m,t[37]=f,t[38]=e):e=t[38],e}let h;t[39]!==n.attachment||t[40]!==o?(h=()=>o(n.attachment),t[39]=n.attachment,t[40]=o,t[41]=h):h=t[41];let g;return t[42]!==m||t[43]!==f||t[44]!==h?(g=(0,$.jsx)(`li`,{"data-result-attachment":!0,children:(0,$.jsx)(`button`,{type:`button`,className:m,onClick:h,children:f})}),t[42]=m,t[43]=f,t[44]=h,t[45]=g):g=t[45],g}function lI(e){let t=(0,Q.c)(26),{attachments:n,authToken:r,conversationId:i,projectId:a,onOpen:o,language:s}=e,c;t[0]!==n.length||t[1]!==s?(c=xe(s).chat.turnOutcome.fileCount.replace(`{{count}}`,String(n.length)),t[0]=n.length,t[1]=s,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=K(`flex min-h-14 cursor-pointer list-none items-center gap-3 px-3 py-2 text-left`,`hover:bg-surface-hover/65 active:bg-surface-active/70`,yc.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`),t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft/70 text-accent-fg`,"aria-hidden":!0,children:(0,$.jsx)(Vr,{className:`size-4`,strokeWidth:1.75})}),t[4]=d):d=t[4];let f;t[5]===l?f=t[6]:(f=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-medium text-fg`,children:l}),t[5]=l,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle transition-transform duration-150 ease-out group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===f?m=t[9]:(m=(0,$.jsxs)(`summary`,{className:u,children:[d,f,p]}),t[8]=f,t[9]=m);let h;if(t[10]!==n||t[11]!==r||t[12]!==i||t[13]!==o||t[14]!==a){let e;t[16]!==r||t[17]!==i||t[18]!==o||t[19]!==a?(e=e=>(0,$.jsx)(cI,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:o},e.key),t[16]=r,t[17]=i,t[18]=o,t[19]=a,t[20]=e):e=t[20],h=n.map(e),t[10]=n,t[11]=r,t[12]=i,t[13]=o,t[14]=a,t[15]=h}else h=t[15];let g;t[21]===h?g=t[22]:(g=(0,$.jsx)(`ul`,{className:`m-0 list-none divide-y divide-edge-subtle border-t border-edge-subtle p-0`,children:h}),t[21]=h,t[22]=g);let _;return t[23]!==m||t[24]!==g?(_=(0,$.jsx)(`li`,{"data-result-attachment-group":!0,children:(0,$.jsxs)(`details`,{className:`group`,children:[m,g]})}),t[23]=m,t[24]=g,t[25]=_):_=t[25],_}function uI(e,t){if(!e)return[];let n=xe(t).chat.turnOutcome;return e.deliverables.map(e=>{let t=aI(e);return{key:`outcome:${e.artifactId}`,attachment:t,href:e.shareUrl,failed:e.availability===`failed`||e.availability===`missing`,meta:[n.availability[e.availability],e.sizeBytes===void 0?null:m_(e.sizeBytes)].filter(Boolean).join(` · `)}})}function dI(e,t){let n=xe(t).chat.turnOutcome;return(e??[]).map((e,t)=>({key:`attachment:${e.id??e.uri??e.name??t}`,attachment:e,meta:[n.generatedFile,e.mimeType,typeof e.size==`number`?m_(e.size):null].filter(Boolean).join(` · `)}))}function fI(e){let t=new Set;for(let n of e?.deliverables??[])for(let e of[n.artifactId,n.sourceFileId,n.workspaceRelativePath]){let n=e?.trim();n&&t.add(`file:${n}`)}return t}function pI(e){let t=(0,Q.c)(46),{view:n,authToken:r,conversationId:i,projectId:a}=e,o=Ee(gI)===`zh`?`zh`:`en`,s;t[0]!==i||t[1]!==a?(s={layout:`assistant`,conversationId:i,projectId:a},t[0]=i,t[1]=a,t[2]=s):s=t[2];let c=rO(s),l=n.deliveries,u,d,f,p,m,h,g,_,v;if(t[3]!==o||t[4]!==n.attachments||t[5]!==n.deliveries||t[6]!==n.outcome){_=Symbol.for(`react.early_return_sentinel`);bb0:{v=l.filter(hI);let e=QP(v),r=eF(v),i=tF(v);f=$P(v),p=fI(n.outcome);let a=nF(v,p).length,s;if(t[16]!==o||t[17]!==n.attachments||t[18]!==n.outcome?(s=[...uI(n.outcome,o),...dI(n.attachments,o)],t[16]=o,t[17]=n.attachments,t[18]=n.outcome,t[19]=s):s=t[19],u=s,d=a>0||u.length>0,e.length===0&&r.length===0&&i.length===0&&!d){_=null;break bb0}m=e.map(mI);let c;t[20]===o?c=t[21]:(c=e=>{let{key:t,presentation:n}=e;return(0,$.jsx)(YF,{previewId:`${t}:${n.reference.id}:${n.snapshot.sourceHash}`,reference:n.reference,sourceHash:n.snapshot.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[20]=o,t[21]=c),h=r.map(c);let y;t[22]===o?y=t[23]:(y=e=>{let{key:t,presentation:n}=e;return(0,$.jsx)(rI,{leaseId:`${t}:${n.reference.id}:${n.sourceHash}`,reference:n.reference,sourceHash:n.sourceHash,preferredHeight:n.preferredHeight,language:o},t)},t[22]=o,t[23]=y),g=i.map(y)}t[3]=o,t[4]=n.attachments,t[5]=n.deliveries,t[6]=n.outcome,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m,t[12]=h,t[13]=g,t[14]=_,t[15]=v}else u=t[7],d=t[8],f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let y;t[24]!==u||t[25]!==r||t[26]!==i||t[27]!==d||t[28]!==o||t[29]!==c||t[30]!==a||t[31]!==f||t[32]!==p||t[33]!==v?(y=d?(0,$.jsxs)(iI,{label:o===`zh`?`本轮交付结果`:`Turn deliverables`,children:[(0,$.jsxs)(`ul`,{className:`m-0 list-none divide-y divide-edge-subtle p-0`,children:[(0,$.jsx)(vF,{deliveries:v,language:o,excludedReferenceKeys:p}),u.length>1?(0,$.jsx)(lI,{attachments:u,authToken:r,conversationId:i,projectId:a,onOpen:c.openAttachment,language:o}):u.map(e=>(0,$.jsx)(cI,{item:e,authToken:r,conversationId:i,projectId:a,onOpen:c.openAttachment},e.key))]}),f.truncated?(0,$.jsx)(`p`,{role:`status`,className:`border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:o===`zh`?`仅显示部分结果`:`Showing partial results`}):null]}):null,t[24]=u,t[25]=r,t[26]=i,t[27]=d,t[28]=o,t[29]=c,t[30]=a,t[31]=f,t[32]=p,t[33]=v,t[34]=y):y=t[34];let b;t[35]!==u.length||t[36]!==r||t[37]!==i||t[38]!==c?(b=u.length>0?(0,$.jsx)(rD,{open:c.open,attachment:c.active,authToken:r,conversationId:i,onClose:c.closePreview}):null,t[35]=u.length,t[36]=r,t[37]=i,t[38]=c,t[39]=b):b=t[39];let x;return t[40]!==m||t[41]!==h||t[42]!==g||t[43]!==y||t[44]!==b?(x=(0,$.jsxs)($.Fragment,{children:[m,h,g,y,b]}),t[40]=m,t[41]=h,t[42]=g,t[43]=y,t[44]=b,t[45]=x):x=t[45],x}function mI(e){let{key:t,presentation:n}=e;return(0,$.jsx)(xF,{presentation:n},t)}function hI(e){let{delivery:t}=e;return ZP(t)}function gI(e){return e.language}function _I(e){let t=(0,Q.c)(39),{outcome:n}=e,r=Ee(bI),i,a,o,s,c,l,u,d;if(t[0]!==r||t[1]!==n.changeSet||t[2]!==n.evidence||t[3]!==n.status){d=Symbol.for(`react.early_return_sentinel`);bb0:{if(o=xe(r).chat.turnOutcome,i=!!n.changeSet,a=n.evidence.length>0,!i&&!a){d=null;break bb0}let e=n.evidence.filter(yI).length,f=n.evidence.filter(vI).length,p=n.status===`succeeded`?o.statusSucceeded:n.status===`failed`?o.statusFailed:o.statusPartial,m=n.status===`succeeded`?S:n.status===`failed`?br:dr,h=[n.changeSet?o.changedFileCount.replace(`{{count}}`,String(n.changeSet.files.length)):null,e>0?o.passedCount.replace(`{{count}}`,String(e)):null,f>0?o.failedCount.replace(`{{count}}`,String(f)):null,a&&e===0&&f===0?`${n.evidence.length} ${o.evidence}`:null].filter(Boolean).join(` · `);l=`group mt-2 max-w-[36rem] rounded-lg bg-surface-panel/15 text-sm`;let g=n.status===`succeeded`?`grid size-5 shrink-0 place-items-center rounded-full bg-success/10 text-success`:n.status===`failed`?`grid size-5 shrink-0 place-items-center rounded-full bg-danger/10 text-danger`:`grid size-5 shrink-0 place-items-center rounded-full bg-warning/10 text-warning`,_;t[12]===m?_=t[13]:(_=(0,$.jsx)(m,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t[12]=m,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsx)(`span`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]===h?y=t[18]:(y=(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:h}),t[17]=h,t[18]=y);let b=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-xs font-medium text-fg`,children:p}),y]}),x;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(lr,{className:`size-4 shrink-0 transition-transform group-open:rotate-90 motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0}),t[19]=x):x=t[19],t[20]!==b||t[21]!==v?(u=(0,$.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-lg px-3 py-2 text-fg-muted transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[v,b,x]}),t[20]=b,t[21]=v,t[22]=u):u=t[22],s=`border-t border-edge-subtle px-3 py-2.5`,c=n.changeSet?(0,$.jsxs)(`section`,{"aria-label":o.changes,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:o.changeSetTitle}),(0,$.jsx)(`span`,{className:`shrink-0 text-fg-subtle`,children:o.changeStats.replace(`{{files}}`,String(n.changeSet.files.length)).replace(`{{added}}`,String(n.changeSet.added)).replace(`{{removed}}`,String(n.changeSet.removed))})]}),(0,$.jsxs)(`div`,{className:`mt-2 border-t border-edge-subtle/70 pt-2`,children:[n.changeSet.files.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 py-1 text-xs`,children:[(0,$.jsx)(`span`,{className:`w-14 shrink-0 text-fg-subtle`,children:o.fileStatus[e.status??`modified`]}),(0,$.jsx)(`code`,{className:`min-w-0 truncate text-fg-muted`,children:e.path})]},e.path)),n.changeSet.files.length>8?(0,$.jsx)(`div`,{className:`pt-1 text-xs text-fg-subtle`,children:o.moreFiles.replace(`{{count}}`,String(n.changeSet.files.length-8))}):null]}),n.changeSet.diff?(0,$.jsxs)(`details`,{className:`mt-2`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer rounded-md px-1.5 py-1 text-xs font-medium text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:o.viewDiff}),n.changeSet.diffTruncated?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-warning`,children:o.diffTruncated}):null,(0,$.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-lg bg-surface-inset p-3 text-xs leading-5 text-fg-muted`,children:(0,$.jsx)(`code`,{children:n.changeSet.diff})})]}):null]}):null}t[0]=r,t[1]=n.changeSet,t[2]=n.evidence,t[3]=n.status,t[4]=i,t[5]=a,t[6]=o,t[7]=s,t[8]=c,t[9]=l,t[10]=u,t[11]=d}else i=t[4],a=t[5],o=t[6],s=t[7],c=t[8],l=t[9],u=t[10],d=t[11];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;t[23]!==i||t[24]!==a?(f=i&&a?(0,$.jsx)(`div`,{className:`my-2 border-t border-edge-subtle`}):null,t[23]=i,t[24]=a,t[25]=f):f=t[25];let p;t[26]!==a||t[27]!==n.evidence||t[28]!==o?(p=a?(0,$.jsxs)(`section`,{"aria-label":o.evidence,children:[(0,$.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg`,children:o.evidence}),n.evidence.map(e=>(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2.5 border-b border-edge-subtle/60 py-1.5 last:border-b-0`,children:[(0,$.jsx)(ai,{className:e.status===`passed`?`size-4 shrink-0 text-success`:e.status===`failed`?`size-4 shrink-0 text-danger`:`size-4 shrink-0 text-warning`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:e.label}),(0,$.jsx)(`span`,{className:e.status===`passed`?`text-xs font-medium text-success`:e.status===`failed`?`text-xs font-medium text-danger`:`text-xs font-medium text-warning`,children:e.status===`passed`?o.passed:e.status===`failed`?o.failed:o.warning})]},e.evidenceId))]}):null,t[26]=a,t[27]=n.evidence,t[28]=o,t[29]=p):p=t[29];let m;t[30]!==s||t[31]!==c||t[32]!==f||t[33]!==p?(m=(0,$.jsxs)(`div`,{className:s,children:[c,f,p]}),t[30]=s,t[31]=c,t[32]=f,t[33]=p,t[34]=m):m=t[34];let h;return t[35]!==l||t[36]!==u||t[37]!==m?(h=(0,$.jsxs)(`details`,{className:l,children:[u,m]}),t[35]=l,t[36]=u,t[37]=m,t[38]=h):h=t[38],h}function vI(e){return e.status===`failed`}function yI(e){return e.status===`passed`}function bI(e){return e.language}function xI(e){let t=(0,Q.c)(14),{view:n,authToken:r,conversationId:i,projectId:a,sourcesLabel:o}=e,s;t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(s=(0,$.jsx)(pI,{view:n,authToken:r,conversationId:i,projectId:a}),t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=s):s=t[4];let c;t[5]===n.outcome?c=t[6]:(c=n.outcome?(0,$.jsx)(_I,{outcome:n.outcome}):null,t[5]=n.outcome,t[6]=c);let l;t[7]!==o||t[8]!==n.sources?(l=n.sources.length>0?(0,$.jsx)(`section`,{className:`rounded-lg bg-surface-panel/10 px-3 py-2.5`,"aria-label":o,children:(0,$.jsx)(aF,{sources:n.sources,className:``})}):null,t[7]=o,t[8]=n.sources,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,$.jsxs)($.Fragment,{children:[s,c,l]}),t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}var SI=3;function CI(e){let t=(0,Q.c)(36),{refs:n,groupLabel:r,noteLabel:i,fileLabel:a,folderLabel:o,sessionLabel:s,browserTabLabel:c,mcpResourceLabel:l,truncatedLabel:u,showMoreLabel:d,showLessLabel:f,onOpen:p}=e,[m,h]=(0,Z.useState)(!1);if(n.length===0)return null;let g=n.length>SI,_;t[0]!==m||t[1]!==n?(_=m?n:n.slice(0,SI),t[0]=m,t[1]=n,t[2]=_):_=t[2];let v=_,y=n.length-SI,b;if(t[3]!==c||t[4]!==a||t[5]!==o||t[6]!==r||t[7]!==l||t[8]!==i||t[9]!==p||t[10]!==s||t[11]!==u||t[12]!==v){let e;t[14]!==c||t[15]!==a||t[16]!==o||t[17]!==r||t[18]!==l||t[19]!==i||t[20]!==p||t[21]!==s||t[22]!==u?(e=e=>{let t=e.kind===`note`,n=t?`button`:`div`,d=e.kind===`file`?e.fileKind===`directory`?o:a:e.kind===`session`?s:e.kind===`browser_tab`?c:e.kind===`mcp_resource`?l:i;return(0,$.jsxs)(n,{...t?{type:`button`,onClick:()=>p(e)}:{},className:K(`group inline-flex min-h-9 min-w-0 max-w-full items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel/80 px-2 py-1.5 text-left`,t&&`transition-colors hover:border-accent/40 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),...t?{"aria-label":`${r}: ${e.title}`}:{},title:e.truncated?u:e.title,children:[(0,$.jsx)(`span`,{className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-accent-soft text-accent-fg`,children:e.kind===`file`&&e.fileKind===`directory`?(0,$.jsx)(Gr,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`file`?(0,$.jsx)(zr,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(pi,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,$.jsx)(Gn,{className:`size-3.5`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,$.jsx)(Or,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(xi,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-fg-muted`,children:d}),(0,$.jsx)(`span`,{className:`max-w-56 truncate text-xs font-medium text-fg sm:max-w-72`,children:e.title})]}),t?(0,$.jsx)(lr,{className:`size-3.5 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":!0}):null]},`${e.kind}:${e.sourceId}`)},t[14]=c,t[15]=a,t[16]=o,t[17]=r,t[18]=l,t[19]=i,t[20]=p,t[21]=s,t[22]=u,t[23]=e):e=t[23],b=v.map(e),t[3]=c,t[4]=a,t[5]=o,t[6]=r,t[7]=l,t[8]=i,t[9]=p,t[10]=s,t[11]=u,t[12]=v,t[13]=b}else b=t[13];let x;t[24]===b?x=t[25]:(x=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap gap-1.5`,children:b}),t[24]=b,t[25]=x);let S;t[26]!==g||t[27]!==m||t[28]!==y||t[29]!==f||t[30]!==d?(S=g?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-8 w-fit items-center gap-1 rounded-md px-2 text-xs 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-expanded":m,onClick:()=>h(wI),children:[m?(0,$.jsx)(ur,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(cr,{className:`size-3.5`,"aria-hidden":!0}),m?f:d.replace(`{{count}}`,String(y))]}):null,t[26]=g,t[27]=m,t[28]=y,t[29]=f,t[30]=d,t[31]=S):S=t[31];let C;return t[32]!==r||t[33]!==x||t[34]!==S?(C=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,role:`group`,"aria-label":r,children:[x,S]}),t[32]=r,t[33]=x,t[34]=S,t[35]=C):C=t[35],C}function wI(e){return!e}function TI(e,t){let n=new Map;for(let r of e){let e=r.sourceName.trim(),i=r.statement.trim().replace(/\s+/g,` `),a=r.origin===`connected_source`?`${r.origin}:${e}`:r.origin,o=r.origin===`connected_source`?t.connected_source.replace(`{{source}}`,e):t[r.origin],s=n.get(a);s?s.items.some(e=>e.statement.trim().replace(/\s+/g,` `)===i)||s.items.push(r):n.set(a,{id:a,label:o,items:[r]})}return Array.from(n.values())}function EI(e){let t=(0,Q.c)(67),{open:n,onOpenChange:r,items:i,labels:a}=e,o;t[0]!==i||t[1]!==a.origins?(o=TI(i,a.origins),t[0]=i,t[1]=a.origins,t[2]=o):o=t[2];let s=o,c=s.reduce(AI,0),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[3]=l):l=t[3];let[u,d]=(0,Z.useState)(l),f,p;t[4]!==c||t[5]!==s||t[6]!==n?(f=()=>{!n||s.length===0||d(new Set(c<=6?s.map(kI):[s[0].id]))},p=[c,s,n],t[4]=c,t[5]=s,t[6]=n,t[7]=f,t[8]=p):(f=t[7],p=t[8]),(0,Z.useEffect)(f,p);let m;t[9]!==u||t[10]!==s?(m=s.length>0&&s.every(e=>u.has(e.id)),t[9]=u,t[10]=s,t[11]=m):m=t[11];let h=m,g;t[12]!==h||t[13]!==s?(g=()=>{d(h?new Set:new Set(s.map(OI)))},t[12]=h,t[13]=s,t[14]=g):g=t[14];let _=g,v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[15]=v):v=t[15];let y=v,b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px]`}),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100dvh-2rem))]`,`w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`),t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,$.jsx)(_r,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[18]=S):S=t[18];let C;t[19]===a.title?C=t[20]:(C=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:a.title}),t[19]=a.title,t[20]=C);let w;t[21]===a.hint?w=t[22]:(w=(0,$.jsx)(Ze,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:a.hint}),t[21]=a.hint,t[22]=w);let T;t[23]!==c||t[24]!==a.itemsSummary?(T=a.itemsSummary.replace(`{{count}}`,String(c)),t[23]=c,t[24]=a.itemsSummary,t[25]=T):T=t[25];let E;t[26]===T?E=t[27]:(E=(0,$.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg-subtle`,children:T}),t[26]=T,t[27]=E);let D;t[28]!==C||t[29]!==w||t[30]!==E?(D=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,w,E]}),t[28]=C,t[29]=w,t[30]=E,t[31]=D):D=t[31];let O;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[32]=O):O=t[32];let k;t[33]===a.close?k=t[34]:(k=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":a.close,title:a.close,children:O})}),t[33]=a.close,t[34]=k);let A;t[35]!==D||t[36]!==k?(A=(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 border-b border-edge-subtle px-4 py-4 sm:px-5`,children:[S,D,k]}),t[35]=D,t[36]=k,t[37]=A):A=t[37];let j;t[38]!==s.length||t[39]!==a.groupSummary?(j=a.groupSummary.replace(`{{count}}`,String(s.length)),t[38]=s.length,t[39]=a.groupSummary,t[40]=j):j=t[40];let M;t[41]===j?M=t[42]:(M=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:j}),t[41]=j,t[42]=M);let N;t[43]!==h||t[44]!==s.length||t[45]!==a.collapseAll||t[46]!==a.expandAll||t[47]!==_?(N=s.length>1?(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-2 py-1 text-xs font-medium text-accent-fg transition-colors duration-150 hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:_,children:h?a.collapseAll:a.expandAll}):null,t[43]=h,t[44]=s.length,t[45]=a.collapseAll,t[46]=a.expandAll,t[47]=_,t[48]=N):N=t[48];let P;t[49]!==M||t[50]!==N?(P=(0,$.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-4 sm:px-5`,children:[M,N]}),t[49]=M,t[50]=N,t[51]=P):P=t[51];let F;if(t[52]!==u||t[53]!==s){let e;t[55]===u?e=t[56]:(e=e=>{let t=u.has(e.id);return(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full items-center gap-3 px-3.5 py-2.5 text-left transition-colors duration-150 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,"aria-expanded":t,onClick:()=>y(e.id),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.label}),(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] tabular-nums text-fg-muted`,children:e.items.length}),(0,$.jsx)(cr,{className:K(`size-4 shrink-0 text-fg-subtle transition-transform duration-200`,t&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0})]}),t?(0,$.jsx)(`div`,{className:`border-t border-edge-subtle px-3.5`,children:e.items.map(DI)}):null]},e.id)},t[55]=u,t[56]=e),F=s.map(e),t[52]=u,t[53]=s,t[54]=F}else F=t[54];let I;t[57]===F?I=t[58]:(I=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3 sm:px-4`,"data-testid":`response-context-scroll-region`,children:(0,$.jsx)(`div`,{className:`space-y-2`,children:F})}),t[57]=F,t[58]=I);let L;t[59]!==A||t[60]!==P||t[61]!==I?(L=(0,$.jsxs)($e,{children:[b,(0,$.jsxs)(et,{className:x,children:[A,P,I]})]}),t[59]=A,t[60]=P,t[61]=I,t[62]=L):L=t[62];let R;return t[63]!==r||t[64]!==n||t[65]!==L?(R=(0,$.jsx)(nt,{open:n,onOpenChange:r,children:L}),t[63]=r,t[64]=n,t[65]=L,t[66]=R):R=t[66],R}function DI(e){return(0,$.jsx)(`p`,{className:`border-b border-edge-subtle py-3 text-sm leading-6 text-fg last:border-b-0`,children:e.statement},e.id)}function OI(e){return e.id}function kI(e){return e.id}function AI(e,t){return e+t.items.length}var jI=K(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg`,`text-fg-muted transition-colors transition-transform duration-150 ease-out`,`hover:bg-surface-hover hover:text-fg active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,yc.disabled),MI=[`misunderstood_intent`,`incorrect`,`did_not_act`,`tone_mismatch`,`too_verbose`,`other`],NI=K(`inline-flex h-8 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-xs text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg active:scale-[0.98]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,yc.disabled),PI=700,FI=120,II=(0,Z.memo)(function({message:e,authToken:t,conversationId:n,workspaceConversationId:r,projectId:i,isStreaming:a,progress:o,reasoningLevel:s=`on`,messageIndex:c,onDeleteRound:u,onRetryUserMessageRound:d,userMessageCanRetry:f=!1,deleteRoundDisabled:p=!1,onSaveAssistantAsNote:m,onSaveAssistantToSourceNote:h,onExtractAssistantTask:g,onForkAssistantTurn:_,readonly:v=!1,density:y=`normal`,suppressAssistantActions:x=!1,onEditUserMessage:C,userMessageCanEdit:w=!0,responseFeedbackEnabled:T=!0}){let E=Ee(e=>e.language),D=xe(E),O=l(),k=b(),A=e.role===`user`,j=e.role===`assistant`,M=(0,Z.useRef)(A&&e.deliveryStatus===`sending`).current,P=A&&e.deliveryStatus===`sending`,I=A&&e.deliveryStatus===`failed`,[L,R]=(0,Z.useState)(!1),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(()=>typeof navigator<`u`&&navigator.onLine===!1),U=A?D.chat.you:j?D.chat.assistant:D.chat.tool;(0,Z.useEffect)(()=>{if(!P||typeof window>`u`)return;let e=()=>H(window.navigator.onLine===!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[P]),(0,Z.useEffect)(()=>{if(P){if(L)return;let e=window.setTimeout(()=>R(!0),V?0:PI);return()=>window.clearTimeout(e)}if(!L)return;let e=0,t=window.requestAnimationFrame(()=>{B(!0),e=window.setTimeout(()=>{R(!1),B(!1)},FI)});return()=>{window.cancelAnimationFrame(t),window.clearTimeout(e)}},[P,V,L]);let W=I||L,G=I?`failed`:`sending`,ee=(0,Z.useCallback)(e=>{let t=`${k.pathname}${k.search}`;O(te(`/notes/${encodeURIComponent(e)}`,t))},[k.pathname,k.search,O]),ne=(0,Z.useMemo)(()=>({input:D.chat.toolInput,output:D.chat.toolOutput,noOutput:D.chat.noOutput}),[D.chat.toolInput,D.chat.toolOutput,D.chat.noOutput]),re=(0,Z.useMemo)(()=>({thoughts:D.chat.thoughts,thoughtsStreaming:D.chat.thoughtsStreaming,workLogTitle:D.chat.workLogTitle,workLogRunning:D.chat.workLogRunning,workLogComplete:D.chat.workLogComplete,workLogPartial:D.chat.workLogPartial,workLogFailed:D.chat.workLogFailed,searchedWeb:D.chat.stepSearchedWeb,searchedMemory:D.chat.stepSearchedMemory,searchedCode:D.chat.stepSearchedCode,searched:D.chat.stepSearched,readFile:D.chat.stepReadFile,stepDetails:D.chat.stepDetails,runCommand:D.chat.stepRunCommand,listDirectory:D.chat.stepListDirectory,writeFile:D.chat.stepWriteFile,editFile:D.chat.stepEditFile,openUrl:D.chat.stepOpenUrl,fetchUrl:D.chat.stepFetchUrl,unknownTool:D.chat.stepUnknownTool,rawThinking:D.chat.rawThinking,toolError:D.chat.toolError,toolActivity:D.chat.toolActivity,memoryActivity:D.chat.memoryActivity}),[D.chat.thoughts,D.chat.thoughtsStreaming,D.chat.workLogTitle,D.chat.workLogRunning,D.chat.workLogComplete,D.chat.workLogPartial,D.chat.workLogFailed,D.chat.stepSearchedWeb,D.chat.stepSearchedMemory,D.chat.stepSearchedCode,D.chat.stepSearched,D.chat.stepReadFile,D.chat.stepDetails,D.chat.stepRunCommand,D.chat.stepListDirectory,D.chat.stepWriteFile,D.chat.stepEditFile,D.chat.stepOpenUrl,D.chat.stepFetchUrl,D.chat.stepUnknownTool,D.chat.rawThinking,D.chat.toolError,D.chat.toolActivity,D.chat.memoryActivity]),ie=(0,Z.useMemo)(()=>({ing:D.chat.stepsClusterIng}),[D.chat.stepsClusterIng]),ae=(0,Z.useMemo)(()=>D.chat.toolCard,[D.chat.toolCard]),oe=s===`off`,se=(0,Z.useMemo)(()=>j?iF({message:e,isStreaming:a,reasoningLevel:s}):null,[j,a,e,s]),ce=(0,Z.useMemo)(()=>se?.answerContent??(e.content??[]).filter(e=>e.type!==`image`),[se,e.content]),le=(0,Z.useMemo)(()=>se?se.attachments:e.attachments,[se,e.attachments]),ue=(0,Z.useMemo)(()=>{let t=new Set(e.userTurnDocument?.parts.flatMap(e=>e.type===`context_ref`?[e.refId]:[])??[]);return e.contextRefs?.filter(e=>!e.refId||!t.has(e.refId))},[e.contextRefs,e.userTurnDocument]),de=!!se?.workLog.items.length,fe=oe||j&&de?null:o,pe=oe?!1:!!e.content?.some(e=>e.type===`thinking`&&e.streaming),me=j?!!se?.answer.showStreamingCursor:a,ge=!!fe?.message||a&&!pe,_e=j&&!v&&!a&&!x,ve=(0,Z.useMemo)(()=>_e?_O(e.content??[]):``,[_e,e.content]),ye=(0,Z.useMemo)(()=>_e&&ve?yO(e.content??[]):``,[_e,ve,e.content]),be=(0,Z.useMemo)(()=>_e&&ve?uP(ve):``,[_e,ve]),Se=(0,Z.useMemo)(()=>({source:{type:`chat-message`,id:`${n??`chat`}:${e.timestamp??c??ve.length}`,title:be.split(`
99
- `)[0]?.slice(0,48)||D.chat.messageReadAloudTitle,href:n?`#/chat/${encodeURIComponent(n)}`:void 0},text:be,language:fP(be,E)}),[ve.length,E,D.chat.messageReadAloudTitle,e.timestamp,c,n,be]),Ce=(0,Z.useMemo)(()=>{if(!A)return``;if(e.userTurnDocument){let t=new Map(e.contextRefs?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]);return cs(e.userTurnDocument,e=>t.get(e))}return ov(e.content)},[A,e.content,e.contextRefs,e.userTurnDocument]),[we,Te]=(0,Z.useState)(null),[De,Oe]=(0,Z.useState)(null),[ke,Ae]=(0,Z.useState)(null),[je,Me]=(0,Z.useState)(!1),[Ne,Pe]=(0,Z.useState)(null),[Fe,Ie]=(0,Z.useState)(!1),[Le,Re]=(0,Z.useState)(!1),[ze,Be]=(0,Z.useState)(!1),[Ve,He]=(0,Z.useState)(!1),[Ue,We]=(0,Z.useState)(null),[Ge,Ke]=(0,Z.useState)([]),[qe,Je]=(0,Z.useState)(!1),[Ye,Xe]=(0,Z.useState)(!1),[Ze,Qe]=(0,Z.useState)(null),[$e,et]=(0,Z.useState)(!1),[tt,nt]=(0,Z.useState)(!1),rt=(0,Z.useRef)(null),it=(0,Z.useCallback)((e,t)=>{let n=hO(e,t);n&&Qe(n)},[]),at=(0,Z.useCallback)(()=>{!n||!e.renderKey||qb.getState().completeProgressiveRender(n,e.renderKey)},[e.renderKey,n]),ot=(0,Z.useCallback)(()=>{ye&&Yt(ye).then(e=>{e&&(Te(`plain`),window.setTimeout(()=>Te(e=>e===`plain`?null:e),2e3))})},[ye]),st=(0,Z.useCallback)(()=>{ve&&Yt(ve).then(e=>{e&&(Te(`markdown`),window.setTimeout(()=>Te(e=>e===`markdown`?null:e),2e3))})},[ve]),ct=(0,Z.useCallback)(()=>{!ve||!m||ke||(Ae(`create-note`),Promise.resolve(m(ve)).then(()=>{Oe(`create-note`),window.setTimeout(()=>Oe(e=>e===`create-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ae(null)))},[ke,ve,m]),lt=(0,Z.useCallback)(()=>{!ve||!h||ke||(Ae(`save-source-note`),Promise.resolve(h(ve)).then(()=>{Oe(`save-source-note`),window.setTimeout(()=>Oe(e=>e===`save-source-note`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ae(null)))},[ke,ve,h]),ut=(0,Z.useCallback)(()=>{!ye&&!ve||!g||ke||(Ae(`extract-task`),Promise.resolve(g(ye||ve)).then(()=>{Oe(`extract-task`),window.setTimeout(()=>Oe(e=>e===`extract-task`?null:e),2e3)}).catch(()=>void 0).finally(()=>Ae(null)))},[ke,ve,ye,g]),dt=(0,Z.useCallback)(()=>{Ce&&Yt(Ce).then(e=>{e&&(Te(`user`),window.setTimeout(()=>Te(e=>e===`user`?null:e),2e3))})},[Ce]),Y=(0,Z.useCallback)(()=>{!e.turnId||!_||je||(Me(!0),Promise.resolve(_(e.turnId)).catch(()=>void 0).finally(()=>Me(!1)))},[je,e.turnId,_]),ft=(0,Z.useCallback)((t,n)=>{!e.turnId||Le||(Re(!0),Ie(!0),Be(!1),q(J(`/api/turns/${encodeURIComponent(e.turnId)}/execution-context/feedback`),{method:`POST`,body:JSON.stringify({rating:t===`helpful`?`helpful`:`irrelevant`,reason:n})}).then(()=>{Pe(t),We(n??null),He(!1)}).catch(()=>Be(!0)).finally(()=>Re(!1)))},[e.turnId,Le]),pt=(0,Z.useCallback)(()=>{Ue&&NT(D.chat.messageFeedbackRepairPrompts[Ue])},[D.chat.messageFeedbackRepairPrompts,Ue]),mt=(0,Z.useCallback)(()=>{!e.turnId||Fe||Le||(Re(!0),q(J(`/api/turns/${encodeURIComponent(e.turnId)}/execution-context`)).then(e=>{Ke(e.resolvedItems.filter(e=>e.included).map(e=>({id:`${e.objectType}:${e.objectId}`,statement:e.content,origin:e.origin,sourceName:e.sourceLabel})))}).catch(()=>void 0).finally(()=>{Ie(!0),Re(!1)}))},[e.turnId,Le,Fe]),ht=(0,Z.useCallback)(()=>{c==null||!u||Xe(!0)},[c,u]),gt=(0,Z.useCallback)(()=>{c==null||!u||(u(c),Xe(!1))},[c,u]),_t=(0,Z.useCallback)(()=>{Xe(!1)},[]);(0,Z.useLayoutEffect)(()=>{if(!A)return;let e=rt.current;if(!e)return;let t=()=>{let t=window.getComputedStyle(e),n=Number.parseFloat(t.lineHeight),r=Number.parseFloat(t.fontSize)||14,i=Number.isFinite(n)?n:r*1.625;nt(e.scrollHeight>i*10+1)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[A,ce,Ce]),(0,Z.useLayoutEffect)(()=>{et(!1)},[A,Ce]);let vt=p||!f;return(0,$.jsxs)(`article`,{className:K(`group/msg flex w-full min-w-0`,A?`justify-end`:`justify-start`,M&&`xopc-chat-user-message-enter`),children:[(0,$.jsxs)(`div`,{className:K(`min-w-0`,A?`flex w-full max-w-[min(78%,var(--max-width-chat-user))] flex-col items-end`:`w-full max-w-[var(--max-width-chat-reading)]`,v&&`max-w-full`),children:[(0,$.jsx)(`span`,{className:`sr-only`,children:U}),A&&ge?(0,$.jsxs)(`div`,{className:`mb-2 flex w-full min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-0.5 text-xs`,children:[fe?.message&&!de?(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:fe.detail??``,children:fe.message}):null,a&&!de&&!pe&&!fe?.message?(0,$.jsx)(`span`,{className:`text-fg-subtle`,children:D.chat.thinkingLabel}):null]}):null,!A&&ge?(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs text-fg-disabled`,children:[fe?.message&&!de?(0,$.jsx)(`span`,{className:`text-fg-subtle`,title:fe.detail??``,children:fe.message}):null,a&&!de&&!pe&&!fe?.message?(0,$.jsx)(`span`,{className:`text-fg-subtle`,children:D.chat.thinkingLabel}):null]}):null,(0,$.jsx)(`div`,{dir:A?`auto`:void 0,className:K(`min-w-0 text-fg`,A&&`chat-user-message`,y===`compact`?`text-sm leading-relaxed`:A?`text-[0.9375rem] leading-[1.6667]`:`text-base leading-[1.6875]`,A&&`w-fit max-w-full rounded-2xl bg-surface-hover/80 px-4 py-3 text-left dark:bg-surface-hover/50`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[se?.workLog.items.length?(0,$.jsx)(hN,{workLog:se.workLog,toolLabels:ne,stepLabels:re,clusterLabels:ie,cardLabels:ae,conversationId:n,workflowOptions:{labels:kN(E)}}):null,(ce?.length??0)>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:A?rt:void 0,"data-chat-find-text":!0,className:K(`min-w-0`,A&&`flex flex-col gap-2`,A&&!$e&&`overflow-hidden`),style:A&&!$e?{maxHeight:`calc(10lh)`}:void 0,children:(0,$.jsx)(Ck,{content:ce,isUser:A,isAssistantMessageStreaming:j&&a,imagePreviewLabel:D.chat.attachmentPreviewImage,onImagePreview:it,conversationId:n,workspaceConversationId:r,projectId:i,progressiveRender:!!e.progressiveRender,onProgressiveRenderComplete:at,userTurnDocument:e.userTurnDocument,contextRefs:e.contextRefs})}),A&&tt?(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex w-fit items-center gap-1 rounded-md px-1.5 py-1 text-xs font-medium text-accent transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>et(e=>!e),"aria-expanded":$e,children:[$e?(0,$.jsx)(ur,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(cr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:$e?D.chat.userMessageCollapse:D.chat.userMessageExpand})]}):null,me?(0,$.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent align-middle`}):null]}):me?(0,$.jsx)(`span`,{className:`inline-block h-3 w-0.5 animate-pulse bg-accent`}):null,se?(0,$.jsx)(xI,{view:se,authToken:t,conversationId:r??n,projectId:i,sourcesLabel:D.chat.searchSourcesHeading.replace(`{{count}}`,String(se.sources.length))}):null,A&&ue?.length?(0,$.jsx)(CI,{refs:ue,groupLabel:D.chat.commandPalette.contextLabel,noteLabel:D.chat.commandPalette.notesSection,fileLabel:D.chat.atMention.files,folderLabel:D.chat.atMention.folders,sessionLabel:D.chat.atMention.chats,browserTabLabel:D.chat.atMention.browserTabs,mcpResourceLabel:D.chat.atMention.mcpResources,truncatedLabel:D.chat.commandPalette.contextTruncated,showMoreLabel:D.chat.contextReferencesMore,showLessLabel:D.chat.contextReferencesLess,onOpen:e=>ee(e.sourceId)}):null,A&&le?.length?(0,$.jsx)(fO,{attachments:le,authToken:t,conversationId:n,workspaceConversationId:r,layout:`user`,centerUserVoiceRow:Ce.length===0}):null]})}),W?(0,$.jsxs)(`div`,{"data-delivery-status":G,role:I?`alert`:`status`,"aria-live":`polite`,"aria-hidden":z&&!I?!0:void 0,className:K(`mt-1 flex min-h-5 items-center justify-end gap-1.5 pe-1 text-xs transition-opacity duration-[120ms] ease-out motion-reduce:transition-none`,I?`text-danger`:`text-fg-subtle`,z&&!I&&`opacity-0`),children:[I?(0,$.jsx)(dr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}):null,(0,$.jsx)(`span`,{children:I?D.chat.userMessageSendFailed:V&&P?D.chat.userMessageWaitingForNetwork:D.chat.userMessageSending}),I&&d&&c!=null?(0,$.jsx)(`button`,{type:`button`,className:`rounded-md px-1.5 py-0.5 font-medium text-danger underline-offset-2 hover:bg-danger/10 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-danger/40`,onClick:()=>d(c),children:D.chat.userMessageRetry}):null]}):null,A&&!a&&!v?(0,$.jsx)(`div`,{className:`mt-1.5 flex h-8 w-full min-w-0 shrink-0 justify-end`,children:(0,$.jsxs)(`div`,{className:K(`flex h-full max-w-full items-center justify-end gap-0.5 sm:gap-2`,`pointer-events-none opacity-0 transition-opacity duration-150 ease-out`,`group-hover/msg:pointer-events-auto group-hover/msg:opacity-100`,`group-focus-within/msg:pointer-events-auto group-focus-within/msg:opacity-100`,`[@media(hover:none)_and_(pointer:coarse)]:pointer-events-auto [@media(hover:none)_and_(pointer:coarse)]:opacity-100`),children:[d&&c!=null&&e.deliveryStatus!==`failed`?(0,$.jsxs)(`button`,{type:`button`,className:K(NI,vt&&`opacity-40`),onClick:()=>d(c),disabled:vt,title:p?D.chat.userMessageActionsWait:f?D.chat.userMessageRetry:D.chat.userMessageRetryDisabledHint,"aria-label":D.chat.userMessageRetry,children:[(0,$.jsx)(Vi,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`max-w-[4.5rem] truncate sm:max-w-none`,children:D.chat.userMessageRetry})]}):null,(0,$.jsx)(`button`,{type:`button`,className:K(NI,`size-8 px-0`),onClick:()=>{if(C&&c!=null){C(e,c);return}NT(Ce,cv(e.attachments))},disabled:!Ce&&!e.attachments?.length&&!e.contextRefs?.length||!w,title:w?D.chat.userMessageEdit:D.chat.userMessageEditDisabledHint,"aria-label":D.chat.userMessageEdit,children:(0,$.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:K(NI,`size-8 px-0`),onClick:dt,disabled:!Ce,title:we===`user`?D.chat.messageCopied:D.chat.userMessageCopy,"aria-label":we===`user`?D.chat.messageCopied:D.chat.userMessageCopy,children:we===`user`?(0,$.jsx)(S,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}),u&&c!=null&&!p?(0,$.jsx)(`button`,{type:`button`,className:K(NI,`size-8 px-0 hover:text-red-500 dark:hover:text-red-400`),onClick:ht,title:D.chat.userMessageDelete,"aria-label":D.chat.userMessageDelete,children:(0,$.jsx)(pa,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0})}):null]})}):null,_e&&ve?(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 flex-wrap items-center gap-2 overflow-visible`,onPointerEnter:mt,onFocusCapture:mt,children:[(0,$.jsx)(`button`,{type:`button`,className:jI,onClick:ot,disabled:!ye,title:we===`plain`?D.chat.messageCopied:D.chat.messageCopyPlainText,"aria-label":we===`plain`?D.chat.messageCopied:D.chat.messageCopyPlainText,children:we===`plain`?(0,$.jsx)(S,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsx)(zP,{input:Se,labels:{read:D.chat.messageReadAloud,preparing:D.chat.messageReadAloudPreparing,pause:D.chat.messageReadAloudPause,resume:D.chat.messageReadAloudResume,retry:D.chat.messageReadAloudRetry}}),_&&e.turnId?(0,$.jsx)(`button`,{type:`button`,className:jI,onClick:Y,disabled:je,title:je?D.chat.messageForkCreating:D.chat.messageForkFromHere,"aria-label":je?D.chat.messageForkCreating:D.chat.messageForkFromHere,children:(0,$.jsx)(qr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,m?(0,$.jsx)(`button`,{type:`button`,className:jI,onClick:ct,disabled:ke!==null,title:De===`create-note`?D.chat.messageSavedToNote:D.chat.messageSaveToNote,"aria-label":De===`create-note`?D.chat.messageSavedToNote:D.chat.messageSaveToNote,children:De===`create-note`?(0,$.jsx)(S,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Lr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,T&&n&&e.timestamp?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:K(jI,Ne===`helpful`&&`bg-surface-active text-fg`),onClick:()=>ft(`helpful`),disabled:Le,title:D.chat.messageHelpful,"aria-label":D.chat.messageHelpful,"aria-pressed":Ne===`helpful`,children:(0,$.jsx)(da,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:K(jI,Ne===`not_helpful`&&`bg-surface-active text-fg`),onClick:()=>He(e=>!e),disabled:Le,title:D.chat.messageNotHelpful,"aria-label":D.chat.messageNotHelpful,"aria-pressed":Ne===`not_helpful`,children:(0,$.jsx)(ua,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),ze?(0,$.jsx)(`span`,{className:`text-xs text-danger`,role:`status`,children:D.chat.messageFeedbackUnavailable}):null]}):null,(0,$.jsxs)(hn,{children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:jI,title:D.chat.messageMoreActions,"aria-label":D.chat.messageMoreActions,children:(0,$.jsx)(F,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-56 rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,children:[(0,$.jsx)(_n,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:st,children:[we===`markdown`?(0,$.jsx)(S,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(Pr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),we===`markdown`?D.chat.messageCopied:D.chat.messageCopyMarkdown]})}),Ge.length>0?(0,$.jsx)(_n,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>Je(e=>!e),children:[(0,$.jsx)(_r,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),D.chat.messageWhyThisAnswer]})}):null,h?(0,$.jsx)(_n,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:lt,disabled:!ve||ke!==null,children:[De===`save-source-note`?(0,$.jsx)(S,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(zr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),De===`save-source-note`?D.chat.messageSavedToSourceNote:D.chat.messageSaveToSourceNote]})}):null,g?(0,$.jsx)(_n,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-xs text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-40`,onClick:ut,disabled:!ye&&!ve||ke!==null,children:[De===`extract-task`?(0,$.jsx)(S,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(oi,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),De===`extract-task`?D.chat.messageTaskExtracted:D.chat.messageExtractTask]})}):null]})})]})]}):null,_e&&Ge.length>0?(0,$.jsx)(EI,{open:qe,onOpenChange:Je,items:Ge,labels:{title:D.chat.messageWhyThisAnswer,hint:D.chat.messageWhyThisAnswerHint,close:D.chat.messageContextClose,itemsSummary:D.chat.messageContextItemsSummary,expandAll:D.chat.messageContextExpandAll,collapseAll:D.chat.messageContextCollapseAll,groupSummary:D.chat.messageContextGroupSummary,origins:D.chat.messageContextOrigins}}):null,_e&&Ve?(0,$.jsxs)(`div`,{className:`mt-2 w-full max-w-xl rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:D.chat.messageFeedbackReasonTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:D.chat.messageFeedbackReasonHint}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:MI.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,disabled:Le,onClick:()=>ft(`not_helpful`,e),children:D.chat.messageFeedbackReasons[e]},e))})]}):null,_e&&Ne===`not_helpful`&&Ue?(0,$.jsxs)(`button`,{type:`button`,className:`mt-2 inline-flex w-fit items-center gap-1.5 rounded-lg bg-accent-soft px-3 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80`,onClick:pt,children:[(0,$.jsx)(Vi,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),D.chat.messageFeedbackRepair]}):null]}),A&&u&&c!=null&&!v?(0,$.jsx)(uS,{open:Ye,title:D.chat.userMessageDeleteConfirmTitle,description:D.chat.userMessageDeleteConfirm,confirmLabel:D.chat.userMessageDeleteOk,cancelLabel:D.chat.userMessageDeleteCancel,destructive:!0,onConfirm:gt,onCancel:_t}):null,(0,$.jsx)(rD,{open:Ze!==null,attachment:Ze,authToken:t,conversationId:n,onClose:()=>Qe(null)})]})});function LI(e,t){return e.renderKey??`${e.timestamp??`n`}-${t}`}function RI(e){return e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``}var zI=1800*1e3;function BI(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function VI(e,t){return e?t?!BI(new Date(e),new Date(t))||e-t>=zI:!0:!1}function HI(e,t,n){let r=new Date(e),i=new Date(t),a=new Date(i);return a.setDate(i.getDate()-1),`${BI(r,i)?n===`zh`?`今天`:`Today`:BI(r,a)?n===`zh`?`昨天`:`Yesterday`:new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en`,{month:`short`,day:`numeric`,year:r.getFullYear()===i.getFullYear()?void 0:`numeric`}).format(r)} ${new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en`,{hour:`2-digit`,minute:`2-digit`}).format(r)}`}var UI=(0,Z.memo)(function(e){let t=(0,Q.c)(53),{messages:n,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,streaming:s,progress:c,reasoningLevel:l,registerListContentRef:u,onPickWelcomePrompt:d,welcomeSpotlight:f,onRetryWelcomeContext:p,onRefreshWelcomeExploration:m,onSelectWelcomeProject:h,welcomeOverlay:g,compactWelcome:_,onDeleteRound:v,onRetryUserMessageRound:y,deleteRoundDisabled:b,onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:C,onForkAssistantTurn:w,onEditUserMessage:T,editLatestUserOnly:E,editRequiresTurnId:D,responseFeedbackEnabled:O,trailingContent:k}=e,A=_===void 0?!1:_,j=E===void 0?!1:E,M=D===void 0?!1:D,N=Ee(WI),P;t[0]===N?P=t[1]:(P=xe(N),t[0]=N,t[1]=P);let F=P;if(n.length===0&&!s){if(g){let e;return t[2]===g?e=t[3]:(e=(0,$.jsx)(`div`,{className:`pb-1.5`,children:g}),t[2]=g,t[3]=e),e}if(d&&f){let e;return t[4]!==A||t[5]!==d||t[6]!==m||t[7]!==p||t[8]!==h||t[9]!==o||t[10]!==f?(e=(0,$.jsx)(`div`,{className:`pb-1.5`,children:(0,$.jsx)(ZD,{spotlight:f,projectId:o,onPickPrompt:d,onRetryContext:p,onRefreshExploration:m,onSelectProject:h,compact:A})}),t[4]=A,t[5]=d,t[6]=m,t[7]=p,t[8]=h,t[9]=o,t[10]=f,t[11]=e):e=t[11],e}let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`text-4xl`,"aria-hidden":!0,children:`🤖`}),t[12]=e):e=t[12];let n;t[13]===F.chat.welcomeTitle?n=t[14]:(n=(0,$.jsx)(`div`,{className:`text-xl font-semibold tracking-tight text-fg`,children:F.chat.welcomeTitle}),t[13]=F.chat.welcomeTitle,t[14]=n);let r;t[15]===F.chat.welcomeDescription?r=t[16]:(r=(0,$.jsx)(`div`,{className:`max-w-sm text-sm leading-relaxed text-fg-muted`,children:F.chat.welcomeDescription}),t[15]=F.chat.welcomeDescription,t[16]=r);let i;return t[17]!==n||t[18]!==r?(i=(0,$.jsx)(`div`,{className:`flex flex-col gap-10 pb-8`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-20 text-center`,children:[e,n,r]})}),t[17]=n,t[18]=r,t[19]=i):i=t[19],i}let I,L,R,z;if(t[20]!==r||t[21]!==i||t[22]!==b||t[23]!==j||t[24]!==M||t[25]!==N||t[26]!==n||t[27]!==v||t[28]!==T||t[29]!==C||t[30]!==w||t[31]!==y||t[32]!==x||t[33]!==S||t[34]!==c||t[35]!==o||t[36]!==l||t[37]!==u||t[38]!==O||t[39]!==s||t[40]!==a){let e=Date.now();I=EF,L=u,R=`flex w-full min-w-0 flex-col gap-8 pb-8`,z=n.map((t,u)=>{let d=u===n.length-1,f=!!(s&&d&&t.role===`assistant`),p=sv(n,u),m=LI(t,u),h=VI(t.timestamp,n[u-1]?.timestamp);return(0,$.jsxs)(`div`,{id:`chat-message-${u}`,className:`scroll-mt-4`,"data-chat-message-index":u,"data-chat-message-row":!0,"data-client-submission-id":t.clientSubmissionId,"data-message-render-key":t.renderKey,children:[h&&t.timestamp?(0,$.jsx)(`div`,{className:`mb-8 flex justify-center`,"data-chat-time-separator":!0,children:(0,$.jsx)(`time`,{suppressHydrationWarning:!0,className:`rounded-md px-2 py-1 text-xs tabular-nums text-fg-disabled`,dateTime:new Date(t.timestamp).toISOString(),children:HI(t.timestamp,e,N)})}):null,(0,$.jsx)(II,{message:t,authToken:r,conversationId:i,workspaceConversationId:a,projectId:o,isStreaming:f,progress:f?c:null,reasoningLevel:l,messageIndex:u,onDeleteRound:v,onRetryUserMessageRound:y,userMessageCanRetry:!!y&&p,deleteRoundDisabled:!!(b&&p),onSaveAssistantAsNote:x,onSaveAssistantToSourceNote:S,onExtractAssistantTask:C,onForkAssistantTurn:w,suppressAssistantActions:f,onEditUserMessage:T,userMessageCanEdit:(!j||p)&&(!M||!!t.turnId)&&t.deliveryStatus!==`sending`,responseFeedbackEnabled:O})]},m)}),t[20]=r,t[21]=i,t[22]=b,t[23]=j,t[24]=M,t[25]=N,t[26]=n,t[27]=v,t[28]=T,t[29]=C,t[30]=w,t[31]=y,t[32]=x,t[33]=S,t[34]=c,t[35]=o,t[36]=l,t[37]=u,t[38]=O,t[39]=s,t[40]=a,t[41]=I,t[42]=L,t[43]=R,t[44]=z}else I=t[41],L=t[42],R=t[43],z=t[44];let B;t[45]!==L||t[46]!==R||t[47]!==z||t[48]!==k?(B=(0,$.jsxs)(`div`,{ref:L,className:R,children:[z,k]}),t[45]=L,t[46]=R,t[47]=z,t[48]=k,t[49]=B):B=t[49];let V;return t[50]!==I||t[51]!==B?(V=(0,$.jsx)(I,{children:B}),t[50]=I,t[51]=B,t[52]=V):V=t[52],V});function WI(e){return e.language}function GI(e){let t=(0,Q.c)(8),{alt:n,className:r,"aria-hidden":i}=e,a=n?.trim()?n:void 0,o=i??(a?void 0:!0),s;t[0]===r?s=t[1]:(s=K(`xopc-loop-logo relative inline-block shrink-0`,r),t[0]=r,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`linearGradient`,{id:`xopc-onboarding-ai-glass`,x1:`198`,y1:`180`,x2:`826`,y2:`844`,gradientUnits:`userSpaceOnUse`,children:[(0,$.jsx)(`stop`,{stopColor:`var(--xopc-loop-ai-highlight)`}),(0,$.jsx)(`stop`,{offset:`0.46`,stopColor:`var(--xopc-loop-ai)`}),(0,$.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-ai-shadow)`})]}),t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(`svg`,{className:`size-full overflow-visible`,viewBox:`0 0 1024 1024`,fill:`none`,"aria-hidden":`true`,children:[(0,$.jsxs)(`defs`,{children:[c,(0,$.jsxs)(`linearGradient`,{id:`xopc-onboarding-human-glass`,x1:`340`,y1:`224`,x2:`700`,y2:`816`,gradientUnits:`userSpaceOnUse`,children:[(0,$.jsx)(`stop`,{stopColor:`var(--xopc-loop-human-highlight)`}),(0,$.jsx)(`stop`,{offset:`0.52`,stopColor:`var(--xopc-loop-human)`}),(0,$.jsx)(`stop`,{offset:`1`,stopColor:`var(--xopc-loop-human-shadow)`})]})]}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__ambient`,cx:`512`,cy:`512`,r:`330`}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__origin`,cx:`512`,cy:`512`,r:`330`}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__ai-glow`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__ai`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-ai-glass)`,strokeDasharray:`1419.162121 654.289030`,transform:`rotate(11.8 512 512)`}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__human`,cx:`512`,cy:`512`,r:`330`,stroke:`url(#xopc-onboarding-human-glass)`,strokeDasharray:`354.790530 1718.660621`,transform:`rotate(284.2 512 512)`}),(0,$.jsx)(`circle`,{className:`xopc-loop-logo__liquid-front`,cx:`512`,cy:`512`,r:`330`,strokeDasharray:`58 2015.451151`,transform:`rotate(11.8 512 512)`})]}),t[3]=l):l=t[3];let u;return t[4]!==o||t[5]!==a||t[6]!==s?(u=(0,$.jsx)(`span`,{className:s,role:`img`,"aria-hidden":o,"aria-label":a,children:l}),t[4]=o,t[5]=a,t[6]=s,t[7]=u):u=t[7],u}var KI=(0,Z.memo)(function(e){let t=(0,Q.c)(19),{visible:n,onClick:r,edge:i,running:a}=e,o=i===void 0?`top`:i,s=a===void 0?!1:a,c=Ee(qI),l;t[0]===c?l=t[1]:(l=xe(c),t[0]=c,t[1]=l);let u=l,d=!n,f=o===`top`?`-top-2 -translate-y-full`:`bottom-2`,p=n?`opacity-100`:`opacity-0`,m;t[2]!==f||t[3]!==p?(m=K(`pointer-events-none absolute inset-x-0 z-20 flex items-center justify-center transition-opacity duration-150 ease-out motion-reduce:transition-none`,f,p),t[2]=f,t[3]=p,t[4]=m):m=t[4];let h=n?`scale-100 opacity-100`:`pointer-events-none translate-y-1 scale-95 opacity-0`,g;t[5]===h?g=t[6]:(g=K(`group relative pointer-events-auto flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-full border border-edge-subtle bg-surface-panel text-fg-muted shadow-surface`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel,h,`motion-reduce:translate-y-0 motion-reduce:scale-100`),t[5]=h,t[6]=g);let _=n?void 0:-1,v;t[7]===s?v=t[8]:(v=s?(0,$.jsx)(`span`,{"data-scroll-to-bottom-running-logo":!0,className:`flex size-5 items-center justify-center`,"aria-hidden":!0,children:(0,$.jsx)(GI,{className:`xopc-loop-logo--stream size-5`})}):(0,$.jsx)(qn,{"data-scroll-to-bottom-arrow":!0,className:`size-4 transition-transform duration-150 ease-out group-hover:translate-y-0.5 motion-reduce:transition-none`,strokeWidth:1.8,"aria-hidden":!0}),t[7]=s,t[8]=v);let y;t[9]!==u.chat.scrollToBottom||t[10]!==r||t[11]!==_||t[12]!==v||t[13]!==g?(y=(0,$.jsx)(`button`,{type:`button`,className:g,tabIndex:_,onClick:r,title:u.chat.scrollToBottom,"aria-label":u.chat.scrollToBottom,children:v}),t[9]=u.chat.scrollToBottom,t[10]=r,t[11]=_,t[12]=v,t[13]=g,t[14]=y):y=t[14];let b;return t[15]!==y||t[16]!==d||t[17]!==m?(b=(0,$.jsx)(`div`,{"data-scroll-to-bottom-dock":!0,"aria-hidden":d,className:m,children:y}),t[15]=y,t[16]=d,t[17]=m,t[18]=b):b=t[18],b});function qI(e){return e.language}function JI(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function YI(e,t=48){return JI(e)<=t}function XI(e){e.scrollTop=e.scrollHeight}function ZI(e){return e.webkitDirectionInvertedFromDevice===!0?e.deltaY>0:e.deltaY<0}function QI(e){let t=(0,Q.c)(42),{hasToken:n,showSessionLoading:r,conversationId:i,chatMessages:a,hasMore:o,loadingMore:s,loadMoreMessages:c}=e,l=(0,Z.useRef)(null),u=(0,Z.useRef)(null),d=(0,Z.useRef)(!0),f=(0,Z.useRef)(null),[p,m]=(0,Z.useState)(!0),h=(0,Z.useRef)(!0),g=(0,Z.useRef)(0),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_={first:void 0,len:0,scrollHeight:0},t[0]=_):_=t[0];let v=(0,Z.useRef)(_),y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{d.current=e},t[1]=y):y=t[1];let b=y,x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{let t=l.current;if(t&&!(!e?.force&&!d.current)){if(e?.force&&b(!0),e?.smooth){t.scrollTo({top:t.scrollHeight,behavior:`smooth`});return}XI(t),m(YI(t))}},t[2]=x):x=t[2];let S=x,C;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{let e=l.current;!e||e.scrollHeight<=e.clientHeight||(b(!1),m(YI(e)))},t[3]=C):C=t[3];let w=C,T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{S();let e=l.current;e&&m(YI(e))},t[4]=T):T=t[4];let E=T,D;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{if(u.current===e||(f.current?.disconnect(),f.current=null,u.current=e,!e))return;let t=new ResizeObserver(E);t.observe(e),f.current=t},t[5]=D):D=t[5];let O=D,k,A;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(k=()=>()=>{f.current?.disconnect()},A=[],t[6]=k,t[7]=A):(k=t[6],A=t[7]),(0,Z.useEffect)(k,A);let j;t[8]!==o||t[9]!==c||t[10]!==s?(j=()=>{let e=l.current;if(!e)return;let t=YI(e);b(t),m(t),e.scrollTop<100&&!t&&o&&!s&&c()},t[8]=o,t[9]=c,t[10]=s,t[11]=j):j=t[11];let M=j,N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{S({force:!0,smooth:e===void 0?!0:e})},t[12]=N):N=t[12];let P=N,F,I;t[13]!==n||t[14]!==r?(F=()=>{if(n){if(r){h.current=!0;return}h.current===!0&&(h.current=!1,b(!0),S({force:!0}))}},I=[r,n,b,S],t[13]=n,t[14]=r,t[15]=F,t[16]=I):(F=t[15],I=t[16]),(0,Z.useLayoutEffect)(F,I);let L;t[17]!==n||t[18]!==r?(L=()=>{!n||r||(v.current={first:void 0,len:0,scrollHeight:0},g.current=0,b(!0),S({force:!0}))},t[17]=n,t[18]=r,t[19]=L):L=t[19];let R;t[20]!==i||t[21]!==n||t[22]!==r?(R=[i,n,r,b,S],t[20]=i,t[21]=n,t[22]=r,t[23]=R):R=t[23],(0,Z.useLayoutEffect)(L,R);let z,B;t[24]!==a.length||t[25]!==r?(z=()=>{if(r)return;let e=a.length,t=g.current;g.current=e,e>t&&d.current&&S()},B=[a.length,r,S],t[24]=a.length,t[25]=r,t[26]=z,t[27]=B):(z=t[26],B=t[27]),(0,Z.useLayoutEffect)(z,B);let V;t[28]!==a[0]||t[29]!==a.length||t[30]!==r?(V=()=>{let e=l.current;if(!e||r)return;let t=v.current,n=a[0],i=a.length,o=e.scrollHeight;i>t.len&&t.len>0&&n!==void 0&&n!==t.first&&t.scrollHeight>0&&(e.scrollTop+=o-t.scrollHeight),v.current={first:n,len:i,scrollHeight:o}},t[28]=a[0],t[29]=a.length,t[30]=r,t[31]=V):V=t[31];let H;t[32]!==a||t[33]!==r?(H=[a,r],t[32]=a,t[33]=r,t[34]=H):H=t[34],(0,Z.useLayoutEffect)(V,H);let U,W;t[35]!==n||t[36]!==r?(U=()=>{if(!n||r)return;let e=l.current;if(!e)return;let t=new ResizeObserver(E);t.observe(e);let i=e=>{Math.abs(e.deltaY)<Math.abs(e.deltaX)||Math.abs(e.deltaY)<.25||ZI(e)&&w()},a=0,o=e=>{e.touches.length===1&&(a=e.touches[0].clientY)},s=e=>{if(e.touches.length!==1)return;let t=e.touches[0].clientY,n=t-a;a=t,n>2&&w()},c=t=>{if(t.button!==0)return;let n=e.offsetWidth-e.clientWidth;if(n<=0)return;let r=e.getBoundingClientRect();t.clientX>=r.right-n&&w()};return e.addEventListener(`wheel`,i,{passive:!0}),e.addEventListener(`pointerdown`,c),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,s,{passive:!0}),()=>{t.disconnect(),e.removeEventListener(`wheel`,i),e.removeEventListener(`pointerdown`,c),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,s)}},W=[n,r,w,E],t[35]=n,t[36]=r,t[37]=U,t[38]=W):(U=t[37],W=t[38]),(0,Z.useLayoutEffect)(U,W);let G;return t[39]!==p||t[40]!==M?(G={scrollRef:l,atBottom:p,registerListContentRef:O,scrollToBottom:P,onScroll:M},t[39]=p,t[40]=M,t[41]=G):G=t[41],G}var $I=256*1024,eL=new TextEncoder;function tL(e){return eL.encode(e).byteLength}function nL(e){return tL(e)<=262144?e:new TextDecoder().decode(eL.encode(e).subarray(0,$I),{stream:!0})}function rL(e){let t=512*1024,n=e.length>20,r=[];for(let i of e.slice(-20).reverse()){let e=i.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
100
- `);if((i.content.some(e=>e.type!==`text`)||i.attachments?.length)&&(n=!0),!e)continue;if(t<=256){n=!0;continue}let a=eL.encode(e),o=a.byteLength+256>t?new TextDecoder().decode(a.subarray(0,t-256),{stream:!0}):e;o!==e&&(n=!0);let s=tL(o)+256;t-=s,r.unshift({role:i.role,content:[{type:`text`,text:o}],timestamp:i.timestamp,renderKey:i.renderKey?.slice(0,128)})}return{messages:r,truncated:n,bytes:512*1024-t}}var iL=`xopc:side-chat-panes:v3`,aL={text:``,attachments:[]};function oL(e){return Math.min(760,Math.max(360,Math.round(e)))}function sL(){return{panes:{},tabs:[],widthPx:520}}function cL(){try{let e=JSON.parse(sessionStorage.getItem(iL)||`{}`),t=Array.isArray(e.tabs)?e.tabs.filter(e=>!!(e?.id&&e.parentConversationId)):[],n=e.panes&&typeof e.panes==`object`?e.panes:{},r=Object.fromEntries(Object.entries(n).map(([e,n])=>{let r=t.filter(t=>t.parentConversationId===e),i=typeof n?.activeId==`string`&&r.some(e=>e.id===n.activeId)?n.activeId:r.at(-1)?.id??null;return[e,{open:n?.open===!0&&r.length>0,activeId:i}]}));for(let e of t)r[e.parentConversationId]??={open:!1,activeId:e.id};return{panes:r,tabs:t,widthPx:oL(typeof e.widthPx==`number`?e.widthPx:520)}}catch{return sL()}}function lL(e){try{sessionStorage.setItem(iL,JSON.stringify(e))}catch{}}var uL=cL(),dL=Oe((e,t)=>{let n=n=>{e(n),queueMicrotask(()=>{let e=t();lL({panes:e.panes,tabs:e.tabs,widthPx:e.widthPx})})},r=(e,r)=>{let i=t().panes[e]??{open:!1,activeId:null};n({panes:{...t().panes,[e]:{...i,...r}}})};return{...uL,drafts:{},readings:{},setDraftText:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??aL,text:r}}}),setDraftAttachments:(n,r)=>e({drafts:{...t().drafts,[n]:{...t().drafts[n]??aL,attachments:r}}}),rememberMessages:(n,r)=>{let i={...t().readings};delete i[n],i[n]=rL(r),i[n].truncated||=t().readings[n]?.truncated??!1;let a=Object.values(i).reduce((e,t)=>e+t.bytes,0);for(;Object.keys(i).length>5||a>2097152;){let e=Object.keys(i)[0];a-=i[e].bytes,delete i[e]}e({readings:i})},markEnded:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,ended:r,runId:void 0}:t)}),markPromoted:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,ended:`promoted`,promotedConversationId:r,runId:void 0}:t)}),replaceTab:(r,i)=>{let a=t();if(!a.tabs.some(e=>e.id===r))return;let o={...a.drafts,[i.id]:a.drafts[r]??aL},s={...a.readings};delete o[r],delete s[r],e({drafts:o,readings:s}),n({tabs:a.tabs.map(e=>e.id===r?{...i,fresh:!0}:e),panes:{...a.panes,[i.parentConversationId]:{open:a.panes[i.parentConversationId]?.open??!1,activeId:a.panes[i.parentConversationId]?.activeId===r?i.id:a.panes[i.parentConversationId]?.activeId??i.id}}})},reset:()=>{e({drafts:{},readings:{},pendingCreate:null}),n({panes:{},tabs:[]})},pendingCreate:null,requestCreate:(t,n=[])=>{e({pendingCreate:{requestId:crypto.randomUUID(),parentConversationId:t,selections:n}}),r(t,{open:!0})},claimPendingCreate:(n,r)=>{let i=t().pendingCreate;return!i||i.parentConversationId!==n||i.requestId!==r?null:(e({pendingCreate:null}),i)},addTab:e=>{let r=[...t().tabs.filter(t=>t.id!==e.id),e],i=t().panes[e.parentConversationId]??{open:!1,activeId:null};n({tabs:r,panes:{...t().panes,[e.parentConversationId]:{...i,activeId:e.id,open:!0}}})},removeTab:r=>{let i=t().tabs.find(e=>e.id===r);if(!i)return;let a={...t().drafts},o={...t().readings};delete a[r],delete o[r],e({drafts:a,readings:o});let s=t().tabs.filter(e=>e.id!==r),c=s.filter(e=>e.parentConversationId===i.parentConversationId),l=t().panes[i.parentConversationId]??{open:!1,activeId:null},u=l.activeId===r?c.at(-1)?.id??null:l.activeId;n({tabs:s,panes:{...t().panes,[i.parentConversationId]:{open:c.length>0&&l.open,activeId:u}}})},setActive:e=>{let n=t().tabs.find(t=>t.id===e);n&&r(n.parentConversationId,{activeId:e,open:!0})},setTabRunId:(e,r)=>n({tabs:t().tabs.map(t=>t.id===e?{...t,runId:r}:t)}),setOpen:(e,t)=>r(e,{open:t}),setWidthPx:e=>n({widthPx:oL(e)})}});Se.subscribe((e,t)=>{if(e.baseUrl!==t.baseUrl||t.conversationId!==void 0&&e.conversationId!==t.conversationId){dL.getState().reset();try{sessionStorage.removeItem(`xopc:side-chat-client-id`)}catch{}}});function fL(e,t){return LN(e,t)}function pL(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 mL(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:`HTTP ${e.status}`}async function hL(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&&Se.getState().onUnauthorized(),!i.ok)throw Error(await mL(i));return i.json()}function gL(e){let t=(0,Q.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=RN(s,r),t[8]=r,t[9]=s,t[10]=u):u=t[10];let d=u,[f,p]=(0,Z.useState)(d?null:s),[m,h]=(0,Z.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),GN(d.noteId,d.attachmentId).then(t=>{e||p(t)}).catch(()=>{e||(h(!0),a?.())}),()=>{e=!0,KN(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,Z.useEffect)(g,_),m){let e;t[16]===n?e=t[17]:(e=K(`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,$.jsx)(Qr,{className:`size-5`}),t[18]=i):i=t[18];let a;return t[19]!==e||t[20]!==r?(a=(0,$.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=K(`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,$.jsx)(`div`,{className:e,"aria-hidden":r}),t[24]=e,t[25]=r,t[26]=i):i=t[26],i}let v;t[27]!==f||t[28]!==i?(v=i?()=>i(f):void 0,t[27]=f,t[28]=i,t[29]=v):v=t[29];let y;t[30]===a?y=t[31]:(y=()=>{h(!0),a?.()},t[30]=a,t[31]=y);let b;return t[32]!==l||t[33]!==n||t[34]!==f||t[35]!==o||t[36]!==v||t[37]!==y?(b=(0,$.jsx)(`img`,{...o,src:f,alt:l,className:n,onClick:v,onError:y}),t[32]=l,t[33]=n,t[34]=f,t[35]=o,t[36]=v,t[37]=y,t[38]=b):b=t[38],b}function _L(e){return e.replace(/xopc-attachment:\/\/notes\/([^/]+)\/([^)\s]+)/gi,`/api/notes/$1/media/$2`)}function vL(e,t){let n=[];return e.querySelectorAll(`.markdown-body img`).forEach(e=>{let r=RN(e.getAttribute(`src`)??``,t);if(!r)return;let i=!1;GN(r.noteId,r.attachmentId).then(t=>{i||(e.src=t)}).catch(()=>{e.classList.add(`note-media-load-failed`)}),n.push(()=>{i=!0,KN(r.noteId,r.attachmentId)})}),e.querySelectorAll(`.markdown-body a`).forEach(e=>{let r=RN(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;GN(r.noteId,r.attachmentId).then(e=>{a||(i.src=e)}).catch(()=>{i.remove()}),n.push(()=>{a=!0,KN(r.noteId,r.attachmentId)})}),()=>{for(let e of n)e()}}function yL(e){let t=(0,Q.c)(17),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,Z.useRef)(null),o;t[4]===r?o=t[5]:(o=()=>{let e=a.current;if(e)return vL(e,r)},t[4]=r,t[5]=o);let s;t[6]!==n||t[7]!==r?(s=[n,r],t[6]=n,t[7]=r,t[8]=s):s=t[8],(0,Z.useLayoutEffect)(o,s);let c;t[9]===n?c=t[10]:(c=_L(n),t[9]=n,t[10]=c);let l;t[11]===i.className?l=t[12]:(l=[`markdown-note`,i.className].filter(Boolean),t[11]=i.className,t[12]=l);let u=l.join(` `),d;return t[13]!==i||t[14]!==c||t[15]!==u?(d=(0,$.jsx)(`div`,{ref:a,children:(0,$.jsx)(ie,{content:c,mermaidActions:!0,...i,className:u})}),t[13]=i,t[14]=c,t[15]=u,t[16]=d):d=t[16],d}async function bL(){return q(J(`/api/notes/project-summaries`))}async function xL(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 q(J(`/api/notes${n?`?${n}`:``}`))}async function SL(e,t=`web`){return(await q(J(`/api/notes/quick-capture`),{method:`POST`,body:JSON.stringify({text:e,channel:t})})).note}async function CL(e,t){return(await q(J(`/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 wL(e){let t=await we(J(`/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 TL(e,t){return(await q(J(`/api/notes/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})).note}async function EL(e){await q(J(`/api/notes/${encodeURIComponent(e)}`),{method:`DELETE`})}async function DL(e){return q(J(`/api/notes/${encodeURIComponent(e)}/shares`))}async function OL(e,t){return q(J(`/api/notes/${encodeURIComponent(e)}/shares`),{method:`POST`,body:JSON.stringify(t)})}async function kL(e,t,n){await q(J(`/api/notes/${encodeURIComponent(e)}/shares/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})}async function AL(e){return(await q(J(`/api/notes/${encodeURIComponent(e)}/hosted-publications`))).payload.publications}async function jL(e,t){return(await q(J(`/api/notes/${encodeURIComponent(e)}/hosted-publications`),{method:`POST`,body:JSON.stringify(t)})).payload}async function ML(e,t,n){return(await q(J(`/api/notes/${encodeURIComponent(e)}/hosted-publications/${encodeURIComponent(t)}/refresh`),{method:`POST`,body:JSON.stringify(n)})).payload}async function NL(e){return q(J(`/api/notes/${encodeURIComponent(e)}/catalyze`),{method:`POST`})}async function PL(e,t){return(await q(J(`/api/notes/${encodeURIComponent(e)}/catalysis-feedback`),{method:`POST`,body:JSON.stringify({feedback:t})})).note}async function FL(e,t={}){return q(J(`/api/notes/${encodeURIComponent(e)}/chat`),{method:`POST`,body:JSON.stringify(t)})}async function IL(e){return(await q(J(`/api/notes/${encodeURIComponent(e)}/threads`))).items}async function LL(e){return q(J(`/api/notes/${encodeURIComponent(e)}/context-status`))}async function RL(e){return q(J(`/api/notes/${encodeURIComponent(e)}/context-rebuild`),{method:`POST`})}async function zL(e,t,n){return(await q(J(`/api/notes/${encodeURIComponent(e)}/append`),{method:`POST`,body:JSON.stringify({content:t,heading:n})})).note}async function BL(e,t={}){return(await q(J(`/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 VL(e,t,n){let r=new FormData;return r.append(`file`,t),(await hL(J(`/api/notes/${encodeURIComponent(e)}/media`),r,n)).attachment}async function HL(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 hL(J(`/api/notes`),n)).note}async function UL(e,t=`web`){let n=await HL(e,{channel:t}),r=n.attachments?.find(e=>e.type===`image`)??n.attachments?.[0];if(!r)return n;let i=`![${r.fileName}](${fL(n.id,r.id)})`;return n.markdown!==i&&(n=await TL(n.id,{markdown:i})),n}async function WL(e,t,n=`web`){let r=await HL(e,{channel:n,kind:`voice`,duration:t}),i=r.attachments?.find(e=>e.type===`audio`)??r.attachments?.[0];if(!i)return r;let a=`[${pL(t)}](${fL(r.id,i.id)})`;return r.markdown!==a&&(r=await TL(r.id,{markdown:a,kind:`voice`})),r}async function GL(e){return(await q(J(`/api/notes/${encodeURIComponent(e)}/history`))).entries}async function KL(e,t){return(await q(J(`/api/notes/${encodeURIComponent(e)}/history/${t}`))).snapshot}async function qL(e,t){return(await q(J(`/api/notes/${encodeURIComponent(e)}/history/restore`),{method:`POST`,body:JSON.stringify({timestamp:t})})).note}var JL=`xopc:side-chat-client-id`;function YL(){let e=sessionStorage.getItem(JL);if(e)return e;let t=crypto.randomUUID();return sessionStorage.setItem(JL,t),t}function XL(){return{"x-xopc-client-instance-id":YL()}}async function ZL(e,t){return(await q(J(`/api/sessions/${encodeURIComponent(e)}/side-chats`),{method:`POST`,headers:XL(),body:JSON.stringify({clientInstanceId:YL(),selections:t})})).sideChat}async function QL(e){return(await q(J(`/api/side-chats/${e}`),{headers:XL()})).sideChat}async function $L(e){return(await q(J(`/api/side-chats/${e}/messages`),{headers:XL()})).messages}async function eR(e,t){return(await q(J(`/api/side-chats/${e}/config`),{method:`PATCH`,headers:XL(),body:JSON.stringify(t)})).sideChat}async function tR(e,t,n){return(await q(J(`/api/side-chats/${e}/inputs`),{method:`POST`,headers:XL(),body:JSON.stringify({content:t,attachments:n})})).payload.runId}async function nR(e,t){await q(J(`/api/side-chats/${e}/abort`),{method:`POST`,headers:XL(),body:JSON.stringify({runId:t})})}async function rR(e,t,n){await q(J(`/api/side-chats/${e}/clarify/${t}`),{method:`POST`,headers:XL(),body:JSON.stringify({answer:n})})}async function iR(e){await q(J(`/api/side-chats/${e}`),{method:`DELETE`,headers:XL()})}async function aR(e){return(await q(J(`/api/side-chats/${e}/heartbeat`),{method:`POST`,headers:XL()})).sideChat}async function oR(e){return(await q(J(`/api/side-chats/${e}/extend`),{method:`POST`,headers:XL()})).sideChat}async function sR(e){return q(J(`/api/side-chats/${e}/promote`),{method:`POST`,headers:XL()})}var cR=`xopc:side-chat-close-confirm-disabled:v1`,lR=()=>{},uR=[];function dR(){try{return localStorage.getItem(cR)===`true`}catch{return!1}}function fR(){try{localStorage.setItem(cR,`true`)}catch{}}function pR(e){return e.role===`user`?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
101
- `).trim():``}function mR(e){return(e.attachments??[]).map(e=>e.name??``).filter(Boolean).join(`
102
- `)}function hR(e,t){let n=e?.body?.code;return n===`INVALID_REQUEST`?t.errorInvalidRequest:n===`NOT_FOUND`?t.errorNotFound:n===`CONFLICT`?t.errorConflict:n===`LIMIT_REACHED`?t.errorLimitReached:n===`CAPACITY_REACHED`?t.errorCapacity:n===`PARENT_NOT_FOUND`?t.parentMissing:n===`INTERNAL_ERROR`?t.failed:e instanceof Error?e.message:String(e)}function gR(e,t){let n=[...e];for(let[e,r]of t){let i=pR(r),a=mR(r),o=r.timestamp??0;if(n.some(e=>e.role===`user`&&pR(e)===i&&mR(e)===a&&Math.abs((e.timestamp??o)-o)<6e4)){t.delete(e);continue}let s=n.findIndex(e=>(e.timestamp??1/0)>o);s<0?n.push(r):n.splice(s,0,r)}return n}function _R(e){let t=(0,Q.c)(123),{parentConversationId:n}=e,r=Ee(MR),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i.sideChat,o;t[2]===n?o=t[3]:(o=e=>e.panes[n]?.open===!0,t[2]=n,t[3]=o);let s=dL(o),c=dL(jR),l;if(t[4]!==c||t[5]!==n){let e;t[7]===n?e=t[8]:(e=e=>e.parentConversationId===n,t[7]=n,t[8]=e),l=c.filter(e),t[4]=c,t[5]=n,t[6]=l}else l=t[6];let u=l,d;t[9]===n?d=t[10]:(d=e=>e.panes[n]?.activeId??null,t[9]=n,t[10]=d);let f=dL(d),p=dL(AR),m=dL(kR),h=dL(OR),g=dL(DR),_=dL(ER),v=dL(TR),y=dL(wR),b=dL(CR),x=dL(SR),S=dL(xR),C=Se(bR),w;t[11]!==f||t[12]!==u?(w=u.find(e=>e.id===f)??null,t[11]=f,t[12]=u,t[13]=w):w=t[13];let T=w,[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(!1),I,L;t[14]!==g||t[15]!==h||t[16]!==a||t[17]!==n||t[18]!==p?(I=()=>{if(!p||p.parentConversationId!==n)return;let e=h(n,p.requestId);if(!e)return;D(!0),k(null);let t=Se.getState();ZL(e.parentConversationId,e.selections).then(e=>{Se.getState().conversationId!==t.conversationId||Se.getState().baseUrl!==t.baseUrl||g({id:e.id,parentConversationId:e.parentConversationId,title:`Side chat`})}).catch(e=>{k(hR(e,a))}).finally(()=>{D(!1)})},L=[g,h,a,n,p],t[14]=g,t[15]=h,t[16]=a,t[17]=n,t[18]=p,t[19]=I,t[20]=L):(I=t[19],L=t[20]),(0,Z.useEffect)(I,L);let R;t[21]===_?R=t[22]:(R=e=>{let t=dL.getState().tabs.find(t=>t.id===e)?.promotedConversationId;_(e),t||iR(e).catch(yR)},t[21]=_,t[22]=R);let z=R,B;t[23]===z?B=t[24]:(B=e=>{let t=dL.getState(),n=t.tabs.find(t=>t.id===e),r=t.readings[e],i=t.drafts[e];if(n?.promotedConversationId){z(e);return}if(r&&!r.messages.length&&!r.truncated&&!i?.text.trim()&&!i?.attachments.length&&!n?.runId||dR()){z(e);return}F(!1),N(e)},t[23]=z,t[24]=B);let V=B,H;t[25]===x?H=t[26]:(H=e=>{e.preventDefault();let t=e.clientX,n=dL.getState().widthPx,r=e.pointerId;e.currentTarget.setPointerCapture(r),j(!0);let i=e=>{let r=Math.min(760,Math.max(360,n+t-e.clientX));document.getElementById(`app-side-chat-panel`)?.style.setProperty(`--side-chat-panel-px`,`${r}px`)},a=e=>{x(Math.min(760,Math.max(360,n+t-e.clientX))),j(!1),window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},t[25]=x,t[26]=H);let U=H;if(!s)return null;let W=a.paneAria,G=A&&`side-chat-panel-resizing`,ee;t[27]===G?ee=t[28]:(ee=K(`relative flex min-h-0 shrink-0 flex-col overflow-hidden border-l border-edge bg-surface-base`,`max-md:fixed max-md:inset-y-0 max-md:right-0 max-md:z-50 max-md:w-[min(92vw,34rem)] max-md:shadow-popover`,`app-side-chat-expanded-width app-side-chat-panel-enter`,G),t[27]=G,t[28]=ee);let te=`${b}px`,ne;t[29]===te?ne=t[30]:(ne={"--side-chat-panel-px":te},t[29]=te,t[30]=ne);let re=ne,ie;t[31]!==a.resizeAria||t[32]!==U?(ie=(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":a.resizeAria,onPointerDown:U,className:`absolute left-0 top-0 z-20 hidden h-full w-2 cursor-col-resize touch-none md:block`}),t[31]=a.resizeAria,t[32]=U,t[33]=ie):ie=t[33];let ae;if(t[34]!==f||t[35]!==a.closeAria||t[36]!==a.endedLabel||t[37]!==a.savedLabel||t[38]!==a.title||t[39]!==V||t[40]!==v||t[41]!==u){let e;t[43]!==f||t[44]!==a.closeAria||t[45]!==a.endedLabel||t[46]!==a.savedLabel||t[47]!==a.title||t[48]!==V||t[49]!==v?(e=e=>(0,$.jsxs)(`div`,{className:K(`flex h-8 shrink-0 items-center rounded-lg pl-3 text-sm`,e.id===f?`bg-surface-hover text-fg`:`text-fg-muted`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`max-w-40 truncate`,onClick:()=>v(e.id),children:[e.title===`Side chat`?a.title:e.title,e.ended?` · ${e.ended===`promoted`?a.savedLabel:a.endedLabel}`:``]}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-md hover:bg-surface-active`,"aria-label":a.closeAria,onClick:()=>V(e.id),children:(0,$.jsx)(ye,{className:`size-3.5`})})]},e.id),t[43]=f,t[44]=a.closeAria,t[45]=a.endedLabel,t[46]=a.savedLabel,t[47]=a.title,t[48]=V,t[49]=v,t[50]=e):e=t[50],ae=u.map(e),t[34]=f,t[35]=a.closeAria,t[36]=a.endedLabel,t[37]=a.savedLabel,t[38]=a.title,t[39]=V,t[40]=v,t[41]=u,t[42]=ae}else ae=t[42];let oe;t[51]!==n||t[52]!==m?(oe=()=>m(n),t[51]=n,t[52]=m,t[53]=oe):oe=t[53];let se;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(ge,{className:`size-4`}),t[54]=se):se=t[54];let ce;t[55]!==E||t[56]!==a.newAria||t[57]!==oe?(ce=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":a.newAria,title:a.newAria,disabled:E,onClick:oe,children:se}),t[55]=E,t[56]=a.newAria,t[57]=oe,t[58]=ce):ce=t[58];let le;t[59]!==n||t[60]!==y?(le=()=>y(n,!1),t[59]=n,t[60]=y,t[61]=le):le=t[61];let ue;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(lr,{className:`size-4`}),t[62]=ue):ue=t[62];let de;t[63]!==a.closePaneAria||t[64]!==le?(de=(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto size-8 shrink-0 p-0`,"aria-label":a.closePaneAria,onClick:le,children:ue}),t[63]=a.closePaneAria,t[64]=le,t[65]=de):de=t[65];let pe;t[66]!==ae||t[67]!==ce||t[68]!==de?(pe=(0,$.jsxs)(`div`,{"data-side-chat-header":!0,className:`flex h-11 shrink-0 items-center gap-1 overflow-x-auto px-2`,children:[ae,ce,de]}),t[66]=ae,t[67]=ce,t[68]=de,t[69]=pe):pe=t[69];let me;t[70]!==T||t[71]!==c||t[72]!==O||t[73]!==a.title||t[74]!==v?(me=O&&T?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-4 py-2 text-xs text-fg-muted`,role:`status`,children:[(0,$.jsx)(`p`,{children:O}),c.filter(vR).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`mr-2 mt-1 rounded border border-edge px-2 py-1`,onClick:()=>{v(e.id),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e.parentConversationId}}))},children:e.title===`Side chat`?a.title:e.title},e.id))]}):null,t[70]=T,t[71]=c,t[72]=O,t[73]=a.title,t[74]=v,t[75]=me):me=t[75];let he;t[76]!==T||t[77]!==O||t[78]!==E||t[79]!==a.temporaryDescription||t[80]!==a.title||t[81]!==n||t[82]!==S||t[83]!==C?(he=T?(0,$.jsx)(NR,{sideChatId:T.id,token:C??void 0,initialRunId:T.runId,onRunIdChange:S,parentConversationId:n},`${T.id}:${C??``}`):(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-8 text-center`,children:[(0,$.jsx)(fe,{className:`mb-4 size-10 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm leading-6 text-fg-muted`,children:a.temporaryDescription}),E?(0,$.jsx)(xn,{className:`mt-4 h-4 w-32`}):null,O?(0,$.jsx)(`p`,{className:`mt-4 text-xs text-red-600 dark:text-red-400`,children:O}):null]}),t[76]=T,t[77]=O,t[78]=E,t[79]=a.temporaryDescription,t[80]=a.title,t[81]=n,t[82]=S,t[83]=C,t[84]=he):he=t[84];let _e=M!==null,ve;t[85]!==a.closeConfirmTitle||t[86]!==a.stopCloseTitle||t[87]!==M||t[88]!==u?(ve=u.find(e=>e.id===M)?.runId?a.stopCloseTitle:a.closeConfirmTitle,t[85]=a.closeConfirmTitle,t[86]=a.stopCloseTitle,t[87]=M,t[88]=u,t[89]=ve):ve=t[89];let be;t[90]!==a.closeConfirmDescription||t[91]!==a.stopCloseDescription||t[92]!==M||t[93]!==u?(be=u.find(e=>e.id===M)?.runId?a.stopCloseDescription:a.closeConfirmDescription,t[90]=a.closeConfirmDescription,t[91]=a.stopCloseDescription,t[92]=M,t[93]=u,t[94]=be):be=t[94];let q;t[95]!==a.closeConfirmAction||t[96]!==a.stopCloseAction||t[97]!==M||t[98]!==u?(q=u.find(e=>e.id===M)?.runId?a.stopCloseAction:a.closeConfirmAction,t[95]=a.closeConfirmAction,t[96]=a.stopCloseAction,t[97]=M,t[98]=u,t[99]=q):q=t[99];let Ce;t[100]!==z||t[101]!==P||t[102]!==M?(Ce=()=>{let e=M;e&&(P&&fR(),N(null),F(!1),z(e))},t[100]=z,t[101]=P,t[102]=M,t[103]=Ce):Ce=t[103];let we;t[104]===Symbol.for(`react.memo_cache_sentinel`)?(we=()=>{N(null),F(!1)},t[104]=we):we=t[104];let Te;t[105]!==P||t[106]!==a.closeConfirmCancel||t[107]!==a.closeConfirmDontAskAgain||t[108]!==_e||t[109]!==ve||t[110]!==be||t[111]!==q||t[112]!==Ce?(Te=(0,$.jsx)(uS,{open:_e,title:ve,description:be,confirmLabel:q,cancelLabel:a.closeConfirmCancel,checkboxLabel:a.closeConfirmDontAskAgain,checkboxChecked:P,onCheckboxCheckedChange:F,destructive:!0,onConfirm:Ce,onCancel:we}),t[105]=P,t[106]=a.closeConfirmCancel,t[107]=a.closeConfirmDontAskAgain,t[108]=_e,t[109]=ve,t[110]=be,t[111]=q,t[112]=Ce,t[113]=Te):Te=t[113];let De;return t[114]!==a.paneAria||t[115]!==ee||t[116]!==re||t[117]!==ie||t[118]!==pe||t[119]!==me||t[120]!==he||t[121]!==Te?(De=(0,$.jsxs)(`aside`,{id:`app-side-chat-panel`,"aria-label":W,className:ee,style:re,children:[ie,pe,me,he,Te]}),t[114]=a.paneAria,t[115]=ee,t[116]=re,t[117]=ie,t[118]=pe,t[119]=me,t[120]=he,t[121]=Te,t[122]=De):De=t[122],De}function vR(e){return!e.ended}function yR(){}function bR(e){return e.conversationId}function xR(e){return e.setTabRunId}function SR(e){return e.setWidthPx}function CR(e){return e.widthPx}function wR(e){return e.setOpen}function TR(e){return e.setActive}function ER(e){return e.removeTab}function DR(e){return e.addTab}function OR(e){return e.claimPendingCreate}function kR(e){return e.requestCreate}function AR(e){return e.pendingCreate}function jR(e){return e.tabs}function MR(e){return e.language}function NR({sideChatId:e,token:t,initialRunId:n,onRunIdChange:r,parentConversationId:i}){let[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(()=>dL.getState().readings[e]?.messages??[]),l=dL(t=>t.drafts[e]?.text??``),u=dL(t=>t.drafts[e]?.attachments??uR),d=(0,Z.useCallback)(t=>dL.getState().setDraftText(e,t),[e]),f=(0,Z.useCallback)(t=>{dL.getState().setDraftAttachments(e,t)},[e]),[p,m]=(0,Z.useState)(()=>dL.getState().tabs.find(t=>t.id===e)?.ended),[h,g]=(0,Z.useState)(!p),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(()=>dL.getState().tabs.find(t=>t.id===e)?.promotedConversationId),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,P]=(0,Z.useState)(Date.now),[F,I]=(0,Z.useState)(0),L=dL(t=>t.tabs.find(t=>t.id===e)?.fresh),R=dL(t=>t.readings[e]?.truncated??!1),z=(0,Z.useRef)(!0),B=(0,Z.useRef)(p),V=(0,Z.useRef)(Se.getState()),H=(0,Z.useCallback)(()=>V.current.conversationId===Se.getState().conversationId&&V.current.baseUrl===Se.getState().baseUrl,[]),U=(0,Z.useCallback)(()=>z.current&&H(),[H]);(0,Z.useEffect)(()=>(z.current=!0,()=>{z.current=!1}),[]);let[W,G]=(0,Z.useState)(!!n),[ee,te]=(0,Z.useState)(n),[ne,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),ue=(0,Z.useRef)(!1),de=(0,Z.useRef)(0),pe=(0,Z.useRef)(0),me=(0,Z.useRef)(!1),he=(0,Z.useRef)(!1),ge=(0,Z.useRef)(new Map),_e=xe(Ee(e=>e.language)),ve=_e.sideChat,ye=FD({chat:_e.chat,initialAttachments:u,onAttachmentsChange:f}),be=uE({conversationId:e,disabled:!!p||_,initialValue:l,onValueChange:d,autoFocusKey:e,shouldSyncSelectionRef:ue}),K=(0,Z.useRef)({}),{scrollRef:q,atBottom:Ce,registerListContentRef:we,scrollToBottom:Te,onScroll:De}=QI({hasToken:!0,showSessionLoading:!1,conversationId:e,chatMessages:s,hasMore:!1,loadingMore:!1,loadMoreMessages:lR});(0,Z.useEffect)(()=>{U()&&(s.length||!h)&&dL.getState().rememberMessages(e,s)},[s,h,e,U]);let Oe=(0,Z.useCallback)(t=>{!U()||B.current||(B.current=t,de.current+=1,m(t),G(!1),te(void 0),ae(null),o(null),M(``),re(null),v(!1),g(!1),c(e=>rL(e).messages),dL.getState().markEnded(e,t))},[U,e]),J=(0,Z.useCallback)(e=>{if(!U()||he.current)return;let t=e;t.body?.code===`EXPIRED`||t.status===410?Oe(t.body?.reason===`waiting`?`waiting`:`idle`):t.status===404||t.body?.code===`NOT_FOUND`?Oe(`unavailable`):v(!0),g(!1)},[Oe,U]),ke=(0,Z.useCallback)(t=>{if(!U()||B.current)return;let n=t.serverNow?Date.parse(t.serverNow):0;n&&n<pe.current||(pe.current=n,o(t),v(!1),t.serverNow&&I(Date.parse(t.serverNow)-Date.now()),P(Date.now()),G(t.status!==`idle`),te(t.runId),r(e,t.runId),ae(t.clarification??null))},[U,r,e]),Ae=(0,Z.useCallback)(async()=>{let t=de.current;try{let[n,r]=await Promise.all([QL(e),$L(e)]);if(!U()||B.current)return;de.current===t&&(ke(n),c(gR(P_(r),ge.current))),g(!1)}catch(e){J(e)}},[ke,J,U,e]);(0,Z.useEffect)(()=>{if(p)return;Ae();let t=!1,n=async()=>{if(t||B.current)return;t=!0;let n=de.current;try{let t=await aR(e);t&&n===de.current&&ke(t)}catch(e){J(e)}finally{t=!1}},r=window.setInterval(()=>{P(Date.now()),n()},3e4),i=()=>{document.visibilityState!==`hidden`&&Ae()};return window.addEventListener(`online`,i),window.addEventListener(`pageshow`,i),document.addEventListener(`visibilitychange`,i),()=>{window.clearInterval(r),window.removeEventListener(`online`,i),window.removeEventListener(`pageshow`,i),document.removeEventListener(`visibilitychange`,i)}},[p,Ae,ke,J,e]),(0,Z.useEffect)(()=>{if(!p)return Fy(`side-chat:${YL()}:${e}`,{onEvent:e=>{e.event===`expired`&&Oe(e.data?.reason===`waiting`?`waiting`:`idle`)},onGap:()=>Ae()})},[p,Oe,Ae,e]),(0,Z.useEffect)(()=>{if(!j)return;let e=window.setTimeout(()=>M(``),5e3);return()=>window.clearTimeout(e)},[j]);let je=a?.expiresAt?Date.parse(a.expiresAt)-(N+F):1/0,Me=!p&&!_&&je<=5*6e4,Ne=async()=>{if(!(y||B.current)){b(!0);try{let t=await oR(e);if(!U()||B.current)return;ke(t),re(null),M(ve.extended)}catch(e){let t=e.status;(t===404||t===410)&&J(e),B.current||re(ve.extendFailed)}finally{b(!1)}}},Pe=async()=>{let t=i??dL.getState().tabs.find(t=>t.id===e)?.parentConversationId;if(!(!t||x)){S(!0),re(null);try{let n=await ZL(t,[]);if(!H())return;dL.getState().replaceTab(e,{id:n.id,parentConversationId:t,title:`Side chat`})}catch(e){if(!U())return;e.body?.code===`PARENT_NOT_FOUND`&&A(!0),re(hR(e,ve))}finally{S(!1)}}},Fe=(0,Z.useCallback)(e=>{de.current+=1,c(t=>{let n=structuredClone(t),r=n.at(-1);return r?.role!==`assistant`&&(r={role:`assistant`,content:[],timestamp:Date.now()},n.push(r)),e(r),n})},[]);(0,Z.useEffect)(()=>{if(!(!ee||p))return Fy(`run:${ee}`,{onEvent:t=>{if(!U()||B.current)return;let n=t.data?.payload??{};t.event===`assistant_message_start`?Fe(()=>{}):t.event===`assistant_delta`?Fe(e=>vb(e.content,String(n.delta??``),String(n.messageId??``))):t.event===`thinking_delta`?Fe(e=>mb(e.content,String(n.delta??``),!0)):t.event===`thinking_end`?Fe(e=>hb(e.content)):t.event===`tool_start`?Fe(e=>Eb(e.content,String(n.toolName??`tool`),n.args,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`tool_end`?Fe(e=>Db(e.content,String(n.toolName??`tool`),n.status===`error`,n.result,String(n.toolCallId??``),Date.now(),n.activity)):t.event===`clarify_request`?(ae({requestId:String(n.requestId??``),kind:n.kind===`approval`?`approval`:`input`,question:String(n.question??``),choices:Array.isArray(n.choices)?n.choices.filter(e=>typeof e==`string`):void 0,suggestedAnswer:typeof n.suggestedAnswer==`string`?n.suggestedAnswer:void 0}),le(null),Ae()):t.event===`error`?re(String(n.message??ve.failed)):t.event===`run_end`&&(G(!1),te(void 0),r(e,void 0),ae(null),Ae())},onGap:()=>Ae()})},[p,U,Fe,r,Ae,ee,e,ve.failed]);let Ie=()=>{let t=l.trim(),n=ye.wireAttachmentsPayload();if(!t&&n.length===0||W||me.current||B.current||_)return;if(tL(t)>262144){re(ve.draftTooLong);return}let i={text:l,attachments:[...ye.attachmentsRef.current]};me.current=!0,be.resetEditor(),ye.clearAttachments(),re(null),de.current+=1;let a=crypto.randomUUID(),o={role:`user`,content:[{type:`text`,text:t}],attachments:i.attachments,timestamp:Date.now(),renderKey:`side-chat-user:${a}`};ge.current.set(a,o),c(e=>[...e,o]),G(!0),tR(e,t,n).then(t=>{!H()||B.current||(dL.getState().setTabRunId(e,t),U()&&(te(t),r(e,t)))}).catch(t=>{if(!H())return;let n=dL.getState();if(!U()&&!n.tabs.some(t=>t.id===e))return;let r=dL.getState().drafts[e]??{text:``,attachments:[]},s={text:r.text?`${i.text}\n${r.text}`:i.text,attachments:[...i.attachments,...r.attachments]};U()?(be.resetEditor({nextText:s.text}),ye.setAttachments(s.attachments)):(d(s.text),f(s.attachments)),ge.current.delete(a);let l=n.readings[e];if(l&&n.rememberMessages(e,l.messages.filter(e=>e.renderKey!==o.renderKey)),!U())return;c(e=>e.filter(e=>e.renderKey!==o.renderKey)),G(!1);let u=t.status;u===404||u===410?J(t):re(hR(t,ve))}).finally(()=>{me.current=!1})},Le=async t=>{if(!(!ie||B.current)){se(!0),le(null);try{await rR(e,ie.requestId,t),ae(null),Ae()}catch(e){e.status===410?J(e):le(hR(e,ve))}finally{se(!1)}}},Re=async()=>{try{await nR(e,ee),U()&&ae(null)}catch(e){if(!U())return;let t=e.status;t===404||t===410?J(e):re(hR(e,ve))}},ze=(0,Z.useCallback)(e=>{be.resetEditor({nextText:e,focus:!0})},[be.resetEditor]),Be=(0,Z.useCallback)(async e=>{try{let t=await SL(e.trim(),`web`);Yl(`success`,_e.chat.messageSavedToNote,void 0,{href:`/notes/${encodeURIComponent(t.id)}`})}catch(e){throw Yl(`error`,e instanceof Error?e.message:_e.notes.quickCaptureFailed),e}},[_e.chat.messageSavedToNote,_e.notes.quickCaptureFailed]),Ve=(0,Z.useCallback)(async()=>{if(!(he.current||W||B.current||s.length===0)){he.current=!0,w(!0),E(!1),re(null);try{let t=await sR(e);if(!H())return;B.current=`promoted`,m(`promoted`),O(t.conversationId),G(!1),te(void 0),ae(null),o(null),r(e,void 0),dL.getState().markPromoted(e,t.conversationId),Yl(`success`,ve.savedTitle,void 0,{href:`/chat/${encodeURIComponent(t.conversationId)}`})}catch(e){if(!U())return;re(hR(e,ve)||ve.saveFailed)}finally{he.current=!1,U()&&w(!1)}}},[U,s.length,r,W,H,e,ve]),He=(0,Z.useCallback)(()=>{if(l.trim()||u.length){E(!0);return}Ve()},[u.length,l,Ve]),Ue=(0,Z.useCallback)(async t=>{let n=await eR(e,t);U()&&!B.current&&o(n)},[U,e]);return K.current={adapters:[],send:Ie,runBusy:W,pendingFollowUpsCount:0,editingFollowUpId:null,onCancelEditFollowUp:()=>{},attachmentsLen:ye.attachments.length,contextRefsLen:0,isComposing:be.isComposing,valueRef:be.valueRef,adjustHeight:be.adjustHeight,editorRef:be.editorRef},(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{ref:q,"data-side-chat-scroll-viewport":!0,onScroll:De,className:`chat-messages h-full overflow-y-auto overflow-x-hidden px-5 py-4 [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,children:[h&&!s.length?(0,$.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-label":ve.creating,children:[(0,$.jsx)(xn,{className:`ml-auto h-12 w-3/4`}),(0,$.jsx)(xn,{className:`h-4 w-full`}),(0,$.jsx)(xn,{className:`h-4 w-4/5`})]}):s.length?(0,$.jsx)(UI,{messages:s,authToken:t,conversationId:e,workspaceConversationId:i,streaming:W,progress:null,reasoningLevel:`on`,registerListContentRef:we,deleteRoundDisabled:W||!!p,onSaveAssistantAsNote:Be,onEditUserMessage:p?void 0:e=>ze(pR(e)),responseFeedbackEnabled:!1}):p?null:(0,$.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center text-center`,children:[(0,$.jsx)(fe,{className:`mb-4 size-9 text-fg-muted`,strokeWidth:1.5}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:ve.title}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:L?ve.freshContext:ve.emptyDescription})]}),R&&p?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:ve.partialReading}):null]}),(0,$.jsx)(KI,{visible:!Ce,onClick:()=>Te(!0),edge:`bottom`,running:W})]}),_&&!p?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:ve.connectionLost}):null,j?(0,$.jsx)(`p`,{role:`status`,className:`shrink-0 px-4 py-2 text-xs text-fg-muted`,children:j}):null,Me?(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-4 py-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:je<=0?ve.verifying:ve.expiring.replace(`{{minutes}}`,String(Math.max(1,Math.ceil(je/6e4))))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`ml-auto h-8 text-xs`,disabled:y||je<=0,onClick:()=>void Ne(),children:ve.keepAlive})]}):null,ie&&!p?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-3 pt-3`,children:(0,$.jsx)(Sc,{prompt:ie,submitting:oe,submitError:ce,labels:_e.chat,onSubmit:Le,onAgentDecide:()=>Le(`Use your best judgment and continue without additional user input.`),onCancel:Re})}):null,ne?(0,$.jsx)(`p`,{className:`border-t border-edge px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:ne}):null,p===`promoted`&&D?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:ve.savedTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:ve.savedDescription}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:D}}))},children:ve.openSavedChat})]})}):p?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge p-3`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold`,"aria-live":`polite`,children:p===`unavailable`?ve.unavailableTitle:ve.expiredTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:k?ve.parentMissing:p===`waiting`?ve.waitExpired:s.length?ve.expiredDescription:ve.unavailableDescription}),l||u.length?(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`label`,{htmlFor:`side-chat-draft-${e}`,className:`text-xs text-fg-muted`,children:ve.unsentDraft}),(0,$.jsx)(iD,{attachments:u,topPadded:!1,onRemove:ye.removeAttachment,className:`mt-1 rounded-t-lg`}),l?(0,$.jsx)(`textarea`,{id:`side-chat-draft-${e}`,value:l,onChange:e=>d(nL(e.target.value)),rows:3,className:`mt-1 w-full resize-y rounded-lg border border-edge bg-surface-base p-2 text-sm`}):null]}):null,(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,disabled:x,onClick:()=>{k?i&&dL.getState().setOpen(i,!1):Pe()},children:k?ve.closePaneAria:x?ve.creating:l.trim()||u.length?ve.newWithDraft:ve.newAria}),s.length&&!k?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ve.replaceHint}):null]})}):(0,$.jsx)(`form`,{"data-side-chat-composer":!0,onSubmit:e=>{e.preventDefault(),Ie()},className:`shrink-0 p-3`,children:(0,$.jsxs)(oD,{dragging:ye.isDragging,onDragOver:e=>{e.dataTransfer?.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,ye.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&ye.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),ye.setIsDragging(!1);let t=e.dataTransfer?.files;t?.length&&ye.processFiles(Array.from(t))},children:[(0,$.jsx)(`input`,{ref:ye.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&ye.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsx)(iD,{attachments:ye.attachments,topPadded:!1,onRemove:ye.removeAttachment}),a?.context.selections.length?(0,$.jsxs)(`div`,{className:`mx-3 mt-3 inline-flex h-8 max-w-[calc(100%-1.5rem)] self-start items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg-muted sm:mx-4`,title:a.context.selections.map(e=>e.label||e.text).join(`
103
- `),children:[(0,$.jsx)(di,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:(a.context.selections.length===1?ve.selectionCount_one:ve.selectionCount_other).replace(`{{count}}`,String(a.context.selections.length))})]}):null,(0,$.jsx)(`div`,{className:a?.context.selections.length?`px-3 sm:px-4`:`px-3 pt-1 sm:px-4`,children:(0,$.jsx)(dE,{editorRef:be.editorRef,disabled:_,placeholder:_e.chat.typeMessage,onWireInput:(e,t)=>{let n=nL(e);tL(e)>262144&&re(ve.draftTooLong),be.onWireInput(n,Math.min(t,n.length))},adjustHeight:be.adjustHeight,processFiles:ye.processFiles,processPastedText:ye.processPastedText,setIsComposing:be.setIsComposing,kbdRef:K,chatMessages:_e.chat})}),(0,$.jsxs)(ND,{children:[(0,$.jsx)(jD,{disabled:_,runBusy:W,attachmentCount:ye.attachments.length,maxAttachments:10,chat:_e.chat,onPickFiles:()=>ye.fileInputRef.current?.click()}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,"aria-label":ve.saveAsChat,title:W?ve.saveBusy:ve.saveAsChat,disabled:C||W||_||s.length===0,onClick:He,children:[(0,$.jsx)(Ui,{className:`size-3.5`}),(0,$.jsx)(`span`,{className:`max-sm:hidden`,children:C?ve.savingChat:ve.saveAsChat})]}),(0,$.jsx)(`div`,{className:`ml-auto min-w-0`,children:a?(0,$.jsx)(gD,{chat:_e.chat,sessionModel:a.config.modelRef,modelDisabled:W||_,onModelChange:(e,t)=>Ue({modelRef:e,thinkingLevel:t}),thinkingLevel:a.config.thinkingLevel,thinkingDisabled:W||_,onThinkingChange:e=>Ue({thinkingLevel:e})}):null}),(0,$.jsx)(MD,{disabled:_||tL(l)>262144,voiceActive:!1,runBusy:W,hasDraft:!!l.trim()||ye.attachments.length>0,showSteeringInterrupt:!1,chat:_e.chat,onSend:Ie,onAbort:()=>void Re()})]})]})}),(0,$.jsx)(uS,{open:T,title:ve.saveDraftTitle,description:ve.saveDraftDescription,confirmLabel:ve.saveDraftAction,cancelLabel:ve.closeConfirmCancel,onConfirm:()=>void Ve(),onCancel:()=>E(!1)})]})}function PR(e){NT(e)}var FR=32e3,IR=264,LR=10;function RR(){let e=(0,Q.c)(36),{pathname:t}=b(),n;e[0]===t?n=e[1]:(n=t.startsWith(`/chat/`)?t.slice(6):``,e[0]=t,e[1]=n);let r=n,i=Ee(UR),a;e[2]===i?a=e[3]:(a=xe(i),e[2]=i,e[3]=a);let o=a.sideChat,s=dL(HR),c=dL(VR),l=Dw(BR),[u,d]=(0,Z.useState)(null),f;e[4]!==r||e[5]!==c?(f=()=>{if(!r||r===`new`||c){d(null);return}let e=window.getSelection(),t=e?.toString().trim()??``;if(!e||e.rangeCount===0||!t||t.length>FR){d(null);return}let n=e.getRangeAt(0),i=WR(e.anchorNode),a=WR(e.focusNode),o=document.getElementById(`app-main-content`),s=document.getElementById(`app-side-chat-panel`),l=!!(s?.contains(i)&&s?.contains(a));if(!i||!a||!l&&(!o?.contains(i)||!o.contains(a))||!i.closest(`[data-chat-message-index]`)||!a.closest(`[data-chat-message-index]`)){d(null);return}let u=n.getBoundingClientRect();if(u.width===0&&u.height===0){d(null);return}let f=Math.min(window.innerWidth-IR-LR,Math.max(LR,u.left+u.width/2-IR/2)),p=u.bottom+8;d({text:t,left:f,top:p+38<window.innerHeight?p:Math.max(LR,u.top-42),fromSide:l})},e[4]=r,e[5]=c,e[6]=f):f=e[6];let p=f,m,h;if(e[7]!==p||e[8]!==t?(m=()=>{if(!t.startsWith(`/chat/`)){d(null);return}let e=()=>window.requestAnimationFrame(p),n=()=>d(null);return document.addEventListener(`pointerup`,e),document.addEventListener(`keyup`,e),window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{document.removeEventListener(`pointerup`,e),document.removeEventListener(`keyup`,e),window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},h=[p,t],e[7]=p,e[8]=t,e[9]=m,e[10]=h):(m=e[9],h=e[10]),(0,Z.useEffect)(m,h),!u||!r||r===`new`)return null;let g=u.fromSide?IR/2:IR,_;e[11]!==u.left||e[12]!==u.top||e[13]!==g?(_={left:u.left,top:u.top,width:g},e[11]=u.left,e[12]=u.top,e[13]=g,e[14]=_):_=e[14];let v;e[15]===u.text?v=e[16]:(v=()=>{PR(u.text),window.getSelection()?.removeAllRanges(),d(null)},e[15]=u.text,e[16]=v);let y;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(ge,{className:`size-3.5 shrink-0`}),e[17]=y):y=e[17];let x;e[18]===o.addToChat?x=e[19]:(x=(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.addToChat}),e[18]=o.addToChat,e[19]=x);let S;e[20]!==v||e[21]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:v,children:[y,x]}),e[20]=v,e[21]=x,e[22]=S):S=e[22];let C;e[23]!==r||e[24]!==o.askInSideChat||e[25]!==o.selectedText||e[26]!==u.fromSide||e[27]!==u.text||e[28]!==s||e[29]!==l?(C=u.fromSide?null:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex flex-1 items-center justify-center gap-1.5 border-l border-edge px-3 transition-colors hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:()=>{let e=decodeURIComponent(r);l(!1),s(e,[{id:crypto.randomUUID(),type:`text`,text:u.text,label:o.selectedText}]),window.getSelection()?.removeAllRanges(),d(null)},children:[(0,$.jsx)(fe,{className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:o.askInSideChat})]}),e[23]=r,e[24]=o.askInSideChat,e[25]=o.selectedText,e[26]=u.fromSide,e[27]=u.text,e[28]=s,e[29]=l,e[30]=C):C=e[30];let w;return e[31]!==o.selectedTextActionsAria||e[32]!==S||e[33]!==C||e[34]!==_?(w=(0,$.jsxs)(`div`,{role:`group`,"aria-label":o.selectedTextActionsAria,className:`fixed z-[70] flex h-9 overflow-hidden rounded-lg border border-edge bg-surface-panel text-xs font-medium text-fg shadow-popover`,style:_,onPointerDown:zR,children:[S,C]}),e[31]=o.selectedTextActionsAria,e[32]=S,e[33]=C,e[34]=_,e[35]=w):w=e[35],w}function zR(e){return e.preventDefault()}function BR(e){return e.setOpen}function VR(e){return e.pendingCreate}function HR(e){return e.requestCreate}function UR(e){return e.language}function WR(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function GR(){let e=(0,Q.c)(28),t=(0,Z.useRef)(null),n=Se(QR),r=Se(ZR),i=Se(XR),a=Se(YR),o=Se(JR),s=Se(qR),c=Ee(KR),l;e[0]===c?l=e[1]:(l=xe(c),e[0]=c,e[1]=l);let u=l.token,d=!!s&&!i,f;e[2]!==d||e[3]!==o?(f=e=>{!e&&!d||e||o()},e[2]=d,e[3]=o,e[4]=f):f=e[4];let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Ye,{className:K(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[2px]`,wn)}),e[5]=p):p=e[5];let m,h;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=K(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4`,Sn,`dark:border-edge`),h=e=>{e.preventDefault(),t.current?.focus()},e[6]=m,e[7]=h):(m=e[6],h=e[7]);let g;e[8]===u.title?g=e[9]:(g=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:u.title}),e[8]=u.title,e[9]=g);let _;e[10]===u.description?_=e[11]:(_=(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:u.description}),e[10]=u.description,e[11]=_);let v;e[12]!==d||e[13]!==o||e[14]!==c?(v=d?(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>o(),children:c===`zh`?`取消`:`Cancel`}):void 0,e[12]=d,e[13]=o,e[14]=c,e[15]=v):v=e[15];let y;e[16]!==r||e[17]!==a||e[18]!==v?(y=(0,$.jsx)(Pd,{className:`mt-4`,baseUrl:r,tokenInputRef:t,onSubmit:a,footerLeft:v}),e[16]=r,e[17]=a,e[18]=v,e[19]=y):y=e[19];let b;e[20]!==g||e[21]!==_||e[22]!==y?(b=(0,$.jsxs)($e,{children:[p,(0,$.jsxs)(et,{className:m,onOpenAutoFocus:h,children:[g,_,y]})]}),e[20]=g,e[21]=_,e[22]=y,e[23]=b):b=e[23];let x;return e[24]!==n||e[25]!==f||e[26]!==b?(x=(0,$.jsx)(nt,{open:n,onOpenChange:f,children:b}),e[24]=n,e[25]=f,e[26]=b,e[27]=x):x=e[27],x}function KR(e){return e.language}function qR(e){return e.conversationId}function JR(e){return e.closeTokenDialog}function YR(e){return e.setBrowserSession}function XR(e){return e.tokenExpired}function ZR(e){return e.baseUrl}function QR(e){return e.tokenDialogOpen}function $R(e){let t=e+`CollectionProvider`,[n,r]=Ie(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=Z.useRef(null),a=Z.useRef(new Map).current;return(0,$.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Je(s),l=Z.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,$.jsx)(c,{ref:qe(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Je(u),p=Z.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=Z.useRef(null),s=qe(t,o),c=a(u,n);return Z.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,$.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return Z.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var ez=Z.createContext(void 0);function tz(e){let t=Z.useContext(ez);return e||t||`ltr`}var nz=!1;function rz(){let[e,t]=Z.useState(nz);return Z.useEffect(()=>{nz||(nz=!0,t(!0))},[]),e}var iz=Z.useSyncExternalStore;function az(){return()=>{}}function oz(){return iz(az,()=>!0,()=>!1)}var sz=typeof iz==`function`?oz:rz,cz=`rovingFocusGroup.onEntryFocus`,lz={bubbles:!1,cancelable:!0},uz=`RovingFocusGroup`,[dz,fz,pz]=$R(uz),[mz,hz]=Ie(uz,[pz]),[gz,_z]=mz(uz),vz=Z.forwardRef((e,t)=>(0,$.jsx)(dz.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)(dz.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,$.jsx)(yz,{...e,ref:t})})}));vz.displayName=uz;var yz=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=Z.useRef(null),p=qe(t,f),m=tz(a),[h,g]=Pe({prop:o,defaultProp:s??null,onChange:c,caller:uz}),[_,v]=Z.useState(!1),y=Re(l),b=fz(n),x=Z.useRef(!1),[S,C]=Z.useState(0);return Z.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(cz,y),()=>e.removeEventListener(cz,y)},[y]),(0,$.jsx)(gz,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:Z.useCallback(e=>g(e),[g]),onItemShiftTab:Z.useCallback(()=>v(!0),[]),onFocusableItemAdd:Z.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:Z.useCallback(()=>C(e=>e-1),[]),children:(0,$.jsx)(Ke.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Fe(e.onMouseDown,()=>{x.current=!0}),onFocus:Fe(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(cz,lz);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Tz([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:Fe(e.onBlur,()=>v(!1))})})}),bz=`RovingFocusGroupItem`,xz=Z.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=He(),l=a||c,u=_z(bz,n),d=u.currentTabStopId===l,f=fz(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=sz();return ze(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),Z.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,$.jsx)(dz.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,$.jsx)(Ke.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Fe(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Fe(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Fe(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=wz(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Ez(n,r+1):n.slice(r+1)}setTimeout(()=>Tz(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});xz.displayName=bz;var Sz={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Cz(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function wz(e,t,n){let r=Cz(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Sz[r]}function Tz(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Ez(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Dz=vz,Oz=xz,kz=[`Enter`,` `],Az=[`ArrowDown`,`PageUp`,`Home`],jz=[`ArrowUp`,`PageDown`,`End`],Mz=[...Az,...jz],Nz={ltr:[...kz,`ArrowRight`],rtl:[...kz,`ArrowLeft`]},Pz={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Fz=`Menu`,[Iz,Lz,Rz]=$R(Fz),[zz,Bz]=Ie(Fz,[Rz,un,hz]),Vz=un(),Hz=hz(),[Uz,Wz]=zz(Fz),[Gz,Kz]=zz(Fz),qz=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Vz(t),[c,l]=Z.useState(null),u=Z.useRef(!1),d=Re(a),f=tz(i);return Z.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),Z.useEffect(()=>{if(!n)return;let e=()=>d(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,$.jsx)(dn,{...s,children:(0,$.jsx)(Uz,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,$.jsx)(Gz,{scope:t,onClose:Z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};qz.displayName=Fz;var Jz=`MenuAnchor`,Yz=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Vz(n);return(0,$.jsx)(mn,{...i,...r,ref:t})});Yz.displayName=Jz;var Xz=`MenuPortal`,[Zz,Qz]=zz(Xz,{forceMount:void 0}),$z=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Wz(Xz,t);return(0,$.jsx)(Zz,{scope:t,forceMount:n,children:(0,$.jsx)(Le,{present:n||a.open,children:(0,$.jsx)(Me,{asChild:!0,container:i,children:r})})})};$z.displayName=Xz;var eB=`MenuContent`,[tB,nB]=zz(eB),rB=Z.forwardRef((e,t)=>{let n=Qz(eB,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Wz(eB,e.__scopeMenu),o=Kz(eB,e.__scopeMenu);return(0,$.jsx)(Iz.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(Le,{present:r||a.open,children:(0,$.jsx)(Iz.Slot,{scope:e.__scopeMenu,children:o.modal?(0,$.jsx)(iB,{...i,ref:t}):(0,$.jsx)(aB,{...i,ref:t})})})})}),iB=Z.forwardRef((e,t)=>{let n=Wz(eB,e.__scopeMenu),r=Z.useRef(null),i=qe(t,r);return Z.useEffect(()=>{let e=r.current;if(e)return Ge(e)},[]),(0,$.jsx)(sB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Fe(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),aB=Z.forwardRef((e,t)=>{let n=Wz(eB,e.__scopeMenu);return(0,$.jsx)(sB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),oB=Je(`MenuContent.ScrollLock`),sB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=Wz(eB,n),_=Kz(eB,n),v=Vz(n),y=Hz(n),b=Lz(n),[x,S]=Z.useState(null),C=Z.useRef(null),w=qe(t,C,g.onContentChange),T=Z.useRef(0),E=Z.useRef(``),D=Z.useRef(0),O=Z.useRef(null),k=Z.useRef(`right`),A=Z.useRef(0),j=m?Be:Z.Fragment,M=m?{as:oB,allowPinchZoom:!0}:void 0,N=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=GB(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};Z.useEffect(()=>()=>window.clearTimeout(T.current),[]),Ue();let P=Z.useCallback(e=>k.current===O.current?.side&&qB(e,O.current?.area),[]);return(0,$.jsx)(tB,{scope:n,searchRef:E,onItemEnter:Z.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:Z.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:Z.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:Z.useCallback(e=>{O.current=e},[]),children:(0,$.jsx)(j,{...M,children:(0,$.jsx)(Ve,{asChild:!0,trapped:i,onMountAutoFocus:Fe(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,$.jsx)(We,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,$.jsx)(Dz,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Fe(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,$.jsx)(pn,{role:`menu`,"aria-orientation":`vertical`,"data-state":BB(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Fe(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!Mz.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);jz.includes(e.key)&&a.reverse(),UB(a)}),onBlur:Fe(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Fe(e.onPointerMove,JB(e=>{let t=e.target,n=A.current!==e.clientX;e.currentTarget.contains(t)&&n&&(k.current=e.clientX>A.current?`right`:`left`,A.current=e.clientX)}))})})})})})})});rB.displayName=eB;var cB=`MenuGroup`,lB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(Ke.div,{role:`group`,...r,ref:t})});lB.displayName=cB;var uB=`MenuLabel`,dB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(Ke.div,{...r,ref:t})});dB.displayName=uB;var fB=`MenuItem`,pB=`menu.itemSelect`,mB=Z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=Z.useRef(null),o=Kz(fB,e.__scopeMenu),s=nB(fB,e.__scopeMenu),c=qe(t,a),l=Z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(pB,{bubbles:!0,cancelable:!0});e.addEventListener(pB,e=>r?.(e),{once:!0}),Ne(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,$.jsx)(hB,{...i,ref:c,disabled:n,onClick:Fe(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Fe(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Fe(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||kz.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});mB.displayName=fB;var hB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=nB(fB,n),s=Hz(n),c=Z.useRef(null),l=qe(t,c),[u,d]=Z.useState(!1),[f,p]=Z.useState(``);return Z.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,$.jsx)(Iz.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,$.jsx)(Oz,{asChild:!0,...s,focusable:!r,children:(0,$.jsx)(Ke.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Fe(e.onPointerMove,JB(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Fe(e.onPointerLeave,JB(e=>o.onItemLeave(e))),onFocus:Fe(e.onFocus,()=>d(!0)),onBlur:Fe(e.onBlur,()=>d(!1))})})})}),gB=`MenuCheckboxItem`,_B=Z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,$.jsx)(TB,{scope:e.__scopeMenu,checked:n,children:(0,$.jsx)(mB,{role:`menuitemcheckbox`,"aria-checked":VB(n)?`mixed`:n,...i,ref:t,"data-state":HB(n),onSelect:Fe(i.onSelect,()=>r?.(VB(n)?!0:!n),{checkForDefaultPrevented:!1})})})});_B.displayName=gB;var vB=`MenuRadioGroup`,[yB,bB]=zz(vB,{value:void 0,onValueChange:()=>{}}),xB=Z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=Re(r);return(0,$.jsx)(yB,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,$.jsx)(lB,{...i,ref:t})})});xB.displayName=vB;var SB=`MenuRadioItem`,CB=Z.forwardRef((e,t)=>{let{value:n,...r}=e,i=bB(SB,e.__scopeMenu),a=n===i.value;return(0,$.jsx)(TB,{scope:e.__scopeMenu,checked:a,children:(0,$.jsx)(mB,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":HB(a),onSelect:Fe(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});CB.displayName=SB;var wB=`MenuItemIndicator`,[TB,EB]=zz(wB,{checked:!1}),DB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=EB(wB,n);return(0,$.jsx)(Le,{present:r||VB(a.checked)||a.checked===!0,children:(0,$.jsx)(Ke.span,{...i,ref:t,"data-state":HB(a.checked)})})});DB.displayName=wB;var OB=`MenuSeparator`,kB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,$.jsx)(Ke.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});kB.displayName=OB;var AB=`MenuArrow`,jB=Z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Vz(n);return(0,$.jsx)(fn,{...i,...r,ref:t})});jB.displayName=AB;var MB=`MenuSub`,[NB,PB]=zz(MB),FB=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Wz(MB,t),o=Vz(t),[s,c]=Z.useState(null),[l,u]=Z.useState(null),d=Re(i);return Z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,$.jsx)(dn,{...o,children:(0,$.jsx)(Uz,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,$.jsx)(NB,{scope:t,contentId:He(),triggerId:He(),trigger:s,onTriggerChange:c,children:n})})})};FB.displayName=MB;var IB=`MenuSubTrigger`,LB=Z.forwardRef((e,t)=>{let n=Wz(IB,e.__scopeMenu),r=Kz(IB,e.__scopeMenu),i=PB(IB,e.__scopeMenu),a=nB(IB,e.__scopeMenu),o=Z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=Z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);Z.useEffect(()=>u,[u]),Z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=qe(t,i.onTriggerChange);return(0,$.jsx)(Yz,{asChild:!0,...l,children:(0,$.jsx)(hB,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":BB(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Fe(e.onPointerMove,JB(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Fe(e.onPointerLeave,JB(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Fe(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||a.searchRef.current!==``&&t.key===` `||Nz[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});LB.displayName=IB;var RB=`MenuSubContent`,zB=Z.forwardRef((e,t)=>{let n=Qz(eB,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Wz(eB,e.__scopeMenu),s=Kz(eB,e.__scopeMenu),c=PB(RB,e.__scopeMenu),l=Z.useRef(null),u=qe(t,l);return(0,$.jsx)(Iz.Provider,{scope:e.__scopeMenu,children:(0,$.jsx)(Le,{present:r||o.open,children:(0,$.jsx)(Iz.Slot,{scope:e.__scopeMenu,children:(0,$.jsx)(sB,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Fe(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Fe(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:Fe(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Pz[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});zB.displayName=RB;function BB(e){return e?`open`:`closed`}function VB(e){return e===`indeterminate`}function HB(e){return VB(e)?`indeterminate`:e?`checked`:`unchecked`}function UB(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function WB(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function GB(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=WB(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function KB(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function qB(e,t){return t?KB({x:e.clientX,y:e.clientY},t):!1}function JB(e){return t=>t.pointerType===`mouse`?e(t):void 0}var YB=qz,XB=Yz,ZB=$z,QB=rB,$B=lB,eV=dB,tV=mB,nV=_B,rV=xB,iV=CB,aV=DB,oV=kB,sV=jB,cV=LB,lV=zB,uV=`DropdownMenu`,[dV,fV]=Ie(uV,[Bz]),pV=Bz(),[mV,hV]=dV(uV),gV=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=pV(t),l=Z.useRef(null),[u,d]=Pe({prop:i,defaultProp:a??!1,onChange:o,caller:uV});return(0,$.jsx)(mV,{scope:t,triggerId:He(),triggerRef:l,contentId:He(),open:u,onOpenChange:d,onOpenToggle:Z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,$.jsx)(YB,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};gV.displayName=uV;var _V=`DropdownMenuTrigger`,vV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=hV(_V,n),o=pV(n),s=qe(t,a.triggerRef);return(0,$.jsx)(XB,{asChild:!0,...o,children:(0,$.jsx)(Ke.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:Fe(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Fe(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});vV.displayName=_V;var yV=`DropdownMenuPortal`,bV=e=>{let{__scopeDropdownMenu:t,...n}=e,r=pV(t);return(0,$.jsx)(ZB,{...r,...n})};bV.displayName=yV;var xV=`DropdownMenuContent`,SV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=hV(xV,n),a=pV(n),o=Z.useRef(!1);return(0,$.jsx)(QB,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Fe(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Fe(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});SV.displayName=xV;var CV=`DropdownMenuGroup`,wV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)($B,{...i,...r,ref:t})});wV.displayName=CV;var TV=`DropdownMenuLabel`,EV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(eV,{...i,...r,ref:t})});EV.displayName=TV;var DV=`DropdownMenuItem`,OV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(tV,{...i,...r,ref:t})});OV.displayName=DV;var kV=`DropdownMenuCheckboxItem`,AV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(nV,{...i,...r,ref:t})});AV.displayName=kV;var jV=`DropdownMenuRadioGroup`,MV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(rV,{...i,...r,ref:t})});MV.displayName=jV;var NV=`DropdownMenuRadioItem`,PV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(iV,{...i,...r,ref:t})});PV.displayName=NV;var FV=`DropdownMenuItemIndicator`,IV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(aV,{...i,...r,ref:t})});IV.displayName=FV;var LV=`DropdownMenuSeparator`,RV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(oV,{...i,...r,ref:t})});RV.displayName=LV;var zV=`DropdownMenuArrow`,BV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(sV,{...i,...r,ref:t})});BV.displayName=zV;var VV=`DropdownMenuSubTrigger`,HV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(cV,{...i,...r,ref:t})});HV.displayName=VV;var UV=`DropdownMenuSubContent`,WV=Z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=pV(n);return(0,$.jsx)(lV,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});WV.displayName=UV;var GV=gV,KV=vV,qV=bV,JV=SV,YV=OV,XV=RV;function ZV(e){return e?e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `):null}function QV(e){let t=(0,Q.c)(15),{item:n,onInvoke:r}=e;if(n.type===`separator`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(XV,{className:`my-1 h-px bg-edge-subtle`}),t[0]=e):e=t[0],e}let i;t[1]===n.accelerator?i=t[2]:(i=ZV(n.accelerator),t[1]=n.accelerator,t[2]=i);let a=i,o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=K(`flex min-h-7 cursor-default select-none items-center gap-6 rounded-md px-2 py-1.5 text-xs text-fg outline-none`,`data-[highlighted]:bg-surface-hover data-[highlighted]:text-fg`),t[3]=o):o=t[3];let s;t[4]!==n.id||t[5]!==r?(s=()=>r(n.id),t[4]=n.id,t[5]=r,t[6]=s):s=t[6];let c;t[7]===n.label?c=t[8]:(c=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.label}),t[7]=n.label,t[8]=c);let l;t[9]===a?l=t[10]:(l=a?(0,$.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-mono text-[11px] text-fg-subtle`,children:a}):null,t[9]=a,t[10]=l);let u;return t[11]!==s||t[12]!==c||t[13]!==l?(u=(0,$.jsxs)(YV,{className:o,onSelect:s,children:[c,l]}),t[11]=s,t[12]=c,t[13]=l,t[14]=u):u=t[14],u}function $V(e){let t=(0,Q.c)(6),{groups:n}=e,r=eH,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=K(`windows-titlebar-interactive flex min-w-0 items-center gap-1`,md),t[0]=i):i=t[0];let a;if(t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=e=>(0,$.jsxs)(GV,{modal:!1,children:[(0,$.jsx)(KV,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:K(`inline-flex h-8 shrink-0 items-center rounded-md px-3 text-sm font-normal text-fg-muted`,`outline-none transition-colors hover:bg-surface-hover hover:text-fg`,`focus-visible:ring-2 focus-visible:ring-accent/60 data-[state=open]:bg-surface-hover data-[state=open]:text-fg`,md),role:`menuitem`,children:e.label})}),(0,$.jsx)(qV,{children:(0,$.jsx)(JV,{align:`start`,sideOffset:4,className:K(`windows-titlebar-interactive z-[90] min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover outline-none`,md),children:e.items.map((t,n)=>(0,$.jsx)(QV,{item:t,onInvoke:r},t.type===`item`?t.id:`${e.id}-separator-${n}`))})})]},e.id),t[3]=e):e=t[3],a=n.map(e),t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:i,role:`menubar`,children:a}),t[4]=a,t[5]=o),o}function eH(e){window.electronAPI?.menu?.invoke(e)}var tH=(0,Z.memo)(function(){let e=(0,Q.c)(11),t=Ee(nH),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],e[0]=n):n=e[0];let[r,i]=(0,Z.useState)(n),a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{if(!tD())return;let e=!1;return window.electronAPI?.menu?.getModel().then(t=>{e||i(t)}).catch(()=>{e||i([])}),()=>{e=!0}},e[1]=a):a=e[1];let o;if(e[2]===t?o=e[3]:(o=[t],e[2]=t,e[3]=o),(0,Z.useEffect)(a,o),!tD())return null;let s,c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=K(`windows-titlebar flex h-9 min-w-0 shrink-0 items-center gap-2 border-b border-edge-subtle`),c=(0,$.jsx)(`div`,{className:K(`windows-titlebar-interactive flex shrink-0 items-center gap-0.5`,md),children:(0,$.jsx)(Zf,{sidebarToggleVariant:`main`})}),e[4]=s,e[5]=c):(s=e[4],c=e[5]);let l;e[6]===r?l=e[7]:(l=(0,$.jsx)($V,{groups:r}),e[6]=r,e[7]=l);let u;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:K(`min-w-8 flex-1 self-stretch`,pd),"aria-hidden":!0}),e[8]=u):u=e[8];let d;return e[9]===l?d=e[10]:(d=(0,$.jsxs)(`header`,{className:s,children:[c,l,u]}),e[9]=l,e[10]=d),d});function nH(e){return e.language}function rH(){let e=(0,Q.c)(16),t=Ee(iH),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n.electron,[i,a]=(0,Z.useState)(null),o,s;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{if(!An())return;let e=window.electronAPI?.gateway;if(e?.onExited)return e.onExited(e=>a(e))},s=[],e[2]=o,e[3]=s):(o=e[2],s=e[3]),(0,Z.useEffect)(o,s),!i)return null;let c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=K(`shrink-0 border-b border-danger/35 bg-danger/10 px-4 py-3 text-sm text-fg shadow-surface`),e[4]=c):c=e[4];let l;e[5]===r.gatewayExitTitle?l=e[6]:(l=(0,$.jsx)(`p`,{className:`font-semibold`,children:r.gatewayExitTitle}),e[5]=r.gatewayExitTitle,e[6]=l);let u;e[7]===r.gatewayExitBody?u=e[8]:(u=(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:r.gatewayExitBody}),e[7]=r.gatewayExitBody,e[8]=u);let d=i.code??`—`,f=i.signal??`—`,p;e[9]!==d||e[10]!==f?(p=(0,$.jsxs)(`p`,{className:`mt-2 font-mono text-xs text-fg-muted`,children:[`exit `,d,` · signal `,f]}),e[9]=d,e[10]=f,e[11]=p):p=e[11];let m;return e[12]!==l||e[13]!==u||e[14]!==p?(m=(0,$.jsxs)(`div`,{className:c,role:`alert`,children:[l,u,p]}),e[12]=l,e[13]=u,e[14]=p,e[15]=m):m=e[15],m}function iH(e){return e.language}function aH(e){return{content:[{type:`text`,text:e}]}}function oH(e,t,n){if(Object.keys(e).length!==1||typeof e[t]!=`string`)throw TypeError(`Expected exactly one string argument: ${t}`);let r=e[t];if(!r||r.length>n)throw TypeError(`Invalid ${t}`);return r}function sH(e){let t=globalThis.atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function cH(e){return[{descriptor:{name:`desktop.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one local file and make it available to the agent.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:Jv,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(t,n){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let r=await e().file.pickEndpointFile();if(!r)throw new DOMException(`File selection cancelled`,`AbortError`);let i=sH(r.dataBase64);if(i.byteLength!==r.size||i.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await n.uploadFile({name:r.name,mimeType:r.mimeType,bytes:i})]}}},{descriptor:{name:`desktop.file.save`,title:`Save a text file`,description:`Ask the user where to save UTF-8 text generated by the agent.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`suggestedName`,`content`],properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}}},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-write`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.suggestedName,r=t.content;if(Object.keys(t).length!==2||typeof n!=`string`||!n||n.length>255||typeof r!=`string`||r.length>2e5||new TextEncoder().encode(r).byteLength>200*1024)throw TypeError(`Invalid file save arguments`);let i=await e().file.saveEndpointText({suggestedName:n,content:r});if(!i.saved)throw new DOMException(`File save cancelled`,`AbortError`);return aH(`Saved ${i.name}`)}},{descriptor:{name:`desktop.notification.show`,title:`Show a notification`,description:`Show a bounded native desktop notification after user confirmation.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`title`,`body`],properties:{title:{type:`string`,minLength:1,maxLength:120},body:{type:`string`,minLength:1,maxLength:500}}},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`notifications`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=t.title,r=t.body;if(Object.keys(t).length!==2||typeof n!=`string`||!n.trim()||n.length>120||typeof r!=`string`||!r.trim()||r.length>500)throw TypeError(`Invalid notification arguments`);let i=e().system;if(!i)throw Error(`Desktop notifications are unavailable`);let a=await i.showEndpointNotification({title:n,body:r});if(!a.ok)throw a.error===`PERMISSION_DENIED`||a.error===`NOTIFICATIONS_DISABLED`?new DOMException(`Desktop notification permission is not granted`,`NotAllowedError`):Error(`Desktop notification failed: ${a.error}`);return aH(`Notification shown.`)}},{descriptor:{name:`desktop.clipboard.read`,title:`Read the clipboard`,description:`Read plain text from the desktop clipboard.`,inputSchema:{type:`object`,additionalProperties:!1,properties:{}},outputSchema:qv,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-read`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){if(Object.keys(t).length!==0)throw TypeError(`Expected no arguments`);let n=e().clipboard;if(!n?.readText)throw Error(`Clipboard read is unavailable`);return aH(await n.readText())}},{descriptor:{name:`desktop.clipboard.write`,title:`Write to the clipboard`,description:`Replace the desktop clipboard with plain text.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`text`],properties:{text:{type:`string`,minLength:1,maxLength:1e5}}},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(t){let n=oH(t,`text`,1e5),r=e().clipboard;if(!r?.writeText||!await r.writeText(n))throw Error(`Clipboard write failed`);return aH(`Clipboard updated.`)}},{descriptor:{name:`desktop.app.open_external`,title:`Open an external URL`,description:`Open an HTTP or HTTPS URL in the default desktop application.`,inputSchema:{type:`object`,additionalProperties:!1,required:[`url`],properties:{url:{type:`string`,minLength:1,maxLength:2048}}},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`open-external-url`],timeoutMs:15e3,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(t){let n=oH(t,`url`,2048),r=new URL(n);if(r.protocol!==`http:`&&r.protocol!==`https:`)throw TypeError(`Only HTTP and HTTPS URLs are allowed`);let i=e().shell;if(!i?.openExternalUrl)throw Error(`External URL opening is unavailable`);let a=await i.openExternalUrl(r.href);if(!a.ok)throw Error(a.error);return aH(`Opened ${r.href}`)}}]}var lH=cH(()=>{if(!window.electronAPI)throw Error(`Desktop bridge is unavailable`);return window.electronAPI}),uH=600,dH=[],fH=new Set;function pH(){for(let e of fH)e()}function mH(){return dH[0]}function hH(e){return fH.add(e),()=>fH.delete(e)}function gH(e){let t=JSON.stringify(e,null,2);return t.length<=uH?t:`${t.slice(0,uH)}\n…`}function _H(e){return e.deadlineAt<=Date.now()?Promise.resolve(!1):new Promise(t=>{let n=window.setTimeout(()=>vH(e.invocationId,!1),e.deadlineAt-Date.now());dH.push({invocationId:e.invocationId,title:e.title,argumentsPreview:gH(e.args),resolve:t,timeout:n}),pH()})}function vH(e,t){let n=dH.findIndex(t=>t.invocationId===e);if(n<0)return;let[r]=dH.splice(n,1);window.clearTimeout(r.timeout),r.resolve(t),pH()}function yH(){let e=dH;dH=[];for(let t of e)window.clearTimeout(t.timeout),t.resolve(!1);pH()}function bH(){return(0,Z.useSyncExternalStore)(hH,mH,mH)}function xH(){let e=(0,Q.c)(38),t=bH(),n=Ee(SH)===`zh`,r=!!t,i;e[0]===t?i=e[1]:(i=e=>{!e&&t&&vH(t.invocationId,!1)},e[0]=t,e[1]=i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[2]=a):a=e[2];let o=n?`允许端侧工具执行?`:`Allow endpoint tool?`,s;e[3]===o?s=e[4]:(s=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:o}),e[3]=o,e[4]=s);let c=t?.title??``,l;e[5]===c?l=e[6]:(l=(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:c}),e[5]=c,e[6]=l);let u;e[7]!==s||e[8]!==l?(u=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-5 py-4`,children:[s,l]}),e[7]=s,e[8]=l,e[9]=u):u=e[9];let d=n?`实际参数`:`Arguments`,f;e[10]===d?f=e[11]:(f=(0,$.jsx)(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:d}),e[10]=d,e[11]=f);let p=t?.argumentsPreview??`{}`,m;e[12]===p?m=e[13]:(m=(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap break-words rounded-lg border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg`,children:p}),e[12]=p,e[13]=m);let h;e[14]!==m||e[15]!==f?(h=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:[f,m]}),e[14]=m,e[15]=f,e[16]=h):h=e[16];let g;e[17]===t?g=e[18]:(g=()=>t&&vH(t.invocationId,!1),e[17]=t,e[18]=g);let _=n?`拒绝`:`Deny`,v;e[19]!==g||e[20]!==_?(v=(0,$.jsx)(X,{onClick:g,children:_}),e[19]=g,e[20]=_,e[21]=v):v=e[21];let y;e[22]===t?y=e[23]:(y=()=>t&&vH(t.invocationId,!0),e[22]=t,e[23]=y);let b=n?`允许`:`Allow`,x;e[24]!==y||e[25]!==b?(x=(0,$.jsx)(X,{variant:`primary`,onClick:y,children:b}),e[24]=y,e[25]=b,e[26]=x):x=e[26];let S;e[27]!==v||e[28]!==x?(S=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[v,x]}),e[27]=v,e[28]=x,e[29]=S):S=e[29];let C;e[30]!==h||e[31]!==S||e[32]!==u?(C=(0,$.jsxs)($e,{children:[a,(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(26rem,calc(100vh-2rem))] w-[min(32rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[u,h,S]})]}),e[30]=h,e[31]=S,e[32]=u,e[33]=C):C=e[33];let w;return e[34]!==r||e[35]!==i||e[36]!==C?(w=(0,$.jsx)(nt,{open:r,onOpenChange:i,children:C}),e[34]=r,e[35]=i,e[36]=C,e[37]=w):w=e[37],w}function SH(e){return e.language}function CH(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function wH(e,...t){if(!CH(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function TH(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function EH(e,t){wH(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function DH(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function OH(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function kH(e,t){return e<<32-t|e>>>t}function AH(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function jH(e){return typeof e==`string`&&(e=AH(e)),wH(e),e}var MH=class{};function NH(e){let t=t=>e().update(jH(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function PH(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function FH(e,t,n){return e&t^~e&n}function IH(e,t,n){return e&t^e&n^t&n}var LH=class extends MH{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=OH(this.buffer)}update(e){TH(this),e=jH(e),wH(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=OH(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){TH(this),EH(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,DH(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;PH(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=OH(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},RH=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),zH=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),BH=new Uint32Array(64),VH=class extends LH{constructor(e=32){super(64,e,8,!1),this.A=RH[0]|0,this.B=RH[1]|0,this.C=RH[2]|0,this.D=RH[3]|0,this.E=RH[4]|0,this.F=RH[5]|0,this.G=RH[6]|0,this.H=RH[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)BH[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=BH[e-15],n=BH[e-2],r=kH(t,7)^kH(t,18)^t>>>3;BH[e]=(kH(n,17)^kH(n,19)^n>>>10)+BH[e-7]+r+BH[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=kH(o,6)^kH(o,11)^kH(o,25),u=l+t+FH(o,s,c)+zH[e]+BH[e]|0,d=(kH(n,2)^kH(n,13)^kH(n,22))+IH(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){DH(BH)}destroy(){this.set(0,0,0,0,0,0,0,0),DH(this.buffer)}},HH=NH(()=>new VH),UH=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`EndpointToolClientError`}};function WH(e){return[...HH(new TextEncoder().encode(Yv(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var GH=class{tools=new Map;constructor(e){for(let t of e){let e=t.descriptor.name;if(this.tools.has(e))throw Error(`Duplicate endpoint tool: ${e}`);this.tools.set(e,{definition:t,revision:WH(t.descriptor)})}}descriptors(){return[...this.tools.values()].map(({definition:e})=>e.descriptor)}get(e){return this.tools.get(e)}},KH=class{options;active=new Map;now;sendMessage;generation=0;constructor(e){this.options=e,this.now=e.now??Date.now}connect(e){this.disconnect(),this.sendMessage=e}disconnect(){this.generation+=1,this.sendMessage=void 0;for(let e of this.active.values())e.controller.abort();this.active.clear()}publishAvailability(){this.send(`endpoint.availability_changed`,{availability:this.options.getAvailability()})}async handleMessage(e){if(e.type===`tool.cancel`){this.cancel(e.payload.invocationId);return}await this.invoke(e)}async invoke(e){let{invocationId:t,toolName:n,arguments:r,descriptorRevision:i,confirmationRequired:a,deadlineAt:o,uploadGrant:s}=e.payload;if(this.active.has(t)){this.sendError(t,`PROTOCOL_ERROR`,`Endpoint invocation is already running`);return}this.send(`tool.received`,{invocationId:t});let c=this.options.registry.get(n);if(!c){this.sendError(t,`TOOL_NOT_FOUND`,`Endpoint tool is not registered`);return}if(c.revision!==i){this.sendError(t,`TOOL_REVISION_MISMATCH`,`Endpoint tool contract changed`);return}let l=c.definition.descriptor,u=l.confirmation===`always`;if(a!==u){this.sendError(t,`PROTOCOL_ERROR`,`Endpoint confirmation policy mismatch`);return}let d={controller:new AbortController,generation:this.generation};this.active.set(t,d);try{this.assertExecutable(t,d,l,o);let e={invocationId:t,descriptor:l,arguments:r,deadlineAt:o,signal:d.controller.signal};if(await this.options.authorize?.(e),this.assertExecutable(t,d,l,o),u){this.send(`tool.progress`,{invocationId:t,message:`Waiting for approval`});let n=await this.options.confirm(e);if(this.assertExecutable(t,d,l,o),!n)throw new UH(`USER_DENIED`,`User denied the endpoint tool call`)}let n=await c.definition.execute(r,{invocationId:t,signal:d.controller.signal,reportProgress:e=>{this.isCurrent(t,d)&&this.send(`tool.progress`,{invocationId:t,...e})},uploadFile:e=>(this.assertExecutable(t,d,l,o),this.options.uploadFile(s,e,{signal:d.controller.signal,invocationId:t}))});this.assertExecutable(t,d,l,o);let i=Hv.array().min(1).max(20).parse(n.content);if(this.send(`tool.result`,{invocationId:t,content:i,...n.details?{details:n.details}:{}}),this.active.delete(t),n.afterSend){let e=d.generation;setTimeout(()=>{this.generation===e&&this.now()<o&&(!l.requiresForeground||this.options.getAvailability()===`foreground`)&&n.afterSend?.()},this.options.afterSendDelayMs??50)}}catch(e){if(!this.isCurrent(t,d))return;this.active.delete(t);let n=this.normalizeError(e);this.sendError(t,n.code,n.message)}}cancel(e){let t=this.active.get(e);t&&(this.active.delete(e),t.controller.abort(),this.send(`tool.cancelled`,{invocationId:e}))}assertExecutable(e,t,n,r){if(!this.isCurrent(e,t)||t.controller.signal.aborted)throw new UH(`TOOL_CANCELLED`,`Endpoint tool call was cancelled`);if(this.now()>=r)throw new UH(`TOOL_TIMEOUT`,`Endpoint tool deadline expired`);if(n.requiresForeground&&this.options.getAvailability()!==`foreground`)throw new UH(`ENDPOINT_NOT_FOREGROUND`,`Endpoint is not foreground`)}isCurrent(e,t){return this.active.get(e)===t&&t.generation===this.generation&&this.sendMessage!==void 0}normalizeError(e){return e instanceof UH?e:e instanceof Error&&e.name===`RealtimeFrameTooLargeError`?new UH(`RESULT_TOO_LARGE`,e.message):e instanceof TypeError?new UH(`INVALID_ARGUMENTS`,e.message):e instanceof Error&&e.name===`AbortError`?new UH(`USER_DENIED`,e.message):e instanceof Error&&e.name===`NotAllowedError`?new UH(`PERMISSION_DENIED`,e.message):new UH(`PROTOCOL_ERROR`,e instanceof Error?e.message:String(e))}sendError(e,t,n){this.send(`tool.error`,{invocationId:e,code:t,message:n})}send(e,t){this.sendMessage?.({protocolVersion:2,messageId:this.options.createMessageId(),type:e,sentAt:this.now(),payload:t})}},qH=`xopc-endpoint-tools`,JH=`identity`,YH=`xopc.endpoint-tools.endpoint-id`,XH;function ZH(e){if(XH?.startsWith(`${e}:`))return XH;let t=sessionStorage.getItem(YH);return t?.startsWith(`${e}:`)?(XH=t,t):(XH=`${e}:${crypto.randomUUID()}`,sessionStorage.setItem(YH,XH),XH)}function QH(e){let t=String.fromCharCode(...new Uint8Array(e));return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/u,``)}function $H(){return new Promise((e,t)=>{let n=indexedDB.open(qH,1);n.onupgradeneeded=()=>n.result.createObjectStore(JH),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Endpoint identity database failed`))})}async function eU(e){let t=await $H();try{return await new Promise((n,r)=>{let i=t.transaction(JH).objectStore(JH).get(e);i.onsuccess=()=>n(i.result),i.onerror=()=>r(i.error??Error(`Endpoint identity read failed`))})}finally{t.close()}}async function tU(e,t){let n=await $H();try{await new Promise((r,i)=>{let a=n.transaction(JH,`readwrite`);a.objectStore(JH).put(t,e),a.oncomplete=()=>r(),a.onerror=()=>i(a.error??Error(`Endpoint identity write failed`))})}finally{n.close()}}async function nU(e){let t=await $H();try{await new Promise((n,r)=>{let i=t.transaction(JH,`readwrite`);i.objectStore(JH).delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error??Error(`Endpoint identity deletion failed`))})}finally{t.close()}}async function rU(e){let t=await eU(e);if(t)return t;let n=await crypto.subtle.generateKey({name:`ECDSA`,namedCurve:`P-256`},!0,[`sign`,`verify`]),r=QH(await crypto.subtle.exportKey(`spki`,n.publicKey)),i=await crypto.subtle.importKey(`pkcs8`,await crypto.subtle.exportKey(`pkcs8`,n.privateKey),{name:`ECDSA`,namedCurve:`P-256`},!1,[`sign`]),a={principalId:crypto.randomUUID(),publicKey:r,privateKey:i};return await tU(e,a),a}async function iU(e){return await nU(e),XH=void 0,sessionStorage.removeItem(YH),rU(e)}async function aU(e,t){return QH(await crypto.subtle.sign({name:`ECDSA`,hash:`SHA-256`},e,new TextEncoder().encode(t)))}var oU=2e3;function sU(){return document.visibilityState===`visible`&&document.hasFocus()?`foreground`:`background`}async function cU(e){if(e.signal.aborted)return!1;let t=()=>vH(e.invocationId,!1);e.signal.addEventListener(`abort`,t,{once:!0});try{return await _H({invocationId:e.invocationId,title:e.descriptor.title,args:e.arguments,deadlineAt:e.deadlineAt})}finally{e.signal.removeEventListener(`abort`,t)}}var lU=class{config;reconnectTimer;connectPromise;detachRealtime;stopped=!1;registrationBlocked=!1;endpointId;turnToken;registry;controller;constructor(e){this.config=e,this.registry=new GH(e.definitions),this.controller=new KH({registry:this.registry,getAvailability:sU,confirm:cU,uploadFile:(e,t)=>this.uploadFile(e,t),createMessageId:()=>crypto.randomUUID()})}async start(){this.stopped=!1,this.registrationBlocked=!1,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`gateway-authenticated`,this.onTokenSaved),await this.connect()}stop(){this.stopped=!0,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`gateway-authenticated`,this.onTokenSaved),window.clearTimeout(this.reconnectTimer),this.detachRealtime?.(),this.detachRealtime=void 0,this.controller.disconnect(),Sv(this.turnToken),this.turnToken=void 0,this.endpointId=void 0,yH()}onTokenSaved=()=>{this.registrationBlocked=!1,this.connect()};onVisibilityChange=()=>{this.controller.publishAvailability()};connect(e=!0){if(this.connectPromise)return this.connectPromise;let t=this.connectOnce(e).finally(()=>{this.connectPromise===t&&(this.connectPromise=void 0)});return this.connectPromise=t,t}async connectOnce(e){if(!(this.stopped||this.registrationBlocked)){window.clearTimeout(this.reconnectTimer);try{let t=await rU(this.config.kind);if(this.stopped)return;let n=await we(J(`/api/endpoint-tools/principals`),{method:`POST`,body:JSON.stringify({principalId:t.principalId,displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,publicKey:t.publicKey})});if(!n.ok){if((await n.json().catch(()=>null))?.error?.code===`PRINCIPAL_REVOKED`){if(!e){this.registrationBlocked=!0;return}let t=await this.config.confirmReenrollment();if(this.stopped)return;if(!t){this.registrationBlocked=!0;return}await iU(this.config.kind),this.stopped||await this.connectOnce(!1);return}if(n.status>=400&&n.status<500){this.registrationBlocked=!0;return}throw Error(`Endpoint registration failed: ${n.status}`)}if(this.stopped)return;let r={createHello:()=>this.createHello(t),onReady:({endpointId:e,turnToken:t})=>{this.endpointId=e,this.turnToken=t,xv(e,t),this.controller.connect(Ny)},onMessage:e=>{this.controller.handleMessage(e)},onDisconnected:()=>{this.controller.disconnect(),Sv(this.turnToken),this.turnToken=void 0,yH()}};this.detachRealtime?.(),this.detachRealtime=My(r)}catch{this.scheduleReconnect()}}}scheduleReconnect(){this.stopped||this.reconnectTimer!==void 0||(this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=void 0,this.connect()},oU))}async createHello(e){let t=ZH(e.principalId);this.endpointId=t;let n={principalId:e.principalId,endpointId:t,connectionInstanceId:crypto.randomUUID(),displayName:this.config.displayName,kind:this.config.kind,platform:this.config.platform,appVersion:this.config.appVersion,availability:sU(),nonce:crypto.randomUUID(),signedAt:Date.now(),signature:`pending`,tools:this.registry.descriptors()},r=await aU(e.privateKey,Xv(n));return{...n,signature:r}}async uploadFile(e,t){if(!e||!this.endpointId)throw Error(`Endpoint file upload grant is unavailable`);if(!t.name||t.name.length>255||!t.mimeType||t.mimeType.length>255||t.bytes.byteLength>e.maxBytes||e.expiresAt<=Date.now())throw TypeError(`Endpoint file is invalid`);let n=new URL(J(e.path),window.location.href);n.searchParams.set(`name`,t.name);let r=t.bytes.buffer.slice(t.bytes.byteOffset,t.bytes.byteOffset+t.bytes.byteLength),i=await we(n,{method:`POST`,headers:{"Content-Type":t.mimeType,"x-endpoint-id":this.endpointId,"x-endpoint-upload-token":e.token},body:r}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error?.message??`Endpoint file upload failed: ${i.status}`);let o=Hv.safeParse(a?.payload);if(!o.success||o.data.type!==`file`)throw Error(`Endpoint file upload returned an invalid response`);return o.data}},uU,dU=new Set;function fU(){for(let e of dU)e()}function pU(e){return dU.add(e),()=>dU.delete(e)}function mU(){return!!uU}function hU(){return uU?Promise.resolve(!1):new Promise(e=>{uU={resolve:e},fU()})}function gU(e){let t=uU;t&&(uU=void 0,t.resolve(e),fU())}function _U(){return(0,Z.useSyncExternalStore)(pU,mU,mU)}function vU(){let e=(0,Q.c)(21),t=_U(),n=Ee(SU)===`zh`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[140] bg-scrim backdrop-blur-[2px]`}),e[0]=r):r=e[0];let i=n?`重新注册此端?`:`Re-enroll this endpoint?`,a;e[1]===i?a=e[2]:(a=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:i}),e[1]=i,e[2]=a);let o=n?`此端身份已被撤销。继续会删除旧密钥并生成一个新的端身份,然后重新连接 Gateway。`:`This endpoint identity was revoked. Continuing deletes the old key, creates a new endpoint identity, and reconnects to the Gateway.`,s;e[3]===o?s=e[4]:(s=(0,$.jsx)(Ze,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:o}),e[3]=o,e[4]=s);let c;e[5]!==a||e[6]!==s?(c=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:[a,s]}),e[5]=a,e[6]=s,e[7]=c):c=e[7];let l=n?`取消`:`Cancel`,u;e[8]===l?u=e[9]:(u=(0,$.jsx)(X,{onClick:bU,children:l}),e[8]=l,e[9]=u);let d=n?`生成新身份`:`Create new identity`,f;e[10]===d?f=e[11]:(f=(0,$.jsx)(X,{variant:`primary`,onClick:yU,children:d}),e[10]=d,e[11]=f);let p;e[12]!==u||e[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[u,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14];let m;e[15]!==p||e[16]!==c?(m=(0,$.jsxs)($e,{children:[r,(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[150] flex h-[min(22rem,calc(100vh-2rem))] w-[min(30rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[c,p]})]}),e[15]=p,e[16]=c,e[17]=m):m=e[17];let h;return e[18]!==t||e[19]!==m?(h=(0,$.jsx)(nt,{open:t,onOpenChange:xU,children:m}),e[18]=t,e[19]=m,e[20]=h):h=e[20],h}function yU(){return gU(!0)}function bU(){return gU(!1)}function xU(e){return!e&&gU(!1)}function SU(e){return e.language}function CU(e){return{content:[{type:`text`,text:e}]}}function wU(){if(!navigator.userActivation?.isActive)throw new DOMException(`A current user gesture is required`,`NotAllowedError`)}function TU(e){return new DOMException(e,`AbortError`)}function EU(e){let t=e.suggestedName,n=e.content;if(Object.keys(e).length!==2||typeof t!=`string`||!t||t===`.`||t===`..`||t.length>255||t.includes(`/`)||t.includes(`\\`)||typeof n!=`string`||n.length>2e5||new TextEncoder().encode(n).byteLength>200*1024)throw TypeError(`Invalid file download arguments`);return{suggestedName:t,content:n}}function DU(){return wU(),new Promise((e,t)=>{let n=document.createElement(`input`);n.type=`file`,n.multiple=!1,n.onchange=()=>{let r=n.files?.[0];r?e(r):t(TU(`File selection cancelled`))},n.oncancel=()=>t(TU(`File selection cancelled`)),n.click()})}function OU(e,t){let n=e[t];if(typeof n!=`string`||n.length===0)throw TypeError(`${t} must be a non-empty string`);return n}function kU(e,t){let n=Object.keys(e).toSorted(),r=t.toSorted();if(n.length!==r.length||n.some((e,t)=>e!==r[t]))throw TypeError(`arguments must contain exactly: ${r.join(`, `)||`no fields`}`)}var AU=[{descriptor:{name:`web.file.pick`,title:`Choose a local file`,description:`Ask the user to choose one browser-accessible file and make it available to the agent.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:Jv,policyId:`personal.foreground-read`,sensitivity:`personal`,effect:`read`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-read`],timeoutMs:12e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`file`]},async execute(e,t){kU(e,[]);let n=await DU();if(n.size>26214400)throw TypeError(`Selected file exceeds ${wv} bytes`);let r=new Uint8Array(await n.arrayBuffer());if(r.byteLength!==n.size||r.byteLength>26214400)throw Error(`Selected file payload is invalid`);return{content:[await t.uploadFile({name:n.name,mimeType:n.type||`application/octet-stream`,bytes:r})]}}},{descriptor:{name:`web.file.download`,title:`Download a text file`,description:`Download bounded UTF-8 text generated by the agent through this browser.`,inputSchema:{type:`object`,properties:{suggestedName:{type:`string`,minLength:1,maxLength:255},content:{type:`string`,maxLength:2e5}},required:[`suggestedName`,`content`],additionalProperties:!1},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`file-download`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){let{suggestedName:t,content:n}=EU(e);wU();let r=URL.createObjectURL(new Blob([n],{type:`text/plain;charset=utf-8`}));try{let e=document.createElement(`a`);e.href=r,e.download=t,e.click()}finally{URL.revokeObjectURL(r)}return CU(`Download started: ${t}`)}},{descriptor:{name:`web.page.get_selection`,title:`Read selected text`,description:`Read the text currently selected in this browser tab.`,inputSchema:{type:`object`,properties:{},additionalProperties:!1},outputSchema:qv,policyId:`public.foreground-read`,sensitivity:`public`,effect:`read`,confirmation:`never`,requiresForeground:!0,requiredPermissions:[],timeoutMs:1e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){return kU(e,[]),CU(window.getSelection()?.toString()??``)}},{descriptor:{name:`web.clipboard.write`,title:`Write clipboard`,description:`Write text to the clipboard from this browser tab.`,inputSchema:{type:`object`,properties:{text:{type:`string`,maxLength:1e5}},required:[`text`],additionalProperties:!1},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`write`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`clipboard-write`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!0,resultKinds:[`text`]},async execute(e){if(kU(e,[`text`]),!navigator.clipboard||!document.hasFocus())throw new DOMException(`Clipboard access requires a focused browser tab`,`NotAllowedError`);let t=OU(e,`text`);if(t.length>1e5)throw TypeError(`text exceeds 100000 characters`);return await navigator.clipboard.writeText(t),CU(`Clipboard updated.`)}},{descriptor:{name:`web.page.navigate`,title:`Navigate page`,description:`Navigate this browser tab to an HTTP or HTTPS URL.`,inputSchema:{type:`object`,properties:{url:{type:`string`,maxLength:4096}},required:[`url`],additionalProperties:!1},outputSchema:qv,policyId:`user.foreground-write`,sensitivity:`personal`,effect:`destructive`,confirmation:`always`,requiresForeground:!0,requiredPermissions:[`navigation`],timeoutMs:3e4,maxConcurrency:1,supportsCancellation:!1,idempotent:!1,resultKinds:[`text`]},async execute(e){kU(e,[`url`]);let t=OU(e,`url`);if(t.length>4096)throw TypeError(`url exceeds 4096 characters`);let n=new URL(t,window.location.href);if(n.protocol!==`http:`&&n.protocol!==`https:`)throw TypeError(`url must use HTTP or HTTPS`);return{content:[{type:`text`,text:`Navigating to ${n.href}`}],afterSend:()=>window.location.assign(n.href)}}}];function jU(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(MU,t);let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xH,{}),(0,$.jsx)(vU,{})]}),e[1]=n):n=e[1],n}function MU(){let e=An();if(e&&window.electronAPI?.computer){let e=!1,t=async()=>{try{let t=await window.electronAPI.computer.status();if(e)return;t.claim?xv(t.claim.endpointId,t.claim.token):Sv()}catch{e||Sv()}};t();let n=window.setInterval(()=>{t()},1e3);return()=>{e=!0,window.clearInterval(n),Sv()}}let t=new lU(e?{kind:`desktop`,platform:window.electronAPI?.platform??`desktop`,displayName:`xopc Desktop`,appVersion:`1`,definitions:lH,confirmReenrollment:hU}:{kind:`web`,platform:`web`,displayName:`Web browser`,appVersion:`1`,definitions:AU,confirmReenrollment:hU});return t.start(),()=>{gU(!1),t.stop()}}var NU=`open-discussion-capture`;function PU(e){window.dispatchEvent(new CustomEvent(NU,{detail:e?{projectId:e}:{}}))}function FU(){let e=(0,Q.c)(3),t=l(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{if(!An())return;let e=window.electronAPI;if(!e?.menu)return;let n=e.menu.onNavigate(e=>{t(e)}),r=e.menu.onTogglePalette(RU),i=e.menu.onQuickCapture(LU),a=e.menu.onToggleSidebar(IU),o=e.menu.onHistoryNavigate(e=>{t(e)});return()=>{n(),r(),i(),a(),o()}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function IU(){Kf.getState().toggleCollapsed()}function LU(){PU()}function RU(){window.dispatchEvent(new CustomEvent(`toggle-command-palette`))}var zU=1500,BU=9e4;function VU(){let e=(0,Q.c)(16),t=Ee(WU),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n.updatePanel,[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(0),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=c.current+=1;a(!0),s(!1),(async()=>{await new Promise(UU);let t=Date.now()+BU;for(;e===c.current&&Date.now()<t;){try{if((await fetch(J(`/api/health`),{signal:AbortSignal.timeout(3e3)})).ok){window.location.reload();return}}catch{}await new Promise(HU)}e===c.current&&s(!0)})()},e[2]=l):l=e[2];let u=l,d,f;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{let e=()=>u();return window.addEventListener(`gateway-restart-initiated`,e),()=>{c.current+=1,window.removeEventListener(`gateway-restart-initiated`,e)}},f=[u],e[3]=d,e[4]=f):(d=e[3],f=e[4]),(0,Z.useEffect)(d,f);let p;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{u()},e[5]=p):p=e[5];let m=p;if(!i)return null;let h=o?`border-red-500/20 bg-red-500/10 text-red-800 dark:text-red-200`:`border-amber-500/25 bg-amber-500/10 text-amber-900 dark:text-amber-100`,g;e[6]===h?g=e[7]:(g=K(`flex min-h-10 w-full items-center justify-center gap-2 border-b px-4 py-2 text-sm`,h),e[6]=h,e[7]=g);let _;e[8]!==r.restartPollRetry||e[9]!==r.restartPollTimeout||e[10]!==r.restartPolling||e[11]!==o?(_=o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:r.restartPollTimeout}),(0,$.jsx)(`button`,{type:`button`,onClick:m,className:`ml-2 rounded bg-accent px-2 py-0.5 text-xs font-medium text-on-accent hover:bg-accent/90`,children:r.restartPollRetry})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartPolling})]}),e[8]=r.restartPollRetry,e[9]=r.restartPollTimeout,e[10]=r.restartPolling,e[11]=o,e[12]=_):_=e[12];let v;return e[13]!==g||e[14]!==_?(v=(0,$.jsx)(`div`,{className:g,children:_}),e[13]=g,e[14]=_,e[15]=v):v=e[15],v}function HU(e){return setTimeout(e,zU)}function UU(e){return setTimeout(e,2e3)}function WU(e){return e.language}async function GU(){if(An()&&window.electronAPI?.gateway?.restart){let e=await window.electronAPI.gateway.restart();return e.ok&&e.token&&await ke(),e}let e=await q(J(`/api/gateway/restart`),{method:`POST`,body:JSON.stringify({})});return e.ok===!1?{ok:!1,message:e.message??e.error??`Gateway restart failed`}:{ok:!0}}function KU({reminder:e,compact:t}){let n=Ee(e=>e.language),r=xe(n).updatePanel,{show:i,dismiss:a,electronQuitAndInstall:o,runNpmUpdate:s,npmUpdateRunning:c}=e,[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=(0,Z.useCallback)(async()=>{u(!0),f(null);try{let e=await GU();if(e.ok){window.dispatchEvent(new Event(`gateway-restart-initiated`));return}f(e.message??`Gateway restart failed`)}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]),m=(0,Z.useCallback)(async()=>{let e=xe(n).updatePanel;f(null);let t=await s();if(t.ok){Jl({tone:`success`,title:e.updateSuccess,message:dm(t.result)?e.updateSuccessAutoRestartDetail:e.updateSuccessDetail,source:n===`zh`?`系统更新`:`System update`,dedupeKey:`system-update`});return}f(`${t.error===`git-checkout`?e.updateErrorGit:t.error===`busy`?e.updateErrorBusy:e.updateErrorFailed}: ${t.message}`)},[s,n]);if(i.kind===`none`)return null;let h=K(`absolute right-2 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1 sm:right-3`,md);return i.kind===`electron-ready`?(0,$.jsxs)(`div`,{className:K(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 px-10 py-2 text-sm sm:px-12`,pd,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,48rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(P,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0`,children:r.reminderElectronReady.replace(`{{version}}`,i.version)})]}),(0,$.jsxs)(`div`,{className:h,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:`rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90`,children:[(0,$.jsx)(Vi,{className:`mr-1 inline size-3`}),r.restartToUpdate]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`rounded p-1 text-fg-muted hover:text-fg`,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ye,{className:`size-4`})})]})]}):i.kind===`electron-error`?(0,$.jsxs)(`div`,{className:K(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-red-500/20 bg-red-500/10 px-10 py-2 text-sm text-fg sm:px-12`,pd,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-[min(100%,52rem)] items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(dr,{className:`size-4 shrink-0 text-red-500 dark:text-red-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:r.reminderElectronUpdateError.replace(`{{detail}}`,i.message)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ye,{className:`size-4`})})]}):i.kind===`electron-downloading`?(0,$.jsxs)(`div`,{className:K(`relative flex min-h-10 w-full min-w-0 flex-col items-center justify-center gap-2 border-b border-edge bg-surface-panel px-10 py-2 text-sm text-fg-muted sm:flex-row sm:gap-4 sm:px-12`,pd,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`flex max-w-full items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(P,{className:`size-4 shrink-0 animate-pulse`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.reminderDownloading.replace(`{{percent}}`,String(i.percent))})]}),(0,$.jsx)(`div`,{className:`h-1.5 w-full max-w-xs rounded-full bg-surface-inset sm:max-w-[12rem]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${i.percent}%`}})}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:K(h,`sm:right-2`),"aria-label":r.dismissAria,children:(0,$.jsx)(ye,{className:`size-4`})})]}):i.kind===`npm-restart-required`?(0,$.jsxs)(`div`,{className:K(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-amber-500/25 bg-amber-500/10 py-2 text-sm`,pd,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(`span`,{children:r.restartRequired.replace(`{{version}}`,i.version)}),(0,$.jsxs)(`button`,{type:`button`,onClick:p,disabled:l,className:K(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,md),children:[l?(0,$.jsx)(ue,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-3 shrink-0`,"aria-hidden":!0}),r.restartGateway]}),d?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:d}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ye,{className:`size-4`})})]}):i.kind===`npm-restarting`?(0,$.jsx)(`div`,{className:K(`relative flex min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm`,pd,t&&`text-xs`),children:(0,$.jsxs)(`div`,{className:`mx-auto flex max-w-[min(100%,52rem)] items-center justify-center gap-2 px-10 pr-14 text-center sm:px-12 sm:pr-16`,children:[(0,$.jsx)(ue,{className:`size-4 shrink-0 animate-spin text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:r.restartingAutomatically.replace(`{{version}}`,i.version)})]})}):i.kind===`npm`?(0,$.jsxs)(`div`,{className:K(`relative hidden min-h-10 w-full min-w-0 items-center justify-center border-b border-accent/20 bg-accent/10 py-2 text-sm md:flex`,pd,t&&`text-xs`),children:[(0,$.jsxs)(`div`,{className:K(`mx-auto flex max-w-[min(100%,52rem)] flex-wrap items-center justify-center gap-x-2 gap-y-1 px-10 pr-14 text-center sm:px-12 sm:pr-16`),children:[(0,$.jsxs)(`span`,{children:[r.reminderNpm.replace(`{{version}}`,i.version),i.channel&&i.channel!==`latest`?` (${i.channel})`:``]}),(0,$.jsxs)(`button`,{type:`button`,onClick:m,disabled:c,className:K(`inline-flex shrink-0 items-center gap-1 rounded bg-accent px-2.5 py-1 text-xs font-medium text-on-accent hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-60`,md),children:[c?(0,$.jsx)(ue,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Vi,{className:`size-3 shrink-0`,"aria-hidden":!0}),c?r.updateRunning:r.updateNow]}),d?(0,$.jsx)(`span`,{className:`w-full text-xs text-danger`,role:`alert`,children:d}):null]}),(0,$.jsx)(`button`,{type:`button`,onClick:a,className:h,"aria-label":r.dismissAria,title:r.dismissHint,children:(0,$.jsx)(ye,{className:`size-4`})})]}):null}function qU(e,t,n){let r=xe(e),i=r.commandPalette.actions,a=r.commandPalette.groups.actions;return[{kind:`action`,id:`action:local-app:create`,title:i.createLocalApp,subtitle:i.createLocalAppSubtitle,groupLabel:a,keywords:[`app`,`local app`,`create app`,`tool`,`workshop`,`coder`,`应用`,`创建应用`,`工具`,`工坊`],run:()=>{n(),t(`/local-apps/new`)}},{kind:`action`,id:`action:automation:create`,title:`Create automation`,subtitle:`Open automations to create a trigger and action`,groupLabel:a,keywords:[`automation`,`schedule`,`trigger`,`action`,`timer`],run:()=>{n(),t(`/automations?action=create`)}},{kind:`action`,id:`action:automation:manage`,title:`Manage automations`,subtitle:`View automations and run history`,groupLabel:a,keywords:[`automation`,`schedule`,`tasks`,`runs`],run:()=>{n(),t(`/automations`)}},{kind:`action`,id:`action:skills:manage`,title:i.manageSkills,subtitle:i.manageSkillsSubtitle,groupLabel:a,keywords:[`skills`,`skill`,`catalog`],run:()=>{n(),t(`/capabilities/skills`)}},{kind:`action`,id:`action:skills:reload`,title:i.reloadSkills,subtitle:i.reloadSkillsSubtitle,groupLabel:a,keywords:[`skills`,`reload`,`refresh`],run:()=>{n(),s(async()=>{let{reloadSkills:e}=await import(`./skill-reload-api-BEV2WXGk.js`).then(e=>e.n);return{reloadSkills:e}},__vite__mapDeps([88,1,27,4,28])).then(({reloadSkills:e})=>e())}}]}function JU(e){if(e)return e.replace(/CmdOrCtrl/g,`Ctrl`).replace(/Command/g,`Ctrl`).replace(/\+/g,` + `)}async function YU(e,t){let n=window.electronAPI?.menu;if(!n)return[];try{let r=await n.getModel(),i=xe(e).commandPalette.groups.actions;return r.flatMap(e=>e.items.flatMap(r=>{if(r.type!==`item`||r.id.startsWith(`role.`))return[];let a=JU(r.accelerator);return[{kind:`action`,id:`desktop-menu:${r.id}`,title:r.label,subtitle:[e.label,a].filter(Boolean).join(` · `)||void 0,groupLabel:i,keywords:[r.id,e.id,e.label,r.accelerator??``],run:()=>{t(),n.invoke(r.id)}}]}))}catch{return[]}}function XU(e){return xe(e).commandPalette.groups}function ZU(e){let t=XU(e);return{[t.navigate]:0,[t.projects]:1,[t.connectors]:2,[t.quickSettings]:3,[t.extensions]:4,[t.sessions]:5,[t.files]:6,[t.commands]:7,[t.skills]:8,[t.actions]:9}}function QU(e){let t=XU(e);return{[t.navigate]:12,[t.projects]:8,[t.connectors]:6,[t.quickSettings]:12,[t.actions]:8,[t.extensions]:8,[t.sessions]:8,[t.files]:10,[t.commands]:6,[t.skills]:6}}function $U(e,t){return ZU(e)[t]??10}var eW=null;function tW(){eW=null}function nW(){return eW||(eW=Promise.allSettled([Jc(),$c()]).then(([e,t])=>{if(e.status===`rejected`&&t.status===`rejected`)throw e.reason;let n={catalog:e.status===`fulfilled`?e.value:[],instances:t.status===`fulfilled`?t.value:[]};return(e.status===`rejected`||t.status===`rejected`)&&(eW=null),n}).catch(e=>{throw eW=null,e}),eW)}function rW(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function iW(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function aW(e,t,n){return e.filter(e=>iW(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function oW(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function sW(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function cW(e,t){return!e.enabled||e.status===`disabled`?t.disabled:e.status===`failed`||e.status===`degraded`||e.status===`not_configured`||e.status===`unauthorized`||e.connectionStatus===`error`||e.connectionStatus===`unauthorized`?t.needsSetup:e.status===`connected`||e.connectionStatus===`connected`?t.connected:t.installed}function lW(e){return e?[e.id,e.description,e.category,e.kind,...e.tags??[],...e.capabilities,...e.benefits??[]]:[]}function uW(e,t){return t?`${e} · ${t}`:e}function dW(e){if(!e.query.trim())return[];let t=new Map(e.catalog.map(e=>[e.id,e])),n=new Set(e.instances.map(e=>e.connectorId)),r=e.instances.map(n=>{let r=t.get(n.connectorId);return{kind:`connector`,id:`connector-instance:${n.instanceId}`,title:n.displayName,subtitle:uW(cW(n,e.labels),r?.description),groupLabel:e.labels.group,keywords:[n.connectorId,n.instanceId,n.materialized.type,...lW(r)],run:()=>{e.close(),e.navigate(`/capabilities/connectors?instance=${encodeURIComponent(n.instanceId)}&tab=connected`)}}}),i=e.catalog.flatMap(t=>t.source!==`builtin`||t.integrationStrategy?.preferred===!1||!rW(t)||n.has(t.id)?[]:[{kind:`connector`,id:`connector:${t.id}`,title:t.displayName,subtitle:uW(e.labels.builtin,t.description),groupLabel:e.labels.group,keywords:lW(t),run:()=>{e.close(),e.navigate(`/capabilities/connectors?connector=${encodeURIComponent(t.id)}&tab=discover`)}}]);return[...r,...i]}function fW(e){return e.trim().toLowerCase()}function pW(e,t){let n=fW(e),r=fW(t);if(!r)return 0;if(!n)return null;if(n===r)return 0;if(n.startsWith(r))return 1;let i=n.indexOf(r);return i>=0?2+Math.min(i,50)/100:null}function mW(e,t){let n=t.trim();if(!n)return 0;let r=[{text:e.title,weight:1},{text:e.subtitle??``,weight:1.75}];for(let t of e.keywords??[])r.push({text:t,weight:1.25});let i=null;for(let e of r){let t=pW(e.text,n);if(t===null)continue;let r=t*e.weight;i=i===null?r:Math.min(i,r)}if(i===null)return null;let a=e.kind===`route`?-.15:e.kind===`project`?-.12:e.kind===`connector`||e.kind===`file`?-.1:e.kind===`session`?-.05:e.kind===`setting`||e.kind===`action`?-.02:0;return Math.max(0,i+a)}function hW(e){return e.toSorted((e,t)=>e.rank===t.rank?e.groupLabel===t.groupLabel?e.title.localeCompare(t.title):e.groupLabel.localeCompare(t.groupLabel):e.rank-t.rank)}var gW=new Set([`logs`]),_W=[`/settings/logs`,`/settings/extensions/debug`,`/settings/ext/`];function vW(e,t){return t===`advanced`?!0:!gW.has(e)}function yW(e,t){return t===`advanced`?!0:!_W.some(t=>e===t||e.startsWith(t))}var bW=`/capabilities/agents`;function xW(e){return`${bW}/${encodeURIComponent(e)}`}var SW=`/capabilities/channels`;function CW(e){return`${SW}/${encodeURIComponent(e.trim().toLowerCase())}`}function wW(e){return e?.trim().toLowerCase()||null}var TW=Oe(sn(e=>({mode:`simple`,setMode:t=>e({mode:t}),setShowAdvanced:t=>e({mode:t?`advanced`:`simple`})}),{name:`xopc-web-settings-mode`}));function EW(){return TW(DW)}function DW(e){return e.mode===`advanced`}var OW=[`settingsAgentBrowser`,`settingsComputerUse`],kW={settingsAgentBrowser:[`browser`,`playwright`,`automation`],settingsComputerUse:[`computer use`,`compute use`,`desktop`,`电脑控制`,`电脑操作`,`桌面控制`,`GUI`,`BYOK`]};function AW(e,t){let n=xe(e).commandPalette.routes.agentsSubtitle;return OW.filter(e=>vW(e,t)).map(t=>({id:`route:settings:agent:${t}`,title:be(e,t),subtitle:n,path:_f(t),keywords:[`agent`,`manifest`,`preset`,`config`,...kW[t]??[]]}))}function jW(e,t){return e.filter(e=>yW(e.path.split(`?`)[0]??e.path,t))}function MW(e){let t=xe(e),n=t.commandPalette.routes,r=t.capabilitiesSettings,i=t.channelsSettings,a=TW.getState().mode;return jW([{id:`route:chat`,title:t.nav.chat,subtitle:n.chatSubtitle,path:`/chat`,keywords:[`chat`,`new`,`compose`,`assistant`]},{id:`route:agents`,title:t.nav.agents,subtitle:n.agentsSubtitle,path:bW,keywords:[`agent`,`persona`,`switch`]},{id:`route:extensions`,title:t.nav.extensions,subtitle:n.extensionsSubtitle,path:ka(`extensions`),keywords:[`extension`,`plugin`,`addon`]},{id:`route:local-apps`,title:t.nav.localApps,subtitle:n.localAppsSubtitle,path:`/local-apps`,keywords:[`app`,`apps`,`local app`,`tool`,`workshop`,`coder`,`应用`,`本地应用`,`工具`,`工坊`]},{id:`route:sessions`,title:t.nav.sessions,subtitle:n.sessionsSubtitle,path:`/settings/sessions`,keywords:[`history`,`archive`,`pin`]},{id:`route:logs`,title:t.nav.logs,subtitle:n.logsSubtitle,path:`/settings/logs`,keywords:[`debug`,`errors`]},{id:`route:skills`,title:t.nav.skills,subtitle:n.skillsSubtitle,path:ka(`skills`),keywords:[`tools`,`catalog`]},{id:`route:connectors`,title:t.nav.connectors,subtitle:n.connectorsSubtitle,path:ka(`connectors`),keywords:[`connector`,`mcp`,`registry`,`integration`,`tools`]},{id:`route:channels`,title:t.nav.channels,subtitle:n.channelsSubtitle,path:SW,keywords:[`telegram`,`weixin`,`feishu`,`channel`]},{id:`route:channels:telegram`,title:`Telegram`,subtitle:n.channelsSubtitle,path:CW(`telegram`),keywords:[`telegram`,`bot`,`channel`,`pairing`]},{id:`route:channels:weixin`,title:`Weixin`,subtitle:n.channelsSubtitle,path:CW(`weixin`),keywords:[`weixin`,`wechat`,`channel`,`qr`]},{id:`route:channels:feishu`,title:`Feishu/Lark`,subtitle:n.channelsSubtitle,path:CW(`feishu`),keywords:[`feishu`,`lark`,`channel`]},{id:`route:channels:telegram:pairing`,title:`Telegram — ${i.hubPairingButton}`,subtitle:n.channelsSubtitle,path:CW(`telegram`),keywords:[`telegram`,`pairing`,`approve`,`dm`]},{id:`route:automations`,title:`Automations`,subtitle:`Triggers, actions, and run history`,path:`/automations`,keywords:[`automation`,`automations`,`schedule`,`tasks`,`history`,`scheduler`]},{id:`route:settings`,title:t.nav.settings,subtitle:n.settingsSubtitle,path:`/settings/overview`,keywords:[`config`,`status`,`providers`,`models`,`agents`,`search`,`preferences`]},{id:`route:settings:capabilities:models`,title:t.nav.settingsModels,subtitle:n.modelsSubtitle,path:yf(`models`),keywords:[`api`,`key`,`provider`,`openai`,`anthropic`,`google`,`gpt`,`claude`,`gemini`,`llm`,`模型`,`模型服务`,`服务商`,`密钥`]},{id:`route:settings:capabilities:image`,title:r.tabs.image,subtitle:n.imageModelsSubtitle,path:yf(`image`),keywords:[`image`,`vision`,`generate`,`picture`,`图片`,`图像`,`视觉`,`生成图片`]},{id:`route:settings:capabilities:voice`,title:t.nav.settingsVoice,subtitle:n.voiceSubtitle,path:yf(`voice`),keywords:[`tts`,`stt`,`speech`,`microphone`,`语音`,`语音识别`,`语音合成`]},{id:`route:settings:capabilities:search`,title:t.nav.settingsSearch,subtitle:n.searchSubtitle,path:yf(`search`),keywords:[`search`,`web`,`tavily`,`serper`,`brave`,`搜索`,`网络搜索`,`联网搜索`]},{id:`route:settings:gateway`,title:t.nav.settingsGateway,subtitle:n.gatewaySubtitle,path:`/settings/gateway`,keywords:[`server`,`port`,`auth`,`token`]},...AW(e,a)],a)}async function NW(e,t={}){let n=new URLSearchParams;return n.set(`q`,e.trim()),t.types?.length&&n.set(`types`,t.types.join(`,`)),t.limit&&n.set(`limit`,String(t.limit)),(await q(J(`/api/search?${n.toString()}`))).hits}function PW(e){Xd.getState().setPreference(e)}function FW(e){Ee.getState().setLanguage(e)}function IW(e,t){let n=xe(e),r=n.commandPalette.quickSettings,i=n.commandPalette.groups.quickSettings;return[{kind:`setting`,id:`setting:model`,title:r.switchModel,subtitle:r.switchModelSubtitle,groupLabel:i,keywords:[`model`,`default model`,`默认模型`,`gpt`,`claude`,`gemini`,`llm`,`模型`],run:()=>t.openModelPalette()},{kind:`setting`,id:`setting:agent`,title:r.switchAgent,subtitle:r.switchAgentSubtitle,groupLabel:i,keywords:[`agent`,`persona`,`bot`],run:()=>t.openAgentPalette()},{kind:`setting`,id:`setting:theme:light`,title:r.themeLight,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`light`,`appearance`],run:()=>{PW(`light`),t.closePalette()}},{kind:`setting`,id:`setting:theme:dark`,title:r.themeDark,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`dark`,`night`],run:()=>{PW(`dark`),t.closePalette()}},{kind:`setting`,id:`setting:theme:system`,title:r.themeSystem,subtitle:r.appearanceSubtitle,groupLabel:i,keywords:[`theme`,`system`,`auto`],run:()=>{PW(`system`),t.closePalette()}},{kind:`setting`,id:`setting:lang:en`,title:r.languageEn,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`english`,`language`,`locale`],run:()=>{FW(`en`),t.closePalette()}},{kind:`setting`,id:`setting:lang:zh`,title:r.languageZh,subtitle:r.languageSubtitle,groupLabel:i,keywords:[`chinese`,`中文`,`language`],run:()=>{FW(`zh`),t.closePalette()}}]}function LW(e){let t=e===`zh`;return[{id:`field:gateway:port`,title:t?`网关端口`:`Gateway Port`,subtitle:t?`设置 HTTP 网关监听端口`:`HTTP gateway listen port`,path:`/settings/gateway`,keywords:[`port`,`listen`,`http`,`server`,`端口`]},{id:`field:gateway:host`,title:t?`网关绑定地址`:`Gateway Host`,subtitle:t?`设置绑定的网络接口`:`Network interface to bind`,path:`/settings/gateway`,keywords:[`host`,`bind`,`interface`,`localhost`,`地址`]},{id:`field:gateway:auth`,title:t?`网关认证令牌`:`Gateway Auth Token`,subtitle:t?`访问网关所需的 Bearer token`:`Bearer token for gateway access`,path:`/settings/gateway`,keywords:[`auth`,`token`,`bearer`,`password`,`security`,`认证`,`令牌`]},{id:`field:agent-defaults:models`,title:t?`Agent 全局模型`:`Global agent models`,subtitle:t?`设置所有 Agent 继承的模型与回退`:`Set inherited models and fallbacks`,path:`/settings/agent-defaults`,keywords:[`agent defaults`,`model intents`,`fallbacks`,`llm`,`全局默认`,`模型意图`]},{id:`field:agent-defaults:skills`,title:t?`Agent 全局技能`:`Global agent skills`,subtitle:t?`设置所有 Agent 默认可用或排除的技能`:`Set skills enabled or excluded for every agent`,path:`/settings/agent-defaults`,keywords:[`agent defaults`,`skills`,`inherit`,`全局默认`,`技能`,`继承`]},{id:`field:agent-defaults:tools`,title:t?`Agent 全局工具权限`:`Global agent tool permissions`,subtitle:t?`设置所有 Agent 继承的 allow、ask 或 deny 策略`:`Set inherited allow, ask, or deny policies`,path:`/settings/agent-defaults`,keywords:[`agent defaults`,`tools`,`permissions`,`allow`,`ask`,`deny`,`工具权限`]},{id:`field:agent-defaults:runtime`,title:t?`Agent 全局运行限制`:`Global agent runtime limits`,subtitle:t?`设置继承的轮次、超时和默认工作流`:`Set inherited turn, timeout, and workflow limits`,path:`/settings/agent-defaults`,keywords:[`agent defaults`,`runtime`,`turns`,`timeout`,`workflow`,`运行限制`]},{id:`field:agent:profile`,title:t?`Agent 个性`:`Agent personality`,subtitle:t?`设置名称、个性指令和可选覆盖`:`Set the name, personality, and optional overrides`,path:bW,keywords:[`agent`,`profile`,`personality`,`instructions`,`agent 个性`,`指令`]},{id:`field:agent:workspace`,title:t?`Agent 工作目录`:`Agent workspace`,subtitle:t?`按需覆盖该 Agent 的自动工作目录`:`Optionally override the automatic workspace`,path:bW,keywords:[`workspace`,`directory`,`folder`,`path`,`cwd`,`工作目录`]},{id:`field:agent:browser`,title:t?`浏览器自动化`:`Browser automation`,subtitle:t?`启用 browser_use 工具`:`Enable browser_use tools`,path:`/settings/agent-browser`,keywords:[`browser`,`browser_use`,`automation`,`浏览器`]},{id:`field:agent:browser-extension`,title:t?`Chrome 扩展连接`:`Chrome extension bridge`,subtitle:t?`安装扩展并启动 WebSocket 桥接`:`Install extension and start the bridge`,path:`/settings/agent-browser`,keywords:[`extension`,`chrome`,`bridge`,`websocket`,`扩展`,`桥接`]},{id:`field:agent:browser-playwright`,title:t?`安装 Playwright Chromium`:`Install Playwright Chromium`,subtitle:t?`本地 Playwright 后端就绪检查`:`Local Playwright backend setup`,path:`/settings/agent-browser`,keywords:[`playwright`,`chromium`,`install`,`local`,`安装`]},{id:`field:agent:browser-headless`,title:t?`浏览器无头模式`:`Browser headless mode`,subtitle:t?`隐藏浏览器窗口`:`Run without a visible window`,path:`/settings/agent-browser`,keywords:[`headless`,`window`,`visible`,`无头`]},{id:`field:agent:browser-private-urls`,title:t?`允许内网 URL`:`Allow private URLs`,subtitle:t?`浏览器导航安全限制`:`Browser navigation security policy`,path:`/settings/agent-browser`,keywords:[`private`,`internal`,`localhost`,`security`,`内网`,`安全`]},{id:`field:voice:sttProvider`,title:t?`STT 语音识别提供商`:`STT Provider`,subtitle:t?`语音转文字服务商`:`Speech-to-text service provider`,path:`/settings/capabilities/voice`,keywords:[`stt`,`speech`,`recognition`,`whisper`,`deepgram`,`语音识别`]},{id:`field:voice:ttsProvider`,title:t?`TTS 语音合成提供商`:`TTS Provider`,subtitle:t?`文字转语音服务商`:`Text-to-speech service provider`,path:`/settings/capabilities/voice`,keywords:[`tts`,`speech`,`synthesis`,`voice`,`elevenlabs`,`语音合成`]},{id:`field:search:engine`,title:t?`搜索引擎`:`Web Search Engine`,subtitle:t?`联网搜索使用的引擎`:`Engine for web search tool`,path:`/settings/capabilities/search`,keywords:[`search`,`engine`,`tavily`,`serper`,`brave`,`bing`,`搜索引擎`]},{id:`field:automations:enabled`,title:t?`自动化`:`Automations`,subtitle:t?`创建和管理自动化`:`Create and manage automations`,path:`/automations`,keywords:[`automation`,`automations`,`scheduler`,`timer`,`自动化`,`调度`]},{id:`field:automations:runs`,title:t?`自动化运行记录`:`Automation Runs`,subtitle:t?`查看自动化执行历史`:`Review automation run history`,path:`/automations`,keywords:[`automation`,`runs`,`history`,`自动化`,`历史`]},{id:`field:channels:telegram`,title:`Telegram Bot Token`,subtitle:t?`配置 Telegram 频道连接`:`Configure Telegram channel connection`,path:SW,keywords:[`telegram`,`bot`,`token`,`channel`,`频道`]},{id:`field:channels:dmPolicy`,title:t?`私聊接入策略`:`DM Access Policy`,subtitle:t?`Telegram 私聊白名单/配对策略`:`Telegram DM allowlist/pairing policy`,path:SW,keywords:[`dm`,`policy`,`pairing`,`allowlist`,`access`,`私聊`,`策略`]},{id:`field:mcp:servers`,title:t?`MCP 服务器配置`:`MCP Servers`,subtitle:t?`外部 MCP 工具服务器列表`:`External MCP tool server registry`,path:`/capabilities/connectors`,keywords:[`mcp`,`server`,`tools`,`external`,`stdio`,`服务器`,`connector`]},{id:`field:heartbeat:interval`,title:t?`心跳间隔`:`Heartbeat Interval`,subtitle:t?`网关存活检测频率`:`Gateway keep-alive check frequency`,path:`/settings/heartbeat`,keywords:[`heartbeat`,`interval`,`keepalive`,`alive`,`心跳`]},{id:`field:tunnel:enabled`,title:t?`公网隧道`:`Public Tunnel`,subtitle:t?`FRP 远程访问隧道开关`:`FRP remote access tunnel toggle`,path:`/settings/remote-access`,keywords:[`tunnel`,`frp`,`remote`,`public`,`ngrok`,`隧道`,`远程`]}]}function RW(e,t,n,r){return LW(e).map(e=>({kind:`setting`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:r,keywords:e.keywords,run:()=>{n(),t(e.path)}}))}function zW(e){return e.acceptsArgs?`/${e.name} `:`/${e.name}`}var BW={main:{key:`assistant`,defaultNames:[`main`,`Main`,`Smart Assistant`],defaultDescriptions:[`General assistant`,`General-purpose personal assistant.`,`Your personal intelligent assistant for answering questions, handling everyday tasks, and chatting with you anytime.`]},coder:{key:`coding`,defaultNames:[`coder`,`Coder`,`Coding Expert`],defaultDescriptions:[`Software development, debugging, refactoring, and tests.`,`Software engineering agent for repository understanding, implementation, debugging, refactoring, tests, and review.`]},writer:{key:`writing`,defaultNames:[`writer`,`Writer`,`Writing Assistant`],defaultDescriptions:[`Drafting, editing, rewriting, and audience-aware content.`]},researcher:{key:`research`,defaultNames:[`researcher`,`Researcher`,`Research Assistant`],defaultDescriptions:[`Deep research, source comparison, and fact synthesis.`]},"data-analyst":{key:`data`,defaultNames:[`data-analyst`,`Data Analyst`],defaultDescriptions:[`Data cleaning, analysis, visualization, and reproducible reports.`]},creative:{key:`creative`,defaultNames:[`creative`,`Creative`,`Creative Assistant`],defaultDescriptions:[`Visual direction, image prompts, design critique, and creative options.`]}};function VW(e){return e?.trim().toLowerCase()??``}function HW(e,t){let n=VW(e);return!!n&&t.some(e=>VW(e)===n)}function UW(e){return BW[VW(e)]}function WW(e,t){let n=e.name?.trim(),r=UW(e.id);return r&&(!n||HW(n,r.defaultNames))?t.builtInAgents[r.key].name:n||e.id}function GW(e,t){let n=e.description?.trim(),r=UW(e.id);return r&&(!n||HW(n,r.defaultDescriptions))?t.builtInAgents[r.key].description:n||``}var KW=3e4,qW=null;function JW(e,t){return e.map(e=>({id:`file:${e.id}`,kind:`file`,name:e.name,description:e.path,relativePath:e.path,isDirectory:e.isDirectory,...t.has(e.path)?{isRecent:!0}:{},fileRef:{sourceId:e.id,expectedVersion:e.revision}}))}async function YW(e,t){let n=t.conversationId?.trim(),r=t.agentId?.trim(),i=t.limit??15,a=e.trim(),o=t.recentPaths??new Set;if(n&&a.length===0){let e=Date.now();if(qW&&qW.key===n&&e-qW.at<KW)return qW.items.map(e=>({...e,...o.has(e.relativePath)?{isRecent:!0}:{isRecent:void 0}}))}let s={conversationId:n,agentId:r},c=JW(a.length===0?await LS(``,s):await zS(a,s,i),o);return n&&a.length===0&&(qW={key:n,at:Date.now(),items:c}),c}async function XW(e,t){return LS(e,{conversationId:t.conversationId,agentId:t.agentId})}function ZW(e,...t){let n=e.trim().toLocaleLowerCase();return!n||t.some(e=>e?.toLocaleLowerCase().includes(n))}async function QW(e){let t=await we(J(e)),n=await t.json().catch(()=>({}));if(!t.ok||!n.payload)throw Error(typeof n.error==`string`?n.error:`HTTP ${t.status}`);return n.payload}var $W=null;async function eG(){if($W&&Date.now()<$W.expiresAt)return $W.items;let e=await QW(`/api/mcp/resources`);return $W={expiresAt:Date.now()+3e4,items:e.resources},e.resources}var tG=[{kind:`file`,search:(e,t)=>YW(e,{conversationId:t.conversationId,agentId:t.currentAgentId,limit:10,recentPaths:t.recentPaths})},{kind:`note`,async search(e,t){return(await xL({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.status!==`trashed`&&!t.selectedContextKeys.has(`note:${e.id}`)).map(e=>({id:`note:${e.id}`,kind:`note`,name:e.title?.trim()||e.snippet?.trim()||xe(t.language).chat.commandPalette.untitledNote,description:e.snippet?.trim()||``,noteRef:{sourceId:e.id,expectedVersion:String(e.updatedAt)}}))}},{kind:`session`,async search(e,t){return(await Yh({...e.trim()?{search:e.trim()}:{},limit:5,sortBy:`updatedAt`,sortOrder:`desc`})).items.filter(e=>e.key!==t.conversationId&&!t.selectedContextKeys.has(`session:${e.key}`)).map(e=>({id:`session:${e.key}`,kind:`session`,name:e.name?.trim()||e.key,description:`${e.messageCount} messages`,sessionRef:{sourceId:e.key,expectedVersion:e.updatedAt}}))}},{kind:`skill`,async search(e,t){return(await QT(t.currentAgentId,t.conversationId)).skills.flatMap(n=>{if(!n.availableForCurrentAgent)return[];let r=PT(n,t.language);return ZW(e,n.name,r.displayName,r.description,...r.searchTerms)?[{id:`skill:${n.name}`,kind:`skill`,name:r.displayName,description:r.description,canonicalName:n.name}]:[]}).slice(0,5)}},{kind:`agent`,async search(e,t){let n=await Mg(),r=xe(t.language).agentsSettings;return n.items.flatMap(t=>{let n=WW(t,r),i=GW(t,r);return ZW(e,t.id,n,i)?[{id:`agent:${t.id}`,kind:`agent`,name:n,description:i,agentId:t.id,...t.avatar?{avatar:t.avatar}:{}}]:[]}).slice(0,5)}},{kind:`browser_tab`,async search(e,t){return(await QW(`/api/browser/tabs?${new URLSearchParams({conversationId:t.conversationId})}`)).tabs.flatMap(n=>!ZW(e,n.title,n.url)||t.selectedContextKeys.has(`browser_tab:${n.id}`)?[]:[{id:`browser-tab:${n.id}`,kind:`browser_tab`,name:n.title||n.url,description:n.url,url:n.url,tabRef:{sourceId:n.id,expectedVersion:n.documentId}}])}},{kind:`mcp_server`,async search(e){return e.startsWith(`mcp:`)?[]:(await QW(`/api/mcp/servers`)).mergedServerIds.flatMap(t=>ZW(e,t,`mcp`)?[{id:`mcp-server:${t}`,kind:`mcp_server`,name:t,description:`MCP server`,serverId:t}]:[]).slice(0,5)}},{kind:`mcp_resource`,async search(e,t){let n=e.match(/^mcp:([^/]+)\/(.*)$/u);if(!e.trim()||e.startsWith(`mcp:`)&&!n)return[];let r=``,i=``;if(n){try{r=decodeURIComponent(n[1])}catch{return[]}i=n[2]?.trim().toLocaleLowerCase()??``}else i=e.trim().toLocaleLowerCase();return(await eG()).filter(e=>!r||e.serverId===r).filter(e=>!i||[e.name,e.title,e.description,e.uri,e.serverId].some(e=>e?.toLocaleLowerCase().includes(i))).filter(e=>!t.selectedContextKeys.has(`mcp_resource:${e.id}`)).map(e=>({id:`mcp-resource:${e.id}`,kind:`mcp_resource`,name:e.title||e.name,description:e.description||`${e.serverId} · ${e.uri}`,serverId:e.serverId,uri:e.uri,resourceRef:{sourceId:e.id,expectedVersion:e.version}}))}}];async function nG(){let e=await q(J(`/api/agents`));if(!e.payload?.defaultId||!Array.isArray(e.payload.agents))throw Error(`Invalid /api/agents response`);return e.payload}async function rG(e){let t=await q(J(`/api/agents/${encodeURIComponent(e)}/effective-config`));if(!t.payload?.config||!t.payload.sources)throw Error(`Invalid effective agent config response`);return t.payload}async function iG(e){let{mutate:t}=await s(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([8,1,4]));await Promise.all([t(`settings-gateway-agents`,e,{revalidate:!1}),t(`setup-checklist-agents`,e,{revalidate:!1}),rn()])}async function aG(e){let t=await q(J(`/api/agents`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.payload?.agentId||!t.payload.agents)throw Error(`Invalid create agent response`);return await iG(t.payload.agents),{...t.payload.agents,createdAgentId:t.payload.agentId}}async function oG(e,t){let n=await q(J(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.payload)throw Error(`Invalid update agent response`);return await iG(n.payload),n.payload}async function sG(e,t=!1){let n=await q(J(`/api/agents/${encodeURIComponent(e)}${t?`?purge=1`:``}`),{method:`DELETE`});if(!n.payload?.agents)throw Error(`Invalid delete agent response`);return await iG(n.payload.agents),n.payload.agents}async function cG(e){let t=(await q(J(`/api/agents/${encodeURIComponent(e)}/files`))).payload,n=typeof t?.profileDir==`string`?t.profileDir.trim():``;if(!t?.files||!n)throw Error(`Invalid agent profile files response`);return{agentId:t.agentId,profileDir:n,files:t.files}}async function lG(e,t){let n=(await q(J(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`))).payload?.content;if(typeof n!=`string`)throw Error(`Invalid agent profile file response`);return n}async function uG(e,t,n){await q(J(`/api/agents/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`),{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})}async function dG(){let e=await q(J(`/api/global-defaults`));if(!e.payload?.defaults||!Array.isArray(e.payload.builtinTools))throw Error(`Invalid global defaults response`);return e.payload}async function fG(e){let t=await q(J(`/api/global-defaults`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaults:e})});if(!t.payload?.defaults||!Array.isArray(t.payload.builtinTools))throw Error(`Invalid global defaults response`);let{mutate:n}=await s(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([8,1,4]));return await Promise.all([n(`settings-gateway-agents`),n(`capability-readiness`),rn()]),t.payload}function pG(){let{pathname:e}=b(),{conversationId:t}=p();if(!e.startsWith(`/chat`)||!t)return;let n=decodeURIComponent(t);return n&&n!==`new`?n:void 0}async function mG(e){let{defaults:t}=await dG();await fG({...t,models:{...t.models,chat:{primary:e,fallbacks:[]}}})}function hG(e,t,n,r){let i=e.trim().toLowerCase();i&&(dh(i),t.startsWith(`/chat`)?window.dispatchEvent(new CustomEvent(`xopc-set-chat-agent`,{detail:{agentId:i}})):n(`/chat/new?projectScope=none`,{state:{agentId:i}}),r())}function gG(e){switch(e.kind){case`connector`:return(0,$.jsx)(ar,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`extension`:return(0,$.jsx)(zi,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`route`:return(0,$.jsx)(oe,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`project`:return(0,$.jsx)(Ur,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`session`:return(0,$.jsx)(oe,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`file`:return(0,$.jsx)(Br,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`command`:return(0,$.jsx)(ca,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`skill`:return(0,$.jsx)(ta,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});case`setting`:return(0,$.jsx)(Ji,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0});case`action`:return(0,$.jsx)(Ca,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0});default:return null}}function _G(e,t,n,r){if(r(),t.startsWith(`/chat`)){NT(e);return}let i=e.match(/^\/skill:(\S+)\s*$/),a=e.match(/^\/(\S+)\s*$/);i?n(`/chat/new?skill=${encodeURIComponent(i[1])}`):a?n(`/chat/new?slash=${encodeURIComponent(a[1])}`):(n(`/chat/new`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{NT(e)})}))}function vG(e){let t=[];for(let n of e.uiExtensions){let r=n.ui?.contributions?.commands;if(Array.isArray(r))for(let i of r)!i||typeof i.id!=`string`||typeof i.title!=`string`||t.push({kind:`extension`,id:`ext:${n.id}:${i.id}`,title:i.title,subtitle:n.name,groupLabel:e.extensionsGroupLabel,keywords:[n.id,n.name,i.id],run:()=>{e.close(),i.opensPanel!==void 0&&i.opensPanel!==``?e.navigate(`/extensions/${encodeURIComponent(n.id)}`):window.dispatchEvent(new CustomEvent(`extension-command`,{detail:{extensionId:n.id,commandId:i.id}}))}})}return t}function yG(e,t){switch(t.type){case`setQuery`:return{...e,query:t.value};case`setSelectedIndex`:{let n=typeof t.value==`function`?t.value(e.selectedIndex):t.value;return{...e,selectedIndex:n}}case`setLayer`:return{...e,paletteLayer:t.layer,query:``,selectedIndex:0};case`resetMain`:return{query:``,selectedIndex:0,paletteLayer:`main`}}}var bG={query:``,selectedIndex:0,paletteLayer:`main`};async function xG(){let e=await q(J(`/api/registry`)),t=[];for(let n of e.payload?.providers??[])for(let e of n.models??[])e.available!==!1&&t.push({id:e.ref,title:e.name||e.ref,subtitle:e.ref});return t.sort((e,t)=>e.title.localeCompare(t.title)),t}async function SG(e){let t=await nG(),n=xe(e).agentsSettings;return t.agents.map(e=>({id:e.id,title:WW(e,n),subtitle:e.id}))}function CG({onClose:e}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=l(),{pathname:i}=b(),a=Ee(e=>e.language),o=ij(),s=pG(),c=yw(e=>e.agentId),u=Ow(e=>e.setPath),[d,f]=(0,Z.useReducer)(yG,bG),[p,m]=(0,Z.useState)(0),[h,g]=(0,Z.useState)(0),{query:_,selectedIndex:v,paletteLayer:y}=d,x=(0,Z.useMemo)(()=>MW(a),[a]),[S]=qh(_,120);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&t.section===`skills`&&m(e=>e+1),g(e=>e+1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[]);let C=Am(nW,[h],{enabled:y===`main`&&!!S.trim(),initial:{catalog:[],instances:[]},errorData:{catalog:[],instances:[]}}),w=(0,Z.useCallback)(()=>{f({type:`setLayer`,layer:`models`})},[]),T=(0,Z.useCallback)(()=>{f({type:`setLayer`,layer:`agents`})},[]),E=Am(async()=>y===`models`?xG():y===`agents`?SG(a):[],[y,a],{enabled:y===`models`||y===`agents`,initial:[],errorData:[]}),D=Am(async()=>{let t=S.trim(),n=e,l=xe(a).commandPalette.groups,d=x.map(e=>({kind:`route`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:l.navigate,keywords:[...e.keywords??[],e.path],run:()=>{n(),r(e.path)}})),f=IW(a,{closePalette:n,openModelPalette:w,openAgentPalette:T}),p=qU(a,r,n),m=dW({query:t,...C.data,labels:{group:l.connectors,...xe(a).commandPalette.connectors},navigate:r,close:n}),h=vG({query:t,close:n,navigate:r,uiExtensions:o,extensionsGroupLabel:l.extensions}),[g,_,v,y,b,E]=await Promise.all([ZT(),iE(),t?NW(t,{types:[`project`],limit:8}).catch(()=>[]):[],Yh({search:t||void 0,limit:8,offset:0}).catch(()=>({items:[]})),(async()=>{let e=s?.trim(),n=c.trim();return!e&&!n?[]:await YW(t,{conversationId:e||void 0,agentId:e?void 0:n||void 0,limit:10}).catch(()=>[])})(),YU(a,n)]),D=v.map(e=>({kind:`project`,id:e.id,title:e.title,subtitle:e.subtitle,groupLabel:l.projects,keywords:[e.payload.project.slug,e.payload.project.workspaceRoot??``,e.payload.project.defaultAgentId??``,e.payload.project.brief??``],run:()=>{n(),r(e.href)}})),O=g.map(e=>({kind:`command`,id:`cmd:${e.id}`,title:`/${e.name}`,subtitle:e.description,groupLabel:l.commands,keywords:[e.id,...e.aliases??[],e.category??``],run:()=>{_G(zW(e),i,r,n)}})),k=_.catalog.flatMap(e=>!e.enabled||e.disableModelInvocation?[]:[{kind:`skill`,id:`skill:${e.name}`,title:`/skill:${e.name}`,subtitle:e.description,groupLabel:l.skills,keywords:[e.source??``,`skill`],run:()=>{_G(`/skill:${e.name} `,i,r,n)}}]),A=(y.items??[]).map(e=>({kind:`session`,id:`session:${e.key}`,title:e.name?.trim()||e.key,subtitle:e.key,groupLabel:l.sessions,keywords:[e.key,...e.tags??[],e.sourceChannel??``],run:()=>{n(),r(`/chat/${encodeURIComponent(e.key)}`)}})),j=b.flatMap(e=>e.isDirectory?[]:[{kind:`file`,id:`file:${e.relativePath}`,title:e.name,subtitle:e.relativePath,groupLabel:l.files,keywords:[e.relativePath],run:()=>{n();let t=e.relativePath.replace(/\\/g,`/`).replace(/^\/+/,``),a=()=>u(t);if(i.startsWith(`/chat`)){a();return}r(`/chat`),window.setTimeout(()=>a(),0)}}]),M=RW(a,r,n,l.navigate),N=[...d,...f,...p,...E,...h,...M,...D,...m,...A,...j,...O,...k],P=[];for(let e of N){let n=mW(e,t);n!==null&&P.push({...e,rank:n})}let F=QU(a),I=hW(P),L=[],R={};for(let e of I){let t=(R[e.groupLabel]??0)+1;if(!(t>(F[e.groupLabel]??6))&&(R[e.groupLabel]=t,L.push(e),L.length>=36))break}return L.sort((e,t)=>$U(a,e.groupLabel)-$U(a,t.groupLabel)||e.rank-t.rank||e.title.localeCompare(t.title)),L},[S,x,o,r,s,c,i,u,a,w,T,e,p,C.data],{enabled:y===`main`,initial:[],errorData:[]}),O=D.data,k=D.loading,A=D.error,j=(0,Z.useMemo)(()=>{let e=_.trim().toLowerCase(),t=E.data;return e?t.filter(t=>t.title.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.subtitle?.toLowerCase().includes(e)??!1)):t},[E.data,_]),M=`${y}|${_}|${String(j.length)}|${String(O.length)}`,N=(0,Z.useRef)(M);if(N.current!==M){N.current=M;let e=y===`main`?Math.max(0,O.length-1):Math.max(0,j.length);v>e&&f({type:`setSelectedIndex`,value:e})}(0,Z.useEffect)(()=>{let e=window.setTimeout(()=>t.current?.focus(),50);return()=>window.clearTimeout(e)},[]);let P=(0,Z.useEffectEvent)(t=>{if(t.key===`Escape`){if(t.preventDefault(),y!==`main`){f({type:`resetMain`});return}e();return}let n=y===`main`?Math.max(0,O.length-1):Math.max(0,j.length);if(t.key===`ArrowDown`){t.preventDefault(),f({type:`setSelectedIndex`,value:e=>Math.min(e+1,n)});return}if(t.key===`ArrowUp`){t.preventDefault(),f({type:`setSelectedIndex`,value:e=>Math.max(0,e-1)});return}if(t.key===`Enter`){if(t.preventDefault(),y===`models`){if(v===0){f({type:`resetMain`});return}let t=j[v-1];if(!t)return;(async()=>{await mG(t.id),rn(),xy(),e(),f({type:`resetMain`})})();return}if(y===`agents`){if(v===0){f({type:`resetMain`});return}let t=j[v-1];if(!t)return;hG(t.id,i,r,e),f({type:`resetMain`});return}let n=O[v];n&&n.run()}});(0,Z.useEffect)(()=>{let e=e=>{P(e)};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),(0,Z.useLayoutEffect)(()=>{let e=n.current;e&&e.querySelector(`[data-global-palette-index="${String(v)}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[v,O,y,j.length]);let F=a===`zh`?`返回`:`Back`;if(y===`models`||y===`agents`){let o=j,s=E.loading;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":a===`zh`?`选择模型或智能体`:`Model or agent picker`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>f({type:`setQuery`,value:e.target.value}),placeholder:y===`models`?a===`zh`?`搜索模型…`:`Search models…`:a===`zh`?`搜索智能体…`:`Search agents…`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsxs)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,children:[(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"data-global-palette-index":0,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-fg-muted`,v===0?`bg-surface-hover`:`hover:bg-surface-inset`].join(` `),onMouseEnter:()=>f({type:`setSelectedIndex`,value:0}),onClick:()=>f({type:`resetMain`}),children:[`← `,F]})}),s?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`加载中…`:`Loading…`}):o.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:a===`zh`?`无结果`:`No results`}):o.map((t,n)=>{let a=n+1;return(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,"data-global-palette-index":a,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,v===a?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>f({type:`setSelectedIndex`,value:a}),onClick:()=>{y===`models`?(async()=>{await mG(t.id),rn(),xy(),e(),f({type:`resetMain`})})():(hG(t.id,i,r,e),f({type:`resetMain`}))},children:(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:t.title}),t.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:t.subtitle}):null]})})},t.id)})]})]})})}let I=``;return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"aria-label":`Global search`,onMouseDown:t=>{t.target===t.currentTarget&&e()},children:(0,$.jsxs)(`div`,{className:`flex w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[(0,$.jsx)(`input`,{ref:t,type:`search`,value:_,onChange:e=>f({type:`setQuery`,value:e.target.value}),placeholder:a===`zh`?`搜索…(会话 / 文件 / 连接器 / 设置 / 命令)`:`Search… (sessions, files, connectors, settings, commands)`,className:`border-b border-edge bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-fg-muted`,autoComplete:`off`,autoCorrect:`off`}),(0,$.jsx)(`ul`,{ref:n,className:`max-h-[min(60vh,26rem)] overflow-y-auto p-2 text-sm [scrollbar-gutter:stable]`,role:`listbox`,"aria-activedescendant":O[v]?`global-hit-${O[v].id}`:void 0,children:O.length===0?(0,$.jsx)(`li`,{className:`rounded-lg px-3 py-6 text-center text-fg-muted`,children:k?a===`zh`?`搜索中…`:`Searching…`:A?A instanceof Error?A.message:String(A):a===`zh`?`无结果`:`No results`}):O.map((e,t)=>{let n=e.groupLabel===I?``:e.groupLabel;return I=e.groupLabel,(0,$.jsxs)(`li`,{children:[n?(0,$.jsx)(`div`,{className:`px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-fg-muted`,children:n}):null,(0,$.jsxs)(`button`,{id:`global-hit-${e.id}`,"data-global-palette-index":t,type:`button`,className:[`flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left`,t===v?`bg-surface-hover text-fg`:`text-fg hover:bg-surface-inset`].join(` `),onMouseEnter:()=>f({type:`setSelectedIndex`,value:t}),onClick:()=>e.run(),children:[(0,$.jsx)(`span`,{className:`mt-0.5`,children:gG(e)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 truncate font-medium`,children:e.title}),e.subtitle?(0,$.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-fg-muted`,children:e.subtitle}):null]})]})]},e.id)})})]})})}function wG(){let e=(0,Q.c)(7),[t,n]=(0,Z.useState)(!1),r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),n(EG))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),(0,Z.useEffect)(r,i);let a,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>{let e=()=>n(!0);return window.addEventListener(`open-command-palette`,e),()=>window.removeEventListener(`open-command-palette`,e)},o=[],e[2]=a,e[3]=o):(a=e[2],o=e[3]),(0,Z.useEffect)(a,o);let s,c;if(e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=()=>n(TG);return window.addEventListener(`toggle-command-palette`,e),()=>window.removeEventListener(`toggle-command-palette`,e)},c=[],e[4]=s,e[5]=c):(s=e[4],c=e[5]),(0,Z.useEffect)(s,c),!t)return null;let l;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(CG,{onClose:()=>n(!1)}),e[6]=l):l=e[6],l}function TG(e){return!e}function EG(e){return!e}function DG(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var OG=K(`inline-flex min-h-11 min-w-11 shrink-0 gap-2 px-3 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,yc.transition,yc.press,yc.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),kG=(0,Z.memo)(function(e){let t=(0,Q.c)(47),{phase:n,elapsedLabel:r,audioLevel:i,partialTranscript:a,finalTranscript:o,error:s,settingsRequired:c,disabled:l,chat:u,onCancel:d,onConfirm:f,onRetry:p}=e,m=n===`transcribing`,h=n===`requesting`,g=n===`starting`,_=n===`error`,v=_?s||u.voiceTranscribeFailed:h?u.voiceRequestingMicrophone:g?u.voiceStartingMicrophone:m?u.voiceTranscribing:u.voiceRecordingStatus,y;t[0]!==o||t[1]!==a?(y=[o,a].filter(Boolean),t[0]=o,t[1]=a,t[2]=y):y=t[2];let b=y.join(` `),x=h||g||m,C;t[3]!==i||t[4]!==_||t[5]!==n?(C=n===`recording`?(0,$.jsx)(`div`,{className:`flex h-5 shrink-0 items-center gap-0.5`,"aria-hidden":!0,children:Array.from({length:9},(e,t)=>{let n=.35+(t%4+1)*.16;return(0,$.jsx)(`span`,{className:`w-0.5 rounded-full bg-fg-muted motion-safe:transition-[height] motion-safe:duration-75`,style:{height:Math.max(3,Math.round(18*Math.min(1,i*n+.08)))}},t)})}):_?(0,$.jsx)(dr,{className:`size-4 shrink-0 text-danger`,"aria-hidden":!0}):(0,$.jsx)(xn,{className:`h-4 w-8`}),t[3]=i,t[4]=_,t[5]=n,t[6]=C):C=t[6];let w=_?`alert`:`status`,T;t[7]!==v||t[8]!==w?(T=(0,$.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm text-fg-muted`,role:w,children:v}),t[7]=v,t[8]=w,t[9]=T):T=t[9];let E;t[10]!==r||t[11]!==n?(E=n===`recording`?(0,$.jsx)(`span`,{className:`shrink-0 text-sm tabular-nums text-fg-muted`,children:r}):null,t[10]=r,t[11]=n,t[12]=E):E=t[12];let D;t[13]!==C||t[14]!==T||t[15]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-1`,children:[C,T,E]}),t[13]=C,t[14]=T,t[15]=E,t[16]=D):D=t[16];let O;t[17]===b?O=t[18]:(O=b?(0,$.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words px-1 text-base text-fg`,children:b}):null,t[17]=b,t[18]=O);let k;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),t[19]=k):k=t[19];let A;t[20]!==u.voiceInputCancel||t[21]!==d?(A=(0,$.jsxs)(`button`,{type:`button`,className:OG,title:u.voiceInputCancel,"aria-label":u.voiceInputCancel,onClick:d,children:[k,u.voiceInputCancel]}),t[20]=u.voiceInputCancel,t[21]=d,t[22]=A):A=t[22];let j;t[23]!==l||t[24]!==_||t[25]!==u.voiceOpenSettings||t[26]!==u.voiceRetry||t[27]!==p||t[28]!==c?(j=_&&c?(0,$.jsxs)(`a`,{href:`#/settings/capabilities/voice`,className:K(OG,`text-accent-fg`),children:[(0,$.jsx)(qi,{className:`size-4`,"aria-hidden":!0}),u.voiceOpenSettings]}):_?(0,$.jsxs)(`button`,{type:`button`,className:OG,disabled:l,"aria-label":u.voiceRetry,onClick:p,children:[(0,$.jsx)(Hi,{className:`size-4`,"aria-hidden":!0}),u.voiceRetry]}):null,t[23]=l,t[24]=_,t[25]=u.voiceOpenSettings,t[26]=u.voiceRetry,t[27]=p,t[28]=c,t[29]=j):j=t[29];let M;t[30]!==l||t[31]!==_||t[32]!==o||t[33]!==u.voiceInputConfirm||t[34]!==f||t[35]!==n?(M=n===`recording`||_&&o?(0,$.jsxs)(`button`,{type:`button`,className:K(OG,`rounded-full bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent`),disabled:l,"aria-label":u.voiceInputConfirm,onClick:f,children:[(0,$.jsx)(S,{className:`size-4`,"aria-hidden":!0}),u.voiceInputConfirm]}):null,t[30]=l,t[31]=_,t[32]=o,t[33]=u.voiceInputConfirm,t[34]=f,t[35]=n,t[36]=M):M=t[36];let N;t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[A,j,M]}),t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;return t[41]!==u.voiceInput||t[42]!==N||t[43]!==x||t[44]!==D||t[45]!==O?(P=(0,$.jsxs)(`section`,{className:`w-full space-y-3 py-3`,"aria-label":u.voiceInput,"aria-busy":x,children:[D,O,N]}),t[41]=u.voiceInput,t[42]=N,t[43]=x,t[44]=D,t[45]=O,t[46]=P):P=t[46],P}),AG=`xopc-voice-input-toggle`,jG=`xopc-voice-input-cancel`,MG=`app-shortcut-recording`,NG=!1;function PG(e,t){let n=new CustomEvent(e,{cancelable:!0,detail:{target:t}});return window.dispatchEvent(n),n.defaultPrevented}function FG(){NG=!0}function IG(){NG=!1}function LG(){return NG?(NG=!1,!0):!1}function RG(e){let t=(0,Q.c)(100),{onClose:n}=e,r=l(),i=Ee(BG),a;t[0]===i?a=t[1]:(a=xe(i),t[0]=i,t[1]=a);let o=a.notes,s;t[2]===i?s=t[3]:(s=xe(i),t[2]=i,t[3]=s);let c=s.chat,u=DD(zG),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),h=(0,Z.useRef)(null),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=e=>{f(t=>DG(t,e)),window.setTimeout(()=>h.current?.focus(),0)},t[4]=g):g=t[4];let _;t[5]!==c||t[6]!==p?(_={disabled:p,chat:c,onTranscript:g},t[5]=c,t[6]=p,t[7]=_):_=t[7];let v=rd(_),{phase:y,voiceActive:b,startVoiceInput:x,cancelVoiceInput:S,confirmVoiceInput:C}=v,w,T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{let e=window.setTimeout(()=>h.current?.focus(),50);return()=>window.clearTimeout(e)},T=[],t[8]=w,t[9]=T):(w=t[8],T=t[9]),(0,Z.useEffect)(w,T);let E,D;t[10]!==S||t[11]!==C||t[12]!==p||t[13]!==x||t[14]!==b||t[15]!==y?(E=()=>{let e=e=>{e.detail?.target===`note`&&(e.preventDefault(),!p&&(y===`recording`?C():(y===`idle`||y===`error`)&&x()))},t=e=>{e.detail?.target!==`note`||!b||(e.preventDefault(),S(),h.current?.focus())};return window.addEventListener(AG,e),window.addEventListener(jG,t),()=>{window.removeEventListener(AG,e),window.removeEventListener(jG,t)}},D=[S,C,p,x,b,y],t[10]=S,t[11]=C,t[12]=p,t[13]=x,t[14]=b,t[15]=y,t[16]=E,t[17]=D):(E=t[16],D=t[17]),(0,Z.useEffect)(E,D);let O;t[18]!==r||t[19]!==n||t[20]!==p||t[21]!==d?(O=async e=>{let t=d.trim();if(!(!t||p)){m(!0);try{let i=await SL(t,`web`);n(),e&&r(`/notes/${i.id}`)}catch{m(!1)}}},t[18]=r,t[19]=n,t[20]=p,t[21]=d,t[22]=O):O=t[22];let k=O,A;t[23]!==k||t[24]!==n?(A=e=>{if(e.key===`Escape`){e.preventDefault(),n();return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),k(!0);return}e.key===`Enter`&&e.shiftKey&&(e.preventDefault(),k(!1))},t[23]=k,t[24]=n,t[25]=A):A=t[25];let j=A,M=o.quickCapturePlaceholder,N;t[26]===n?N=t[27]:(N=e=>{e.target===e.currentTarget&&n()},t[26]=n,t[27]=N);let P;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(oa,{className:`size-4 text-accent`}),t[28]=P):P=t[28];let F;t[29]===o.quickCapturePlaceholder?F=t[30]:(F=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-edge px-4 py-3`,children:[P,(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:o.quickCapturePlaceholder})]}),t[29]=o.quickCapturePlaceholder,t[30]=F);let I;t[31]!==c||t[32]!==j||t[33]!==o.quickCapturePlaceholder||t[34]!==p||t[35]!==d||t[36]!==v.audioLevel||t[37]!==v.cancelVoiceInput||t[38]!==v.confirmVoiceInput||t[39]!==v.elapsedLabel||t[40]!==v.error||t[41]!==v.finalTranscript||t[42]!==v.partialTranscript||t[43]!==v.phase||t[44]!==v.retryVoiceInput||t[45]!==v.settingsRequired||t[46]!==v.voiceActive?(I=v.voiceActive?(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(kG,{phase:v.phase,elapsedLabel:v.elapsedLabel,audioLevel:v.audioLevel,partialTranscript:v.partialTranscript,finalTranscript:v.finalTranscript,error:v.error,settingsRequired:v.settingsRequired,disabled:p,chat:c,onCancel:v.cancelVoiceInput,onConfirm:v.confirmVoiceInput,onRetry:v.retryVoiceInput})}):(0,$.jsx)(`textarea`,{ref:h,value:d,onChange:e=>f(e.target.value),onKeyDown:j,placeholder:o.quickCapturePlaceholder,disabled:p,rows:4,className:`resize-none border-none bg-transparent px-4 py-3 text-sm leading-relaxed text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`,minHeight:`6rem`,maxHeight:`40vh`}}),t[31]=c,t[32]=j,t[33]=o.quickCapturePlaceholder,t[34]=p,t[35]=d,t[36]=v.audioLevel,t[37]=v.cancelVoiceInput,t[38]=v.confirmVoiceInput,t[39]=v.elapsedLabel,t[40]=v.error,t[41]=v.finalTranscript,t[42]=v.partialTranscript,t[43]=v.phase,t[44]=v.retryVoiceInput,t[45]=v.settingsRequired,t[46]=v.voiceActive,t[47]=I):I=t[47];let L=p||v.voiceActive,R;t[48]===n?R=t[49]:(R=()=>{n(),PU()},t[48]=n,t[49]=R);let z;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(Zn,{className:`size-3.5`,"aria-hidden":!0}),t[50]=z):z=t[50];let B;t[51]===o.discussionCapture.title?B=t[52]:(B=(0,$.jsx)(`span`,{children:o.discussionCapture.title}),t[51]=o.discussionCapture.title,t[52]=B);let V;t[53]!==L||t[54]!==R||t[55]!==B?(V=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:L,onClick:R,children:[z,B]}),t[53]=L,t[54]=R,t[55]=B,t[56]=V):V=t[56];let H=p||v.voiceActive,U=c.voiceInput,W;t[57]===u?W=t[58]:(W=vD(u).join(`+`),t[57]=u,t[58]=W);let G=`${U} (${W})`,ee=c.voiceInput,te;t[59]===u?te=t[60]:(te=vD(u).join(`+`),t[59]=u,t[60]=te);let ne=`${ee} (${te})`,re;t[61]===v?re=t[62]:(re=()=>void v.startVoiceInput(),t[61]=v,t[62]=re);let ie;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(hi,{className:`size-3.5`,"aria-hidden":!0}),t[63]=ie):ie=t[63];let ae;t[64]===c.voiceInput?ae=t[65]:(ae=(0,$.jsx)(`span`,{children:c.voiceInput}),t[64]=c.voiceInput,t[65]=ae);let oe;t[66]!==H||t[67]!==G||t[68]!==ne||t[69]!==re||t[70]!==ae?(oe=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-1 text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,disabled:H,title:G,"aria-label":ne,onClick:re,children:[ie,ae]}),t[66]=H,t[67]=G,t[68]=ne,t[69]=re,t[70]=ae,t[71]=oe):oe=t[71];let se;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Enter`}),t[72]=se):se=t[72];let ce;t[73]===o.quickCaptureHintEnter?ce=t[74]:(ce=(0,$.jsxs)(`span`,{children:[se,` `,o.quickCaptureHintEnter]}),t[73]=o.quickCaptureHintEnter,t[74]=ce);let le;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Shift+Enter`}),t[75]=le):le=t[75];let ue;t[76]===o.quickCaptureHintShift?ue=t[77]:(ue=(0,$.jsxs)(`span`,{children:[le,` `,o.quickCaptureHintShift]}),t[76]=o.quickCaptureHintShift,t[77]=ue);let de;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(`kbd`,{className:`rounded bg-surface-hover px-1 py-0.5 font-mono text-[10px]`,children:`Esc`}),t[78]=de):de=t[78];let fe;t[79]===o.quickCaptureHintEsc?fe=t[80]:(fe=(0,$.jsxs)(`span`,{children:[de,` `,o.quickCaptureHintEsc]}),t[79]=o.quickCaptureHintEsc,t[80]=fe);let pe;t[81]!==V||t[82]!==oe||t[83]!==ce||t[84]!==ue||t[85]!==fe?(pe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-fg-muted`,children:[V,oe,ce,ue,fe]}),t[81]=V,t[82]=oe,t[83]=ce,t[84]=ue,t[85]=fe,t[86]=pe):pe=t[86];let me;t[87]===p?me=t[88]:(me=p&&(0,$.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-accent border-t-transparent`}),t[87]=p,t[88]=me);let he;t[89]!==pe||t[90]!==me?(he=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-4 py-2`,children:[pe,me]}),t[89]=pe,t[90]=me,t[91]=he):he=t[91];let ge;t[92]!==F||t[93]!==I||t[94]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex w-full max-w-lg flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,children:[F,I,he]}),t[92]=F,t[93]=I,t[94]=he,t[95]=ge):ge=t[95];let _e;return t[96]!==o.quickCapturePlaceholder||t[97]!==N||t[98]!==ge?(_e=(0,$.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-start justify-center bg-black/40 p-4 pt-[min(18vh,7rem)]`,role:`dialog`,"aria-modal":`true`,"data-voice-input-scope":`note`,"aria-label":M,onMouseDown:N,children:ge}),t[96]=o.quickCapturePlaceholder,t[97]=N,t[98]=ge,t[99]=_e):_e=t[99],_e}function zG(e){return e.shortcut}function BG(e){return e.language}function VG(){let e=(0,Q.c)(11),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(!1),a=Se(WG),o=SD(UG),s,c;e[0]!==r||e[1]!==o||e[2]!==a?(s=()=>{let e=e=>{r||TD(e,o)&&(e.preventDefault(),a&&n(HG))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},c=[r,o,a],e[0]=r,e[1]=o,e[2]=a,e[3]=s,e[4]=c):(s=e[3],c=e[4]),(0,Z.useEffect)(s,c);let l,u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=e=>{i(!!e.detail?.active)};return window.addEventListener(`quick-capture-shortcut-recording`,e),window.addEventListener(MG,e),()=>{window.removeEventListener(`quick-capture-shortcut-recording`,e),window.removeEventListener(MG,e)}},u=[],e[5]=l,e[6]=u):(l=e[5],u=e[6]),(0,Z.useEffect)(l,u);let d,f;if(e[7]===a?(d=e[8],f=e[9]):(d=()=>{let e=()=>{a&&n(!0)};return window.addEventListener(`open-quick-capture`,e),()=>window.removeEventListener(`open-quick-capture`,e)},f=[a],e[7]=a,e[8]=d,e[9]=f),(0,Z.useEffect)(d,f),!t)return null;let p;return e[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(RG,{onClose:()=>n(!1)}),e[10]=p):p=e[10],p}function HG(e){return!e}function UG(e){return e.shortcut}function WG(e){return e.conversationId}var GG=t({acknowledgeDiscussionConsent:()=>qG,cancelDiscussion:()=>eK,createDiscussion:()=>JG,getDiscussion:()=>YG,getDiscussionCaptureSettings:()=>KG,getDiscussionForNote:()=>XG,getDiscussionTranscript:()=>ZG,getRecordingChunks:()=>nK,getRecordingJob:()=>aK,retryDiscussion:()=>$G,sealRecording:()=>iK,unlinkDiscussionProject:()=>tK,uploadDiscussionSegment:()=>QG,uploadRecordingChunk:()=>rK});function KG(){return q(J(`/api/discussion-capture/settings`))}function qG(e){return q(J(`/api/discussion-capture/settings`),{method:`PUT`,body:JSON.stringify({consentPolicyVersion:e})})}async function JG(e){return q(J(`/api/discussions`),{method:`POST`,body:JSON.stringify(e)})}function YG(e){return q(J(`/api/discussions/${encodeURIComponent(e)}`))}async function XG(e){try{return await q(J(`/api/discussions/by-note/${encodeURIComponent(e)}`))}catch(e){if(e.status===404)return null;throw e}}function ZG(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/transcript`))}function QG(e,t,n){let r=new FormData;return r.set(`file`,n.blob,`segment-${t}.wav`),r.set(`startedAtMs`,String(n.startedAtMs)),r.set(`endedAtMs`,String(n.endedAtMs)),r.set(`sha256`,n.sha256),q(J(`/api/discussions/${encodeURIComponent(e)}/segments/${t}`),{method:`PUT`,body:r})}function $G(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/retry`),{method:`POST`})}function eK(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/cancel`),{method:`POST`})}function tK(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/project`),{method:`DELETE`})}function nK(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/recording/chunks`))}function rK(e,t,n,r){return q(J(`/api/discussions/${encodeURIComponent(e)}/recording/chunks/${t}`),{method:`PUT`,headers:{"Content-Type":`application/octet-stream`,"x-audio-sha256":r},body:n})}function iK(e,t){return q(J(`/api/discussions/${encodeURIComponent(e)}/capture/seal`),{method:`POST`,body:JSON.stringify(t)})}function aK(e){return q(J(`/api/discussions/${encodeURIComponent(e)}/recording/job`))}var oK=`xopc-discussion-drafts`,sK=2,cK=`drafts`,lK=`chunks`,uK=`segments`;function dK(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function fK(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`)),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`))})}function pK(){return typeof indexedDB>`u`?Promise.reject(Error(`Local recording storage is unavailable`)):new Promise((e,t)=>{let n=indexedDB.open(oK,sK);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(cK)||e.createObjectStore(cK,{keyPath:`id`}),e.objectStoreNames.contains(lK)||e.createObjectStore(lK,{keyPath:[`draftId`,`index`]}).createIndex(`draftId`,`draftId`),e.objectStoreNames.contains(uK)||e.createObjectStore(uK,{keyPath:[`draftId`,`sequence`]}).createIndex(`draftId`,`draftId`)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??Error(`Could not open local recording storage`))})}async function mK(e){let t=await pK();try{let n=t.transaction(cK,`readwrite`);n.objectStore(cK).put(e),await fK(n)}finally{t.close()}}async function hK(e,t){let n=await pK();try{let r=n.transaction(t?[lK,cK]:[lK],`readwrite`,{durability:`strict`});r.objectStore(lK).put(e),t&&r.objectStore(cK).put(t),await fK(r)}finally{n.close()}}async function gK(){let e=await pK();try{let t=e.transaction(cK,`readonly`),n=fK(t),r=await dK(t.objectStore(cK).getAll());return await n,r.sort((e,t)=>t.updatedAt-e.updatedAt)}finally{e.close()}}async function _K(e,t){let n=await pK();try{let r=n.transaction(lK,`readonly`),i=fK(r),a=await dK(r.objectStore(lK).get([e,t]));return await i,a}finally{n.close()}}async function vK(e){let t=await pK();try{let n=t.transaction(uK,`readwrite`);n.objectStore(uK).put(e),await fK(n)}finally{t.close()}}async function yK(e){let t=await pK();try{let n=t.transaction(uK,`readonly`),r=fK(n),i=await dK(n.objectStore(uK).index(`draftId`).getAll(e));return await r,i.sort((e,t)=>e.sequence-t.sequence)}finally{t.close()}}async function bK(e,t){let n=await pK();try{let r=n.transaction(uK,`readwrite`);r.objectStore(uK).delete([e,t]),await fK(r)}finally{n.close()}}async function xK(e){let t=await pK();try{let n=t.transaction([cK,lK,uK],`readwrite`);n.objectStore(cK).delete(e);let r=n.objectStore(lK),i=r.index(`draftId`).openKeyCursor(IDBKeyRange.only(e));i.onsuccess=()=>{let e=i.result;e&&(r.delete(e.primaryKey),e.continue())};let a=n.objectStore(uK),o=a.index(`draftId`).openKeyCursor(IDBKeyRange.only(e));o.onsuccess=()=>{let e=o.result;e&&(a.delete(e.primaryKey),e.continue())},await fK(n)}finally{t.close()}}var SK=3e4;function CK(e,t){let n=e?.retryAfterMs;return typeof n==`number`&&Number.isFinite(n)?Math.min(SK,Math.max(0,n)):Math.min(SK,1e3*2**Math.min(t,5))}function wK(e){let t=e?.status;return typeof t!=`number`||t===408||t===429||t>=500}function TK(e,t){return t.throwIfAborted(),new Promise((n,r)=>{let i=()=>{globalThis.clearTimeout(a),r(t.reason??new DOMException(`Aborted`,`AbortError`))},a=globalThis.setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}async function EK(e,t,n){let r=0;for(;!n.aborted;){let i=await t.list(e.draftId);t.onPendingCount?.(i.length);let a=i[0];if(!a)return;try{let n=await t.upload(e.discussionId,a);await t.remove(e.draftId,a),t.onTranscript?.(n),r=0}catch(e){if(n.aborted)throw n.reason??e;if(!wK(e))throw e;await TK(CK(e,r),n),r+=1}}}async function DK(e){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}async function OK(e,t){let n=t,r=performance.now()+5*6e4;for(;n.state===`queued`||n.state===`running`;){if(performance.now()>=r)throw Error(`Recording is still processing. Your draft is saved; retry to check its result.`);await new Promise(e=>setTimeout(e,1e3)),n=await aK(e)}if(n.state!==`completed`)throw Error(n.error??`Recording processing was cancelled`);return YG(e)}async function kK(e,t,n,r=!0){if(r){let e=await YG(t);if(e.discussion.audioAttachmentId)return e;if(e.recordingJob?.state===`queued`||e.recordingJob?.state===`running`)return OK(t,e.recordingJob)}let i=new Map((await nK(t)).map(e=>[e.sequence,e]));for(let r=0;r<e.chunkCount;r+=1){let a=await _K(e.id,r);if(!a)throw Error(`Missing local recording chunk ${r}`);if(a.blob.size>8388608)throw Error(`Recording chunk exceeds the supported size`);let o=await DK(a.blob);if(i.has(r)&&i.get(r).sha256!==o)throw Error(`Stored recording differs from this draft`);i.has(r)||await rK(t,r,a.blob,o),n(Math.round((r+1)/e.chunkCount*100))}if(r)return OK(t,await iK(t,{lastSequence:e.lastSequence,chunkCount:e.chunkCount,mimeType:e.mimeType,fileName:e.fileName??`meeting-${e.startedAt}.${e.mimeType.includes(`mp4`)?`m4a`:e.mimeType.includes(`ogg`)?`ogg`:`webm`}`}))}async function AK(e,t){let n=await navigator.storage?.estimate?.();if(n?.quota&&n.usage!==void 0&&n.quota-n.usage<e.size*1.1)throw Error(`Not enough local storage to safely import this recording`);let r={id:t,mimeType:e.type||(/\.mp3$/i.test(e.name)?`audio/mpeg`:/\.wav$/i.test(e.name)?`audio/wav`:/\.(m4a|mp4)$/i.test(e.name)?`audio/mp4`:/\.ogg$/i.test(e.name)?`audio/ogg`:`audio/webm`),fileName:e.name,startedAt:Date.now(),updatedAt:Date.now(),durationMs:1e3,chunkCount:0,lastSequence:-1,state:`stopped`};try{for(let n=0;n<e.size;n+=Rs)await hK({draftId:t,index:r.chunkCount,blob:e.slice(n,n+Rs),createdAt:Date.now()}),r.chunkCount+=1;return await mK(r),r}catch(e){throw await xK(t),e}}var jK=class{now;accumulated=0;started=null;constructor(e=()=>performance.now()){this.now=e}get elapsedMs(){return this.accumulated+(this.started===null?0:Math.max(0,this.now()-this.started))}resume(){this.started===null&&(this.started=this.now())}pause(){this.accumulated=this.elapsedMs,this.started=null}reset(e=0){this.accumulated=e,this.started=null}},MK=4,NK=15,PK=.6,FK=.5,IK=.5,LK=.015;function RK(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function zK(e){let t=await crypto.subtle.digest(`SHA-256`,await e.arrayBuffer());return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var BK=class{sampleRate;chunks=[];bufferedSamples=0;segmentStartSample=0;sequence=0;silenceSamples=0;hasSpeech=!1;constructor(e){this.sampleRate=e}add(e){if(e.length===0)return[];this.chunks.push(e),this.bufferedSamples+=e.length,Bu(e)>=LK?(this.hasSpeech=!0,this.silenceSamples=0):this.silenceSamples+=e.length;let t=this.sampleRate*NK;return this.bufferedSamples>=t?this.hasSpeech?[this.emit(`max`)]:(this.discardBuffered(),[]):this.hasSpeech&&this.bufferedSamples>=this.sampleRate*MK&&this.silenceSamples>=this.sampleRate*PK?[this.emit(`silence`)]:[]}finish(){return!this.hasSpeech||this.bufferedSamples<this.sampleRate*IK?(this.discardBuffered(),[]):[this.emit(`final`)]}cancel(){this.chunks=[],this.bufferedSamples=0}get lastSequence(){return this.sequence-1}emit(e){let t=RK(this.chunks),n=e===`max`?Math.min(t.length,this.sampleRate*NK):t.length,r=t.slice(0,n),i=e===`max`?Math.min(n,this.sampleRate*FK):0,a=t.slice(n-i),o=Math.round(this.segmentStartSample/this.sampleRate*1e3),s=Math.round((this.segmentStartSample+n)/this.sampleRate*1e3),c={sequence:this.sequence++,samples:r,startedAtMs:o,endedAtMs:s};return this.segmentStartSample+=n-i,this.chunks=a.length?[a]:[],this.bufferedSamples=a.length,this.hasSpeech=a.length>0&&Bu(a)>=LK,this.silenceSamples=this.hasSpeech?0:a.length,c}discardBuffered(){this.segmentStartSample+=this.bufferedSamples,this.chunks=[],this.bufferedSamples=0,this.silenceSamples=0,this.hasSpeech=!1}},VK=class e{capture;accumulator;emitState;onSegment;stopped=!1;constructor(e,t,n,r){this.capture=e,this.accumulator=t,this.emitState=n,this.onSegment=r}static async start(t,n){let r={pending:new Set},i,a=[],o=await qu.start(t,{onSamples:e=>{if(!i){a.push(e);return}for(let t of i.accumulator.add(e))i.emit(t)}});i=new e(o,new BK(o.sampleRate),r,n);for(let e of a)for(let t of i.accumulator.add(e))i.emit(t);return i}pause(){this.capture.pause()}resume(){this.capture.resume()}async stop(){if(this.stopped)return this.accumulator.lastSequence;this.stopped=!0,await this.capture.stop();for(let e of this.accumulator.finish())this.emit(e);if(await Promise.all(this.emitState.pending),this.emitState.error)throw this.emitState.error;return this.accumulator.lastSequence}cancel(){this.stopped||(this.stopped=!0,this.capture.cancel(),this.accumulator.cancel())}emit(e){let t=Vu(e.samples,this.capture.sampleRate),n=new Blob([Hu(t)],{type:`audio/wav`}),r=(async()=>{await this.onSegment({sequence:e.sequence,blob:n,startedAtMs:e.startedAtMs,endedAtMs:e.endedAtMs,sha256:await zK(n)})})().catch(e=>{this.emitState.error??=e});this.emitState.pending.add(r),r.then(()=>this.emitState.pending.delete(r))}},HK=Is,UK=100*1024*1024,WK=32*1024*1024;function GK(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/mp4`,`audio/ogg;codecs=opus`,`audio/webm`].find(e=>MediaRecorder.isTypeSupported(e))}function KK(){let e=(0,Z.useRef)(Symbol(`meeting-capture`)),t=(0,Z.useRef)(0),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(`idle`),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(!0),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(0),b=(0,Z.useRef)(new jK),x=(0,Z.useRef)(Promise.resolve()),S=(0,Z.useRef)(0),C=(0,Z.useRef)(null),w=(0,Z.useRef)(null),T=(0,Z.useCallback)(async()=>{try{c(await gK())}catch{c([])}},[]);(0,Z.useEffect)(()=>{T()},[T]);let E=(0,Z.useCallback)(()=>{w.current!=null&&window.clearInterval(w.current),w.current=null,Xu(e.current),_.current?.getTracks().forEach(e=>e.stop()),_.current=null,h.current=null},[]);(0,Z.useEffect)(()=>()=>{t.current+=1,g.current?.cancel(),E()},[E]);let D=(0,Z.useCallback)(e=>{let t=v.current;if(!t||e.size===0||C.current)return;if(S.current+e.size>WK){let e=Error(`Local storage cannot keep up with recording. Recording stopped; saved chunks can be recovered.`);C.current=e,f(e.message),i(`error`),g.current?.cancel(),E();return}S.current+=e.size;let n=y.current;y.current+=Math.ceil(e.size/Rs),x.current=x.current.then(async()=>{for(let r=0,i=n;r<e.size;r+=Rs,i+=1){if(C.current)return;let n=v.current;if(!n||n.id!==t.id)return;let a={...n,chunkCount:i+1,durationMs:Math.max(n.durationMs,b.current.elapsedMs),updatedAt:Date.now()};if(await hK({draftId:t.id,index:i,blob:e.slice(r,r+Rs),createdAt:Date.now()},a),v.current?.id!==t.id)return;v.current=a,o(a)}}).catch(e=>{C.current=e instanceof Error?e:Error(`Local recording storage failed`),f(C.current.message),i(`error`),g.current?.cancel(),E()}).finally(()=>{S.current-=e.size})},[E]),O=(0,Z.useCallback)(async()=>{if(C.current)throw C.current;let e=h.current;if(!e||e.state===`inactive`)return v.current;i(`stopping`),b.current.pause();let t=g.current?await g.current.stop().catch(()=>-1):-1;if(g.current=null,await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()}),await x.current,C.current)throw C.current;let n=v.current;if(!n)return E(),i(`error`),f(`The recording draft could not be recovered.`),null;let r={...n,state:`stopped`,lastSequence:t,durationMs:Math.min(HK,Math.max(1e3,b.current.elapsedMs)),updatedAt:Date.now()};return await mK(r),v.current=r,o(r),u(r.durationMs),E(),i(`stopped`),await T(),r},[T,E]),k=(0,Z.useCallback)(()=>{if(n.current)return n.current;let e=O().finally(()=>{n.current=null});return n.current=e,e},[O]),A=(0,Z.useCallback)(async n=>{if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`)return f(`Audio recording is not supported in this environment.`),i(`error`),null;if(!Yu(e.current))return f(`The microphone is being used by a voice call. End the call before recording.`),null;let r=++t.current;f(null),i(`requesting_permission`);try{await x.current,C.current=null,S.current=0;let a=await navigator.storage?.estimate?.();if(a?.quota!=null&&a.usage!=null&&a.quota-a.usage<UK)throw Error(`Not enough local storage for a discussion recording.`);let s=await navigator.mediaDevices.getUserMedia({audio:!0});if(r!==t.current)return s.getTracks().forEach(e=>e.stop()),Xu(e.current),null;_.current=s;let c=GK(),l=c?new MediaRecorder(s,{mimeType:c,audioBitsPerSecond:64e3}):new MediaRecorder(s,{audioBitsPerSecond:64e3}),d=Date.now(),p={id:crypto.randomUUID(),...n.projectId?{projectId:n.projectId}:{},mimeType:l.mimeType||c||`audio/webm`,startedAt:d,updatedAt:d,durationMs:0,chunkCount:0,lastSequence:-1,state:`recording`};await mK(p),await navigator.storage?.persist?.().catch(()=>!1),h.current=l,v.current=p,y.current=0,b.current.reset(),b.current.resume(),x.current=Promise.resolve(),l.ondataavailable=e=>D(e.data),l.onerror=()=>{f(`The microphone stopped unexpectedly. Saved audio can be recovered.`),k()},s.getAudioTracks().forEach(e=>e.addEventListener(`ended`,()=>void k(),{once:!0})),l.start(5e3);try{g.current=await VK.start(s,e=>n.onLiveSegment(p.id,e)),m(!0)}catch{g.current=null,m(!1)}return o(p),u(0),i(`recording`),w.current=window.setInterval(()=>{let e=b.current.elapsedMs;u(e),e>=HK&&k()},1e3),p}catch(e){return g.current?.cancel(),g.current=null,E(),f(e instanceof Error?e.message:`Microphone permission was denied.`),i(`error`),null}},[D,k,E]),j=(0,Z.useCallback)(()=>{h.current?.state===`recording`&&(b.current.pause(),u(b.current.elapsedMs),h.current.pause(),g.current?.pause(),i(`paused`))},[]),M=(0,Z.useCallback)(()=>{h.current?.state===`paused`&&(b.current.resume(),h.current.resume(),g.current?.resume(),i(`recording`))},[]),N=(0,Z.useCallback)(async e=>{let t=v.current;if(!t)return;let n={...t,serverDiscussionId:e,updatedAt:Date.now()};v.current=n,o(n),await mK(n)},[]);return{phase:r,draft:a,recoverableDrafts:s,elapsedMs:l,error:d,liveTranscriptionAvailable:p,start:A,pause:j,resume:M,stop:k,restore:(0,Z.useCallback)(async e=>{await x.current,C.current=null;let t={...e,state:`stopped`,updatedAt:Date.now()};await mK(t),v.current=t,b.current.reset(t.durationMs),o(t),u(t.durationMs),f(null),i(`stopped`)},[]),discard:(0,Z.useCallback)(async e=>{await x.current,await xK(e),v.current?.id===e&&(v.current=null,o(null),u(0),i(`idle`)),await T()},[T]),markUploadFailed:(0,Z.useCallback)(async()=>{let e=v.current;if(!e)return;let t={...e,state:`upload_failed`,updatedAt:Date.now()};await mK(t),v.current=t,o(t),await T()},[T]),reset:(0,Z.useCallback)(()=>{v.current=null,b.current.reset(),o(null),u(0),f(null),i(`idle`)},[]),setServerDiscussionId:N,refreshRecoverableDrafts:T}}function qK(e){let t=Math.max(0,Math.floor(e/1e3));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function JK(){let e=l(),t=Se(e=>e.conversationId),n=xe(Ee(e=>e.language)).notes.discussionCapture,r=KK(),[i,a]=(0,Z.useState)(!1),[o,c]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(0),[w,T]=(0,Z.useState)(0),[E,D]=(0,Z.useState)(null),O=(0,Z.useRef)(null),k=(0,Z.useRef)(!1),A=(0,Z.useRef)(!1),j=(0,Z.useRef)(null),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(0,Z.useRef)(null),F=(0,Z.useRef)(()=>{}),I=(0,Z.useCallback)(()=>{let e=P.current;if(e)return e;let t=M.current;if(!t)return Promise.resolve();let r=new AbortController;N.current=r;let i=EK(t,{list:yK,upload:(e,t)=>QG(e,t.sequence,t),remove:(e,t)=>bK(e,t.sequence),onTranscript:h,onPendingCount:T},r.signal).finally(()=>{P.current===i&&(P.current=null,N.current===r&&(N.current=null))});return P.current=i,i.then(()=>{window.setTimeout(()=>F.current(),0)}).catch(e=>{r.signal.aborted||D(e instanceof Error?e.message:n.saveFailed)}),i},[]);F.current=()=>{let e=M.current;!e||P.current||yK(e.draftId).then(e=>{T(e.length),e.length>0&&I()})};let L=(0,Z.useCallback)((e,t)=>{let n=M.current;return n&&(n.draftId!==e||n.discussionId!==t)&&(N.current?.abort(),P.current=null),M.current={draftId:e,discussionId:t},I()},[I]),R=(0,Z.useCallback)(async(e,t)=>{for(M.current={draftId:e,discussionId:t};;){await I();let t=await yK(e);if(T(t.length),t.length===0)return}},[I]),z=(0,Z.useCallback)(async(e,t)=>{await vK({draftId:e,...t,createdAt:Date.now()}),T(e=>e+1),I()},[I]),B=(0,Z.useCallback)(async(e,t)=>{c(null),d(void 0),a(!0),D(null),h(null),p(null),C(0);let i=await r.start({...e?{projectId:e}:{},onLiveSegment:z});if(!i)return;A.current=!0;let o=JG({clientRequestId:i.id,...e?{contextProjectId:e}:{},consentPolicyVersion:t,source:An()?`electron`:`web`});j.current=o;try{let e=await o;p(e),await r.setServerDiscussionId(e.discussion.id),L(i.id,e.discussion.id)}catch(e){D(e instanceof Error?e.message:n.saveFailed)}},[L,n.saveFailed,r,z]);(0,Z.useEffect)(()=>()=>N.current?.abort(),[]);let V=(0,Z.useCallback)(async e=>{if(!(!t||r.phase===`recording`||r.phase===`paused`||g)){a(!0),D(null);try{let t=await KG();if(t.consentAcknowledgedAt==null){d(e),c(t.consentPolicyVersion);return}await B(e,t.consentPolicyVersion)}catch(e){D(e instanceof Error?e.message:n.saveFailed)}}},[B,n.saveFailed,g,r.phase,t]);(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail?.projectId;V(t)};return window.addEventListener(NU,e),()=>window.removeEventListener(NU,e)},[V]),(0,Z.useEffect)(()=>{let e=r.draft,t=f?.discussion.id;!e||!t||!e.chunkCount||g||O.current||![`recording`,`paused`].includes(r.phase)||(O.current=kK(e,t,C,!1).catch(e=>D(e instanceof Error?e.message:n.saveFailed)).finally(()=>{O.current=null}))},[r.draft,r.phase,f?.discussion.id,g,n.saveFailed]);let H=(0,Z.useCallback)(async()=>{let e=f?.discussion.id;if(!e)return;let[t,n]=await Promise.all([YG(e),ZG(e)]);p(t),h(n)},[f?.discussion.id]);(0,Z.useEffect)(()=>{let e=()=>void H();return window.addEventListener(`discussion-segment-updated`,e),window.addEventListener(`discussion-updated`,e),()=>{window.removeEventListener(`discussion-segment-updated`,e),window.removeEventListener(`discussion-updated`,e)}},[H]);let U=async()=>{if(o!=null)try{await qG(o),await B(u,o)}catch(e){D(e instanceof Error?e.message:n.saveFailed)}},W=async()=>{if(!k.current){k.current=!0,A.current=!1,_(!0),D(null);try{let t=await r.stop();if(!t)throw Error(n.emptyRecording);let i=await j.current;if(!i)throw Error(n.saveFailed);y(!0),await O.current,await kK(t,i.discussion.id,C),await R(t.id,i.discussion.id).catch(()=>void 0),p(await YG(i.discussion.id)),await r.discard(t.id),M.current=null,T(0),e(`/notes/${encodeURIComponent(i.note.id)}`)}catch(e){await r.markUploadFailed(),D(e instanceof Error?e.message:n.saveFailed),a(!0)}finally{k.current=!1,_(!1),y(!1)}}};(0,Z.useEffect)(()=>{r.phase===`stopped`&&A.current&&W()});let G=()=>{f&&e(`/notes/${encodeURIComponent(f.note.id)}`)},ee=async()=>{if(f)try{p(await tK(f.discussion.id))}catch(e){D(e instanceof Error?e.message:n.saveFailed)}},te=async()=>{let e=r.recoverableDrafts[0];if(!(!e||b)){x(!0),a(!0),D(null),C(0);try{await r.restore(e);let t=await KG();if(t.consentAcknowledgedAt==null)throw Error(n.consent);let i=e.serverDiscussionId?await YG(e.serverDiscussionId).catch(()=>null):null;if(i||=await JG({clientRequestId:e.id,...e.projectId?{contextProjectId:e.projectId}:{},consentPolicyVersion:t.consentPolicyVersion,source:An()?`electron`:`web`}),j.current=Promise.resolve(i),p(i),await r.setServerDiscussionId(i.discussion.id),i.discussion.audioAttachmentId&&[`sealing`,`organizing`,`completed`].includes(i.discussion.status)){await r.discard(e.id);return}if(i.discussion.status===`cancelled`)throw Error(`This recording was cancelled`);let a=(await yK(e.id)).reduce((e,t)=>Math.max(e,t.sequence),e.lastSequence);i.discussion.audioAttachmentId||await kK({...e,lastSequence:a},i.discussion.id,C),await R(e.id,i.discussion.id).catch(()=>void 0);let o=await YG(i.discussion.id);if(o.discussion.status===`needs_attention`){let{retryDiscussion:e}=await s(async()=>{let{retryDiscussion:e}=await Promise.resolve().then(()=>GG);return{retryDiscussion:e}},void 0);await e(i.discussion.id)}else p(o);await r.discard(e.id)}catch(e){await r.markUploadFailed(),D(e instanceof Error?e.message:n.saveFailed)}finally{x(!1)}}},ne=async()=>{let e=r.recoverableDrafts[0];e&&(e.serverDiscussionId&&await eK(e.serverDiscussionId).catch(()=>void 0),await r.discard(e.id))};if(!i)return v?(0,$.jsxs)(`aside`,{className:`fixed bottom-5 right-5 z-[125] w-[min(24rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-panel p-4 shadow-elevated`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.finalizing}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:w>0?n.syncingSegments.replace(`{{count}}`,String(w)):S>=100?n.verifyingRecording:n.saved}),(0,$.jsx)(`div`,{className:`mt-3 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full bg-accent transition-[width]`,style:{width:`${S}%`}})}),f?(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(X,{variant:`ghost`,onClick:G,children:[(0,$.jsx)(zr,{className:`size-4`,"aria-hidden":!0}),n.openNote]})}):null]}):r.recoverableDrafts[0]?(0,$.jsxs)(`aside`,{className:`fixed bottom-5 right-5 z-[125] w-[min(24rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-panel p-4 shadow-elevated`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.recoveredTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.recoveredDescription}),(0,$.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,$.jsx)(X,{variant:`ghost`,disabled:b,onClick:()=>void ne(),children:n.discard}),(0,$.jsx)(X,{variant:`primary`,disabled:b,onClick:()=>void te(),children:b?n.recovering:n.recover})]})]}):null;if(o!=null)return(0,$.jsx)(`div`,{className:`fixed inset-0 z-[130] flex items-center justify-center bg-black/45 p-4`,role:`dialog`,"aria-modal":`true`,children:(0,$.jsxs)(`div`,{className:`w-[min(28rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-panel p-5 shadow-elevated`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.consentTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.consent})]}),(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,onClick:()=>a(!1),children:(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0})})]}),E?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:E}):null,(0,$.jsxs)(X,{variant:`primary`,className:`mt-5 w-full`,onClick:()=>void U(),children:[(0,$.jsx)(hi,{className:`size-4`,"aria-hidden":!0}),n.consentAction]})]})});let re=r.phase===`recording`||r.phase===`paused`||r.phase===`requesting_permission`,ie=f?.discussion.projectId&&f.discussion.projectInferenceSource!==`context`,ae=(m?.stats.uploaded??0)+(m?.stats.transcribing??0);return(0,$.jsxs)(`aside`,{className:`fixed bottom-5 right-5 z-[125] flex w-[min(26rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,"aria-label":n.title,children:[(0,$.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${re?`animate-pulse bg-danger`:`bg-accent`}`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:f?.note.title??n.title}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:g?n.finalizing:r.phase===`paused`?n.paused:r.phase===`requesting_permission`?n.requesting:n.recording})]})]}),!re&&!g?(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover`,"aria-label":n.close,onClick:()=>a(!1),children:(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0})}):null]}),(0,$.jsxs)(`div`,{className:`grid gap-3 px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`font-mono text-3xl tabular-nums text-fg`,children:qK(r.elapsedMs)}),(0,$.jsxs)(`section`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:n.liveTranscript}),w>0?(0,$.jsx)(`span`,{children:n.syncingSegments.replace(`{{count}}`,String(w))}):ae>0?(0,$.jsx)(`span`,{children:n.processingSegments.replace(`{{count}}`,String(ae))}):null]}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:m?.text||(r.liveTranscriptionAvailable?n.waitingTranscript:n.liveUnavailable)})]}),ie?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-accent-soft px-3 py-2 text-xs text-accent-fg`,children:[(0,$.jsx)(`span`,{children:n.projectLinked}),(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 font-medium`,onClick:()=>void ee(),children:[(0,$.jsx)(ga,{className:`size-3`,"aria-hidden":!0}),` `,n.undo]})]}):null,g&&S>0?(0,$.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full bg-accent transition-[width]`,style:{width:`${S}%`}})}):null,E||r.error?(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:E??r.error}):null]}),(0,$.jsxs)(`footer`,{className:`flex items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.maxDuration}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f?(0,$.jsxs)(X,{variant:`ghost`,onClick:G,children:[(0,$.jsx)(zr,{className:`size-4`,"aria-hidden":!0}),n.openNote]}):null,r.phase===`recording`?(0,$.jsxs)(X,{onClick:r.pause,children:[(0,$.jsx)(Ai,{className:`size-4`,"aria-hidden":!0}),n.pause]}):null,r.phase===`paused`?(0,$.jsxs)(X,{onClick:r.resume,children:[(0,$.jsx)(Li,{className:`size-4`,"aria-hidden":!0}),n.resume]}):null,r.phase===`recording`||r.phase===`paused`?(0,$.jsxs)(X,{variant:`primary`,disabled:g,onClick:()=>void W(),children:[(0,$.jsx)(ra,{className:`size-4`,"aria-hidden":!0}),n.stop]}):null]})]})]})}var YK=4e3;function XK(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=typeof t.conversationId==`string`?t.conversationId.trim():``,r=typeof t.runId==`string`?t.runId.trim():``;return n&&r?{conversationId:n,runId:r}:null}function ZK(e){let t=XK(e);if(!t||!e||typeof e!=`object`)return null;let n=e.status;return n!==`success`&&n!==`error`&&n!==`cancelled`&&n!==`suspended`?null:{...t,status:n}}async function QK(){let e=await we(J(`/api/session-runs`));if(!e.ok)throw Error(`Active session runs failed (${e.status})`);let t=await e.json();if(!Array.isArray(t.payload?.runs))throw Error(`Active session runs response is invalid`);return t.payload.runs.map(XK).filter(e=>!!e)}function $K(e){window.dispatchEvent(new CustomEvent(`session-transcript-updated`,{detail:{key:e}}))}function eq(){let e=!1,t,n,r=new Map,i=({conversationId:e,runId:t})=>`${e}\u0000${t}`,a=({conversationId:e,runId:t},n=!1)=>{r.has(i({conversationId:e,runId:t}))||(Uy(e)!==t&&Wy(e,t),ib.setResumeRunId(e,t),tx(e),n&&window.dispatchEvent(new CustomEvent(`run-started`,{detail:{conversationId:e,runId:t}})))},o=({conversationId:e,runId:t})=>{let n=ib.reconcileInactive(e,t),r=qy(e,t);!n&&r&&qb.getState().clearStreamingState(e),(n||r)&&(ix(e),$K(e))},s=({conversationId:e,runId:t,status:n})=>{r.set(i({conversationId:e,runId:t}),Date.now());let a=ib.reconcileTerminal(e,t,n),o=qy(e,t);if(!a&&o){qb.getState().clearStreamingState(e);let t=qb.getState().focusedConversationId===e;n===`error`?rx(e,!t):n===`suspended`?ax(e):n===`success`?nx(e,!t):ix(e),$K(e)}},c=()=>{e||t!==void 0||Jy().length===0||(t=window.setTimeout(()=>{t=void 0,l()},YK))},l=()=>{if(n)return n;let t=Jy();return n=QK().then(n=>{if(e)return;let i=Date.now()-10*6e4;for(let[e,t]of r)t<i&&r.delete(e);let s=new Map(n.map(e=>[e.conversationId,e.runId])),c=new Map(t.map(e=>[e.conversationId,e.runId]));for(let e of n){let t=Uy(e.conversationId),n=c.get(e.conversationId);t&&t!==n&&t!==e.runId||a(e,!0)}for(let e of t)s.get(e.conversationId)!==e.runId&&o(e)}).catch(()=>{}).finally(()=>{n=void 0,c()}),n},u=e=>{let t=XK(e.detail);t&&(a(t),c())},d=e=>{let t=ZK(e.detail);t&&s(t)},f=()=>void l();return window.addEventListener(`run-started`,u),window.addEventListener(`run-completed`,d),window.addEventListener(`agent-run-ended`,d),window.addEventListener(`gateway-realtime-connected`,f),l(),()=>{e=!0,t!==void 0&&window.clearTimeout(t),window.removeEventListener(`run-started`,u),window.removeEventListener(`run-completed`,d),window.removeEventListener(`agent-run-ended`,d),window.removeEventListener(`gateway-realtime-connected`,f)}}function tq(){let e=(0,Q.c)(3),t=Se(oq),n;e[0]===t?n=e[1]:(n=[t],e[0]=t,e[1]=n),(0,Z.useEffect)(aq,n);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[2]=r):r=e[2],(0,Z.useEffect)(nq,r)}function nq(){let e=iq,t=rq;return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}}function rq(){document.visibilityState===`visible`&&Py()}function iq(){return Py()}function aq(){return jy()}function oq(e){return e.conversationId}function sq(e){let t=new Set;return(n,r)=>{let i=Bt.safeParse(r);if(!i.success)return;let a=i.data;n!==`resources:${a.kind}s`||t.has(a.eventId)||(t.add(a.eventId),t.size>1024&&t.delete(t.values().next().value),e(a))}}function cq(e,t){let n=Array.isArray(e)?e[0]:e;return typeof n==`string`&&(n===t||n.startsWith(`${t}-`)||n.startsWith(`${t}s`))}var lq=new Set([`automation-chat-agents`,`channel-routing-agents`,`gateway-chat-agents`,`picker-agents-list`,`settings-gateway-agents`,`setup-checklist-agents`,`workflow-agents`,`workflow-route-agents`]);function uq(e){let t=Array.isArray(e)?e[0]:e;return typeof t==`string`&&lq.has(t)}function dq(){tq();let{mutate:e}=Xt(),t=Se(e=>e.conversationId);return(0,Z.useEffect)(()=>VA(),[]),(0,Z.useEffect)(()=>eq(),[]),(0,Z.useEffect)(()=>{let n=(t,n)=>{e(e=>cq(e,t)),t===`project`&&window.dispatchEvent(new CustomEvent(`project-resource-changed`,{detail:{id:n}}))},r=sq(e=>{e.kind!==`note`&&e.kind!==`task`&&e.kind!==`project`||(n(e.kind,e.id),e.kind===`note`&&window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.id}})))}),i=0,a=[],o=async()=>{let e=++i;a.forEach(e=>e()),a=[];try{let{capabilities:t}=await q(J(`/api/capabilities/operations`));if(e!==i)return;a=[`note`,`task`,`project`].filter(e=>t.some(t=>t.id===`xopc.${e}s.list`)).map(e=>{let t=Fy(`resources:${e}s`,{onEvent:e=>{e.event===`resource.changed`&&r(e.topic,e.data)},onGap:()=>n(e)},0);return n(e),t})}catch{}},s=()=>{o()};return t&&o(),window.addEventListener(`gateway-realtime-connected`,s),()=>{i++,a.forEach(e=>e()),window.removeEventListener(`gateway-realtime-connected`,s)}},[e,t]),(0,Z.useEffect)(()=>{let t=()=>{eE(),e(uq)},n=e=>{tW();let t=nn(e.detail);t===`skills`?rE():t===`agents`&&eE()},r=t=>{let n=t.detail?.topic;(n===`gateway`||n===`sessions`)&&e(()=>!0)};return window.addEventListener(`agent-catalog`,t),window.addEventListener(`config-reload`,n),window.addEventListener(`realtime-gap`,r),()=>{window.removeEventListener(`agent-catalog`,t),window.removeEventListener(`config-reload`,n),window.removeEventListener(`realtime-gap`,r)}},[e]),null}var fq=`xopc.browser-notifications.v1`,pq={enabled:!1,completed:!0,failed:!0};function mq(){try{let e=JSON.parse(localStorage.getItem(fq)??`{}`);return{enabled:typeof e.enabled==`boolean`?e.enabled:pq.enabled,completed:typeof e.completed==`boolean`?e.completed:pq.completed,failed:typeof e.failed==`boolean`?e.failed:pq.failed}}catch{return{...pq}}}function hq(e){let t={...mq(),...e};try{localStorage.setItem(fq,JSON.stringify(t))}catch{}return t}var gq=`xopc.notification-delivery.v1`,_q=200;function vq(){try{let e=JSON.parse(localStorage.getItem(gq)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function yq(e){return vq().includes(e)}function bq(e){try{let t=[e,...vq().filter(t=>t!==e)].slice(0,_q);localStorage.setItem(gq,JSON.stringify(t))}catch{}}function xq(e){return e.notification.systemAllowed===!1||!e.preferences.enabled?{notify:!1,reason:`disabled`}:e.notification.status===`success`&&!e.preferences.completed||e.notification.status===`error`&&!e.preferences.failed?{notify:!1,reason:`status-disabled`}:e.permissionGranted?e.appFocused?{notify:!1,reason:`focused`}:e.alreadyDelivered?{notify:!1,reason:`duplicate`}:{notify:!0}:{notify:!1,reason:`permission`}}function Sq(){return!An()&&typeof Notification<`u`&&`serviceWorker`in navigator&&window.isSecureContext}async function Cq(){let e=await navigator.serviceWorker.register(`/notification-sw.js`);return await navigator.serviceWorker.ready,e}async function wq(e){if(!Sq()||!xq({notification:e,preferences:mq(),permissionGranted:Notification.permission===`granted`,appFocused:document.visibilityState===`visible`&&document.hasFocus(),alreadyDelivered:yq(e.id)}).notify)return!1;try{return await(await Cq()).showNotification(e.title,{body:e.body,tag:e.id,icon:`/pwa-192x192.png`,data:{route:e.route}}),bq(e.id),!0}catch{return!1}}async function Tq(){if(!Sq())return`unsupported`;let e=Notification.permission==="default"?await Notification.requestPermission():Notification.permission;return e===`granted`&&await Cq(),e}async function Eq(e,t){if(!Sq()||Notification.permission!==`granted`)return!1;try{return await(await Cq()).showNotification(e,{body:t,tag:`xopc-notification-test`,icon:`/pwa-192x192.png`,data:{route:`/chat/new`}}),!0}catch{return!1}}async function Dq(e){let t=window.electronAPI?.system;if(!An()||!t?.showProductNotification)return!1;let n=await t.getBehavior().catch(()=>null);if(!n||!xq({notification:e,preferences:{enabled:n.notifyEnabled,completed:!0,failed:!0},permissionGranted:!0,appFocused:!1,alreadyDelivered:yq(e.id)}).notify)return!1;let r=await t.showProductNotification({id:e.id,title:e.title,body:e.body,target:e.target}).catch(()=>null);return r?.ok&&r.outcome===`shown`?(bq(e.id),!0):!1}var Oq=`xopc.notifications.cursor.v1`,kq=`xopc.notifications.consumer.v1`;function Aq(e){try{return window.localStorage.getItem(e)}catch{return null}}function jq(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Mq(){return Aq(Oq)}function Nq(e){jq(Oq,e)}function Pq(){let e=Aq(kq);if(e)return e;let t=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`;return jq(kq,t),t}async function Fq(){let e=[],t=Mq();for(let n=0;n<10;n+=1){let n=new URLSearchParams({since:String(Date.now()-5*6e4),limit:`100`});t&&n.set(`after`,t);let r=await we(`/api/notifications?${n}`);if(!r.ok)break;let i=await r.json().catch(()=>null);if(!Array.isArray(i?.items))break;let a=i.items.flatMap(e=>{let t=Ms.safeParse(e);return t.success?[t.data]:[]});if(e.push(...a),t=a.at(-1)?.id??t,i.items.length<100||a.length===0)break}return e}async function Iq(e){await we(`/api/notifications/${encodeURIComponent(e)}/ack`,{method:`POST`,body:JSON.stringify({consumerId:Pq(),surface:An()?`electron`:`web`})}).catch(()=>null)}function Lq(e){let t=Ms.safeParse(e);return t.success?t.data:null}function Rq(e,t){let n=Ns(e,t),r=e.type===`chat.failed`||e.type===`task.blocked`||e.type===`task.failed`||e.type===`task.needs_input`||e.type===`automation.failed`||e.type===`work_discovery.failed`,i=e.target.kind===`automation_run`?`automation`:e.target.kind===`scene_result`||e.target.kind===`scene_digest`?`scene`:e.target.kind===`work_discovery`?`understanding`:e.target.kind;return{systemAllowed:e.payload.deliveryMode!==`auto`&&(!e.payload.deliveryChannel||[`all`,`browser`].includes(String(e.payload.deliveryChannel))),id:e.id,title:n.localizedTitle,body:n.localizedBody??n.localizedTitle,route:Ps(e.target,`web`),target:e.target,status:r?`error`:`success`,source:i}}function zq(){let e=(0,Q.c)(3),t=Ee(Vq),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=!0,n=null,r=new Set,i=(e,n,i)=>{let a=n===void 0?!0:n,o=i===void 0?!0:i,s=Lq(e);if(!s)return;if(r.has(s.id)){o&&Nq(s.id);return}r.add(s.id);let c=Rq(s,t);Jl({tone:c.status===`success`?`success`:`error`,title:c.title,message:c.body,source:c.source,href:c.route,dedupeKey:c.id}),a&&(Dq(c),wq(c)),o&&Nq(s.id),Iq(s.id)},a=()=>n||(n=Fq().then(t=>{if(e){let e=Date.now()-3e5;t.forEach(t=>i(t,t.createdAt>=e))}}).finally(()=>{n=null}),n),o=e=>{i(e.detail,!0,!1),a().then(()=>a())},s=()=>void a();window.addEventListener(`notification-created`,o),window.addEventListener(`realtime-gap`,s),a();let c=Bq;return navigator.serviceWorker?.addEventListener(`message`,c),()=>{e=!1,window.removeEventListener(`notification-created`,o),window.removeEventListener(`realtime-gap`,s),navigator.serviceWorker?.removeEventListener(`message`,c)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function Bq(e){let t=e.data;t?.type!==`xopc:notification-click`||typeof t.route!=`string`||t.route.startsWith(`/`)&&!t.route.startsWith(`//`)&&(window.location.hash=t.route)}function Vq(e){return e.language}async function Hq(e){let t=await q(J(`/api/support/report`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)});return{report:t.report,investigationPrompt:t.investigationPrompt}}function Uq(e){let t=new Date(e.capturedAt).toISOString().replace(/[:.]/g,`-`),n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`xopc-diagnostics-${t}.json`,i.click(),URL.revokeObjectURL(r)}function Wq(e,t){let n=6e3,r=e.markdown.length<=n?e.markdown:`${e.markdown.slice(0,n)}\n\n---\n${t}`;return`https://github.com/xopcai/xopc/issues/new?${new URLSearchParams({title:e.title,body:r}).toString()}`}async function Gq(e){let t=window.electronAPI?.shell?.openExternalUrl;if(t)try{return(await t(e)).ok}catch{return!1}return window.open(e,`_blank`,`noopener,noreferrer`)!==null}function Kq(e){let t=new TextEncoder().encode(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return{type:`file`,mimeType:`text/markdown`,data:btoa(n),name:`xopc-diagnostics.md`,size:t.byteLength}}async function qq(e,t,n={}){let r=n.fetch??q,i=n.getTurnClaim??Cv,a=n.randomUUID??(()=>crypto.randomUUID()),o=(await r(J(`/api/sessions`),{method:`POST`,body:JSON.stringify({channel:`webchat`,agentId:`main`})})).session.key.trim();if(!o)throw Error(`Session create did not return a session key`);await r(J(`/api/sessions/${encodeURIComponent(o)}`),{method:`PATCH`,body:JSON.stringify({name:e.title,tags:[`support`],replaceTags:!0,customData:{genericNewChatShell:!0,kind:`support-investigation`,supportReportCapturedAt:e.capturedAt}})}).catch(()=>void 0);let s=await i();return await r(J(`/api/sessions/${encodeURIComponent(o)}/inputs`),{method:`POST`,body:JSON.stringify({clientMessageId:a(),delivery:`next`,content:t,attachments:[Kq(e.markdown)],origin:s})}),o}function Jq({open:e,onOpenChange:t,seed:n}){let r=xe(Ee(e=>e.language)).supportReport,i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,C]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{e&&(o(n?.problem??``),c(n?.reproduction??``),u(n?.expected??``),f(null),m(``),g(!1),v(!1),b(null),C(null))},[e,n]);async function w(){let e=a.trim();if(!e){b(r.problemRequired);return}g(!0),b(null),C(null);try{let t=await Hq({...n,problem:e,reproduction:s.trim()||void 0,expected:l.trim()||void 0,occurredAt:n?.occurredAt??new Date().toISOString(),clientContext:{currentPage:window.location.href,surface:window.electronAPI?`electron`:`web`,userAgent:navigator.userAgent,...n?.clientContext}});f(t.report),m(t.investigationPrompt)}catch(e){b(e instanceof Error?e.message:r.collectFailed)}finally{g(!1)}}async function T(){if(!d)return!1;let e=await Yt(d.markdown);return C(e?r.copied:r.copyFailed),e||(i.current?.focus(),i.current?.select()),e}async function E(){d&&(d.markdown.length>6e3&&await T(),await Gq(Wq(d,r.githubTruncated))||b(r.openFailed))}async function D(){if(!(!d||!p)){v(!0),b(null);try{let e=await qq(d,p);t(!1),window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{conversationId:e}}))}catch(e){b(e instanceof Error?e.message:r.sessionFailed)}finally{v(!1)}}}return(0,$.jsx)(nt,{open:e,onOpenChange:t,children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[220] bg-scrim`}),(0,$.jsxs)(et,{className:K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[221] flex h-[min(42rem,calc(100vh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover dark:border-edge`),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:r.title}),(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle})]}),(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":r.close,children:(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:[h?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":r.collecting,children:[(0,$.jsx)(xn,{className:`h-20 w-full`}),(0,$.jsx)(xn,{className:`h-24 w-full`}),(0,$.jsx)(xn,{className:`h-32 w-full`})]}):d?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-accent-soft px-3 py-2.5 text-sm text-accent-fg`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium`,children:r.ready}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5`,children:r.readyDetail.replace(`{{checks}}`,String(d.doctor.length)).replace(`{{logs}}`,String(d.logs.length)).replace(`{{redactions}}`,String(d.redaction.replacements))})]})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-report-preview`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.preview}),(0,$.jsx)(`textarea`,{ref:i,id:`support-report-preview`,value:d.markdown,readOnly:!0,className:`h-96 w-full resize-none rounded-xl border border-edge bg-surface-base p-3 font-mono text-xs leading-5 text-fg outline-none focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(ta,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.investigationHint]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-problem`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.problem}),(0,$.jsx)(`textarea`,{id:`support-problem`,value:a,onChange:e=>o(e.target.value),placeholder:r.problemPlaceholder,className:`min-h-28 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`,autoFocus:!0})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-reproduction`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.reproduction}),(0,$.jsx)(`textarea`,{id:`support-reproduction`,value:s,onChange:e=>c(e.target.value),placeholder:r.reproductionPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`label`,{className:`block`,htmlFor:`support-expected`,children:[(0,$.jsx)(`span`,{className:`mb-1.5 block text-xs font-medium text-fg-muted`,children:r.expected}),(0,$.jsx)(`textarea`,{id:`support-expected`,value:l,onChange:e=>u(e.target.value),placeholder:r.expectedPlaceholder,className:`min-h-20 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent`})]}),(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),r.privacy]})]}),y?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-warning`,role:`alert`,children:y}):null,x?(0,$.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-accent-fg`,role:`status`,children:[(0,$.jsx)(S,{className:`size-4`,"aria-hidden":!0}),x]}):null]}),(0,$.jsx)(`footer`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge px-5 py-3`,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:`ghost`,disabled:_,onClick:()=>{f(null),m(``)},children:r.back}),(0,$.jsxs)(X,{onClick:()=>void T(),children:[(0,$.jsx)(wr,{className:`size-4`,"aria-hidden":!0}),r.copy]}),(0,$.jsxs)(X,{onClick:()=>Uq(d),children:[(0,$.jsx)(P,{className:`size-4`,"aria-hidden":!0}),r.download]}),(0,$.jsxs)(X,{onClick:()=>void E(),children:[(0,$.jsx)(I,{className:`size-4`,"aria-hidden":!0}),r.submit]}),(0,$.jsxs)(X,{variant:`primary`,disabled:_,onClick:()=>void D(),children:[_?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ta,{className:`size-4`,"aria-hidden":!0}),_?r.startingInvestigation:r.startInvestigation]})]}):(0,$.jsxs)(X,{variant:`primary`,disabled:h,onClick:()=>void w(),children:[h?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,h?r.collecting:r.collect]})})]})]})})}function Yq(e){if(!e.startsWith(`/chat/`)||e.startsWith(`/chat/task/`))return;let t=e.slice(6);if(!(!t||t===`new`))try{return decodeURIComponent(t)}catch{return}}function Xq(){let e=(0,Q.c)(6),{pathname:t}=b(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(),o,s;e[0]===t?(o=e[1],s=e[2]):(o=()=>{let e=e=>{let n=e.detail??{};a({conversationId:Yq(t),...n}),r(!0)};return window.addEventListener(Jm,e),()=>window.removeEventListener(Jm,e)},s=[t],e[0]=t,e[1]=o,e[2]=s),(0,Z.useEffect)(o,s);let c;return e[3]!==n||e[4]!==i?(c=(0,$.jsx)(Jq,{open:n,onOpenChange:r,seed:i}),e[3]=n,e[4]=i,e[5]=c):c=e[5],c}var Zq=new Intl.DateTimeFormat(`zh-CN`,{dateStyle:`medium`,timeStyle:`short`}),Qq=new Intl.DateTimeFormat(`en`,{dateStyle:`medium`,timeStyle:`short`});function $q(e,t){return(t===`zh`?Zq:Qq).format(new Date(e))}function eJ({filePath:e,onClose:t,targetLine:n,projectId:r,conversationId:i,agentId:a}){let o=Ee(e=>e.language),s=xe(o),c=Xd(e=>e.resolved),l=bC({filePath:e,projectId:r,conversationId:i,agentId:a}),{dialogOpen:u,loading:d,result:f,error:p,pendingParams:m,createShareLink:h,confirmShareLink:g,handleOpenChange:_}=lw(),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),{expanded:S,setExpanded:C}=$E(!!e,u),w=e?sC(e):``,T=[`text`,`markdown`,`code`,`html`].includes(l.descriptor.type),E=(0,Z.useCallback)(async()=>{if(e){if(await Yt(e)){y(!0),Yl(`success`,s.workspace.pathCopied,void 0,{duration:2500}),window.setTimeout(()=>y(!1),2e3);return}Yl(`warning`,s.clipboard.copyFailed,void 0,{duration:4e3})}},[e,s.clipboard.copyFailed,s.workspace.pathCopied]),D=(0,Z.useCallback)(()=>{l.fileResourceId&&h({fileId:l.fileResourceId,fileName:w})},[h,w,l.fileResourceId]),O=(0,Z.useCallback)(async()=>{await uw(()=>l.onOpenWithSystemApp(),s.chat.attachmentPreviewOpenLocalFailed)},[s.chat.attachmentPreviewOpenLocalFailed,l.onOpenWithSystemApp]),k=(0,Z.useCallback)(async()=>{await uw(()=>l.onChooseOpenWithApp(),s.workspace.openFileFailed)},[s.workspace.openFileFailed,l.onChooseOpenWithApp]),A=(0,Z.useCallback)(async e=>{await uw(()=>l.onOpenWithRecentApp(e),s.workspace.openFileFailed)},[s.workspace.openFileFailed,l.onOpenWithRecentApp]),j=(0,Z.useCallback)(async()=>{await uw(()=>l.onRevealInFolder(),s.workspace.revealFileFailed)},[s.workspace.revealFileFailed,l.onRevealInFolder]),M=(0,Z.useCallback)(()=>{C(!1),t()},[t]),N=!!(e&&!l.loading&&!l.loadError),P={onDownload:()=>void l.onDownload(),canDownload:l.canDownload,onOpenWithSystemApp:()=>void O(),canOpenWithSystemApp:l.canOpenWithSystemApp,onChooseOpenWithApp:()=>void l.onChooseOpenWithApp(),canChooseOpenWithApp:l.canChooseOpenWithApp};if(!e)return null;let F=(0,$.jsx)(`div`,{className:K(`flex h-full min-h-0 flex-col bg-surface-panel`,S&&`fixed inset-0 z-[65] h-[100dvh] w-screen`,S&&nD()),children:(0,$.jsx)(QE,{header:{subtitle:(0,$.jsxs)($.Fragment,{children:[!l.loading&&l.mtimeMs!=null?(0,$.jsxs)(`p`,{suppressHydrationWarning:!0,className:`min-w-0 truncate`,title:new Date(l.mtimeMs).toISOString(),children:[s.workspace.lastModified,`: `,$q(l.mtimeMs,o),n?` · Line ${n}`:``]}):null,l.loading?(0,$.jsx)(xn,{className:`h-3.5 w-32`}):null,T&&l.sourceEditMode&&l.saveStatus!==`idle`?(0,$.jsx)(`span`,{className:K(`shrink-0`,l.saveStatus===`error`&&`text-red-600 dark:text-red-400`),children:l.saveStatus===`saving`?s.workspace.saving:l.saveStatus===`error`?s.workspace.saveFailed:s.workspace.saved}):null]}),expanded:S,onToggleExpanded:N?()=>C(e=>!e):void 0,onClose:M,edit:T?{active:l.sourceEditMode,onToggle:()=>l.setSourceEditMode(e=>!e)}:void 0,wordWrap:T&&l.sourceEditMode?{active:b,onToggle:()=>x(e=>!e)}:void 0,share:{onClick:D,loading:d,disabled:!l.fileResourceId||l.loading||!!l.loadError},openWithSystemApp:l.canOpenWithSystemApp?{onClick:()=>void O()}:void 0,chooseApp:l.canChooseOpenWithApp?{onClick:()=>void k()}:void 0,recommendedApps:l.recommendedOpenWithApps,recentApps:l.recentOpenWithApps,onOpenWithApp:e=>void A(e),onRevealInFolder:l.canRevealInFolder?()=>void j():void 0,copyPath:{copied:v,onClick:()=>void E()}},chat:{createFile:l.createAttachmentFile,projectId:r,conversationId:i,agentId:a,disabled:l.saveStatus===`saving`},language:o,resolvedTheme:c,descriptor:l.descriptor,loading:l.loading,loadError:l.loadError,textContent:l.textContent,binaryBuffer:l.binaryBuffer,fileResourceId:l.fileResourceId,mtimeMs:l.mtimeMs,targetLine:n,extractedText:l.extractedText,extractedTextTruncated:l.extractedTextTruncated,workspaceEditing:{sourceEditMode:l.sourceEditMode,onSourceChange:l.onSourceChange,sourceWordWrap:b,isDark:c===`dark`},actions:P})});return(0,$.jsxs)($.Fragment,{children:[S?(0,Hn.createPortal)(F,document.body):F,(0,$.jsx)(BC,{open:u,onOpenChange:_,loading:d,error:p,result:f,pendingParams:m,onConfirm:e=>void g(e)})]})}var tJ=(0,Z.memo)(function(e){let t=(0,Q.c)(34),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{allowOutsideChat:r,conversationId:i}=n,a=r===void 0?!1:r,{pathname:o,search:s}=b(),{conversationId:c}=p(),l=Dw(nJ),u=Ow(rJ),d;t[2]!==i||t[3]!==c||t[4]!==o||t[5]!==u||t[6]!==l?(d=u??i??l??(o.startsWith(`/chat`)&&c&&c!==`new`?decodeURIComponent(c):void 0),t[2]=i,t[3]=c,t[4]=o,t[5]=u,t[6]=l,t[7]=d):d=t[7];let f=d,m=Ow(iJ),h=Ow(aJ),g=Ow(oJ),_;t[8]!==f||t[9]!==o||t[10]!==g||t[11]!==s?(_=g??(!f&&o.startsWith(`/chat`)?new URLSearchParams(s).get(`projectId`):null),t[8]=f,t[9]=o,t[10]=g,t[11]=s,t[12]=_):_=t[12];let v=_,y=Ow(sJ),x=yw(cJ),S,C;t[13]!==a||t[14]!==o||t[15]!==y||t[16]!==l?(S=()=>{!a&&!l&&!o.startsWith(`/chat`)&&y(null)},C=[a,o,y,l],t[13]=a,t[14]=o,t[15]=y,t[16]=l,t[17]=S,t[18]=C):(S=t[17],C=t[18]),(0,Z.useEffect)(S,C);let w,T;if(t[19]!==m||t[20]!==y?(w=()=>{if(!m)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||(y(null),e.stopPropagation())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},T=[m,y],t[19]=m,t[20]=y,t[21]=w,t[22]=T):(w=t[21],T=t[22]),(0,Z.useEffect)(w,T),!m)return null;let E=v??void 0,D;t[23]===x?D=t[24]:(D=x.trim()||void 0,t[23]=x,t[24]=D);let O;t[25]===y?O=t[26]:(O=()=>y(null),t[25]=y,t[26]=O);let k;return t[27]!==f||t[28]!==h||t[29]!==m||t[30]!==D||t[31]!==O||t[32]!==E?(k=(0,$.jsx)(`div`,{role:`region`,"aria-label":`File preview`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:(0,$.jsx)(eJ,{filePath:m,targetLine:h,projectId:E,conversationId:f,agentId:D,onClose:O})}),t[27]=f,t[28]=h,t[29]=m,t[30]=D,t[31]=O,t[32]=E,t[33]=k):k=t[33],k});function nJ(e){return e.conversationIdOverride}function rJ(e){return e.conversationId}function iJ(e){return e.path}function aJ(e){return e.line}function oJ(e){return e.projectId}function sJ(e){return e.setPath}function cJ(e){return e.agentId}var lJ=(0,Z.createContext)({target:null,register:()=>()=>{}});function uJ(e){let t=(0,Q.c)(9),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],t[0]=r):r=t[0];let[i,a]=(0,Z.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>(a(t=>[...t,e]),()=>a(t=>t.filter(t=>t!==e))),t[1]=o):o=t[1];let s=o,c;t[2]===i?c=t[3]:(c=i.at(-1)??null,t[2]=i,t[3]=c);let l;t[4]===c?l=t[5]:(l={target:c,register:s},t[4]=c,t[5]=l);let u=l,d;return t[6]!==n||t[7]!==u?(d=(0,$.jsx)(lJ,{value:u,children:n}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d}function dJ(){let e=(0,Q.c)(2),{register:t}=(0,Z.useContext)(lJ),n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(`div`,{ref:t,className:`min-w-0 shrink-0`}),e[0]=t,e[1]=n),n}function fJ(){return(0,Z.useContext)(lJ).target}function pJ(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var mJ=`inline-flex size-11 shrink-0 items-center justify-center rounded-full text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent motion-safe:transition-colors`;function hJ(){let e=(0,Q.c)(26),t=Ee(_J)===`zh`,n=RP(),r=fJ(),[i,a]=(0,Z.useState)(!1),o=(0,Z.useId)(),s=n.source&&n.status!==`idle`,c=n.status===`preparing`,l=n.status===`playing`,u=n.status===`error`,d=n.status===`ended`,f=c?t?`正在准备语音`:`Preparing audio`:u?t?`朗读失败,请重试`:`Unable to play. Try again`:d?t?`播放完毕`:`Finished`:l?t?`正在朗读`:`Reading aloud`:t?`已暂停`:`Paused`,p;e[0]!==o||e[1]!==r||e[2]!==d||e[3]!==i||e[4]!==u||e[5]!==l||e[6]!==c||e[7]!==n||e[8]!==f||e[9]!==s||e[10]!==t?(p=s?(0,$.jsx)(`section`,{"aria-label":t?`语音播报`:`Read aloud`,className:K(`shrink-0`,r?`pb-2`:`px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-2`),children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl overflow-hidden rounded-xl border border-edge bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-16 items-center gap-1 p-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),"aria-expanded":i,"aria-controls":o,className:`flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-lg px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.source?.title}),(0,$.jsxs)(`span`,{className:`block text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{role:`status`,children:f}),!u&&!c?(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,pJ(n.currentTime)]}):null]})]}),(0,$.jsx)(cr,{"aria-hidden":!0,className:K(`size-4 shrink-0 text-fg-muted`,i&&`rotate-180`)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:l?n.pause:n.resume,disabled:c,className:K(mJ,`disabled:opacity-50`),"aria-label":d?t?`重新播放`:`Replay`:u?t?`重试朗读`:`Retry reading`:l?t?`暂停朗读`:`Pause reading`:t?`继续朗读`:`Resume reading`,children:c?(0,$.jsx)(xn,{className:`size-5 rounded-full`}):u?(0,$.jsx)(Hi,{className:`size-5`,"aria-hidden":!0}):l?(0,$.jsx)(Ai,{className:`size-5`,"aria-hidden":!0}):(0,$.jsx)(Li,{className:`size-5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:n.stop,className:mJ,"aria-label":t?`停止朗读`:`Stop reading`,children:(0,$.jsx)(ye,{className:`size-5`,"aria-hidden":!0})})]}),n.durationComplete?(0,$.jsx)(`div`,{className:`h-0.5 bg-surface-active`,"aria-hidden":!0,children:(0,$.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${Math.min(100,n.currentTime/n.duration*100)}%`}})}):null,i?(0,$.jsxs)(`div`,{id:o,className:`space-y-3 border-t border-edge-subtle p-4`,children:[n.durationComplete?(0,$.jsx)(vJ,{duration:n.duration,currentTime:n.currentTime,disabled:c,onSeek:n.seek,label:t?`播放进度`:`Playback position`},`${n.source?.type}:${n.source?.id}`):null,n.currentText?(0,$.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words text-sm text-fg-muted`,children:n.currentText}):null,n.source?.href?(0,$.jsx)(`a`,{href:n.source.href,className:`inline-flex min-h-11 items-center rounded-lg text-sm text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t?`返回来源`:`Return to source`}):null,u?(0,$.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-fg-muted`,children:n.error}):null,(0,$.jsx)(A,{contentClassName:`[&_button]:min-h-11`,value:String(n.rate),allowEmpty:!1,placeholder:`1×`,ariaLabel:t?`播放速度`:`Playback speed`,options:[.75,1,1.25,1.5,2].map(gJ),triggerClassName:`min-h-11 w-28`,onChange:e=>n.setRate(Number(e))})]}):null]})}):null,e[0]=o,e[1]=r,e[2]=d,e[3]=i,e[4]=u,e[5]=l,e[6]=c,e[7]=n,e[8]=f,e[9]=s,e[10]=t,e[11]=p):p=e[11];let m=p,h;e[12]!==r||e[13]!==m?(h=r?(0,Hn.createPortal)(m,r):m,e[12]=r,e[13]=m,e[14]=h):h=e[14];let g=t?`使用在线朗读`:`Use online read aloud`,_=t?`朗读默认使用 Microsoft Edge 在线语音服务,待朗读文本会发送至 Microsoft 进行语音合成。`:`Read aloud uses Microsoft Edge online speech by default. The text will be sent to Microsoft for speech synthesis.`,v=t?`同意并朗读`:`Agree and read`,y=t?`取消`:`Cancel`,b;e[15]!==n.acceptConsent||e[16]!==n.consentRequired||e[17]!==n.declineConsent||e[18]!==g||e[19]!==_||e[20]!==v||e[21]!==y?(b=(0,$.jsx)(uS,{open:n.consentRequired,title:g,description:_,confirmLabel:v,cancelLabel:y,onConfirm:n.acceptConsent,onCancel:n.declineConsent}),e[15]=n.acceptConsent,e[16]=n.consentRequired,e[17]=n.declineConsent,e[18]=g,e[19]=_,e[20]=v,e[21]=y,e[22]=b):b=e[22];let x;return e[23]!==h||e[24]!==b?(x=(0,$.jsxs)($.Fragment,{children:[h,b]}),e[23]=h,e[24]=b,e[25]=x):x=e[25],x}function gJ(e){return{value:String(e),label:`${e}×`}}function _J(e){return e.language}function vJ(e){let t=(0,Q.c)(25),{duration:n,currentTime:r,disabled:i,onSeek:a,label:o}=e,[s,c]=(0,Z.useState)(null),l;t[0]!==a||t[1]!==s?(l=()=>{s!==null&&(a(s),c(null))},t[0]=a,t[1]=s,t[2]=l):l=t[2];let u=l,d;t[3]===o?d=t[4]:(d=(0,$.jsx)(`span`,{children:o}),t[3]=o,t[4]=d);let f=s??r,p;t[5]===f?p=t[6]:(p=pJ(f),t[5]=f,t[6]=p);let m;t[7]===n?m=t[8]:(m=pJ(n),t[7]=n,t[8]=m);let h;t[9]!==p||t[10]!==m?(h=(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[p,` / `,m]}),t[9]=p,t[10]=m,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==h?(g=(0,$.jsxs)(`span`,{className:`flex justify-between gap-3`,children:[d,h]}),t[12]=d,t[13]=h,t[14]=g):g=t[14];let _=s??Math.min(r,n),v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>c(Number(e.target.value)),t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>c(null),t[16]=y):y=t[16];let b;t[17]!==u||t[18]!==i||t[19]!==n||t[20]!==_?(b=(0,$.jsx)(`input`,{type:`range`,min:0,max:n,step:.1,value:_,disabled:i,onChange:v,onPointerUp:u,onKeyUp:u,onBlur:u,onPointerCancel:y,className:`block h-11 w-full accent-accent`}),t[17]=u,t[18]=i,t[19]=n,t[20]=_,t[21]=b):b=t[21];let x;return t[22]!==b||t[23]!==g?(x=(0,$.jsxs)(`label`,{className:`block text-xs text-fg-muted`,children:[g,b]}),t[22]=b,t[23]=g,t[24]=x):x=t[24],x}function yJ(){let e=(0,Q.c)(11),t=l(),n=Se(xJ),r=DD(bJ),i=(0,Z.useRef)(!1),a=(0,Z.useRef)(!1),o,s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=e=>{i.current=!!e.detail?.active};return window.addEventListener(MG,e),()=>window.removeEventListener(MG,e)},s=[],e[0]=o,e[1]=s):(o=e[0],s=e[1]),(0,Z.useEffect)(o,s);let c,u;e[2]!==t||e[3]!==n?(c=()=>{let e=window.electronAPI?.voiceInputHotkey;if(typeof e?.onEvent!=`function`)return;let r=e.onEvent(e=>{if(e===`press`){if(i.current||!n)return;a.current=!0}else{if(!a.current)return;a.current=!1}PG(`xopc-voice-input-toggle`,document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`)||(e===`press`?(FG(),t(`/chat`)):IG())});return()=>{a.current=!1,r()}},u=[t,n],e[2]=t,e[3]=n,e[4]=c,e[5]=u):(c=e[4],u=e[5]),(0,Z.useEffect)(c,u);let d,f;return e[6]!==t||e[7]!==r||e[8]!==n?(d=()=>{let e=e=>{if(i.current||e.repeat||e.isComposing)return;let a=document.querySelector(`[data-voice-input-scope="note"]`)?`note`:`chat`;if(e.key===`Escape`){PG(`xopc-voice-input-cancel`,a)&&(e.preventDefault(),e.stopPropagation());return}TD(e,r)&&(e.preventDefault(),e.stopPropagation(),n&&(PG(`xopc-voice-input-toggle`,a)||(FG(),t(`/chat`))))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},f=[t,r,n],e[6]=t,e[7]=r,e[8]=n,e[9]=d,e[10]=f):(d=e[9],f=e[10]),(0,Z.useEffect)(d,f),null}function bJ(e){return e.shortcut}function xJ(e){return e.conversationId}var SJ=`inline-flex items-center gap-px rounded-pill border border-edge bg-surface-hover p-1 dark:border-edge`,CJ=`touch-target inline-flex shrink-0 items-center justify-center rounded-pill text-xs font-medium leading-none transition-[color,background-color,box-shadow] duration-150 ease-out text-fg-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel active:scale-100`,wJ=`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,TJ=[{value:`en`,label:`EN`},{value:`zh`,label:`中文`}];function EJ(e){let t=(0,Q.c)(5),{value:n,onChange:r}=e,i;t[0]!==r||t[1]!==n?(i=TJ.map(e=>{let t=e.value===n;return(0,$.jsx)(`button`,{type:`button`,"aria-pressed":t,className:K(CJ,`h-9 min-w-11 px-2`,t?K(wJ,`text-fg`):`text-fg-subtle hover:text-fg`),onClick:()=>r(e.value),children:e.label},e.value)}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`div`,{className:SJ,role:`group`,"aria-label":`Language / 语言`,children:i}),t[3]=i,t[4]=a),a}var DJ=new Set([`anthropic`,`deepseek`,`google`,`kimi-coding`,`minimax`,`openai`,`xopc-cloud`]);function OJ(e){return DJ.has(e)}function kJ(e){let t=(0,Q.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=K(`shrink-0`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,className:a,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function AJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#5786FE`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(kJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function jJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#E73562`,d:`M11.43 3.92a.86.86 0 1 0-1.718 0v14.236a1.999 1.999 0 0 1-3.997 0V9.022a.86.86 0 1 0-1.718 0v3.87a1.999 1.999 0 0 1-3.997 0V11.49a.57.57 0 0 1 1.139 0v1.404a.86.86 0 0 0 1.719 0V9.022a1.999 1.999 0 0 1 3.997 0v9.134a.86.86 0 0 0 1.719 0V3.92a1.998 1.998 0 1 1 3.996 0v11.788a.57.57 0 1 1-1.139 0zm10.572 3.105a2 2 0 0 0-1.999 1.997v7.63a.86.86 0 0 1-1.718 0V3.923a1.999 1.999 0 0 0-3.997 0v16.16a.86.86 0 0 1-1.719 0V18.08a.57.57 0 1 0-1.138 0v2a1.998 1.998 0 0 0 3.996 0V3.92a.86.86 0 0 1 1.719 0v12.73a1.999 1.999 0 0 0 3.996 0V9.023a.86.86 0 1 1 1.72 0v6.686a.57.57 0 0 0 1.138 0V9.022a2 2 0 0 0-1.998-1.997`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(kJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function MJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`m1.053 16.91 9.538 2.55a21 20.981 0 0 0 .06 2.031l5.956 1.592a12 11.99 0 0 1-15.554-6.172m-1.02-5.79 11.352 3.035a21 20.981 0 0 0-.469 2.01l10.817 2.89a12 11.99 0 0 1-1.845 2.004L.658 15.918a12 11.99 0 0 1-.625-4.796m1.593-5.146L13.573 9.17a21 20.981 0 0 0-1.01 1.874l11.297 3.02a21 20.981 0 0 1-.67 2.362l-11.55-3.087L.125 10.26a12 11.99 0 0 1 1.499-4.285ZM6.067 1.58l11.285 3.016a21 20.981 0 0 0-1.688 1.719l7.824 2.091a21 20.981 0 0 1 .513 2.664L2.107 5.218a12 11.99 0 0 1 3.96-3.638M21.68 4.866 7.222 1.003A12 11.99 0 0 1 21.68 4.866`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(kJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function NJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`currentColor`,d:`M22.28 9.82a5.98 5.98 0 0 0-.516-4.91 6.04 6.04 0 0 0-6.51-2.9A6.06 6.06 0 0 0 4.98 4.18a5.98 5.98 0 0 0-3.99 2.9 6.04 6.04 0 0 0 .743 7.09 5.98 5.98 0 0 0 .511 4.91 6.05 6.05 0 0 0 6.51 2.9A5.98 5.98 0 0 0 13.26 24a6.05 6.05 0 0 0 5.77-4.20 5.98 5.98 0 0 0 3.99-2.9 6.05 6.05 0 0 0-.748-7.07zm-9.02 12.60a4.47 4.47 0 0 1-2.87-1.04l.142-.08 4.77-2.75a.795.79 0 0 0 .393-.681v-6.73l2.02 1.16a.071.07 0 0 1 .038.05v5.58a4.50 4.50 0 0 1-4.49 4.49zm-9.66-4.12a4.47 4.47 0 0 1-.535-3.01l.142.08 4.78 2.75a.771.77 0 0 0 .781 0l5.84-3.36v2.33a.08.08 0 0 1-.033.06L9.74 19.95a4.49 4.49 0 0 1-6.14-1.64zM2.34 7.89a4.48 4.48 0 0 1 2.36-1.97V11.6a.766.76 0 0 0 .388.67l5.81 3.35-2.02 1.16a.076.07 0 0 1-.071 0l-4.83-2.78A4.50 4.50 0 0 1 2.34 7.87zm16.59 3.85L13.10 8.36 15.11 7.2a.076.07 0 0 1 .071 0l4.83 2.79a4.49 4.49 0 0 1-.677 8.10v-5.67a.79.79 0 0 0-.407-.667zm2.01-3.02-.142-.085-4.77-2.78a.776.77 0 0 0-.785 0L9.40 9.23V6.89a.066.06 0 0 1 .028-.062l4.83-2.78a4.49 4.49 0 0 1 6.68 4.66zM8.30 12.86l-2.02-1.16a.08.08 0 0 1-.038-.057V6.07a4.49 4.49 0 0 1 7.37-3.45l-.142.08L8.70 5.45a.795.79 0 0 0-.393.68zm1.09-2.36 2.60-1.5 2.60 1.5v2.99l-2.59 1.5-2.60-1.5Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(kJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function PJ(e){let t=(0,Q.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`path`,{fill:`#D4A27F`,d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,$.jsx)(kJ,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function FJ(e){let t=(0,Q.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i,a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`gemini-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#4285F4`}),(0,$.jsx)(`stop`,{offset:`50%`,stopColor:`#9B72CB`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#D96570`})]})}),a=(0,$.jsx)(`path`,{fill:`url(#gemini-grad)`,d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`}),t[3]=i,t[4]=a):(i=t[3],a=t[4]);let o;return t[5]!==n||t[6]!==r?(o=(0,$.jsxs)(kJ,{className:n,...r,children:[i,a]}),t[5]=n,t[6]=r,t[7]=o):o=t[7],o}function IJ(e){let t=(0,Q.c)(22),{providerId:n,className:r}=e,i;t[0]===r?i=t[1]:(i={className:r,"aria-hidden":!0},t[0]=r,t[1]=i);let a=i;switch(n){case`xopc-cloud`:{let e;return t[2]===r?e=t[3]:(e=(0,$.jsx)(gd,{className:r,"aria-hidden":!0}),t[2]=r,t[3]=e),e}case`deepseek`:{let e;return t[4]===a?e=t[5]:(e=(0,$.jsx)(AJ,{...a}),t[4]=a,t[5]=e),e}case`minimax`:{let e;return t[6]===a?e=t[7]:(e=(0,$.jsx)(jJ,{...a}),t[6]=a,t[7]=e),e}case`kimi-coding`:{let e;return t[8]===a?e=t[9]:(e=(0,$.jsx)(MJ,{...a}),t[8]=a,t[9]=e),e}case`moonshotai`:case`moonshotai-cn`:{let e;return t[10]===a?e=t[11]:(e=(0,$.jsx)(MJ,{...a}),t[10]=a,t[11]=e),e}case`openai`:{let e;return t[12]===a?e=t[13]:(e=(0,$.jsx)(NJ,{...a}),t[12]=a,t[13]=e),e}case`anthropic`:{let e;return t[14]===a?e=t[15]:(e=(0,$.jsx)(PJ,{...a}),t[14]=a,t[15]=e),e}case`google`:{let e;return t[16]===a?e=t[17]:(e=(0,$.jsx)(FJ,{...a}),t[16]=a,t[17]=e),e}default:{let e;t[18]===r?e=t[19]:(e=K(`flex items-center justify-center text-2xl`,r),t[18]=r,t[19]=e);let n;return t[20]===e?n=t[21]:(n=(0,$.jsx)(`span`,{className:e,children:`🤖`}),t[20]=e,t[21]=n),n}}}function LJ(e){return cn(e)}async function RJ(){return(await q(J(`/api/providers/meta`))).payload?.providers??[]}function zJ(e){if(!e||typeof e!=`object`||!(`providers`in e))return{};let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&(n[e]=r);return n}function BJ(e,t,n){let r=new Set(n.map(e=>e.provider));return e.map(e=>({...e,configured:e.configured||r.has(e.id),apiKey:t[e.id]??(e.activeKeySource===`extension`?``:e.configured||r.has(e.id)?`••••••••••••`:``)}))}async function VJ(e){await q(J(`/api/config`),{method:`PATCH`,body:JSON.stringify({providers:e})}),await Bn()}async function HJ(e){await q(J(`/api/providers/${encodeURIComponent(e)}/key`),{method:`DELETE`}),await Bn()}async function UJ(e){let t=await q(J(`/api/providers/${encodeURIComponent(e)}/reveal-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}var WJ={id:`xopc-cloud`,name:`XOPC Cloud`,category:`common`,supportsOAuth:!0,supportsApiKey:!1,configured:!1,onboardingFeatured:!0,hint:`Connect your XOPC account. No API key required.`},GJ=[{id:`deepseek`,name:`DeepSeek`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`openai`,name:`OpenAI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`anthropic`,name:`Anthropic`,category:`common`,supportsOAuth:!0,supportsApiKey:!0,configured:!1,onboardingFeatured:!0},{id:`google`,name:`Google AI`,category:`common`,supportsOAuth:!1,supportsApiKey:!0,configured:!1,onboardingFeatured:!0}],KJ=new Map([WJ,...GJ].map((e,t)=>[e.id,t]));function qJ(e,t){let n=e?.filter(e=>e.onboardingFeatured&&OJ(e.id)),r=n?.length?n:GJ;return(t?[e?.find(e=>e.id===`xopc-cloud`)??WJ,...r.filter(e=>e.id!==`google`&&e.id!==`xopc-cloud`)]:r).slice().sort((e,t)=>(KJ.get(e.id)??999)-(KJ.get(t.id)??999))[0]}function JJ(e){let t=e.recommendedModels?.map(e=>e.name||e.id).filter(Boolean).slice(0,2);return t?.length?t.join(`, `):e.hint}function YJ(e){let t=(0,Q.c)(24),{onSelect:n,onBrowseProviders:r,disabled:i,browseDisabled:a}=e,o=i===void 0?!1:i,s=a===void 0?!1:a,c=Ee(XJ),l;t[0]===c?l=t[1]:(l=xe(c),t[0]=c,t[1]=l);let u=l.onboarding.providerRecommended,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1},t[2]=d):d=t[2];let{data:f}=Zt(`onboarding-provider-meta`,RJ,d),p;if(t[3]!==f||t[4]!==o||t[5]!==n||t[6]!==u){let e=qJ(f,An());p=e?(0,$.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>n(e.id),className:`group flex w-full items-center gap-3.5 rounded-xl border border-accent/30 bg-accent-soft/45 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-accent/55 hover:bg-accent-soft/65 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-base/70`,children:(0,$.jsx)(IJ,{providerId:e.id,className:`size-7`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-base font-semibold text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`rounded-full bg-accent px-2 py-0.5 text-[10px] font-semibold text-on-accent`,children:u})]}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:JJ(e)})]}),(0,$.jsx)(lr,{className:`size-4.5 shrink-0 text-accent-fg/80`,"aria-hidden":!0})]}):null,t[3]=f,t[4]=o,t[5]=n,t[6]=u,t[7]=p}else p=t[7];let m=o||s,h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[10px] border border-edge-subtle bg-surface-panel text-fg-muted`,children:(0,$.jsx)(ei,{className:`size-5`,"aria-hidden":!0})}),t[8]=h):h=t[8];let g=c===`zh`?`连接我自己的模型服务`:`Connect my own model service`,_;t[9]===g?_=t[10]:(_=(0,$.jsx)(`span`,{className:`block text-base font-semibold text-fg`,children:g}),t[9]=g,t[10]=_);let v=s&&!o?c===`zh`?`正在加载可用的模型服务…`:`Loading available model services…`:c===`zh`?`使用自己的账号、API Key、本地模型或私有接口。`:`Use your own account, API key, local model, or private endpoint.`,y;t[11]===v?y=t[12]:(y=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:v}),t[11]=v,t[12]=y);let b;t[13]!==y||t[14]!==_?(b=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[_,y]}),t[13]=y,t[14]=_,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(lr,{className:`size-4.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[16]=x):x=t[16];let S;t[17]!==r||t[18]!==b||t[19]!==m?(S=(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:r,className:`mt-3 flex min-h-16 w-full items-center gap-3.5 rounded-xl border border-edge bg-surface-base/65 p-3.5 text-left transition-[border-color,background-color] duration-200 hover:border-edge-strong hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,children:[h,b,x]}),t[17]=r,t[18]=b,t[19]=m,t[20]=S):S=t[20];let C;return t[21]!==S||t[22]!==p?(C=(0,$.jsxs)(`div`,{children:[p,S]}),t[21]=S,t[22]=p,t[23]=C):C=t[23],C}function XJ(e){return e.language}function ZJ(){if(!An())return;let e=window.location.hash.startsWith(`#/`)?window.location.hash.slice(1):`/`;return e.length<=2048?e:`/`}async function QJ(e){let t=await we(J(`/api/auth/oauth-async/start`),{method:`POST`,body:JSON.stringify({provider:e,client:An()?`desktop`:`web`,returnPath:ZJ()})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`OAuth start failed: ${t.status}`)}return(await t.json()).payload}async function $J(e){let t=await we(J(`/api/auth/oauth-async/${encodeURIComponent(e)}/status`));if(!t.ok)throw Error(`OAuth status: ${t.status}`);return(await t.json()).payload}async function eY(e,t){let n=await we(J(`/api/auth/oauth-async/${encodeURIComponent(e)}/code`),{method:`POST`,body:JSON.stringify({code:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Submit code failed: ${n.status}`)}}async function tY(e){let t=await we(J(`/api/auth/oauth-async/${encodeURIComponent(e)}/cancel`),{method:`POST`});if(!t.ok)throw Error(`Cancel OAuth failed: ${t.status}`)}async function nY(e){let t=await we(J(`/api/auth/oauth-async/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Cleanup session failed: ${t.status}`)}async function rY(e){let t=await we(J(`/api/auth/oauth/${encodeURIComponent(e)}`),{method:`DELETE`});if(!t.ok)throw Error(`Revoke OAuth failed: ${t.status}`)}function iY({providerId:e,displayName:t,connected:n,onConnected:r}){let i=Ee(e=>e.language)===`zh`,[a,o]=(0,Z.useState)(`idle`),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{d.current=!0,f.current?.close(),f.current=null},[]);let p=async()=>{d.current=!1,c(null),u(null),o(`waiting`);let t=An();t||(f.current?.close(),f.current=window.open(`about:blank`,`xopc-oauth`),f.current&&(f.current.opener=null));let n=null,a=null;try{for(n=(await QJ(e)).sessionId;!d.current;){if(await new Promise(e=>window.setTimeout(e,1e3)),d.current)return;let e=await $J(n);if(e.authUrl&&e.authUrl!==a)if(a=e.authUrl,u(e.authUrl),t){let t=await window.electronAPI?.shell?.openExternalUrl(e.authUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else f.current&&!f.current.closed&&f.current.location.replace(e.authUrl);if(e.status===`failed`||e.status===`cancelled`)throw Error(e.error??e.message??`OAuth authorization failed`);if(e.status===`completed`){await Bn(),f.current?.close(),f.current=null,o(`connected`),r?.();return}}}catch(e){f.current?.close(),f.current=null,d.current||(o(`idle`),c(e instanceof Error?e.message:i?`连接失败`:`Connection failed`))}finally{n&&nY(n).catch(()=>{})}},m=n||a===`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)(Er,{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}),m?(0,$.jsx)(j,{className:`size-4 text-emerald-500`,"aria-label":i?`已连接`:`Connected`}):null]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a===`waiting`?i?`请在浏览器中完成 OAuth 授权。`:`Complete OAuth authorization in your browser.`:m?i?`已通过 OAuth 连接。`:`Connected with OAuth.`:i?`使用 OAuth 连接,无需 API Key。`:`Connect with OAuth. No API key is required.`}),a===`waiting`&&l?(0,$.jsx)(`a`,{className:`mt-1 inline-flex text-sm text-accent hover:underline`,href:l,target:`_blank`,rel:`noreferrer`,children:i?`打开授权页面`:`Open authorization page`}):null,s?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-danger`,children:s}):null]})]}),(0,$.jsxs)(X,{type:`button`,variant:m?`secondary`:`primary`,disabled:a===`waiting`,onClick:()=>void p(),children:[a===`waiting`?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,a===`waiting`?i?`等待授权…`:`Waiting…`:m?i?`重新授权`:`Reauthorize`:i?`授权`:`Authorize`]})]})}function aY(){if(An())return null;let e=window.open(`about:blank`,`xopc-oauth`);return e&&(e.opener=null),e}async function oY(e,t){return An()?(await window.electronAPI?.shell?.openExternalUrl(e))?.ok===!0:!t||t.closed?!1:(t.location.replace(e),!0)}function sY(e){e&&!e.closed&&e.close()}function cY(e,t){return e===`single`?t.getApiKey:e===`intl`?t.getApiKeyIntl:t.getApiKeyCn}var lY={openai:{apiKeyUrl:`https://platform.openai.com/api-keys`,pricingUrl:`https://openai.com/pricing`,docsUrl:`https://platform.openai.com/docs`,description:`The most widely used LLM provider. Powers ChatGPT.`,descriptionZh:`最广泛使用的 LLM 服务商,ChatGPT 背后的技术。`,bestFor:[`general`,`coding`,`vision`],freeTier:!1,freeTierNote:`Pay-as-you-go; new accounts may receive trial credits.`,aliases:[`chatgpt`,`gpt`,`gpt-4`,`gpt4`,`gpt-4o`,`gpt4o`],envVars:[`OPENAI_API_KEY`]},anthropic:{apiKeyUrl:`https://console.anthropic.com/settings/keys`,pricingUrl:`https://www.anthropic.com/pricing`,docsUrl:`https://docs.anthropic.com`,description:`Anthropic model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Anthropic 模型服务。可用模型由网关目录动态加载。`,bestFor:[`long context`,`coding`,`reasoning`],freeTier:!1,aliases:[`claude`,`claude 3`,`claude sonnet`,`claude opus`,`claude haiku`],envVars:[`ANTHROPIC_OAUTH_TOKEN`,`ANTHROPIC_API_KEY`]},google:{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Google AI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`Google AI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`multimodal`,`long context`,`general`],freeTier:!0,freeTierNote:`Free tier available via Google AI Studio.`,aliases:[`gemini`,`google gemini`,`bard`,`google ai`],envVars:[`GEMINI_API_KEY`,`GOOGLE_API_KEY`]},"google-vertex":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/vertex-ai/pricing`,docsUrl:`https://cloud.google.com/vertex-ai/docs`,description:`Google Vertex AI — enterprise-grade model hosting on GCP.`,descriptionZh:`Google Vertex AI,企业级 GCP 托管模型服务。`,bestFor:[`enterprise`,`multimodal`,`compliance`],freeTier:!1,aliases:[`vertex`,`vertex ai`,`gcp`,`google cloud`],envVars:[`GOOGLE_CLOUD_API_KEY`,`GOOGLE_CLOUD_PROJECT`,`GOOGLE_CLOUD_LOCATION`]},"google-gemini-cli":{apiKeyUrl:`https://aistudio.google.com/app/apikey`,pricingUrl:`https://ai.google.dev/pricing`,docsUrl:`https://ai.google.dev/docs`,description:`Gemini via CLI token — for users authenticated with the Gemini CLI tool.`,descriptionZh:`通过 Gemini CLI 令牌访问 Gemini,适合已安装 CLI 工具的用户。`,bestFor:[`general`,`multimodal`],freeTier:!0,freeTierNote:`Uses your existing Gemini CLI authentication.`,aliases:[`gemini cli`,`gemini-cli`],envVars:[`GEMINI_CLI_TOKEN`,`GOOGLE_TOKEN`]},"google-antigravity":{apiKeyUrl:`https://console.cloud.google.com/apis/credentials`,pricingUrl:`https://cloud.google.com/pricing`,docsUrl:`https://cloud.google.com/docs`,description:`Google Antigravity — internal/experimental Google AI endpoint.`,descriptionZh:`Google Antigravity,Google 内部/实验性 AI 端点。`,bestFor:[`experimental`],freeTier:!1,aliases:[`antigravity`,`google antigravity`],envVars:[`ANTIGRAVITY_API_KEY`]},groq:{apiKeyUrl:`https://console.groq.com/keys`,pricingUrl:`https://groq.com/pricing/`,docsUrl:`https://console.groq.com/docs`,description:`Extremely fast inference — ideal for latency-sensitive applications.`,descriptionZh:`推理速度极快,适合对延迟敏感的场景。`,bestFor:[`speed`,`cheap`],freeTier:!0,freeTierNote:`Generous free tier with rate limits.`,aliases:[`groq`,`llama on groq`,`mixtral on groq`],envVars:[`GROQ_API_KEY`]},deepseek:{apiKeyUrl:`https://platform.deepseek.com/api_keys`,pricingUrl:`https://api-docs.deepseek.com/quick_start/pricing/`,docsUrl:`https://platform.deepseek.com/api-docs/`,description:`DeepSeek model access through an OpenAI-compatible API.`,descriptionZh:`通过 OpenAI 兼容 API 访问 DeepSeek 模型。`,bestFor:[`reasoning`,`cheap`,`coding`],freeTier:!0,freeTierNote:`Free credits may be available for new accounts.`,aliases:[`deepseek`,`deep seek`,`deepseek v4`,`deepseek-v4`,`r1`],envVars:[`DEEPSEEK_API_KEY`]},"volcengine-ark":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Ark — OpenAI-compatible access to Doubao and custom Ark endpoints.`,descriptionZh:`火山方舟,通过 OpenAI 兼容接口访问豆包与自定义方舟 endpoint。`,bestFor:[`chinese`,`general`,`enterprise`],aliases:[`volcengine`,`ark`,`doubao`,`volces`,`火山方舟`,`豆包`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"volcengine-plan":{apiKeyUrl:`https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey`,pricingUrl:`https://www.volcengine.com/docs/82379/1099320`,docsUrl:`https://www.volcengine.com/docs/82379/1302008`,description:`Volcengine Doubao Coding Plan — Ark coding endpoint.`,descriptionZh:`火山方舟豆包 Coding Plan,使用 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`volcengine plan`,`ark coding`,`doubao coding`,`火山方舟 coding`],envVars:[`ARK_API_KEY`,`VOLCENGINE_API_KEY`]},"byteplus-plan":{apiKeyUrl:`https://console.byteplus.com/ark/region:ark+ap-southeast-1/apiKey`,pricingUrl:`https://docs.byteplus.com/en/docs/ModelArk`,docsUrl:`https://docs.byteplus.com/en/docs/ModelArk/OpenAI`,description:`BytePlus Doubao Coding Plan — international Ark coding endpoint.`,descriptionZh:`BytePlus 豆包 Coding Plan,国际区 Ark coding endpoint。`,bestFor:[`coding`,`chinese`],aliases:[`byteplus`,`byteplus plan`,`doubao coding international`],envVars:[`BYTEPLUS_API_KEY`,`ARK_API_KEY`]},xai:{apiKeyUrl:`https://console.x.ai/`,pricingUrl:`https://x.ai/api`,docsUrl:`https://docs.x.ai/`,description:`xAI model access. Available models are loaded from the gateway catalog.`,descriptionZh:`xAI 模型服务。可用模型由网关目录动态加载。`,bestFor:[`reasoning`,`real-time`],freeTier:!1,aliases:[`grok`,`xai`,`x.ai`],envVars:[`XAI_API_KEY`]},cerebras:{apiKeyUrl:`https://cloud.cerebras.ai/platform/`,pricingUrl:`https://cloud.cerebras.ai/platform/`,docsUrl:`https://inference-docs.cerebras.ai/`,description:`Ultra-fast inference on custom AI chips. Fastest Llama inference available.`,descriptionZh:`基于专用 AI 芯片的超快推理,Llama 推理速度业界最快。`,bestFor:[`speed`],freeTier:!0,freeTierNote:`Free tier available.`,aliases:[`cerebras`],envVars:[`CEREBRAS_API_KEY`]},mistral:{apiKeyUrl:`https://console.mistral.ai/api-keys/`,pricingUrl:`https://mistral.ai/technology/#pricing`,docsUrl:`https://docs.mistral.ai/`,description:`European open-weight models. Good balance of quality and cost.`,descriptionZh:`欧洲开源模型,质量与成本平衡好。`,bestFor:[`general`,`cheap`,`coding`],freeTier:!1,aliases:[`mistral`,`mixtral`,`codestral`],envVars:[`MISTRAL_API_KEY`]},openrouter:{apiKeyUrl:`https://openrouter.ai/keys`,pricingUrl:`https://openrouter.ai/models`,docsUrl:`https://openrouter.ai/docs`,description:`API gateway to 100+ models from many providers with a single key.`,descriptionZh:`统一 API 网关,一个 Key 访问 100+ 模型。`,bestFor:[`general`,`flexibility`],freeTier:!0,freeTierNote:`Some models are free; pay-per-use for others.`,aliases:[`openrouter`,`open router`],envVars:[`OPENROUTER_API_KEY`]},"azure-openai-responses":{apiKeyUrl:`https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI`,pricingUrl:`https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/`,docsUrl:`https://learn.microsoft.com/en-us/azure/ai-services/openai/`,description:`OpenAI models hosted on Azure. Enterprise SLA and data residency.`,descriptionZh:`Azure 托管的 OpenAI 模型,企业级 SLA 和数据合规。`,bestFor:[`enterprise`,`compliance`,`coding`],freeTier:!1,aliases:[`azure`,`azure openai`,`aoai`],envVars:[`AZURE_OPENAI_API_KEY`,`AZURE_OPENAI_BASE_URL`]},"amazon-bedrock":{apiKeyUrl:`https://console.aws.amazon.com/iam/home#/security_credentials`,pricingUrl:`https://aws.amazon.com/bedrock/pricing/`,docsUrl:`https://docs.aws.amazon.com/bedrock/`,description:`AWS Bedrock hosted model access with enterprise controls.`,descriptionZh:`AWS Bedrock 托管模型服务,提供企业级控制能力。`,bestFor:[`enterprise`,`compliance`],freeTier:!1,aliases:[`bedrock`,`aws`,`amazon`],envVars:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`]},minimax:{apiKeyUrl:`https://platform.minimax.io/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimax.io/docs/guides/models-intro`,docsUrl:`https://platform.minimax.io/docs/guides/quickstart-preparation`,description:`MiniMax — Chinese multimodal model with strong text and audio capabilities.`,descriptionZh:`MiniMax,国产多模态模型,文本和音频能力强。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax`,`mini max`,`abab`],envVars:[`MINIMAX_API_KEY`]},"minimax-cn":{apiKeyUrl:`https://platform.minimaxi.com/user-center/basic-information/interface-key`,pricingUrl:`https://platform.minimaxi.com/document/Price`,docsUrl:`https://platform.minimaxi.com/document/Announcement`,description:`MiniMax (China endpoint) — domestic access for Chinese users.`,descriptionZh:`MiniMax 国内端点,国内用户直连访问。`,bestFor:[`multimodal`,`chinese`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`minimax cn`,`minimax china`,`abab`],envVars:[`MINIMAX_CN_API_KEY`,`MINIMAX_API_KEY`]},stepfun:{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun OpenAI-compatible endpoint.`,descriptionZh:`阶跃星辰 StepFun OpenAI 兼容端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun`,`step`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun China — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 中国区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun cn`,`step cn`,`阶跃星辰`],envVars:[`STEPFUN_API_KEY`]},"stepfun-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun International — OpenAI-compatible chat endpoint.`,descriptionZh:`阶跃星辰 StepFun 国际区 OpenAI 兼容对话端点。`,bestFor:[`chinese`,`reasoning`,`general`],aliases:[`stepfun intl`,`step international`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan`,`step plan`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-cn":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan China — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 中国区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan cn`,`step plan cn`,`阶跃 plan`],envVars:[`STEPFUN_API_KEY`]},"stepfun-plan-intl":{apiKeyUrl:`https://platform.stepfun.com/interface-key`,pricingUrl:`https://platform.stepfun.com/docs/pricing`,docsUrl:`https://platform.stepfun.com/docs`,description:`StepFun Step Plan International — coding/planning endpoint.`,descriptionZh:`阶跃星辰 Step Plan 国际区 coding/planning 专用端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`stepfun plan intl`,`step plan international`],envVars:[`STEPFUN_API_KEY`]},"kimi-coding":{apiKeyUrl:`https://platform.kimi.com/console/api-keys`,pricingUrl:`https://platform.kimi.com/docs/pricing/chat`,docsUrl:`https://platform.kimi.com/docs`,description:`Kimi Coding — dedicated Anthropic-compatible coding endpoint.`,descriptionZh:`Kimi Coding,Anthropic 兼容的专用 coding 端点。`,bestFor:[`coding`,`chinese`,`vision`],freeTier:!0,freeTierNote:`注册赠送免费额度。`,aliases:[`kimi coding`,`moonshot coding`,`kimi code`],envVars:[`KIMI_API_KEY`,`MOONSHOT_API_KEY`]},moonshotai:{apiKeyUrl:`https://platform.moonshot.ai/console/api-keys`,pricingUrl:`https://platform.moonshot.ai/docs/pricing`,docsUrl:`https://platform.moonshot.ai/docs`,description:`Moonshot Kimi — international API (api.moonshot.ai).`,descriptionZh:`月之暗面 Kimi 国际版 API(api.moonshot.ai)。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot`,`kimi`,`moonshot ai`],envVars:[`MOONSHOT_API_KEY`]},"moonshotai-cn":{apiKeyUrl:`https://platform.moonshot.cn/console/api-keys`,pricingUrl:`https://platform.moonshot.cn/docs/pricing/chat`,docsUrl:`https://platform.moonshot.cn/docs`,description:`Moonshot Kimi — China region endpoint.`,descriptionZh:`月之暗面 Kimi 中国区域端点。`,bestFor:[`coding`,`chinese`,`long context`],freeTier:!0,aliases:[`moonshot cn`,`kimi cn`],envVars:[`MOONSHOT_API_KEY`]},fal:{apiKeyUrl:`https://fal.ai/dashboard/keys`,pricingUrl:`https://fal.ai/pricing`,docsUrl:`https://fal.ai/docs`,description:`fal — serverless image and media generation APIs.`,descriptionZh:`fal:无服务器图像与媒体生成 API。`,bestFor:[`image`,`video`],freeTier:!0,aliases:[`fal ai`,`fal.ai`],envVars:[`FAL_KEY`,`FAL_API_KEY`]},fireworks:{apiKeyUrl:`https://fireworks.ai/account/api-keys`,pricingUrl:`https://fireworks.ai/pricing`,docsUrl:`https://docs.fireworks.ai`,description:`Fireworks AI — fast inference for open and proprietary models.`,descriptionZh:`Fireworks AI,多种开源与商业模型的高速推理服务。`,bestFor:[`speed`,`coding`,`open weights`],freeTier:!0,aliases:[`fireworks ai`,`fireworks`],envVars:[`FIREWORKS_API_KEY`]},together:{apiKeyUrl:`https://api.together.xyz/settings/api-keys`,pricingUrl:`https://www.together.ai/pricing`,docsUrl:`https://docs.together.ai`,description:`Together AI — hosted Llama, Qwen, DeepSeek, and more.`,descriptionZh:`Together AI,托管 Llama、Qwen、DeepSeek 等模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,aliases:[`together ai`,`together.xyz`],envVars:[`TOGETHER_API_KEY`]},"cloudflare-workers-ai":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/workers-ai`,pricingUrl:`https://developers.cloudflare.com/workers-ai/platform/pricing/`,docsUrl:`https://developers.cloudflare.com/workers-ai/`,description:`Cloudflare Workers AI — models at the edge via Cloudflare API.`,descriptionZh:`Cloudflare Workers AI,通过 Cloudflare API 在边缘运行模型。`,bestFor:[`edge`,`latency`],freeTier:!0,aliases:[`workers ai`,`cf workers ai`],envVars:[`CLOUDFLARE_API_KEY`]},"cloudflare-ai-gateway":{apiKeyUrl:`https://dash.cloudflare.com/?to=/:account/ai/ai-gateway`,pricingUrl:`https://developers.cloudflare.com/ai-gateway/pricing/`,docsUrl:`https://developers.cloudflare.com/ai-gateway/`,description:`Cloudflare AI Gateway — unified OpenAI/Anthropic-compatible routing.`,descriptionZh:`Cloudflare AI Gateway,统一 OpenAI/Anthropic 兼容路由。`,bestFor:[`routing`,`observability`,`enterprise`],freeTier:!0,aliases:[`cf ai gateway`,`cloudflare gateway`],envVars:[`CLOUDFLARE_API_KEY`]},xiaomi:{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo — API billing through the MiMo open platform; endpoint api.xiaomimimo.com.`,descriptionZh:`小米 MiMo 按量计费线路,在开放平台创建密钥;接口域名为 api.xiaomimimo.com。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi`,`mimo`,`小米`,`xiaomimimo`],envVars:[`XIAOMI_API_KEY`]},"xiaomi-token-plan-cn":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — China region (token-plan-cn.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 中国区(token-plan-cn.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token cn`,`mimo token cn`],envVars:[`XIAOMI_TOKEN_PLAN_CN_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-ams":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Amsterdam region (token-plan-ams.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 阿姆斯特丹(token-plan-ams.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token ams`,`mimo token ams`],envVars:[`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"xiaomi-token-plan-sgp":{apiKeyUrl:`https://platform.xiaomimimo.com/#/console/api-keys`,pricingUrl:`https://mimo.mi.com/`,docsUrl:`https://platform.xiaomimimo.com/`,description:`Xiaomi MiMo Token Plan — Singapore region (token-plan-sgp.xiaomimimo.com).`,descriptionZh:`小米 MiMo Token 套餐 · 新加坡(token-plan-sgp.xiaomimimo.com)。`,bestFor:[`general`,`coding`],freeTier:!1,aliases:[`xiaomi token sgp`,`mimo token sgp`],envVars:[`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,`XIAOMI_TOKEN_PLAN_API_KEY`]},"ant-ling":{apiKeyUrl:`https://ling.tbox.cn/`,docsUrl:`https://ling.tbox.cn/`,description:`Ant Ling — domestic OpenAI-compatible access to Ling and Ring models.`,descriptionZh:`蚂蚁 Ling,国内 OpenAI 兼容服务,提供 Ling 与 Ring 系列模型。`,bestFor:[`chinese`,`reasoning`,`coding`],aliases:[`ant ling`,`ling`,`ring`,`蚂蚁 ling`,`蚂蚁灵`],envVars:[`ANT_LING_API_KEY`,`LING_API_KEY`]},"zai-coding-global":{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM Coding Plan — international z.ai endpoint.`,descriptionZh:`智谱 GLM Coding Plan 国际区 z.ai 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding`,`zhipu coding global`,`glm coding global`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},"zai-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China endpoint from the pi-ai provider catalog.`,descriptionZh:`智谱 GLM Coding Plan 中国区,来自 pi-ai 内置 provider 目录。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zai coding cn`,`zhipu coding cn`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-coding-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM Coding Plan — China BigModel endpoint.`,descriptionZh:`智谱 GLM Coding Plan 中国区 BigModel 端点。`,bestFor:[`coding`,`reasoning`,`chinese`],aliases:[`zhipu coding`,`glm coding cn`,`智谱 coding`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`,`ZAI_API_KEY`]},"zhipu-cn":{apiKeyUrl:`https://bigmodel.cn/usercenter/proj-mgmt/apikeys`,pricingUrl:`https://bigmodel.cn/pricing`,docsUrl:`https://docs.bigmodel.cn/cn/guide/start/model-overview`,description:`Zhipu GLM China — BigModel OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 中国区,通过 BigModel OpenAI 兼容接口访问。`,bestFor:[`chinese`,`reasoning`,`general`],freeTier:!0,aliases:[`zhipu`,`glm`,`bigmodel`,`智谱`,`z.ai cn`],envVars:[`ZHIPU_API_KEY`,`BIGMODEL_API_KEY`]},huggingface:{apiKeyUrl:`https://huggingface.co/settings/tokens`,pricingUrl:`https://huggingface.co/pricing`,docsUrl:`https://huggingface.co/docs/api-inference/`,description:`Access thousands of open-source models via Hugging Face Inference API.`,descriptionZh:`通过 Hugging Face 访问数千个开源模型。`,bestFor:[`open source`,`flexibility`],freeTier:!0,freeTierNote:`Free tier with rate limits.`,aliases:[`huggingface`,`hugging face`,`hf`],envVars:[`HF_TOKEN`,`HUGGINGFACE_TOKEN`]},opencode:{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode — AI coding assistant provider.`,descriptionZh:`OpenCode,AI 代码助手服务商。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode`,`open code`],envVars:[`OPENCODE_API_KEY`]},"opencode-go":{apiKeyUrl:`https://opencode.ai/auth`,pricingUrl:`https://opencode.ai/docs`,docsUrl:`https://opencode.ai/docs/providers/`,description:`OpenCode Go — AI coding assistant provider (Go variant).`,descriptionZh:`OpenCode Go,AI 代码助手服务商(Go 版本)。`,bestFor:[`coding`],freeTier:!1,aliases:[`opencode go`,`opencode-go`],envVars:[`OPENCODE_API_KEY`]},zai:{apiKeyUrl:`https://z.ai/manage-apikey/apikey-list`,pricingUrl:`https://z.ai/manage-apikey/billing`,docsUrl:`https://docs.z.ai/guides/overview/quick-start`,description:`Zhipu GLM International — z.ai OpenAI-compatible endpoint.`,descriptionZh:`智谱 GLM 国际区,通过 z.ai OpenAI 兼容接口访问。`,bestFor:[`general`,`reasoning`,`chinese`],freeTier:!1,aliases:[`zai`,`z.ai`,`zhipu global`,`glm global`,`智谱`],envVars:[`ZAI_API_KEY`,`Z_AI_API_KEY`]},dashscope:{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope service provider.`,descriptionZh:`阿里百炼 / DashScope 服务 provider。`,bestFor:[`chinese`,`coding`,`image`,`speech`],freeTier:!0,aliases:[`dash scope`,`alibaba dashscope`,`qwen`,`tongyi`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-cn":{apiKeyUrl:`https://dashscope.console.aliyun.com/apiKey`,pricingUrl:`https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-thousand-questions-metering-and-billing`,docsUrl:`https://help.aliyun.com/zh/model-studio/developer-reference/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope China — Qwen LLMs through the China endpoint.`,descriptionZh:`阿里百炼 / DashScope 中国区:通过国内端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope cn`,`alibaba dashscope cn`,`qwen cn`,`tongyi cn`,`阿里百炼`,`通义千问`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"dashscope-intl":{apiKeyUrl:`https://modelstudio.console.alibabacloud.com/`,pricingUrl:`https://www.alibabacloud.com/help/en/model-studio/billing-for-tongyi-qianwen`,docsUrl:`https://www.alibabacloud.com/help/en/model-studio/compatibility-of-openai-with-dashscope`,description:`Alibaba Bailian / DashScope International — Qwen LLMs through the international endpoint.`,descriptionZh:`阿里百炼 / DashScope 国际区:通过国际端点访问通义千问 LLM。`,bestFor:[`chinese`,`coding`,`image`],freeTier:!0,aliases:[`dash scope intl`,`alibaba cloud dashscope`,`qwen intl`,`tongyi intl`],envVars:[`DASHSCOPE_API_KEY`,`QWEN_API_KEY`]},"vercel-ai-gateway":{apiKeyUrl:`https://vercel.com/account/tokens`,pricingUrl:`https://vercel.com/pricing`,docsUrl:`https://vercel.com/docs/ai/ai-gateway`,description:`Vercel AI Gateway — route requests to multiple LLM providers via Vercel.`,descriptionZh:`Vercel AI Gateway,通过 Vercel 路由请求到多个 LLM 服务商。`,bestFor:[`flexibility`,`enterprise`],freeTier:!1,aliases:[`vercel gateway`,`vercel ai gateway`],envVars:[`AI_GATEWAY_API_KEY`,`VERCEL_AI_GATEWAY_API_KEY`]},"github-copilot":{apiKeyUrl:`https://github.com/settings/tokens`,pricingUrl:`https://github.com/features/copilot#pricing`,docsUrl:`https://docs.github.com/en/copilot`,description:`GitHub Copilot — use your GitHub token to access Copilot models.`,descriptionZh:`使用 GitHub 令牌访问 Copilot 模型。`,bestFor:[`coding`],freeTier:!0,freeTierNote:`Free for verified students and open-source maintainers.`,aliases:[`github copilot`,`copilot`,`github`],envVars:[`COPILOT_GITHUB_TOKEN`,`GH_TOKEN`,`GITHUB_TOKEN`,`GITHUB_COPILOT_TOKEN`]}};function uY(e,t){let n=lY[e];return n&&n.apiKeyUrl?[{href:n.apiKeyUrl,kind:`single`}]:[]}var dY=[`common`,`domestic`,`specialty`,`enterprise`,`oauth`,`extension`];function fY(e){let t=new Map;for(let e of dY)t.set(e,[]);for(let n of e){let e=n.category||`specialty`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t}var pY=[{value:`openai-completions`,label:`OpenAI Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-generative-ai`,label:`Google Generative AI`},{value:`azure-openai-responses`,label:`Azure OpenAI`},{value:`bedrock-converse-stream`,label:`AWS Bedrock`},{value:`openai-codex-responses`,label:`OpenAI Codex`},{value:`google-gemini-cli`,label:`Google Gemini CLI`},{value:`google-vertex`,label:`Google Vertex AI`}];function mY(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&`message`in t.error){let e=t.error.message;return typeof e==`string`?e:void 0}}function hY(e){if(!e||typeof e!=`object`)return{providers:{}};let t=e,n=t.providers;return n&&typeof n==`object`&&!Array.isArray(n)?e:{...t,providers:{}}}async function gY(){let e=await we(J(`/api/models-json`)),t=await e.json().catch(()=>({}));if(!e.ok||!t.ok||!t.payload)throw Error(mY(t)||`HTTP ${e.status}`);return{...t.payload,config:hY(t.payload.config)}}async function _Y(e){let t=await we(J(`/api/models-json`),{method:`PATCH`,body:JSON.stringify({config:e})}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(mY(n)||`HTTP ${t.status}`);return await Bn(),n.payload}async function vY(e){let t=await we(J(`/api/models-json/discover-models`),{method:`POST`,body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(mY(n)||`HTTP ${t.status}`);return n.payload.models}function yY(e,t,n){return{id:e,name:t||e,input:[`text`],contextWindow:128e3,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},...n}}var bY={ollama:{label:`Ollama`,providerId:`ollama`,config:{baseUrl:`http://localhost:11434/v1`,api:`openai-completions`,apiKey:`ollama`}},lmstudio:{label:`LM Studio`,providerId:`lmstudio`,config:{baseUrl:`http://localhost:1234/v1`,api:`openai-completions`,apiKey:`lmstudio`}},openrouter:{label:`OpenRouter`,providerId:`openrouter`,config:{baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,apiKey:``}},zhipuCn:{label:`Zhipu GLM China`,providerId:`zhipu-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiGeneral:{label:`Zhipu GLM International`,providerId:`zai`,config:{baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},dashscopeCn:{label:`Alibaba Bailian / DashScope China`,providerId:`dashscope-cn`,description:`China OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},dashscopeIntl:{label:`Alibaba Bailian / DashScope International`,providerId:`dashscope-intl`,description:`International OpenAI-compatible Qwen endpoint`,config:{baseUrl:`https://dashscope-intl.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,apiKey:`DASHSCOPE_API_KEY`,models:[{id:`qwen3.7-max`,name:`Qwen3.7 Max`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.7-plus`,name:`Qwen3.7 Plus`,contextWindow:1e6,input:[`text`,`image`]},{id:`qwen3.6-flash`,name:`Qwen3.6 Flash`,contextWindow:1e6,input:[`text`]}]}},volcengineArk:{label:`Volcengine Ark`,providerId:`volcengine-ark`,description:`Use your Ark endpoint id as the model id`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ep-your-endpoint-id`,name:`Ark endpoint ID`,contextWindow:128e3,input:[`text`]}]}},volcenginePlan:{label:`Volcengine Doubao Coding Plan`,providerId:`volcengine-plan`,description:`Doubao coding-plan endpoint on Volcengine Ark`,config:{baseUrl:`https://ark.cn-beijing.volces.com/api/coding/v3`,api:`openai-completions`,apiKey:`ARK_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},byteplusPlan:{label:`BytePlus Doubao Coding Plan`,providerId:`byteplus-plan`,description:`Doubao coding-plan endpoint on BytePlus`,config:{baseUrl:`https://ark.ap-southeast.bytepluses.com/api/coding/v3`,api:`openai-completions`,apiKey:`BYTEPLUS_API_KEY`,models:[{id:`ark-code-latest`,name:`Ark Coding Plan`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-code`,name:`Doubao Seed 2.0 Code`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-pro`,name:`Doubao Seed 2.0 Pro`,contextWindow:256e3,maxTokens:4096,input:[`text`]},{id:`doubao-seed-2.0-lite`,name:`Doubao Seed 2.0 Lite`,contextWindow:256e3,maxTokens:4096,input:[`text`]}]}},deepseek:{label:`DeepSeek`,providerId:`deepseek`,config:{baseUrl:`https://api.deepseek.com`,api:`openai-completions`,apiKey:`DEEPSEEK_API_KEY`,models:[{id:`deepseek-v4-pro`,name:`DeepSeek V4 Pro`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]},{id:`deepseek-v4-flash`,name:`DeepSeek V4 Flash`,contextWindow:1e6,maxTokens:393216,reasoning:!0,input:[`text`]}]}},moonshotCn:{label:`Kimi / Moonshot China`,providerId:`moonshotai-cn`,config:{baseUrl:`https://api.moonshot.cn/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]}]}},moonshotIntl:{label:`Kimi / Moonshot International`,providerId:`moonshotai`,config:{baseUrl:`https://api.moonshot.ai/v1`,api:`openai-completions`,apiKey:`MOONSHOT_API_KEY`,models:[{id:`kimi-k2.7-code`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-k2.6`,name:`Kimi K2.6`,contextWindow:128e3,input:[`text`]}]}},kimiCoding:{label:`Kimi Coding`,providerId:`kimi-coding`,description:`Dedicated Kimi coding endpoint`,config:{baseUrl:`https://api.kimi.com/coding`,api:`anthropic-messages`,apiKey:`KIMI_API_KEY`,headers:{"User-Agent":`KimiCLI/1.5`},models:[{id:`k2p7`,name:`Kimi K2.7 Code`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]},{id:`kimi-for-coding`,name:`Kimi For Coding`,contextWindow:262144,maxTokens:32768,reasoning:!0,input:[`text`,`image`]}]}},stepfunIntl:{label:`StepFun International`,providerId:`stepfun-intl`,config:{baseUrl:`https://api.stepfun.ai/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunCn:{label:`StepFun China`,providerId:`stepfun-cn`,config:{baseUrl:`https://api.stepfun.com/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanIntl:{label:`StepFun Step Plan International`,providerId:`stepfun-plan-intl`,config:{baseUrl:`https://api.stepfun.ai/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},stepfunPlanCn:{label:`StepFun Step Plan China`,providerId:`stepfun-plan-cn`,config:{baseUrl:`https://api.stepfun.com/step_plan/v1`,api:`openai-completions`,apiKey:`STEPFUN_API_KEY`,models:[{id:`step-3.7-flash`,name:`Step 3.7 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash-2603`,name:`Step 3.5 Flash 2603`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`step-3.5-flash`,name:`Step 3.5 Flash`,contextWindow:1e6,reasoning:!0,input:[`text`]}]}},xiaomi:{label:`Xiaomi MiMo`,providerId:`xiaomi`,config:{baseUrl:`https://api.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanCn:{label:`Xiaomi MiMo Token Plan China`,providerId:`xiaomi-token-plan-cn`,config:{baseUrl:`https://token-plan-cn.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_CN_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanAms:{label:`Xiaomi MiMo Token Plan Amsterdam`,providerId:`xiaomi-token-plan-ams`,config:{baseUrl:`https://token-plan-ams.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_AMS_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},xiaomiTokenPlanSgp:{label:`Xiaomi MiMo Token Plan Singapore`,providerId:`xiaomi-token-plan-sgp`,config:{baseUrl:`https://token-plan-sgp.xiaomimimo.com/v1`,api:`openai-completions`,apiKey:`XIAOMI_TOKEN_PLAN_SGP_API_KEY`,models:[{id:`mimo-v2.5-pro`,name:`MiMo V2.5 Pro`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5-pro-ultraspeed`,name:`MiMo V2.5 Pro UltraSpeed`,contextWindow:1e6,reasoning:!0,input:[`text`]},{id:`mimo-v2.5`,name:`MiMo V2.5`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]}]}},minimax:{label:`MiniMax`,providerId:`minimax`,description:`Anthropic-compatible endpoint preferred for agent workflows`,config:{baseUrl:`https://api.minimax.io/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}},zhipuCodingCn:{label:`Zhipu GLM Coding Plan China`,providerId:`zhipu-coding-cn`,config:{baseUrl:`https://open.bigmodel.cn/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZHIPU_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},zaiCodingGlobal:{label:`Zhipu GLM Coding Plan International`,providerId:`zai-coding-global`,config:{baseUrl:`https://api.z.ai/api/coding/paas/v4`,api:`openai-completions`,apiKey:`ZAI_API_KEY`,models:[{id:`glm-5.2`,name:`GLM 5.2`,contextWindow:1e6,maxTokens:65536,reasoning:!0,input:[`text`]}]}},minimaxCn:{label:`MiniMax China`,providerId:`minimax-cn`,config:{baseUrl:`https://api.minimaxi.com/anthropic`,api:`anthropic-messages`,apiKey:`MINIMAX_CN_API_KEY`,authHeader:!0,models:[{id:`MiniMax-M3`,name:`MiniMax M3`,contextWindow:1e6,reasoning:!0,input:[`text`,`image`]},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800,input:[`text`]},{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800,input:[`text`]}]}}},xY=Object.entries(bY).map(([e,t])=>({key:e,...t}));function SY(e){return bY[e]?.providerId??e}function CY(e){return xY.find(t=>t.providerId===e)?.key}var wY=new Set([`dashscope-cn`,`dashscope-intl`,`volcengine-ark`,`volcengine-plan`,`byteplus-plan`,`stepfun-cn`,`stepfun-intl`,`stepfun-plan-cn`,`stepfun-plan-intl`,`zhipu-cn`,`zai-coding-global`,`zhipu-coding-cn`]);function TY(e){if(wY.has(e))return CY(e)}function EY(e,t){let n=TY(e);if(!n)return;let r=bY[n];if(r)return{providerId:r.providerId,config:{...r.config,apiKey:t?.trim()||r.config.apiKey,models:r.config.models?.map(e=>({...e}))}}}var DY=[{value:`text`,labelKey:`inputTextOnly`},{value:`text,image`,labelKey:`inputTextVision`}];function OY(){return K(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,xd,`dark:border-edge`)}function kY(){return K(vd,_d)}function AY(e){return(e.input||[`text`]).includes(`image`)?`text,image`:`text`}function jY(e){return e===`text,image`?[`text`,`image`]:[`text`]}var MY=`xopc-cloud`;function NY(e){let t=(0,Q.c)(22),{open:n,onOpenChange:r,builtinRows:i,customConfig:a,labels:o,language:s,onSaved:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={type:`pick`},t[0]=l):l=t[0];let[u,d]=(0,Z.useState)(l),[f,p]=(0,Z.useState)(``),m=(0,Z.useRef)(0),h;t[1]===r?h=t[2]:(h=e=>{e||window.setTimeout(()=>{d({type:`pick`}),p(``),m.current=0},200),r(e)},t[1]=r,t[2]=h);let g=h,_;t[3]!==g||t[4]!==c?(_=e=>{c(e),g(!1)},t[3]=g,t[4]=c,t[5]=_):_=t[5];let v=_,y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Ye,{className:K(`xopc-dialog-overlay fixed inset-0 bg-scrim`,wn)}),t[6]=y):y=t[6];let b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=K(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(40rem,calc(100vh-3rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,Sn),t[7]=b):b=t[7];let x;t[8]!==i||t[9]!==a||t[10]!==v||t[11]!==o||t[12]!==s||t[13]!==f||t[14]!==u.presetKey||t[15]!==u.providerId||t[16]!==u.type?(x=(0,$.jsxs)($e,{children:[y,(0,$.jsx)(et,{className:b,children:u.type===`pick`?(0,$.jsx)(FY,{builtinRows:i,searchQuery:f,onSearchChange:p,labels:o,language:s,scrollTopRef:m,onPickBuiltin:e=>{let t=TY(e);d(t?{type:`custom`,presetKey:t}:{type:`builtin`,providerId:e})},onPickCustom:()=>d({type:`custom`})}):u.type===`builtin`?(0,$.jsx)(VY,{providerId:u.providerId,builtinRows:i,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:()=>v(u.providerId)}):(0,$.jsx)(WY,{initialPresetKey:u.presetKey,customConfig:a,labels:o,language:s,onBack:()=>d({type:`pick`}),onSaved:v})})]}),t[8]=i,t[9]=a,t[10]=v,t[11]=o,t[12]=s,t[13]=f,t[14]=u.presetKey,t[15]=u.providerId,t[16]=u.type,t[17]=x):x=t[17];let S;return t[18]!==g||t[19]!==n||t[20]!==x?(S=(0,$.jsx)(nt,{open:n,onOpenChange:g,children:x}),t[18]=g,t[19]=n,t[20]=x,t[21]=S):S=t[21],S}function PY(e){let t=(0,Q.c)(4),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=K(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.press),t[0]=r):r=t[0];let i;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),t[1]=i):i=t[1];let a;return t[2]===n?a=t[3]:(a=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:r,"aria-label":n,children:i})}),t[2]=n,t[3]=a),a}function FY(e){let t=(0,Q.c)(60),{builtinRows:n,searchQuery:r,onSearchChange:i,labels:a,language:o,scrollTopRef:s,onPickBuiltin:c,onPickCustom:l}=e,u;t[0]===r?u=t[1]:(u=r.trim().toLowerCase(),t[0]=r,t[1]=u);let d=u,f=(0,Z.useRef)(null),p,m;t[2]===s?(p=t[3],m=t[4]):(p=()=>{let e=f.current;e&&s.current>0&&(e.scrollTop=s.current)},m=[s],t[2]=s,t[3]=p,t[4]=m),(0,Z.useLayoutEffect)(p,m);let h;bb0:{if(!d){h=n;break bb0}let e;if(t[5]!==n||t[6]!==d){let r;t[8]===d?r=t[9]:(r=e=>{let t=lY[e.id]?.aliases??[];return e.id.toLowerCase().includes(d)||e.name.toLowerCase().includes(d)||t.some(e=>e.toLowerCase().includes(d))},t[8]=d,t[9]=r),e=n.filter(r),t[5]=n,t[6]=d,t[7]=e}else e=t[7];h=e}let g=h,_,v,y,b,x,S;if(t[10]!==g||t[11]!==a||t[12]!==o||t[13]!==c||t[14]!==l||t[15]!==i||t[16]!==d||t[17]!==s||t[18]!==r){let e=g.find(RY),n=g.filter(LY),u;t[25]===g?u=t[26]:(u=fY(g.filter(IY)),t[25]=g,t[26]=u);let p=u,m;t[27]===o?m=t[28]:(m=e=>{let t=lY[e.id];return o===`zh`?t?.descriptionZh??t?.description:t?.description},t[27]=o,t[28]=m);let h=m,C;t[29]===a.step1Title?C=t[30]:(C=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:a.step1Title}),t[29]=a.step1Title,t[30]=C);let w;t[31]===a.step1Subtitle?w=t[32]:(w=(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:a.step1Subtitle}),t[31]=a.step1Subtitle,t[32]=w);let T;t[33]!==C||t[34]!==w?(T=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[C,w]}),t[33]=C,t[34]=w,t[35]=T):T=t[35];let E;t[36]===a.close?E=t[37]:(E=(0,$.jsx)(PY,{label:a.close}),t[36]=a.close,t[37]=E),t[38]!==T||t[39]!==E?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pb-3 pt-5`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=S):S=t[40];let D;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ve,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[41]=D):D=t[41];let O;t[42]===i?O=t[43]:(O=e=>i(e.target.value),t[42]=i,t[43]=O);let k=a.searchPlaceholder,A;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(A=K(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg placeholder:text-fg-subtle`,xd),t[44]=A):A=t[44],t[45]!==a.searchPlaceholder||t[46]!==r||t[47]!==O?(_=(0,$.jsx)(`div`,{className:`px-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[D,(0,$.jsx)(`input`,{type:`search`,value:r,onChange:O,placeholder:k,autoComplete:`off`,className:A})]})}),t[45]=a.searchPlaceholder,t[46]=r,t[47]=O,t[48]=_):_=t[48],v=f,t[49]===s?y=t[50]:(y=e=>{s.current=e.currentTarget.scrollTop},t[49]=s,t[50]=y),b=`min-h-0 flex-1 overscroll-contain overflow-y-auto px-5 pb-5`,x=d&&g.length===0?(0,$.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:a.noResults}):d?(0,$.jsx)(zY,{title:a.searchResults,children:g.map(e=>(0,$.jsx)(BY,{row:e,description:h(e),labels:a,onPick:c},e.id))}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e?(0,$.jsx)(zY,{title:a.quickStart,children:(0,$.jsx)(BY,{row:e,description:h(e),labels:a,prominent:!0,onPick:c})}):null,n.length>0?(0,$.jsx)(zY,{title:a.connectedSection,children:n.map(e=>(0,$.jsx)(BY,{row:e,description:h(e),labels:a,onPick:c},e.id))}):null,dY.map(e=>{let t=p.get(e)??[];return t.length===0?null:(0,$.jsx)(zY,{title:a.categories[e]??e,children:t.map(e=>(0,$.jsx)(BY,{row:e,description:h(e),labels:a,onPick:c},e.id))},e)}),(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:K(`flex w-full items-center gap-3 rounded-xl bg-surface-hover/25 px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base/60 text-fg-muted`,children:(0,$.jsx)(ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:a.addCustom}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:a.customDescription})]}),(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]})]}),t[10]=g,t[11]=a,t[12]=o,t[13]=c,t[14]=l,t[15]=i,t[16]=d,t[17]=s,t[18]=r,t[19]=_,t[20]=v,t[21]=y,t[22]=b,t[23]=x,t[24]=S}else _=t[19],v=t[20],y=t[21],b=t[22],x=t[23],S=t[24];let C;t[51]!==v||t[52]!==y||t[53]!==b||t[54]!==x?(C=(0,$.jsx)(`div`,{ref:v,onScroll:y,className:b,children:x}),t[51]=v,t[52]=y,t[53]=b,t[54]=x,t[55]=C):C=t[55];let w;return t[56]!==_||t[57]!==C||t[58]!==S?(w=(0,$.jsxs)($.Fragment,{children:[S,_,C]}),t[56]=_,t[57]=C,t[58]=S,t[59]=w):w=t[59],w}function IY(e){return e.id!==MY&&!e.configured}function LY(e){return e.configured&&e.id!==MY}function RY(e){return e.id===MY}function zY(e){let t=(0,Q.c)(7),{title:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h3`,{className:`mb-1.5 px-1 text-xs font-semibold text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,$.jsx)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,$.jsxs)(`section`,{children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function BY(e){let t=(0,Q.c)(27),{row:n,description:r,labels:i,prominent:a,onPick:o}=e,s=a===void 0?!1:a,c;t[0]!==o||t[1]!==n.id?(c=()=>o(n.id),t[0]=o,t[1]=n.id,t[2]=c):c=t[2];let l=s&&`bg-surface-base/80`,u;t[3]===l?u=t[4]:(u=K(`flex min-h-12 w-full items-center gap-3 rounded-lg bg-surface-base/55 px-3 py-2.5 text-left transition-colors`,`hover:bg-surface-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,l),t[3]=l,t[4]=u);let d;t[5]===n.name?d=t[6]:(d=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:n.name}),t[5]=n.name,t[6]=d);let f;t[7]!==i||t[8]!==s?(f=s?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:i.recommended}):null,t[7]=i,t[8]=s,t[9]=f):f=t[9];let p;t[10]!==d||t[11]!==f?(p=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[d,f]}),t[10]=d,t[11]=f,t[12]=p):p=t[12];let m;t[13]===r?m=t[14]:(m=r?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:r}):null,t[13]=r,t[14]=m);let h;t[15]!==p||t[16]!==m?(h=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m]}),t[15]=p,t[16]=m,t[17]=h):h=t[17];let g;t[18]!==i||t[19]!==n.configured?(g=n.configured?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),i.connected]}):null,t[18]=i,t[19]=n.configured,t[20]=g):g=t[20];let _;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(lr,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[21]=_):_=t[21];let v;return t[22]!==g||t[23]!==c||t[24]!==u||t[25]!==h?(v=(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:u,children:[h,g,_]}),t[22]=g,t[23]=c,t[24]=u,t[25]=h,t[26]=v):v=t[26],v}function VY({providerId:e,builtinRows:t,labels:n,language:r,onBack:i,onSaved:a}){let o=t.find(t=>t.id===e),s=lY[e],c=r===`zh`?s?.descriptionZh??s?.description:s?.description,[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(null),v=xe(r).providersSettings,y=Ad(v),b=(0,Z.useMemo)(()=>uY(e,r),[e,r]),x=o?.supportsApiKey!==!1,S=o?.supportsOAuth===!0,[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(`idle`),[k,A]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(null),[I,L]=(0,Z.useState)(``),R=(0,Z.useRef)(null),z=(0,Z.useRef)(null),B=D===`waiting`||D===`waiting_code`;(0,Z.useEffect)(()=>{if(!C||!B)return;let t=window.setInterval(()=>{(async()=>{try{let n=await $J(C);n.status===`waiting_auth`||n.status===`waiting_code`?(O(n.status===`waiting_code`?`waiting_code`:`waiting`),E(n.message??null),A(n.authUrl??null),N(n.instructions??null),F(n.deviceCode??null),n.authUrl&&n.authUrl!==z.current&&(z.current=n.authUrl,oY(n.authUrl,R.current).catch(()=>{}))):n.status===`completed`?(window.clearInterval(t),sY(R.current),R.current=null,e===`xopc-cloud`&&await Bn(),O(`success`),E(n.message??v.saved),window.setTimeout(a,600)):(n.status===`failed`||n.status===`cancelled`)&&(window.clearInterval(t),sY(R.current),R.current=null,O(`error`),E(n.error??n.message??v.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(t)},[C,B,a,e,v.revokeFailed,v.saved]),(0,Z.useEffect)(()=>()=>{C&&nY(C).catch(()=>{})},[C]),(0,Z.useEffect)(()=>()=>{sY(R.current),R.current=null},[]);let V=async()=>{sY(R.current),R.current=aY(),z.current=null,O(`waiting`),E(v.oauthStarting),A(null),N(null),F(null),m(null);try{w((await QJ(e)).sessionId)}catch(e){sY(R.current),R.current=null,O(`error`),E(e instanceof Error?e.message:v.revokeFailed)}},H=async()=>{if(C){try{await tY(C)}catch{}sY(R.current),R.current=null,z.current=null,O(`idle`),E(null),w(null),A(null),N(null),F(null)}},U=async()=>{if(!(!C||!I.trim()))try{await eY(C,I.trim()),L(``),E(v.oauthProcessingCode)}catch(e){O(`error`),E(e instanceof Error?e.message:v.revokeFailed)}},W=async()=>{let t=l.trim();if(!(!t||!x)){f(!0),m(null);try{await VJ({[e]:t}),g(!0),window.setTimeout(a,600)}catch(e){m(e instanceof Error?e.message:n.saveError)}finally{f(!1)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-3 pt-5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:K(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.press),"aria-label":n.back,children:(0,$.jsx)(lr,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(tt,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:o?.name??e}),(0,$.jsx)(PY,{label:n.close})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 pb-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-hover/20 p-4`,children:[c?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c}):null,x?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`builtin-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(Od,{id:`builtin-api-key`,value:l,onChange:u,placeholder:n.apiKeyPlaceholder,labels:y,inputRef:_,onKeyDown:e=>{e.key===`Enter`&&W()}})]}):null,S?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/55 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:v.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v.oauthHint})]}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:B,onClick:()=>void V(),children:[B?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,v.oauth]})]}),T?(0,$.jsx)(`p`,{className:K(`text-xs`,D===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:T}):null,D===`waiting`||D===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[k?(0,$.jsxs)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[v.openAuthPage,(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]}):null,(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:()=>void H(),children:v.cancelOAuth})]}):null,M?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:M}):null,P?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base/70 px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:P}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:v.deviceCodeHint})]}):null,D===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>e.key===`Enter`&&void U(),placeholder:v.pasteRedirectUrl,className:K(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,xd)}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void U(),children:v.submitCode})]}):null]}):null,b.length>0&&x?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:b.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[cY(e,n),(0,$.jsx)(`span`,{className:`size-3`,"aria-hidden":!0,children:`↗`})]},e))}):null,p?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:p}):null]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 bg-surface-hover/15 px-5 py-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),x?(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!l.trim()||d||h,onClick:()=>void W(),children:h?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),n.saved]}):d?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save}):null]})]})}function HY(e=`custom`){if(e!==`custom`&&bY[e]){let t=bY[e].config;return{preset:e,providerId:SY(e),baseUrl:t.baseUrl??``,api:t.api??`openai-completions`,apiKey:t.apiKey??``,modelIds:t.models?.map(e=>e.id)??[``],error:null}}return{preset:`custom`,providerId:``,baseUrl:``,api:`openai-completions`,apiKey:``,modelIds:[``],error:null}}function UY(e,t){switch(t.type){case`applyPreset`:return t.key===`custom`?{...e,preset:`custom`,error:null}:bY[t.key]?HY(t.key):e;case`setProviderId`:return{...e,providerId:t.value};case`setBaseUrl`:return{...e,baseUrl:t.value};case`setApi`:return{...e,api:t.value};case`setApiKey`:return{...e,apiKey:t.value};case`addModelSlot`:return{...e,modelIds:[...e.modelIds,``]};case`updateModelId`:return{...e,modelIds:e.modelIds.map((e,n)=>n===t.index?t.value:e)};case`setModelIds`:return{...e,modelIds:t.values.length>0?t.values:[``]};case`removeModelSlot`:return{...e,modelIds:e.modelIds.filter((e,n)=>n!==t.index)};case`setError`:return{...e,error:t.value}}}function WY({initialPresetKey:e,customConfig:t,labels:n,language:r,onBack:i,onSaved:a}){let[o,s]=(0,Z.useReducer)(UY,void 0,()=>HY(e)),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),f=Ad(xe(r).providersSettings),{preset:p,providerId:m,baseUrl:h,api:g,apiKey:_,modelIds:v,error:y}=o,b=async()=>{let e=m.trim(),r=h.trim();if(!e){s({type:`setError`,value:n.providerIdRequired});return}if(!r){s({type:`setError`,value:n.baseUrlRequired});return}let i=v.map(e=>e.trim()).filter(Boolean);l(!0),s({type:`setError`,value:null});try{let n=t?.providers??{},o=p===`custom`?void 0:bY[p]?.config,s={...o??{},baseUrl:r,api:g,apiKey:_.trim()||void 0,models:i.map(e=>o?.models?.find(t=>t.id===e)??{id:e})};await _Y({providers:{...n,[e]:s}}),a(e)}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.saveError})}finally{l(!1)}},x=async()=>{let e=m.trim()||SY(p)||`custom`,t=h.trim();if(!t){s({type:`setError`,value:n.baseUrlRequired});return}d(!0),s({type:`setError`,value:null});try{let r=p===`custom`?void 0:bY[p]?.config,i=(await vY({providerId:e,baseUrl:t,apiKey:_.trim()||void 0,api:g,headers:r?.headers})).map(e=>e.id).filter(e=>e&&!e.includes(`/`));s({type:`setModelIds`,values:i}),i.length===0&&s({type:`setError`,value:n.discoverModelsHint})}catch(e){s({type:`setError`,value:e instanceof Error?e.message:n.discoverModelsHint})}finally{d(!1)}},S=m.trim()&&h.trim(),C=(g===`openai-completions`||g===`openai-responses`)&&h.trim();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-3 pt-5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:i,className:K(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.press),"aria-label":n.back,children:(0,$.jsx)(lr,{className:`size-4 rotate-180`,"aria-hidden":!0})}),(0,$.jsx)(tt,{className:`min-w-0 flex-1 text-base font-semibold text-fg`,children:n.step2CustomTitle}),(0,$.jsx)(PY,{label:n.close})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 pb-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.customDescription}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-preset`,className:`text-sm font-medium text-fg`,children:n.presetLabel}),(0,$.jsxs)(E,{id:`custom-preset`,value:p,onChange:e=>s({type:`applyPreset`,key:e.target.value}),className:kY(),children:[(0,$.jsx)(O,{value:`custom`,children:n.presetCustom}),xY.map(e=>(0,$.jsx)(O,{value:e.key,children:e.label},e.key))]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-provider-id`,className:`text-sm font-medium text-fg`,children:n.providerIdLabel}),(0,$.jsx)(`input`,{id:`custom-provider-id`,type:`text`,autoComplete:`off`,value:m,onChange:e=>s({type:`setProviderId`,value:e.target.value}),placeholder:n.providerIdPlaceholder,className:K(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,xd)})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`custom-base-url`,type:`url`,autoComplete:`off`,value:h,onChange:e=>s({type:`setBaseUrl`,value:e.target.value}),placeholder:n.baseUrlPlaceholder,className:K(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,xd)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-type`,className:`text-sm font-medium text-fg`,children:n.apiTypeLabel}),(0,$.jsx)(E,{id:`custom-api-type`,value:g,onChange:e=>s({type:`setApi`,value:e.target.value}),className:kY(),children:pY.map(e=>(0,$.jsx)(O,{value:e.value,children:e.label},e.value))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-api-key`,className:`text-sm font-medium text-fg`,children:n.apiKeyLabel}),(0,$.jsx)(Od,{id:`custom-api-key`,value:_,onChange:e=>s({type:`setApiKey`,value:e}),placeholder:n.apiKeyPlaceholder,labels:f})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.modelIdLabel}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`gap-1.5`,disabled:!C||u,onClick:()=>void x(),children:[u?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),u?n.discoveringModels:n.discoverModels]})]}),v.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,autoComplete:`off`,value:e,onChange:e=>s({type:`updateModelId`,index:t,value:e.target.value}),placeholder:n.modelIdPlaceholder,className:K(`flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,xd)}),v.length>1?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s({type:`removeModelSlot`,index:t}),className:K(`rounded-lg p-1.5 text-fg-subtle hover:bg-surface-hover hover:text-fg`,yc.press),children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})}):null]},e||`model-slot-${t}`)),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`w-fit gap-1.5 text-fg-muted`,onClick:()=>s({type:`addModelSlot`}),children:[(0,$.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),n.addModel]})]}),y?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:y}):null]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 bg-surface-hover/15 px-5 py-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:i,children:n.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,disabled:!S||c,onClick:()=>void b(),children:c?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})]})]})}function GY(){let e=(0,Q.c)(29),t=!!Se(ZY),{data:n,isLoading:r}=an(t),i;e[0]===t?i=e[1]:(i=t?J(`/api/providers/meta`):null,e[0]=t,e[1]=i);let a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},e[2]=a):a=e[2];let{data:o,isLoading:s}=Zt(i,XY,a),c;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},e[3]=c):c=e[3];let{data:l,isLoading:u}=Zt(t?zn:null,YY,c),d;e[4]===l?d=e[5]:(d=l===void 0?[]:l,e[4]=l,e[5]=d);let f=d,p;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},e[6]=p):p=e[6];let{data:m}=Zt(t?Vn:null,JY,p),h;bb0:{if(!o||n===void 0){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[7]=t):t=e[7],h=t;break bb0}let t;e[8]!==n?.payload?.config||e[9]!==o||e[10]!==f?(t=BJ(o,zJ(n?.payload?.config),f),e[8]=n?.payload?.config,e[9]=o,e[10]=f,e[11]=t):t=e[11],h=t}let g=h,_;bb1:{if(!m){_=null;break bb1}let t;e[12]===m.config?t=e[13]:(t=hY(m.config),e[12]=m.config,e[13]=t),_=t}let v=_,y;if(e[14]!==g||e[15]!==v||e[16]!==o||e[17]!==f){y=[];let t=new Set((o??[]).filter(qY).map(KY)),n;e[19]===v?n=e[20]:(n=new Set(v?Object.keys(v.providers):[]),e[19]=v,e[20]=n);let r=n;for(let e of g){if(!t.has(e.id))continue;let n=r.has(e.id),i=n?v.providers[e.id]?.models?.length??0:f.filter(t=>t.provider===e.id).length;y.push({id:e.id,name:e.name,configured:!0,isCustom:n,modelCount:i})}if(v){let t;e[21]===v.providers?t=e[22]:(t=Object.entries(v.providers),e[21]=v.providers,e[22]=t);for(let[e,n]of t)y.some(t=>t.id===e)||y.push({id:e,name:e,configured:!0,isCustom:!0,modelCount:n.models?.length??0})}e[14]=g,e[15]=v,e[16]=o,e[17]=f,e[18]=y}else y=e[18];let b=y,x=r||s||u,S;return e[23]!==g||e[24]!==b||e[25]!==v||e[26]!==x||e[27]!==f?(S={cards:b,loading:x,builtinRows:g,customConfig:v,allModels:f},e[23]=g,e[24]=b,e[25]=v,e[26]=x,e[27]=f,e[28]=S):S=e[28],S}function KY(e){return e.id}function qY(e){return e.configured}function JY(){return gY()}function YY(){return Ln()}async function XY(e){let{payload:t}=await(await fetch(e,{credentials:`same-origin`,redirect:`error`})).json();return t?.providers??[]}function ZY(e){return e.conversationId}function QY(e){let t=(0,Q.c)(12),{labels:n,data:r,onAdd:i,onManage:a}=e,{cards:o,loading:s}=r;if(s){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(xn,{className:`h-6 w-48 max-w-full`}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,"aria-busy":`true`,children:[e,(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:[1,2,3].map(eX)})]}),t[1]=n):n=t[1],n}let c;if(t[2]!==o||t[3]!==n||t[4]!==i||t[5]!==a){let e=o.filter($Y),r=e.length>0?n.titleCount.replace(`{{count}}`,String(e.length)):n.title,s;t[7]===r?s=t[8]:(s=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[7]=r,t[8]=s);let l=e.length>0?(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`gap-1.5`,onClick:i,children:[(0,$.jsx)(ge,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]}):null,u;t[9]!==s||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11],c=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u,e.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/25 px-6 py-10 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.empty}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.emptyHint}),(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`mt-4 gap-1.5`,onClick:i,children:[(0,$.jsx)(ge,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),n.addProvider]})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-1 rounded-xl bg-surface-hover/20 p-1`,children:e.map(e=>(0,$.jsx)(tX,{card:e,labels:n,onManage:()=>a(e.id,e.isCustom)},e.id))})]}),t[2]=o,t[3]=n,t[4]=i,t[5]=a,t[6]=c}else c=t[6];return c}function $Y(e){return e.configured}function eX(e){return(0,$.jsx)(xn,{className:`h-16 rounded-lg`},e)}function tX(e){let t=(0,Q.c)(26),{card:n,labels:r,onManage:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=K(`group relative flex min-h-16 w-full flex-col justify-center gap-2 rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors sm:flex-row sm:items-center sm:gap-4`,`hover:bg-surface-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,yc.pressCard),t[0]=a):a=t[0];let o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(j,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}),t[1]=o):o=t[1];let s;t[2]===n.name?s=t[3]:(s=(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-semibold leading-snug text-fg`,children:n.name}),t[2]=n.name,t[3]=s);let c;t[4]!==n.isCustom||t[5]!==r.custom?(c=n.isCustom?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:r.custom}):null,t[4]=n.isCustom,t[5]=r.custom,t[6]=c):c=t[6];let l;t[7]!==s||t[8]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[o,s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9];let u;t[10]!==n.modelCount||t[11]!==r.modelsCount||t[12]!==r.noModels?(u=n.modelCount>0?r.modelsCount.replace(`{{count}}`,String(n.modelCount)):r.noModels,t[10]=n.modelCount,t[11]=r.modelsCount,t[12]=r.noModels,t[13]=u):u=t[13];let d;t[14]===u?d=t[15]:(d=(0,$.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-subtle`,children:u}),t[14]=u,t[15]=d);let f;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(qi,{className:`size-3`,"aria-hidden":!0}),t[16]=f):f=t[16];let p;t[17]===r.manage?p=t[18]:(p=(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-accent-fg`,children:[f,r.manage]}),t[17]=r.manage,t[18]=p);let m;t[19]!==d||t[20]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-4 pl-6 sm:justify-end sm:pl-0`,children:[d,p]}),t[19]=d,t[20]=p,t[21]=m):m=t[21];let h;return t[22]!==i||t[23]!==m||t[24]!==l?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:a,children:[l,m]}),t[22]=i,t[23]=m,t[24]=l,t[25]=h):h=t[25],h}function nX(){return q(J(`/api/user-model`))}async function rX(){let e=await nX();return{profile:{callName:typeof e.profile.callName==`string`?e.profile.callName:``,role:typeof e.profile.role==`string`?e.profile.role:``,pronouns:typeof e.profile.pronouns==`string`?e.profile.pronouns:``,timezone:typeof e.profile.timezone==`string`?e.profile.timezone:``,locale:typeof e.profile.locale==`string`?e.profile.locale:``},...typeof e.suggestedCallName==`string`?{suggestedCallName:e.suggestedCallName}:{}}}async function iX(e){let t=await q(J(`/api/user-model/profile`),{method:`PATCH`,body:JSON.stringify(e)});return{callName:t.profile.callName??``,role:t.profile.role??``,pronouns:t.profile.pronouns??``,timezone:t.profile.timezone??``,locale:t.profile.locale??``}}function aX(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function oX(e,t){return q(J(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({statement:t})})}function sX(e,t){return q(J(`/api/user-model/priorities/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)})}function cX(e){let t=Date.now();return q(J(`/api/user-model/priorities`),{method:`POST`,body:JSON.stringify({targetType:`topic`,targetId:e.title.trim(),rank:`primary`,urgency:1,scope:{type:`global`},validFrom:t,validTo:e.validTo})})}function lX(e,t){return q(J(`/api/user-model/rules/${encodeURIComponent(e)}/status`),{method:`PATCH`,body:JSON.stringify({status:t})})}function uX(e){return q(J(`/api/user-model/rules`),{method:`POST`,body:JSON.stringify({category:e.category,statement:e.statement,priority:50,scope:e.scope,conditions:{...e.conditions,requiresConfirmation:!1}})})}function dX(e,t,n){return q(J(`/api/knowledge-memory/${encodeURIComponent(e.id)}/review`),{method:`POST`,body:JSON.stringify({action:t,expectedStatus:e.status,...n===void 0?{}:{content:n}})})}function fX(e){return q(J(`/api/user-model/assertions/${encodeURIComponent(e)}`),{method:`DELETE`})}function pX(e){return q(J(`/api/knowledge-memory/${encodeURIComponent(e)}`),{method:`DELETE`})}var mX={step:`callName`,selectedProvider:null,apiKey:``,busy:!1,error:null,callName:``,connectedModelRef:null};function hX(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`prefillCallName`:return e.callName.trim()?e:{...e,callName:t.value}}}var gX=[`callName`,`provider`,`apiKey`,`success`],_X=e=>gX.indexOf(e)+1;function vX(e){let t=(0,Q.c)(5),{step:n,label:r}=e,i=_X(n)-1,a;t[0]===i?a=t[1]:(a=gX.map((e,t)=>(0,$.jsx)(`span`,{className:K(`h-1.5 rounded-full transition-[width,background-color] duration-200 motion-reduce:transition-none`,t===i?`w-5 bg-accent`:`w-1.5`,t<i?`bg-accent/45`:t>i?`bg-edge-strong`:void 0),"aria-hidden":!0},e)),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-label":r,children:a}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}function yX({onComplete:e,onDismiss:t,canDismiss:n=!0}){let r=Ee(e=>e.language),i=Ee(e=>e.setLanguage),a=xe(r).onboarding,[o,s]=(0,Z.useReducer)(hX,mX),[c,l]=(0,Z.useState)(!1),u=GY(),{step:d,selectedProvider:f,apiKey:p,busy:m,error:h,callName:g}=o,_=(0,Z.useMemo)(()=>a.stepOf.replace(`{{current}}`,String(_X(d))).replace(`{{total}}`,String(gX.length)),[a.stepOf,d]),v=(0,Z.useCallback)(async e=>{s({type:`patch`,patch:{error:null}});try{return(await Ln(!0)).filter(t=>t.provider===e).sort((e,t)=>e.recommended===t.recommended?(e.name||e.id).localeCompare(t.name||t.id,void 0,{sensitivity:`base`}):e.recommended?-1:1)[0]??null}catch(e){return s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}}),null}},[]);(0,Z.useEffect)(()=>{let e=!1,t;return(async()=>{for(let n=0;n<3;n+=1)try{let{profile:t,suggestedCallName:n}=await rX();if(e)return;let r=t.callName.trim()||n?.trim();r&&s({type:`prefillCallName`,value:r});return}catch{n<2&&await new Promise(e=>{t=setTimeout(e,250*(n+1))})}})(),()=>{e=!0,t!==void 0&&clearTimeout(t)}},[]);let y=async()=>{let e=g.trim();s({type:`patch`,patch:{busy:!0,error:null}});try{await iX({...e?{callName:e}:{},timezone:aX(),locale:r===`zh`?`zh-CN`:`en-US`}),s({type:`patch`,patch:{step:`provider`}})}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{busy:!1}})}},b=(0,Z.useCallback)(async e=>{let t=await dG();if((await fG({...t.defaults,models:{...t.defaults.models,chat:{primary:e,fallbacks:[]}}})).defaults.models.chat.primary!==e)throw Error(r===`zh`?`默认模型未能保存,请重试。`:`The default model could not be saved. Try again.`);rn(),Rn(),xy(),await iX({...g.trim()?{callName:g.trim()}:{},timezone:aX(),locale:r===`zh`?`zh-CN`:`en-US`}),s({type:`patch`,patch:{step:`success`,connectedModelRef:e,error:null}})},[g,r]),x=async()=>{s({type:`patch`,patch:{busy:!0,error:null}});try{await e()}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{busy:!1}})}},S=async()=>{if(!(!f||!p.trim())){s({type:`patch`,patch:{busy:!0,error:null}});try{let e=EY(f,p.trim());if(e){let t=await gY(),n=t.config.providers[e.providerId]??{};await _Y({...t.config,providers:{...t.config.providers,[e.providerId]:{...n,...e.config}}})}else await VJ({[f]:p.trim()});let t=await v(f);if(!t)throw Error(r===`zh`?`服务已连接,但没有找到可用模型。请检查服务配置或选择其他服务。`:`The service is connected, but no available model was found. Check its configuration or choose another service.`);await b(t.id)}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{busy:!1}})}}},C=async()=>{s({type:`patch`,patch:{busy:!0,error:null}});try{let e=await v(`xopc-cloud`);if(!e)throw Error(r===`zh`?`XOPC Cloud 已连接,但没有找到可用模型,请稍后重试。`:`XOPC Cloud connected, but no available model was found. Try again shortly.`);await b(e.id)}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{busy:!1}})}},w=async e=>{s({type:`patch`,patch:{busy:!0,error:null}});try{let t=await v(e);if(!t)throw Error(r===`zh`?`服务已连接,但没有找到可用模型。请检查服务配置或选择其他服务。`:`The service is connected, but no available model was found. Check its configuration or choose another service.`);await b(t.id)}catch(e){s({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{s({type:`patch`,patch:{busy:!1}})}};return(0,$.jsxs)(`div`,{className:`xopc-onboarding-experience relative flex h-full min-h-0 w-full flex-col overflow-hidden`,"data-step":d,children:[(0,$.jsx)(`header`,{className:`relative z-20 flex h-18 shrink-0 items-center justify-end px-5 sm:px-8 lg:px-10`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(EJ,{value:r,onChange:e=>{s({type:`patch`,patch:{error:null}}),i(e)}}),n?(0,$.jsx)(`button`,{type:`button`,"aria-label":a.skipSetup,className:`inline-flex size-10 items-center justify-center rounded-xl text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:t,children:(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0})}):null]})}),(0,$.jsxs)(`main`,{className:`xopc-onboarding-scroll relative z-10 grid min-h-0 flex-1 overflow-y-auto lg:grid-cols-[minmax(18rem,0.8fr)_minmax(30rem,1.2fr)]`,children:[(0,$.jsx)(`section`,{className:`xopc-onboarding-visual relative hidden min-h-0 items-center justify-center overflow-hidden lg:flex`,children:(0,$.jsxs)(`div`,{className:`xopc-onboarding-mark relative flex size-64 items-center justify-center`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`xopc-onboarding-mark-halo absolute inset-[10%] rounded-full`}),(0,$.jsx)(`span`,{className:`xopc-onboarding-mark-trace absolute inset-[13%] rounded-full`}),(0,$.jsx)(`span`,{className:`xopc-onboarding-mark-core relative flex size-36 items-center justify-center`,children:(0,$.jsx)(GI,{className:`relative z-10 size-28 lg:size-32`})})]})}),(0,$.jsx)(`section`,{className:`app-main-surface xopc-onboarding-scroll flex min-h-[30rem] items-center overflow-y-auto bg-surface-panel px-5 py-8 sm:px-10 lg:min-h-0 lg:px-[clamp(3rem,6vw,6rem)]`,children:(0,$.jsxs)(`div`,{className:`xopc-onboarding-stage w-full max-w-[30rem]`,children:[d===`callName`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:a.title}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:a.step0Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:a.step0Subtitle}),(0,$.jsxs)(`label`,{className:`mt-9 block`,children:[(0,$.jsxs)(`span`,{className:`mb-2 flex items-center justify-between text-[13px] font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:a.profileCallNameLabel}),(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r===`zh`?`可选`:`Optional`})]}),(0,$.jsx)(`input`,{autoFocus:!0,autoComplete:`name`,value:g,onChange:e=>s({type:`patch`,patch:{callName:e.target.value}}),onKeyDown:e=>{e.key===`Enter`&&!m&&y()},placeholder:a.profileCallNamePlaceholder,className:`h-12 w-full rounded-xl border border-edge bg-surface-base/80 px-3.5 text-[15px] text-fg outline-none transition-[border-color,box-shadow,background-color] duration-200 placeholder:text-fg-subtle hover:border-edge-strong focus:border-accent focus:bg-surface-base focus:ring-4 focus:ring-accent/10 motion-reduce:transition-none`})]}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:h?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:h}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(vX,{step:d,label:_}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:m,onClick:()=>void y(),children:[m?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,m?a.savingProfile:a.continue,m?null:(0,$.jsx)(lr,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,d===`provider`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:r===`zh`?`模型设置`:`Model setup`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:a.step1Title}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:a.step1Subtitle}),(0,$.jsx)(`div`,{className:`mt-8`,children:(0,$.jsx)(YJ,{onSelect:e=>s({type:`patch`,patch:{selectedProvider:e,step:`apiKey`,apiKey:``,error:null}}),onBrowseProviders:()=>l(!0),disabled:m,browseDisabled:u.loading})}),(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:h?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:h}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-8`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`justify-self-start`,onClick:()=>s({type:`patch`,patch:{step:`callName`,error:null}}),children:a.back}),(0,$.jsx)(vX,{step:d,label:_}),(0,$.jsx)(`span`,{})]})]}):null,d===`apiKey`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-accent-fg`,children:a.step2Title}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:f===`xopc-cloud`?r===`zh`?`连接 XOPC Cloud`:`Connect XOPC Cloud`:r===`zh`?`连接 ${f??``}`:`Connect ${f??``}`}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:f===`xopc-cloud`?r===`zh`?`登录后会自动同步可用模型,不需要填写 API Key。`:`Sign in to sync available models automatically. No API key is required.`:a.step2Subtitle}),(0,$.jsx)(`div`,{className:`mt-9`,children:f===`xopc-cloud`?(0,$.jsx)(iY,{providerId:`xopc-cloud`,displayName:`XOPC Model Service`,connected:!1,onConnected:()=>void C()}):(0,$.jsxs)($.Fragment,{children:[f&&lY[f]?.apiKeyUrl?(0,$.jsxs)(`a`,{href:lY[f].apiKeyUrl,target:`_blank`,rel:`noopener noreferrer`,className:`mb-4 inline-flex items-center gap-1.5 text-sm font-medium text-accent-fg hover:underline`,children:[r===`zh`?`获取 API Key`:`Get an API key`,(0,$.jsx)(I,{className:`size-3.5`})]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:a.step2Placeholder}),(0,$.jsx)(Od,{value:p,onChange:e=>s({type:`patch`,patch:{apiKey:e}}),placeholder:a.step2Placeholder,labels:Ad(xe(r).providersSettings),inputClassName:`h-12 rounded-xl bg-surface-base/80 px-3.5 text-[15px] ring-accent focus:border-accent focus:ring-4 focus:ring-accent/10`})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`size-4 text-accent-fg`}),a.step2SecurityNote.replace(`🔒 `,``)]})]})}),m&&f===`xopc-cloud`?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r===`zh`?`正在应用推荐模型…`:`Applying the recommended model…`}):null,(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:h?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:h}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`justify-self-start`,disabled:m,onClick:()=>s({type:`patch`,patch:{step:`provider`,error:null}}),children:a.back}),(0,$.jsx)(vX,{step:d,label:_}),f===`xopc-cloud`?(0,$.jsx)(`span`,{}):(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:m||!p.trim(),onClick:()=>void S(),children:[m?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,a.continue,m?null:(0,$.jsx)(lr,{className:`size-4`,"aria-hidden":!0})]})]})]}):null,d===`success`?(0,$.jsxs)(`div`,{className:`flex min-h-[30rem] flex-col`,children:[(0,$.jsx)(`span`,{className:`flex size-11 items-center justify-center rounded-xl bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,children:(0,$.jsx)(j,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`mt-6 text-xs font-medium tracking-wide text-accent-fg`,children:r===`zh`?`模型设置完成`:`Model setup complete`}),(0,$.jsx)(`h1`,{className:`mt-3 text-[2rem] font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:r===`zh`?`一切准备好了`:`You’re ready to go`}),(0,$.jsx)(`p`,{className:`mt-3 max-w-md text-sm leading-6 text-fg-muted`,children:r===`zh`?`聊天模型已经可用。图片生成、语音和电脑控制等能力可以稍后按需配置。`:`Your chat model is ready. Image, voice, and computer-use capabilities can be configured later.`}),o.connectedModelRef?(0,$.jsxs)(`div`,{className:`mt-8 rounded-xl bg-surface-hover/25 px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r===`zh`?`默认聊天模型`:`Default chat model`}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium text-fg`,title:o.connectedModelRef,children:o.connectedModelRef})]}):null,(0,$.jsx)(`div`,{className:`mt-3 min-h-5`,children:h?(0,$.jsx)(`p`,{className:`text-sm text-danger`,role:`alert`,children:h}):null}),(0,$.jsxs)(`div`,{className:`mt-auto grid grid-cols-[1fr_auto_1fr] items-center gap-3 pt-10`,children:[(0,$.jsx)(`span`,{}),(0,$.jsx)(vX,{step:d,label:_}),(0,$.jsxs)(X,{variant:`primary`,className:`h-11 justify-self-end px-5`,disabled:m,onClick:()=>void x(),children:[m?(0,$.jsx)(ue,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,r===`zh`?`开始使用 XOPC`:`Start using XOPC`,m?null:(0,$.jsx)(lr,{className:`size-4`,"aria-hidden":!0})]})]})]}):null]},d)})]}),(0,$.jsx)(NY,{open:c,onOpenChange:l,builtinRows:u.builtinRows,customConfig:u.customConfig,labels:xe(r).capabilitiesSettings.addProviderDialog,language:r,onSaved:e=>void w(e)})]})}function bX(e){return e?.enabled===!0&&(e.state.status===`not_started`||e.state.status===`in_progress`)}function xX(e){let t=e.needsModelSetup&&!e.modelGuideDismissed,n=!e.needsModelSetup&&bX(e.workDiscovery);return{open:e.authenticated&&!e.settingsRoute&&e.modelSetupReady&&!e.closed&&(t||n),stage:t?`setup`:`work`}}var SX=new Set([`completed`,`failed`,`canceled`]);function CX(){return new Promise(e=>window.setTimeout(e,1200))}async function wX(e,t){let n=[],r=t.wait??CX;for(let i=0;i<e.length&&!t.shouldStop?.();i+=1){let a=e[i];if(a)try{await t.grantDirectory(a.rootPath);let o=await t.startRun(a.rootPath);for(t.onRun(o,i,e.length);!SX.has(o.status)&&!t.shouldStop?.();)await r(),o=await t.fetchRun(o.id),t.onRun(o,i,e.length);if(n.push(o),o.status===`canceled`||t.shouldStop?.())break}catch(e){if(t.onError?.(e,a,i),t.shouldStop?.())break}}return n}function TX(e,t){let n=e.result?.conversationStarter?.trim();if(n)return n;let r=e.result?.suggestions.find(t=>t.id===e.result?.primarySuggestionId)??e.result?.suggestions[0];if(r?.actionPrompt.trim())return r.actionPrompt.trim();let i=e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return t===`zh`?`请先结合 ${i} 当前目录和最近变更,帮我说明这个项目在做什么、现在最值得关注什么,以及建议我下一步从哪里开始。`:`Help me understand ${i}: explain what this project is doing, what matters most right now, and where I should start next.`}var EX={zh:{eyebrow:`当前理解`,summaryTitle:`我理解的是这样`,summaryQuestion:`可以继续,也可以随时修改。`,matches:`准确,继续`,adjust:`修改`,why:`查看依据`,evidenceHint:`这些内容只用于本次判断。`,current:`当前`,ongoing:`持续`,longTerm:`长期`,correctionTitle:`告诉我正确的重点`,correctionPlaceholder:`你现在真正想推进什么?`,continueWithCorrection:`按此继续`,starterTitle:`从这里开始`,starterHint:`可以修改后直接开始对话。`,startConversation:`进入对话`,cancel:`取消`},en:{eyebrow:`Current understanding`,summaryTitle:`Here’s how I understand it`,summaryQuestion:`Continue, or adjust this anytime.`,matches:`Accurate, continue`,adjust:`Edit`,why:`View sources`,evidenceHint:`These sources are only used for this assessment.`,current:`Current`,ongoing:`Ongoing`,longTerm:`Long term`,correctionTitle:`Tell me the right focus`,correctionPlaceholder:`What do you want to move forward right now?`,continueWithCorrection:`Continue`,starterTitle:`Start here`,starterHint:`Edit this if needed, then start the conversation.`,startConversation:`Start conversation`,cancel:`Cancel`}};function DX(e){let t=(0,Q.c)(76),{run:n,language:r,busy:i,error:a,onFinish:o,onStartConversation:s}=e,c=EX[r],l=n.result?.lowConfidence===!0,u;t[0]!==r||t[1]!==n?(u=TX(n,r),t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=u,[f,p]=(0,Z.useState)(l),[m,h]=(0,Z.useState)(l?d:``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),S,C,w,T,E,D,O,k,A,j,M;if(t[3]!==m||t[4]!==b||t[5]!==o||t[6]!==s||t[7]!==n.result||t[8]!==c.current||t[9]!==c.evidenceHint||t[10]!==c.eyebrow||t[11]!==c.longTerm||t[12]!==c.ongoing||t[13]!==c.summaryTitle||t[14]!==c.why){let e=n.result?.workThreads?.slice(0,3)??[],r=n.result?.suggestions.find(e=>e.id===n.result?.primarySuggestionId)??n.result?.suggestions[0],i;t[26]!==m||t[27]!==o?(i=async e=>{_(!0),await o(e,e===`corrected`?m.trim():void 0)||_(!1)},t[26]=m,t[27]=o,t[28]=i):i=t[28],S=i;let a;t[29]!==m||t[30]!==s?(a=async()=>{let e=m.trim();e&&(y(!0),await s(e,`corrected`)||y(!1))},t[29]=m,t[30]=s,t[31]=a):a=t[31],C=a,M=`xopc-understanding-reveal flex min-h-full flex-1 flex-col`,w=`polite`,k=`xopc-reveal-scene mx-auto flex w-full max-w-[40rem] flex-1 flex-col justify-center py-6 text-center sm:py-10`,t[32]===c.eyebrow?A=t[33]:(A=(0,$.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.2em] text-accent-fg`,children:c.eyebrow}),t[32]=c.eyebrow,t[33]=A),t[34]===c.summaryTitle?j=t[35]:(j=(0,$.jsx)(`h1`,{className:`mx-auto mt-4 max-w-[34rem] text-3xl font-semibold tracking-[-0.035em] text-fg sm:text-[2.25rem]`,children:c.summaryTitle}),t[34]=c.summaryTitle,t[35]=j),T=`xopc-understanding-hero-card relative mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel px-6 py-7 text-left shadow-surface sm:px-8`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(`div`,{className:`mb-5 flex size-9 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,"aria-hidden":!0,children:(0,$.jsx)(ta,{className:`size-[1.125rem]`})}),t[36]=E):E=t[36];let l=n.result?.projectSummary;t[37]===l?D=t[38]:(D=(0,$.jsx)(`p`,{className:`relative text-lg font-medium leading-8 text-fg sm:text-xl`,children:l}),t[37]=l,t[38]=D),O=n.result?.currentState||e.length||r?.evidence.length?(0,$.jsxs)(`div`,{className:`relative mt-5 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>x(kX),children:[c.why,(0,$.jsx)(cr,{className:K(`size-3.5 transition-transform`,b&&`rotate-180`)})]}),b?(0,$.jsxs)(`div`,{className:`mt-3 space-y-3 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`text-fg-subtle`,children:c.evidenceHint}),n.result?.currentState?(0,$.jsx)(`p`,{children:n.result.currentState}):null,e.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,$.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.title}),` · `,e.horizon===`current`?c.current:e.horizon===`ongoing`?c.ongoing:c.longTerm]},e.id))}):null,r?.evidence.slice(0,3).map(OX)]}):null]}):null,t[3]=m,t[4]=b,t[5]=o,t[6]=s,t[7]=n.result,t[8]=c.current,t[9]=c.evidenceHint,t[10]=c.eyebrow,t[11]=c.longTerm,t[12]=c.ongoing,t[13]=c.summaryTitle,t[14]=c.why,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E,t[20]=D,t[21]=O,t[22]=k,t[23]=A,t[24]=j,t[25]=M}else S=t[15],C=t[16],w=t[17],T=t[18],E=t[19],D=t[20],O=t[21],k=t[22],A=t[23],j=t[24],M=t[25];let N;t[39]!==T||t[40]!==E||t[41]!==D||t[42]!==O?(N=(0,$.jsxs)(`div`,{className:T,children:[E,D,O]}),t[39]=T,t[40]=E,t[41]=D,t[42]=O,t[43]=N):N=t[43];let P;t[44]!==S||t[45]!==i||t[46]!==v||t[47]!==m||t[48]!==f||t[49]!==l||t[50]!==C||t[51]!==g||t[52]!==c.adjust||t[53]!==c.cancel||t[54]!==c.continueWithCorrection||t[55]!==c.correctionPlaceholder||t[56]!==c.correctionTitle||t[57]!==c.matches||t[58]!==c.startConversation||t[59]!==c.starterHint||t[60]!==c.starterTitle||t[61]!==c.summaryQuestion?(P=f?(0,$.jsxs)(`div`,{className:`xopc-reveal-calibration mx-auto mt-7 w-full max-w-xl rounded-xl border border-edge bg-surface-panel p-5 text-left shadow-surface`,children:[(0,$.jsx)(`label`,{className:`text-sm font-semibold text-fg`,htmlFor:`understanding-correction`,children:l?c.starterTitle:c.correctionTitle}),l?(0,$.jsx)(`p`,{className:`mt-1.5 text-xs leading-5 text-fg-muted`,children:c.starterHint}):null,(0,$.jsx)(`textarea`,{id:`understanding-correction`,value:m,onChange:e=>h(e.target.value),placeholder:c.correctionPlaceholder,className:`mt-3 min-h-24 w-full resize-y rounded-xl border border-edge bg-surface-base px-3 py-2.5 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/15`}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[l?null:(0,$.jsx)(X,{variant:`ghost`,disabled:g,onClick:()=>p(!1),children:c.cancel}),(0,$.jsx)(X,{variant:`primary`,disabled:i||v||!m.trim(),onClick:()=>void C(),children:l?c.startConversation:c.continueWithCorrection})]})]}):(0,$.jsxs)(`div`,{className:`mx-auto mt-8 w-full max-w-sm`,children:[(0,$.jsx)(`p`,{className:`text-base font-medium text-fg`,children:c.summaryQuestion}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,$.jsx)(X,{className:`h-11 flex-1`,variant:`primary`,disabled:g,onClick:()=>void S(`confirmed`),children:c.matches}),(0,$.jsx)(X,{className:`h-11 flex-1`,variant:`secondary`,disabled:g,onClick:()=>p(!0),children:c.adjust})]})]}),t[44]=S,t[45]=i,t[46]=v,t[47]=m,t[48]=f,t[49]=l,t[50]=C,t[51]=g,t[52]=c.adjust,t[53]=c.cancel,t[54]=c.continueWithCorrection,t[55]=c.correctionPlaceholder,t[56]=c.correctionTitle,t[57]=c.matches,t[58]=c.startConversation,t[59]=c.starterHint,t[60]=c.starterTitle,t[61]=c.summaryQuestion,t[62]=P):P=t[62];let F;t[63]===a?F=t[64]:(F=a?(0,$.jsx)(`p`,{className:`mt-5 text-sm text-danger`,role:`alert`,children:a}):null,t[63]=a,t[64]=F);let I;t[65]!==N||t[66]!==P||t[67]!==F||t[68]!==k||t[69]!==A||t[70]!==j?(I=(0,$.jsxs)(`div`,{className:k,children:[A,j,N,P,F]}),t[65]=N,t[66]=P,t[67]=F,t[68]=k,t[69]=A,t[70]=j,t[71]=I):I=t[71];let L;return t[72]!==w||t[73]!==I||t[74]!==M?(L=(0,$.jsx)(`section`,{className:M,"aria-live":w,children:I}),t[72]=w,t[73]=I,t[74]=M,t[75]=L):L=t[75],L}function OX(e,t){return(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(se,{className:`mt-0.5 size-3.5 shrink-0 text-accent-fg`}),(0,$.jsxs)(`span`,{children:[e.path?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`font-mono text-fg`,children:e.path}),`: `]}):null,e.observation]})]},`${t}-${e.path??e.observation}`)}function kX(e){return!e}function AX(e,t){return Object.fromEntries(e.map(e=>[e,t]))}function jX(e,t){let n=AX(t,`running`);for(let t of e)n[t.sourceId]=t.status;return n}async function MX(e){if(!e)return;let t=Date.now()+75e3;for(;Date.now()<t;){try{let t=await WD(e);if(PX.getState().updateDirectoryRun(t),t.status===`completed`||t.status===`failed`||t.status===`canceled`)return}catch{}await new Promise(e=>window.setTimeout(e,800))}}var NX={status:`idle`,drawerOpen:!1,directoryStatus:`idle`,directoryRun:null,sources:{},itemCounts:{},memories:[],threads:[],error:void 0},PX=Oe((e,t)=>({...NX,setDrawerOpen:n=>{!n&&t().status===`completed`?e({...NX}):e({drawerOpen:n})},finish:()=>e({...NX}),updateDirectoryRun:n=>{let r=n.status===`completed`?`completed`:n.status===`failed`||n.status===`canceled`?`failed`:`running`,i=Object.values(t().sources).every(e=>e!==`running`&&e!==`idle`),a=Object.values(t().sources).some(e=>e===`denied`||e===`failed`||e===`partial`);e({directoryStatus:r,directoryRun:n,status:r===`completed`&&i?a?`partial`:`completed`:r===`failed`&&i?`partial`:`running`})},collectSources:async(n,r,i)=>{let a=window.electronAPI?.understandingSources?.collect;if(!(!a||!r.length)){e({status:`running`,sources:AX(r,`running`),itemCounts:Object.fromEntries(r.map(e=>[e,0])),memories:[],threads:[],error:void 0});try{let o=await a(r),s=jX(o,r),c=Object.fromEntries(o.map(e=>[e.sourceId,e.items.length]));e({sources:s,itemCounts:c});let l=o.flatMap(e=>e.status===`completed`?e.items:[]),u=Object.fromEntries(o.flatMap(e=>e.checkpoint?[[e.sourceId,e.checkpoint]]:[]));l.length&&await MX(n);let d=l.length?await HD(l,n,i,u):{profileCandidates:[],workThreads:[],knowledgeCandidates:[],sourceStatuses:[]};for(let e of d.sourceStatuses)s[e.sourceId]=e.status;let f=d.profileCandidates,p=Object.values(s).some(e=>e===`denied`||e===`failed`||e===`partial`),m=d.sourceStatuses.flatMap(e=>e.error?[e.error]:[]),h=!n||t().directoryStatus===`completed`;e({sources:s,itemCounts:c,memories:f,threads:d.workThreads,...m.length?{error:m.join(`; `)}:{},status:h?p?`partial`:`completed`:`running`})}catch(t){e(e=>({status:`partial`,sources:Object.fromEntries(Object.entries(e.sources).map(([e,t])=>[e,t===`running`?`failed`:t])),error:t instanceof Error?t.message:String(t)}))}}}})),FX={folder:oe,file:zr,recent:Nr,git:se,calendar:or,task:oi,note:$n,mail:si,message:pi,service:Ii,data:Or};function IX(e){let t=(0,Q.c)(28),{signals:n,ariaLabel:r,centerLabel:i}=e,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==i||t[2]!==n){let e=n.slice(0,3);a=Math.max(0,n.length-e.length),c=`xopc-source-convergence mx-auto mt-9 w-full max-w-[34rem] overflow-hidden rounded-xl border border-edge bg-surface-panel px-5 py-6 shadow-surface sm:px-6`,l=`img`,u=r;let p;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsxs)(`div`,{className:`xopc-source-convergence-core relative flex size-16 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`xopc-source-convergence-core-glow absolute -inset-5 rounded-full`}),(0,$.jsx)(GI,{className:`relative size-12`})]}),t[11]=p):p=t[11],t[12]===i?d=t[13]:(d=(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,"aria-hidden":!0,children:[p,(0,$.jsx)(`span`,{className:`mt-3 text-[11px] font-semibold tracking-[0.16em] text-fg-muted`,children:i})]}),t[12]=i,t[13]=d),t[14]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`div`,{className:`mt-5 h-1 overflow-hidden rounded-full bg-surface-hover`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`xopc-source-convergence-progress block h-full w-2/5 rounded-full bg-accent`})}),t[14]=f):f=t[14],o=`mt-5 divide-y divide-edge-subtle border-y border-edge-subtle`,s=e.map(LX),t[0]=r,t[1]=i,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[15]!==o||t[16]!==s?(p=(0,$.jsx)(`div`,{className:o,children:s}),t[15]=o,t[16]=s,t[17]=p):p=t[17];let m;t[18]===a?m=t[19]:(m=a>0?(0,$.jsxs)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,"aria-hidden":!0,children:[`+`,a]}):null,t[18]=a,t[19]=m);let h;return t[20]!==c||t[21]!==l||t[22]!==u||t[23]!==d||t[24]!==f||t[25]!==p||t[26]!==m?(h=(0,$.jsxs)(`div`,{className:c,role:l,"aria-label":u,children:[d,f,p,m]}),t[20]=c,t[21]=l,t[22]=u,t[23]=d,t[24]=f,t[25]=p,t[26]=m,t[27]=h):h=t[27],h}function LX(e){let t=FX[e.kind];return(0,$.jsxs)(`div`,{className:`flex min-h-12 items-center gap-3 py-2.5 text-left`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,title:e.detail,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.label}),e.meta?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:e.meta}):null]}),(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-accent`})]},e.id)}var RX={sm:{frame:`size-9 rounded-lg`,image:`size-7`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-8`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-10`,fallback:`size-5`}};function zX(e){let t=(0,Q.c)(15),{connector:n,size:r,className:i}=e,a=r===void 0?`md`:r,o=n?.branding?.logoUrl,[s,c]=(0,Z.useState)(!1),l=RX[a],u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{c(!1)},t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=[o],t[1]=o,t[2]=d),(0,Z.useEffect)(u,d);let f;t[3]!==i||t[4]!==l.frame?(f=K(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-white`,l.frame,i),t[3]=i,t[4]=l.frame,t[5]=f):f=t[5];let p=n?.displayName,m;t[6]!==l.fallback||t[7]!==l.image||t[8]!==s||t[9]!==o?(m=o&&!s?(0,$.jsx)(`img`,{src:o,alt:``,loading:`lazy`,draggable:!1,className:K(`object-contain`,l.image),onError:()=>c(!0)}):(0,$.jsx)(wi,{className:K(`text-fg-muted`,l.fallback),"aria-hidden":!0}),t[6]=l.fallback,t[7]=l.image,t[8]=s,t[9]=o,t[10]=m):m=t[10];let h;return t[11]!==f||t[12]!==p||t[13]!==m?(h=(0,$.jsx)(`span`,{className:f,title:p,children:m}),t[11]=f,t[12]=p,t[13]=m,t[14]=h):h=t[14],h}async function BX(e,t){let n=await q(J(e),t);if(!n.ok)throw Error(n.error??`Connection request failed.`);return n.payload}function VX({definition:e,instance:t,onClose:n,onChanged:r}){let i=Ee(e=>e.language)===`zh`,[a,o]=(0,Z.useState)(t),[s,c]=(0,Z.useState)(),[l,u]=(0,Z.useState)(),[d,f]=(0,Z.useState)(),[p,m]=(0,Z.useState)(),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(),y=a?.instanceId??e.id,b=(0,Z.useCallback)(async()=>{let e=await BX(`/api/connectors/${encodeURIComponent(y)}/accounts`);c(e),e.authorization&&u(e.authorization)},[y]);(0,Z.useEffect)(()=>{a&&b().catch(e=>v(String(e)))},[a,b]);let x=l&&[`preparing`,`awaiting_user`,`verifying`].includes(l.status);(0,Z.useEffect)(()=>{if(!x||!l)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await BX(`/api/connectors/authorizations/${l.id}`);if(e)return;u(t.authorization),t.authorization.status===`succeeded`&&(await b(),a&&await r(a))}catch(t){e||v(String(t))}finally{t=!1}}},i=()=>{n()},o=()=>{document.visibilityState===`visible`&&i()};i();let s=setInterval(i,1500);return window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,o),()=>{e=!0,clearInterval(s),window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,o)}},[x,l?.id,a,r,b]);let S=l?.challenge?.type===`qr_code`?l.challenge.artifactId:void 0;(0,Z.useEffect)(()=>{if(!S){f(void 0);return}let e=!1,t;return we(J(`/api/connectors/authorizations/${S}/artifact`)).then(async n=>{if(!n.ok)throw Error(`QR code unavailable.`);let r=await n.blob();e||(t=URL.createObjectURL(r),f(t))}).catch(t=>{e||v(String(t))}),()=>{e=!0,t&&URL.revokeObjectURL(t)}},[S]);let C=async t=>{g(!0),v(void 0);try{let n=a??await sl(e.id,{});o(n),u((await BX(`/api/connectors/${encodeURIComponent(n.instanceId)}/authorizations`,{method:`POST`,body:JSON.stringify({accountId:t})})).authorization)}catch(e){v(e instanceof Error?e.message:String(e))}finally{g(!1)}},w=async e=>{g(!0),v(void 0);try{await BX(`/api/connectors/${encodeURIComponent(y)}/policy`,{method:`PATCH`,body:JSON.stringify({maxScope:e})}),await b()}catch(e){v(String(e))}finally{g(!1)}},T=async e=>{g(!0),v(void 0);try{await BX(`/api/connectors/accounts/${encodeURIComponent(e)}`,{method:`DELETE`}),await b()}catch(e){v(String(e))}finally{g(!1)}},D=async e=>{if(a){g(!0),v(void 0);try{if(e===`remove`)await ul(y),await r(a),n();else if(e===`toggle`){let e=await Pl(y,!a.enabled);o(e),await r(e)}else{let e=await dl(y);m(e.ok?i?`验证通过,可用操作:${e.toolCount}`:`Verified: ${e.toolCount} actions`:e.error??e.action??e.status)}}catch(e){v(String(e))}finally{g(!1)}}},k=()=>{a&&r(a),n()};return(0,$.jsx)(nt,{open:!0,onOpenChange:e=>{e||k()},children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`fixed inset-0 z-50 bg-black/40`}),(0,$.jsxs)(et,{className:`fixed left-1/2 top-1/2 z-50 flex h-[min(38rem,calc(100dvh-2rem))] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel text-fg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(tt,{className:`font-semibold`,children:e.displayName}),(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:i?`连接账号并设置允许的操作。`:`Connect an account and choose allowed actions.`})]}),(0,$.jsx)(X,{variant:`ghost`,onClick:k,"aria-label":i?`关闭`:`Close`,children:(0,$.jsx)(ye,{className:`size-4`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[_?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:_}):null,a&&!s?(0,$.jsx)(xn,{className:`h-24 w-full`}):null,a?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{disabled:h||!!x,onClick:()=>void D(`toggle`),children:a.enabled?i?`停用`:`Disable`:i?`启用`:`Enable`}),(0,$.jsx)(X,{disabled:h||!!x||!a.enabled,onClick:()=>void D(`test`),children:i?`检查连接`:`Check connection`}),(0,$.jsx)(X,{variant:`ghost`,disabled:h||!!x,onClick:()=>void D(`remove`),children:i?`移除连接器`:`Remove connector`})]}):null,p?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}):null,s?.accounts.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:e.label??e.id}),(0,$.jsx)(`p`,{className:`break-all text-xs text-fg-muted`,children:String(e.identity.openId??e.identity.botId??e.identity.userId??e.id)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.enabled&&e.status===`active`?i?`已连接`:`Connected`:i?`已断开`:`Disconnected`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(X,{variant:`secondary`,disabled:h||!!x||a?.enabled===!1,onClick:()=>void C(e.id),children:i?`重新连接`:`Reconnect`}),(0,$.jsx)(X,{variant:`ghost`,disabled:h||!!x||!e.enabled,onClick:()=>void T(e.id),children:i?`断开本地连接`:`Disconnect locally`})]})]},e.id)),s?.policy?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-sm`,children:i?`允许的操作`:`Allowed actions`}),(0,$.jsxs)(E,{value:s.policy.maxScope,onChange:e=>void w(e.target.value),disabled:h,children:[(0,$.jsx)(O,{value:`read`,children:i?`仅查看`:`Read only`}),(0,$.jsx)(O,{value:`write`,children:i?`查看并执行操作`:`Read and write`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`写入操作需要确认。断开本地连接不会撤销第三方授权。`:`Writes require confirmation. Local disconnection does not revoke provider authorization.`})]}):null,l?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,"aria-live":`polite`,children:[(0,$.jsx)(`p`,{className:`text-sm`,children:l.status===`succeeded`?i?`账号验证成功`:`Account verified`:l.status===`preparing`?i?`正在准备授权…`:`Preparing authorization…`:l.status===`verifying`?i?`授权已完成,正在验证账号…`:`Authorization complete. Verifying account…`:x?i?`请完成当前步骤,返回后会自动检查结果。`:`Complete this step. We will check the result when you return.`:l.error??(i?`授权已结束,请重新连接。`:`Authorization ended. Connect again.`)}),x&&l.challenge&&l.challenge.totalSteps>1?(0,$.jsxs)(`p`,{className:`text-sm font-medium`,children:[i?`第 ${l.challenge.step} / ${l.challenge.totalSteps} 步`:`Step ${l.challenge.step} of ${l.challenge.totalSteps}`,l.challenge.step>1?i?`:上一步已完成,请打开新的授权页面继续。`:`: Previous step complete. Open the new authorization page to continue.`:i?`:完成后还需要继续授权账号。`:`: Account authorization follows this step.`]}):null,x&&l.challenge?.type===`open_url`?(0,$.jsx)(`a`,{href:l.challenge.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-sm text-accent underline`,children:i?`打开授权页面`:`Open authorization page`},l.challenge.url):null,x&&S?d?(0,$.jsx)(`img`,{src:d,alt:i?`授权二维码`:`Authorization QR code`,className:`mx-auto size-56 bg-white object-contain`}):(0,$.jsx)(xn,{className:`mx-auto size-56`}):null,x?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>{BX(`/api/connectors/authorizations/${l.id}/cancel`,{method:`POST`}).then(()=>u({...l,status:`cancelled`,challenge:void 0})).catch(e=>v(String(e)))},children:i?`取消授权`:`Cancel authorization`}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(X,{variant:`secondary`,onClick:k,children:i?`关闭`:`Close`}),(0,$.jsxs)(X,{disabled:h||!!x||a?.enabled===!1,onClick:()=>void C(),children:[h?(0,$.jsx)(ue,{className:`mr-2 size-4 animate-spin`}):null,i?`连接账号`:`Connect account`]})]})]})]})})}function HX(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function UX(e,t){return e.runtime.type===`composio`?t.connectorDescriptions[e.runtime.toolkit.toLowerCase()]??e.description:e.description}function WX(e){return e instanceof Error?e.message:String(e)}function GX(e,t){let n=WX(e);return/APIKey_InsufficientPermissions/i.test(n)||/["\\]?code["\\]?\s*:\s*812\b/i.test(n)||/session_management/i.test(n)&&/write access|write permission|at least ["\\]?write/i.test(n)?t.composioSessionWritePermissionRequired:n}var KX=K(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,xd),qX=K(KX,`min-h-28 font-mono`);function JX(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function YX(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function XX({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=UX(a,i),s=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,l=a.understanding!=null,[u,d]=(0,Z.useState)(!s),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(s),[g,_]=(0,Z.useState)(null),[v,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!s)return;let e=!1;return nl().then(t=>{e||(p(t),d(t.configured))}).catch(t=>{e||_(t instanceof Error?t.message:String(t))}).finally(()=>{e||h(!1)}),()=>{e=!0}},[a.id,s]),(0,Z.useEffect)(()=>{if(!c||!u)return;let e=!1;return S(!0),pl(c).then(t=>{e||b(t)}).catch(t=>{e||_(t instanceof Error?t.message:String(t))}).finally(()=>{e||S(!1)}),()=>{e=!0}},[u,c]);let T=(0,Z.useCallback)(async()=>{let n=An(),o=a.runtime.type===`mcp`&&a.auth.mode===`oauth`,d=(s||o)&&!n?window.open(``,`_blank`):null;d&&(d.opener=null),_(null),t({...e,installing:!0,error:null,result:null,health:null});try{if(s&&!u)throw Error(i.composioSetupSignInRequired);let f=s&&c?v??await pl(c):null,p=e.config.authConfigId?.trim();if(f?.requiresCustomAuthConfig&&!p)throw Error(i.composioAuthConfigRequired);if(p){let e=f?.authConfigs.find(e=>e.id===p);if(!e||e.status!==`ENABLED`||!e.isEnabledForToolRouter)throw Error(i.composioAuthConfigUnavailable)}let m={};for(let t of a.setup.config??[]){let n=YX(t.type,e.config[t.key]??``);n!==void 0&&(m[t.key]=n)}p&&(m.authConfigId=p);let h=e.store?await Qc(e.store.packageName,{secrets:e.secrets,config:m},e.store.version):await sl(a.id,{secrets:e.secrets,config:m,definition:a.source===`registry`?a:void 0}),g=null;try{if(s){let e=await el(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else d?d.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await ml(c,e.connectionId,12e4,e.attemptId);if(d?.close(),l&&C){if(!t.accountId)throw Error(`Connector account is unavailable.`);await Dl(t.accountId)}}else if(o){let e=await el(h.instanceId);if(!e.authorizationUrl&&e.status!==`connected`)throw Error(`The MCP server did not return an authorization URL.`);if(e.authorizationUrl)if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else d?d.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);await tl(h.instanceId),d?.close()}}catch(n){d?.close(),t({...e,installing:!1,result:null,health:null,error:s?GX(n,i):n instanceof Error?n.message:String(n)}),await r(h);return}if(!s)try{g=await dl(h.instanceId)}catch{g=null}t({...e,installing:!1,result:h,health:g}),await r(h)}catch(n){d?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[l,v,u,c,a,e,s,C,t,r,i.composioAuthConfigRequired,i.composioAuthConfigUnavailable,i.composioSetupSignInRequired]),D=v?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[],k=v?.requiresCustomAuthConfig===!0,A=u&&k&&!e.config.authConfigId?.trim();return(0,$.jsx)(nt,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(et,{className:K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,s?`max-h-[calc(100dvh-2rem)] w-[min(100%-2rem,32rem)]`:`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,42rem)]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(zX,{connector:a,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:HX(i.connectDialogTitle,{name:a.displayName})}),(0,$.jsx)(Ze,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o})]})]}),(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:K(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(ye,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsx)(`div`,{className:K(`min-h-0 overflow-y-auto px-6 py-5`,!s&&`flex-1`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[s&&m?(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,"aria-busy":`true`,"aria-label":i.composioSetupTitle,children:[(0,$.jsx)(xn,{className:`h-4 w-40`}),(0,$.jsx)(xn,{className:`mt-2 h-3 w-72 max-w-full`}),(0,$.jsx)(xn,{className:`mt-3 h-16 w-full rounded-xl`})]}):s&&!u?(0,$.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(iY,{providerId:`xopc-cloud`,displayName:`XOPC Cloud`,connected:!1,onConnected:()=>{nl().then(e=>{p(e),d(e.configured)})}})}),(0,$.jsx)(y,{to:`/settings/connector-service`,onClick:n,className:`mt-3 block text-xs text-accent-fg`,children:i.composioSetupByok})]}):null,s&&l?(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:C,onChange:e=>w(e.currentTarget.checked)}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,s&&u&&f?.mode===`managed`?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:k?i.composioCloudAuthUnavailable:i.composioSetupManaged}):null,s&&u&&f?.mode===`byok`?(0,$.jsxs)(`details`,{open:k,className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:i.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:k?i.composioAuthConfigRequiredHint:i.composioAuthConfigManaged})]}),f?.mode===`byok`?(0,$.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioAuthConfigManage,(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0})]}):(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:i.composioSetupManaged})]}),x?(0,$.jsx)(xn,{className:`mt-3 h-10 w-full`}):(0,$.jsxs)(E,{className:K(KX,`mt-3`),value:e.config.authConfigId??``,onChange:n=>t({...e,config:{...e.config,authConfigId:n.currentTarget.value},error:null}),children:[k?null:(0,$.jsx)(O,{value:``,children:i.composioAuthConfigManaged}),k&&!e.config.authConfigId?(0,$.jsx)(O,{value:``,disabled:!0,children:i.composioAuthConfigSelect}):null,D.map(e=>(0,$.jsxs)(O,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`,` · `,e.id]},e.id))]}),!x&&k&&D.length===0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-700 dark:text-amber-300`,children:i.composioAuthConfigEmpty}):null]}):null,s&&u&&f?.mode===`byok`?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:i.composioSessionWritePermissionHint}):null,e.store?(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,$.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,$.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,$.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.links??[]).length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 rounded-xl border border-edge bg-surface-base p-3`,children:(a.setup.links??[]).map(e=>{let t=e.external!==!1&&/^https:\/\//i.test(e.href);return(0,$.jsxs)(`a`,{href:t?e.href:`#${e.href}`,target:t?`_blank`:void 0,rel:t?`noopener noreferrer`:void 0,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent-fg hover:underline`,children:[e.label,t?(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}):null]},`${e.label}:${e.href}`)})}):null,(a.setup.secrets??[]).map(n=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,$.jsx)(Od,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,$.jsx)(`textarea`,{className:qX,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,$.jsx)(`input`,{className:KX,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,$.jsx)(ue,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,$.jsx)(`p`,{className:`min-w-0 max-w-full break-words rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600 [overflow-wrap:anywhere]`,children:e.error}):null,g?(0,$.jsx)(`p`,{className:`min-w-0 max-w-full break-words rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600 [overflow-wrap:anywhere]`,children:g}):null,e.result?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,$.jsx)(`span`,{className:K(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:JX(e.health?.status,i)})]}),(0,$.jsx)(`p`,{className:`mt-3`,children:e.health?.ok?i.connectionReady:e.health?i.connectionNeedsSetup:i.installedWithoutHealth}),e.health?.action?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})}),(0,$.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,$.jsxs)(X,{variant:`primary`,disabled:!!e.result||e.installing||m||x||A||s&&!u,onClick:()=>void T(),children:[e.installing?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):e.result?(0,$.jsx)(j,{className:`size-4`}):(0,$.jsx)(wi,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function ZX(e){let t=(0,Q.c)(2),n;return t[0]===e?n=t[1]:(n=e.draft.connector.runtime.type===`cli`?(0,$.jsx)(VX,{definition:e.draft.connector,onClose:e.onClose,onChanged:e.onInstalled}):(0,$.jsx)(XX,{...e}),t[0]=e,t[1]=n),n}function QX(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}var $X=[`gmail`,`googlecalendar`,`googledrive`,`github`,`linear`];function eZ({toolkit:e,displayName:t,description:n,category:r,mode:i,bootstrapWindowDays:a,logoFileName:o=e}){return{id:`composio-${e}`,version:`sessions-v1`,displayName:t,description:n,category:r,kind:`composio`,source:`registry`,capabilities:[`tools`,`auth.oauth`,`events`,`workflows`,`context`,`memory_source`],benefits:[`understand`,`act`],understanding:{mode:i,bootstrapWindowDays:a,readOnly:!0},tags:[`composio`,e,`verified`],branding:{logoUrl:`/connector-icons/${o}.svg`,source:`builtin`},verificationLevel:`verified`,auth:{mode:`oauth`,provider:`composio`},setup:{},runtime:{type:`composio`,toolkit:e,role:`toolkit`},integrationStrategy:{lane:`composio`,workload:`long_tail`,preferred:!0}}}var tZ=[eZ({toolkit:`gmail`,displayName:`Gmail`,description:`Find and understand recent email, then draft or send with your approval.`,category:`automation`,mode:`activity`,bootstrapWindowDays:30}),eZ({toolkit:`googlecalendar`,displayName:`Google Calendar`,description:`Understand your schedule and work with approved calendar events.`,category:`automation`,mode:`activity`,bootstrapWindowDays:90,logoFileName:`google-calendar`}),eZ({toolkit:`googledrive`,displayName:`Google Drive`,description:`Search and understand approved files in Google Drive.`,category:`data`,mode:`inventory`,bootstrapWindowDays:90,logoFileName:`google-drive`}),eZ({toolkit:`github`,displayName:`GitHub`,description:`Understand repositories, issues, pull requests, and reviews.`,category:`code`,mode:`activity`,bootstrapWindowDays:90}),eZ({toolkit:`linear`,displayName:`Linear`,description:`Understand and work with Linear issues and projects.`,category:`code`,mode:`activity`,bootstrapWindowDays:60})];function nZ(e){return e.runtime.type===`composio`&&e.runtime.role===`toolkit`?e.runtime.toolkit.toLocaleLowerCase():``}function rZ(e){let t=new Map($X.map((e,t)=>[e,t]));return e.filter(e=>e.understanding!=null&&nZ(e)).sort((e,n)=>(t.get(nZ(e))??2**53-1)-(t.get(nZ(n))??2**53-1)||e.displayName.localeCompare(n.displayName))}function iZ(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return rZ([...n.values()])}var aZ=2500;function oZ(e){return!!(e?.enabled&&(e.status===`connected`||e.connectionStatus===`connected`||e.authStatus===`connected`))}function sZ(e){return e===`gmail`?`mail`:e===`googlecalendar`?`calendar`:e===`googledrive`?`data`:e===`github`?`git`:e===`linear`?`task`:`service`}function cZ(e){let t=(0,Q.c)(58),{busy:n,onBack:r,onContinue:i,onSkip:a,onConnectedSignalsChange:o}=e,s=xe(Ee(pZ)),c=s.onboarding.workDiscovery,l=s.connectorsSettings,[u,d]=(0,Z.useState)(fZ),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),[h,g]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C=async()=>{let e=await $c();return m(e),e},t[1]=C):C=t[1];let w=C,T,E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{let e=!1,t=window.setTimeout(()=>{e||g(!1)},aZ);return $c().then(t=>{e||m(t)}).catch(t=>{e||v(t instanceof Error?t.message:String(t))}).finally(()=>{e||g(!1),window.clearTimeout(t)}),Yc({page:1,pageSize:24,verification:`verified`}).then(t=>{e||d(iZ(tZ,t.connectors))}).catch(dZ),()=>{e=!0,window.clearTimeout(t)}},E=[],t[2]=T,t[3]=E):(T=t[2],E=t[3]),(0,Z.useEffect)(T,E);let D;t[4]===p?D=t[5]:(D=new Map(p.map(uZ)),t[4]=p,t[5]=D);let O=D,k;if(t[6]!==u||t[7]!==O){let e;t[9]===O?e=t[10]:(e=e=>{if(!oZ(O.get(e.id)))return[];let t=nZ(e);return[{id:e.id,label:e.displayName,kind:sZ(t)}]},t[9]=O,t[10]=e),k=u.flatMap(e),t[6]=u,t[7]=O,t[8]=k}else k=t[8];let A=k,M,N;t[11]!==A||t[12]!==o?(M=()=>{o(A)},N=[A,o],t[11]=A,t[12]=o,t[13]=M,t[14]=N):(M=t[13],N=t[14]),(0,Z.useEffect)(M,N);let P;t[15]!==u||t[16]!==y?(P=y?u:u.slice(0,3),t[15]=u,t[16]=y,t[17]=P):P=t[17];let F=P,I=A.length,L;t[18]!==l||t[19]!==c.connected||t[20]!==c.noWorkServices||t[21]!==O||t[22]!==h||t[23]!==S||t[24]!==F?(L=F.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base/55`,children:F.map(e=>{let t=oZ(O.get(e.id));return(0,$.jsxs)(`article`,{className:`flex min-h-[4.75rem] items-center gap-3 px-3 py-3 sm:px-4`,children:[(0,$.jsx)(zX,{connector:e,size:`sm`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-1 text-xs text-fg-muted`,children:e.description})]}),t?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs font-medium text-success`,children:[(0,$.jsx)(j,{className:`size-4`}),c.connected]}):h?(0,$.jsx)(xn,{className:`h-8 w-[4.5rem] shrink-0 rounded-lg`,"aria-label":l.loading}):(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 px-3 text-xs`,onClick:()=>S(QX(e)),children:[(0,$.jsx)(ge,{className:`size-3.5`}),l.connect]})]},e.id)})}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center text-sm text-fg-muted`,children:c.noWorkServices}),t[18]=l,t[19]=c.connected,t[20]=c.noWorkServices,t[21]=O,t[22]=h,t[23]=S,t[24]=F,t[25]=L):L=t[25];let R;t[26]!==u.length||t[27]!==c.showFewerServices||t[28]!==c.showMoreServices||t[29]!==y||t[30]!==b?(R=u.length>3?(0,$.jsxs)(`button`,{type:`button`,className:`mx-auto mt-3 flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>b(lZ),children:[y?(0,$.jsx)(ur,{className:`size-3.5`}):(0,$.jsx)(cr,{className:`size-3.5`}),y?c.showFewerServices:c.showMoreServices]}):null,t[26]=u.length,t[27]=c.showFewerServices,t[28]=c.showMoreServices,t[29]=y,t[30]=b,t[31]=R):R=t[31];let z;t[32]!==c.connectorLoadFailed||t[33]!==_?(z=_?(0,$.jsxs)(`p`,{className:`mt-3 text-center text-xs text-danger`,role:`alert`,children:[c.connectorLoadFailed,`: `,_]}):null,t[32]=c.connectorLoadFailed,t[33]=_,t[34]=z):z=t[34];let B;t[35]===n?B=t[36]:(B=n?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):null,t[35]=n,t[36]=B);let V;t[37]!==n||t[38]!==c.startUnderstanding||t[39]!==i||t[40]!==B?(V=(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:n,onClick:i,children:[B,c.startUnderstanding]}),t[37]=n,t[38]=c.startUnderstanding,t[39]=i,t[40]=B,t[41]=V):V=t[41];let H;t[42]!==n||t[43]!==c.back||t[44]!==r?(H=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:n,onClick:r,children:c.back}),t[42]=n,t[43]=c.back,t[44]=r,t[45]=H):H=t[45];let U;t[46]!==V||t[47]!==H?(U=(0,$.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[V,H]}),t[46]=V,t[47]=H,t[48]=U):U=t[48];let W;t[49]!==n||t[50]!==c.skipAndEnter||t[51]!==a?(W=(0,$.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,disabled:n,onClick:a,children:c.skipAndEnter}),t[49]=n,t[50]=c.skipAndEnter,t[51]=a,t[52]=W):W=t[52];let G;return t[53]!==l||t[54]!==x||t[55]!==w||t[56]!==S?(G=x?(0,$.jsx)(ZX,{draft:x,onChange:S,onClose:()=>S(null),t:l,onInstalled:async()=>{await w(),S(null)}}):null,t[53]=l,t[54]=x,t[55]=w,t[56]=S,t[57]=G):G=t[57],(0,$.jsxs)(`section`,{className:`mx-auto flex w-full max-w-[42rem] flex-1 flex-col`,"aria-labelledby":`work-discovery-connectors-title`,children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:c.connectorStepEyebrow}),(0,$.jsx)(`h1`,{id:`work-discovery-connectors-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:c.connectorStepTitle}),(0,$.jsx)(`p`,{className:`mx-auto mt-3 max-w-[36rem] text-[0.95rem] leading-7 text-fg-muted`,children:c.connectorStepSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-3 shadow-surface sm:p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1 pb-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.popularWorkServices}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:c.connectorsOptional})]}),I?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success`,children:[(0,$.jsx)(j,{className:`size-3.5`}),c.connectedCount.replace(`{{count}}`,String(I))]}):null]}),L,R,z]}),U,W,G]})}function lZ(e){return!e}function uZ(e){return[e.connectorId,e]}function dZ(){}function fZ(){return rZ(tZ)}function pZ(e){return e.language}var mZ=new Set([`local-recent-files`,`chromium-bookmarks`,`apple-notes`,`apple-mail`,`apple-calendar`,`apple-reminders`]);function hZ(e){return new Set(e.filter(e=>e.availability===`available`&&mZ.has(e.id)).map(e=>e.id))}var gZ=t({WorkDiscoveryPage:()=>xZ}),_Z=[`folder_structure`,`recent_progress`,`next_steps`];function vZ(e){return e instanceof Error?e.message:String(e)}function yZ(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-2).join(`/`)||e}function bZ(e,t){return e.replace(`{{count}}`,String(t))}function xZ({embedded:e=!1,onRequestClose:t,onNavigateAway:n}={}){let r=Ee(e=>e.language),i=xe(r).onboarding.workDiscovery,a=xe(r).chat.workingDirectory,o=l(),[s]=u(),c=s.get(`new`)===`1`,[d,f]=(0,Z.useState)(`loading`),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)([]),[O,k]=(0,Z.useState)(()=>new Set),[A,j]=(0,Z.useState)([]),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)({current:0,total:0}),[L,R]=(0,Z.useState)([]),[z,B]=(0,Z.useState)(()=>new Set),[V,H]=(0,Z.useState)([]),U=(0,Z.useRef)(!1),W={recent_documents:`recent`,calendar:`calendar`,tasks:`task`,notes:`note`,mail:`mail`,messages:`message`,code_activity:`git`,files:`file`},G=_?.snapshot?.projectKind??p?.projectKind,ee=G===`coding`?i.codingProject:G===`general`?i.generalProject:G===`unknown`?i.unknownProject:null,te=(_?.snapshot?.files??[]).slice(0,4).map(e=>({id:`snapshot-file:${e.relativePath}`,label:yZ(e.relativePath),kind:e.source===`git_change`?`recent`:`file`,meta:e.source===`git_change`?i.sourceSignals.changedFile:e.source===`document`?i.sourceSignals.contextFile:i.sourceSignals.structureFile,detail:e.relativePath})),ne=_?.rootPath??p?.canonicalRootPath,re=te.length===0?(p?.fingerprint.recentAreas??[]).slice(0,2).map(e=>({id:`recent-area:${e}`,label:e,kind:`recent`,meta:i.sourceSignals.recentArea,detail:e})):[],ie=te.length===0?re.length>0?re:[{id:`project-files`,label:i.sourceSignals.projectFiles,kind:`file`,meta:i.sourceSignals.scanningFiles},{id:`recent-changes`,label:i.sourceSignals.recentChanges,kind:`recent`,meta:i.sourceSignals.checkingChanges}]:[],ae=_?.snapshot?.sampledPathCount,se=[ee,ae==null?null:bZ(i.sourceSignals.filesScanned,ae)].filter(e=>!!e).join(` · `),ce=_?.snapshot?.branch??p?.fingerprint.branch,le=_?.snapshot?.changedPathCount??p?.fingerprint.changedFileCount,de=[{id:`work-folder`,label:ne?yZ(ne):i.sourceSignals.workFolder,kind:`folder`,...se?{meta:se}:{},...ne?{detail:ne}:{}},...te,...ie,{id:`git-state`,label:ce??i.sourceSignals.gitState,kind:`git`,...le==null?{}:{meta:bZ(i.sourceSignals.changedFiles,le)},...ce?{detail:`Git · ${ce}`}:{}},...L.filter(e=>z.has(e.id)).map(e=>({id:e.id,label:e.displayName,kind:W[e.category]??`data`})),...V],fe=e=>{B(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,Z.useEffect)(()=>{let e=!1;return window.electronAPI?.understandingSources?.catalog().then(t=>{e||(R(t),B(hZ(t)))}),()=>{e=!0}},[]);let pe=(0,Z.useCallback)(e=>{PX.getState().updateDirectoryRun(e),v(e),e.status===`completed`?f(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?f(`error`):f(`running`)},[]),me=async()=>{b(!0),C(null);try{let e=await BD();if(g(e.processingTarget),!e.candidates.length){C(i.noCandidates);return}D(e.candidates),k(new Set([e.candidates[0].rootPath])),f(`candidates`)}catch(e){C(vZ(e))}finally{b(!1)}},he=e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},ge=(0,Z.useCallback)((e,t,n)=>{PX.getState().updateDirectoryRun(e),v(e),I({current:t+1,total:n}),j(n=>{let r=[...n];return r[t]=e,r}),f(`running`)},[]),_e=(0,Z.useCallback)(e=>{j(t=>t.map(t=>t?.id===e.id?e:t))},[]),ve=async()=>{let e=E.filter(e=>O.has(e.rootPath));if(!e.length)return;b(!0),C(null),j([]),I({current:1,total:e.length}),P(!0),U.current=!1;let t=!1,n=h?.remoteModel?`remote_allowed`:`local_only`;try{let r=await wX(e,{grantDirectory:e=>VD(e,n),startRun:UD,fetchRun:WD,shouldStop:()=>U.current,onRun:(e,r,i)=>{ge(e,r,i),t||(t=!0,PX.getState().collectSources(e.id,[...z],n))},onError:(t,n,r)=>{I({current:r+1,total:e.length}),C(i.folderAnalysisFailed.replace(`{{folder}}`,n.displayName).replace(`{{error}}`,vZ(t)))}});if(U.current)return;let a=r.find(e=>e.status===`completed`)??r.at(-1);a?pe(a):f(`candidates`)}catch(e){C(vZ(e)),f(`candidates`)}finally{P(!1),b(!1)}},be=fx({onPicked:(0,Z.useCallback)(async e=>{b(!0),C(null);try{let t=await zD(e);m(t),g({provider:t.provider,remoteModel:t.remoteModel}),f(`consent`)}catch(e){C(vZ(e)),f(`intro`)}finally{b(!1)}},[])});(0,Z.useEffect)(()=>{if(!c){let e=PX.getState().directoryRun;if(e){pe(e);return}}let e=!1,n=window.setTimeout(()=>{e||f(`intro`)},4e3);return LD().then(async({enabled:r,state:i})=>{if(!e){if(!r){window.clearTimeout(n),t?t():o(`/chat`,{replace:!0});return}if(!c&&i.activeRunId)try{let t=await WD(i.activeRunId);e||(window.clearTimeout(n),pe(t));return}catch{}e||(window.clearTimeout(n),f(`intro`))}}).catch(t=>{window.clearTimeout(n),e||(C(vZ(t)),f(`intro`))}),()=>{e=!0,window.clearTimeout(n)}},[pe,o,t,c]),(0,Z.useEffect)(()=>{if(!_||d!==`running`||N)return;let e=!1,t=async()=>{try{let t=await WD(_.id);e||pe(t)}catch{}},n=window.setInterval(()=>void t(),1200),r=e=>{let n=e.detail;(!n?.runId||n.runId===_.id)&&t()};for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.addEventListener(e,r);return()=>{e=!0,window.clearInterval(n);for(let e of[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`])window.removeEventListener(e,r)}},[pe,N,d,_]);let q=async()=>{b(!0);try{await RD()}finally{t?t():o(`/chat`,{replace:!0})}},Se=async()=>{if(p){b(!0),C(null),j([]),I({current:0,total:0});try{let e=p.remoteModel?`remote_allowed`:`local_only`;await VD(p.canonicalRootPath,e);let t=await UD(p.canonicalRootPath);pe(t),PX.getState().collectSources(t.id,[...z],e)}catch(e){C(vZ(e)),f(`consent`)}finally{b(!1)}}},Ce=(e,t,r=!1)=>{let i=new URLSearchParams;t&&i.set(`draft`,t),t&&r&&i.set(`autoSend`,`1`);let a=i.toString();n?.(),o(`/chat/${encodeURIComponent(e)}${a?`?${a}`:``}`)},we=e=>{v(e),T(!1),e.status===`completed`?f(e.feedback?.recognitionDecision===`confirmed`?`recommendation`:`recognition`):e.status===`failed`||e.status===`canceled`?f(`error`):f(`running`)},Te=async()=>{_&&(U.current=!0,pe(await GD(_.id)))},De=()=>{n?.(),o(`/chat`)},Oe=()=>{if(p){Se();return}ve()},J=()=>{f(p?`consent`:E.length?`candidates`:`intro`)},ke=async(e,t)=>{if(!_)return;await JD(_.id,e.id).catch(()=>{});let n=t?`${r===`zh`?`先帮我评估这个方向,不要修改文件:`:`First assess this direction without changing files:`}\n\n${e.actionPrompt}`:e.actionPrompt;Ce(_.conversationId,n)},Ae=async(e,t)=>{if(!_)return!1;b(!0),C(null);try{let n=await qD(_.id,e,t);return v(n),_e(n),f(`recommendation`),!0}catch(e){return C(vZ(e)),!1}finally{b(!1)}},je=async(e,t)=>{if(!_)return!1;b(!0),C(null);try{let n=await qD(_.id,t,t===`corrected`?e:void 0);return v(n),_e(n),Ce(_.conversationId,e,!0),!0}catch(e){return C(vZ(e)),!1}finally{b(!1)}},Me=_?.result?.suggestions.find(e=>e.id===_.result?.primarySuggestionId)??_?.result?.suggestions[0],Ne=_?.result?.suggestions.filter(e=>e.id!==Me?.id)??[],Pe=e=>e===`command`?i.riskCommand:e===`file_write`?i.riskFileWrite:i.riskAnalysis,Fe=A.filter(e=>e?.status===`completed`),Ie=e&&d===`candidates`,Le=Fe.length>1?(0,$.jsxs)(`div`,{className:`mt-6 rounded-xl border border-edge bg-surface-panel p-2`,children:[(0,$.jsx)(`p`,{className:`px-2 pb-2 text-xs font-medium text-fg-muted`,children:i.analysisResults}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Fe.map(e=>{let t=E.find(t=>t.rootPath===e.rootPath)?.displayName??e.rootPath.split(/[\\/]/).filter(Boolean).at(-1)??e.rootPath;return(0,$.jsx)(`button`,{type:`button`,className:`rounded-lg px-3 py-2 text-sm font-medium transition ${e.id===_?.id?`bg-accent text-on-accent`:`bg-surface-hover text-fg hover:bg-surface-active`}`,onClick:()=>we(e),children:t},e.id)})})]}):null;return(0,$.jsxs)(`div`,{className:e?`xopc-work-discovery-experience relative flex h-full min-h-0 flex-1 flex-col overflow-hidden`:`xopc-work-discovery-experience relative flex min-h-full flex-1 flex-col`,children:[(0,$.jsxs)(`main`,{className:e?`app-main-surface xopc-work-discovery-stage xopc-onboarding-scroll relative z-10 mx-auto my-3 flex min-h-0 w-[calc(100%_-_1.5rem)] ${d===`recognition`?`max-w-[58rem]`:`max-w-[46rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-7 shadow-surface sm:my-4 sm:w-[calc(100%_-_2rem)] sm:px-8 sm:py-9 ${Ie?`overflow-hidden`:`overflow-y-auto`}`:`app-main-surface mx-auto my-4 flex w-[calc(100%_-_2rem)] ${d===`recognition`?`max-w-[58rem]`:`max-w-[40rem]`} flex-1 flex-col rounded-xl bg-surface-panel px-5 py-10 shadow-surface sm:px-8 sm:py-16`,children:[d===`intro`?(0,$.jsx)(`div`,{className:K(`flex items-center justify-center`,e?`mb-7 sm:mb-9`:`mb-10`),children:(0,$.jsxs)(`div`,{className:`xopc-discovery-logo relative flex size-16 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`xopc-discovery-logo-glow absolute -inset-5 rounded-full`,"aria-hidden":!0}),(0,$.jsx)(GI,{className:`relative size-12`})]})}):null,d===`loading`?(0,$.jsxs)(`section`,{className:`mx-auto flex min-h-[32rem] w-full max-w-md flex-1 flex-col items-center justify-center text-center`,"aria-busy":!0,"aria-label":i.loading,children:[(0,$.jsx)(xn,{className:`size-14 rounded-xl`}),(0,$.jsx)(xn,{className:`mt-7 h-5 w-44 rounded-full`}),(0,$.jsx)(xn,{className:`mt-3 h-3.5 w-64 max-w-full rounded-full`})]}):null,d===`intro`?(0,$.jsxs)(`section`,{className:`flex flex-1 flex-col text-center`,"aria-labelledby":`work-discovery-title`,children:[(0,$.jsxs)(`div`,{className:`mx-auto max-w-[36rem]`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,$.jsx)(`h1`,{id:`work-discovery-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mx-auto mt-3 max-w-[34rem] text-[0.95rem] leading-7 text-fg-muted`,children:i.subtitle})]}),(0,$.jsxs)(`div`,{className:`mx-auto mt-9 w-full max-w-md`,children:[L.length?(0,$.jsxs)(`div`,{className:`mb-5 overflow-hidden rounded-xl border border-edge bg-surface-panel text-left shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.localSourcesTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.localSourcesSubtitle})]}),(0,$.jsx)(`div`,{className:`grid border-t border-edge-subtle sm:grid-cols-2`,children:L.map(e=>{let t=z.has(e.id);return(0,$.jsxs)(`button`,{type:`button`,className:K(`flex min-h-12 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 text-left text-sm transition-colors last:border-b-0 sm:[&:nth-last-child(-n+2)]:border-b-0 sm:[&:nth-child(odd)]:border-r`,t?`bg-accent-soft/55 text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":t,onClick:()=>fe(e.id),children:[(0,$.jsx)(`span`,{className:`truncate font-medium`,children:e.displayName}),(0,$.jsx)(`span`,{className:K(`flex size-5 shrink-0 items-center justify-center rounded-full border transition-colors`,t?`border-accent bg-accent text-on-accent`:`border-edge`),children:t?(0,$.jsx)(S,{className:`size-3`,"aria-hidden":!0}):null})]},e.id)})})]}):null,(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`h-12 w-full gap-2`,onClick:()=>void me(),disabled:y||be.picking,children:[y?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(Xi,{className:`size-4`}),i.quickScan]}),(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`mt-3 h-11 w-full gap-2`,onClick:be.pick,disabled:y||be.picking,children:[be.picking?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(oe,{className:`size-4`}),i.chooseFolderManually]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-start justify-center gap-2 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,$.jsx)(`span`,{children:i.quickScanNote})]}),x?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:x}):null]}),(0,$.jsx)(`button`,{type:`button`,className:`mx-auto mt-auto pt-10 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),disabled:y,children:i.skip})]}):null,d===`candidates`?(0,$.jsxs)(`section`,{className:e?`flex h-full min-h-0 flex-col`:void 0,"aria-labelledby":`work-discovery-candidates-title`,children:[(0,$.jsxs)(`div`,{className:e?`shrink-0 text-center`:`text-center`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,$.jsx)(`h1`,{id:`work-discovery-candidates-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.candidatesTitle}),(0,$.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.candidatesSubtitle})]}),(0,$.jsx)(`div`,{className:e?`xopc-onboarding-scroll mt-5 min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain pr-1`:`mt-7 space-y-2`,children:E.map((e,t)=>{let n=O.has(e.rootPath);return(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:`flex w-full items-start gap-3 rounded-xl border p-4 text-left transition ${n?`border-accent bg-accent-soft/45`:`border-edge bg-surface-panel hover:border-edge-strong`}`,onClick:()=>he(e.rootPath),children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-md border ${n?`border-accent bg-accent text-on-accent`:`border-edge bg-surface-base text-transparent`}`,children:(0,$.jsx)(S,{className:`size-3.5`})}),(0,$.jsx)(oe,{className:`mt-0.5 size-5 shrink-0 text-accent-fg`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.displayName}),t===0?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[0.7rem] font-medium text-accent-fg`,children:i.recommendedCandidate}):null]}),(0,$.jsx)(`span`,{className:`mt-1 block truncate font-mono text-xs text-fg-muted`,children:e.rootPath}),(0,$.jsxs)(`span`,{className:`mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:e.projectKind===`coding`?i.codingProject:e.projectKind===`general`?i.generalProject:i.unknownProject}),e.branch?(0,$.jsx)(`span`,{children:i.branchValue.replace(`{{branch}}`,e.branch)}):null,e.changedFileCount>0?(0,$.jsx)(`span`,{children:i.changedFiles.replace(`{{count}}`,String(e.changedFileCount))}):null]})]})]},e.id)})}),(0,$.jsxs)(`div`,{className:e?`shrink-0 border-t border-edge-subtle pt-4`:void 0,children:[(0,$.jsxs)(`div`,{className:`${e?``:`mt-5 `}flex items-start gap-2 rounded-xl bg-surface-hover/70 px-4 py-3 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,$.jsxs)(`span`,{children:[i.multiFolderPrivacyNote,` `,h?.remoteModel?i.providerDisclosure.replace(`{{provider}}`,h.provider):i.localDisclosure]})]}),x?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:x}):null,(0,$.jsxs)(`div`,{className:`${e?`mt-4`:`mt-7`} flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:y||O.size===0,onClick:()=>f(`connectors`),children:i.continueToConnectors}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:y,onClick:be.pick,children:i.chooseFolderManually})]}),(0,$.jsx)(`button`,{type:`button`,className:`${e?`mt-3`:`mt-6`} mx-auto block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>f(`intro`),children:i.back})]})]}):null,d===`consent`&&p?(0,$.jsxs)(`section`,{"aria-labelledby":`work-discovery-consent-title`,children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.sourceStepEyebrow}),(0,$.jsx)(`h1`,{id:`work-discovery-consent-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.selectedTitle}),(0,$.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.selectedSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-8 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-3.5`,children:[(0,$.jsx)(oe,{className:`size-5 shrink-0 text-accent-fg`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:p.displayName}),(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg-muted`,children:p.canonicalRootPath})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:p.projectKind===`coding`?i.codingProject:p.projectKind===`general`?i.generalProject:i.unknownProject})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 border-b border-edge-subtle bg-surface-base/35 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.localFingerprint}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:p.fingerprint.branch?i.branchValue.replace(`{{branch}}`,p.fingerprint.branch):i.noGitBranch})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentActivity}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:i.changedFiles.replace(`{{count}}`,String(p.fingerprint.changedFileCount))})]}),p.fingerprint.recentAreas.length>0?(0,$.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.recentAreas}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.fingerprint.recentAreas.map(e=>(0,$.jsx)(`code`,{className:`rounded-md bg-surface-hover px-2 py-1 text-xs text-fg`,children:e},e))})]}):null]}),(0,$.jsxs)(`div`,{className:`divide-y divide-edge-subtle px-4`,children:[(0,$.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,$.jsx)(zr,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willRead}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willReadValue})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,$.jsx)(ye,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.willIgnore}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.willIgnoreValue})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 py-4`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`}),(0,$.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:p.remoteModel?i.providerDisclosure.replace(`{{provider}}`,p.provider):i.localDisclosure})]})]})]}),x?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-danger`,role:`alert`,children:x}):null,(0,$.jsxs)(`div`,{className:`mt-7 flex flex-col gap-3 sm:flex-row-reverse`,children:[(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`h-11 flex-1`,disabled:y,onClick:()=>f(`connectors`),children:i.continueToConnectors}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-11 flex-1`,disabled:y,onClick:be.pick,children:i.changeFolder})]}),(0,$.jsx)(`button`,{type:`button`,className:`mx-auto mt-6 block text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>void q(),children:i.skip})]}):null,d===`connectors`?(0,$.jsx)(cZ,{busy:y,onBack:J,onContinue:Oe,onSkip:()=>void q(),onConnectedSignalsChange:H}):null,d===`running`&&_?(0,$.jsxs)(`section`,{"aria-labelledby":`work-discovery-running-title`,"aria-live":`polite`,children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingStepEyebrow}),(0,$.jsx)(`h1`,{id:`work-discovery-running-title`,className:`text-2xl font-semibold tracking-tight text-fg`,children:i.analyzingTitle}),(0,$.jsx)(`p`,{className:`mt-3 text-[0.95rem] leading-7 text-fg-muted`,children:i.analyzingSubtitle}),F.total>1?(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-accent-fg`,children:i.analyzingFolderProgress.replace(`{{current}}`,String(F.current)).replace(`{{total}}`,String(F.total))}):null]}),(0,$.jsx)(IX,{signals:de,ariaLabel:i.sourceSignals.ariaLabel,centerLabel:i.sourceSignals.centerLabel}),(0,$.jsx)(`div`,{className:`xopc-understanding-progress mx-auto mt-6 grid max-w-[34rem] grid-cols-3 gap-2`,children:_Z.map((e,t)=>{let n=Math.max(0,_Z.indexOf(_.stage??`folder_structure`)),r=t<n,a=t===n;return(0,$.jsxs)(`div`,{className:`xopc-understanding-step min-w-0 text-left`,"data-active":a||void 0,"data-complete":r||void 0,children:[(0,$.jsx)(`span`,{className:K(`block h-1 rounded-full`,a||r?`bg-accent`:`bg-surface-hover`)}),(0,$.jsx)(`span`,{className:K(`mt-2 block text-[11px] leading-4`,a?`font-medium text-fg`:`text-fg-muted`),children:i.stages[e]})]},e)})}),(0,$.jsx)(`p`,{className:`mt-4 truncate text-center font-mono text-xs text-fg-muted`,children:_.rootPath}),(0,$.jsx)(`p`,{className:`mx-auto mt-4 max-w-lg text-center text-xs leading-5 text-fg-muted`,children:i.backgroundChoiceHint}),(0,$.jsxs)(`div`,{className:`mx-auto mt-5 flex max-w-md flex-col gap-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-11 w-full`,onClick:De,children:i.continueInBackground}),(0,$.jsx)(`button`,{type:`button`,className:`mx-auto text-sm text-fg-muted hover:text-danger hover:underline`,onClick:()=>void Te(),children:i.cancelAnalysis})]})]}):null,d===`recognition`&&_?.result?(0,$.jsx)(DX,{run:_,language:r,busy:y,error:x,onFinish:Ae,onStartConversation:je},_.id):null,d===`recommendation`&&_?.result&&Me?(0,$.jsxs)(`section`,{"aria-labelledby":`work-discovery-recommendation-title`,children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.16em] text-accent-fg`,children:i.understandingConfirmed}),(0,$.jsx)(`h1`,{id:`work-discovery-recommendation-title`,className:`mt-2 text-2xl font-semibold tracking-tight text-fg`,children:i.primaryRecommendationTitle})]}),Le,(0,$.jsx)(`article`,{className:`mt-7 rounded-xl border border-edge bg-surface-panel p-5 shadow-surface sm:p-7`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-xl bg-surface-hover text-fg-muted`,children:(0,$.jsx)(lr,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Me.title}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Me.rationale}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:[(0,$.jsx)(M,{className:`size-3.5`}),i.estimatedMinutes.replace(`{{count}}`,String(Me.estimatedMinutes))]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-fg-muted`,children:Pe(Me.risk)})]}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:i.expectedTask}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg`,children:Me.expectedTask})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,$.jsx)(X,{variant:`primary`,className:`h-10 px-4`,onClick:()=>void ke(Me,!1),children:i.startRecommendedAction}),(0,$.jsx)(X,{className:`h-10 px-4`,variant:`secondary`,onClick:()=>void ke(Me,!0),children:i.explainFirst})]})]})]})}),Ne.length>0?(0,$.jsxs)(`div`,{className:`mt-5 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between py-2 text-sm font-medium text-fg-muted hover:text-fg`,onClick:()=>T(e=>!e),children:[i.otherDirections,(0,$.jsx)(cr,{className:`size-4 transition-transform ${w?`rotate-180`:``}`})]}),w?(0,$.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-panel px-4`,children:Ne.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 py-4 text-left`,onClick:()=>void ke(e,!0),children:[(0,$.jsx)(lr,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:e.expectedTask})]})]},e.id))}):null]}):null,(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center justify-center gap-x-5 gap-y-3`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ce(_.conversationId),children:i.doSomethingElse}),(0,$.jsx)(`button`,{type:`button`,className:`text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>f(`recognition`),children:i.correctUnderstanding})]})]}):null,d===`error`&&_?(0,$.jsxs)(`section`,{className:`text-center`,"aria-labelledby":`work-discovery-error-title`,children:[(0,$.jsx)(`div`,{className:`mx-auto flex size-11 items-center justify-center rounded-xl bg-danger-soft text-danger`,children:(0,$.jsx)(ye,{className:`size-5`})}),(0,$.jsx)(`h1`,{id:`work-discovery-error-title`,className:`mt-5 text-2xl font-semibold tracking-tight text-fg`,children:i.errorTitle}),(0,$.jsx)(`p`,{className:`mx-auto mt-3 max-w-lg text-sm leading-6 text-fg-muted`,children:_.errorMessage}),(0,$.jsxs)(`div`,{className:`mx-auto mt-7 flex max-w-md flex-col gap-3 sm:flex-row-reverse`,children:[(0,$.jsx)(X,{variant:`primary`,className:`h-11 flex-1`,onClick:()=>void KD(_.id).then(pe),children:i.retry}),(0,$.jsx)(X,{variant:`secondary`,className:`h-11 flex-1`,onClick:()=>{v(null),m(null),f(`intro`)},children:i.chooseDifferent})]}),(0,$.jsx)(`button`,{type:`button`,className:`mt-6 text-sm text-fg-muted hover:text-fg hover:underline`,onClick:()=>Ce(_.conversationId),children:i.openConversation})]}):null]},d),be.hasNativePicker?null:(0,$.jsx)(Cx,{open:be.modalOpen,onOpenChange:be.setModalOpen,initialAbsolutePath:p?.canonicalRootPath,onConfirm:be.confirmPick,wd:a})]})}function SZ(e){if(!e||typeof e!=`object`||Array.isArray(e))return!0;let t=e.agents;if(!t)return!0;let n=t.defaults?.models?.chat?.primary?.trim()??``;return!((t.list?.find(e=>e.enabled!==!1&&e.id===t.default))?.models?.chat?.primary?.trim()||n)}function CZ(e){let{enabled:t,ready:n,configError:r,modelsError:i,config:a,modelsData:o}=e;if(!t||!n||r||i)return!1;let s=SZ(a),c=!Array.isArray(o)||o.length===0;return s||c}var wZ=`xopc-onboarding-model-setup-dismissed`;function TZ(e){let t=(0,Q.c)(21),[n,r]=(0,Z.useState)(EZ),{data:i,error:a,isLoading:o,mutate:s}=an(e),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={revalidateOnFocus:!1},t[0]=c):c=t[0];let{data:l,isLoading:u,error:d,mutate:f}=Zt(e?zn:null,Ln,c),p=!e||!o&&!u,m=i?.payload?.config,h;t[1]!==a||t[2]!==e||t[3]!==l||t[4]!==d||t[5]!==p||t[6]!==m?(h=CZ({enabled:e,ready:p,configError:a,modelsError:d,config:m,modelsData:l}),t[1]=a,t[2]=e,t[3]=l,t[4]=d,t[5]=p,t[6]=m,t[7]=h):h=t[7];let g=h,_;t[8]!==s||t[9]!==f?(_=async()=>{await Promise.all([s(),f()])},t[8]=s,t[9]=f,t[10]=_):_=t[10];let v=_,y,b;t[11]!==e||t[12]!==f?(y=()=>{if(!e)return;let t=()=>{f()};return window.addEventListener(`config-reload`,t),()=>window.removeEventListener(`config-reload`,t)},b=[e,f],t[11]=e,t[12]=f,t[13]=y,t[14]=b):(y=t[13],b=t[14]),(0,Z.useEffect)(y,b);let x;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{try{localStorage.setItem(wZ,`1`)}catch{}r(!0)},t[15]=x):x=t[15];let S=x,C;return t[16]!==n||t[17]!==g||t[18]!==p||t[19]!==v?(C={needsSetup:g,ready:p,refresh:v,guideDismissed:n,dismissPermanently:S},t[16]=n,t[17]=g,t[18]=p,t[19]=v,t[20]=C):C=t[20],C}function EZ(){return typeof localStorage<`u`&&localStorage.getItem(`xopc-onboarding-model-setup-dismissed`)===`1`}function DZ(){let e=(0,Q.c)(40),t=Se(PZ),n=Ee(NZ),r;e[0]===n?r=e[1]:(r=xe(n),e[0]=n,e[1]=r);let i=r,{pathname:a}=b(),o=l(),s=TZ(!!t),c=a.startsWith(`/settings`),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1),m;e[2]!==p||e[3]!==d||e[4]!==t?(m=()=>{if(p(!1),!t){d(null);return}let e=!1;return LD().then(t=>{e||d(t)}).catch(MZ),()=>{e=!0}},e[2]=p,e[3]=d,e[4]=t,e[5]=m):m=e[5];let h;e[6]===t?h=e[7]:(h=[t],e[6]=t,e[7]=h),(0,Z.useEffect)(m,h);let g=xX({authenticated:!!t,settingsRoute:c,modelSetupReady:s.ready,needsModelSetup:s.needsSetup,modelGuideDismissed:s.guideDismissed,workDiscovery:u,closed:f}),_;e[8]===p?_=e[9]:(_=()=>{p(!0)},e[8]=p,e[9]=_);let v=_,y;e[10]!==v||e[11]!==o?(y=()=>{v(),o(`/chat`)},e[10]=v,e[11]=o,e[12]=y):y=e[12];let x=y,S;e[13]!==v||e[14]!==s?(S=()=>{v(),s.dismissPermanently(),RD().catch(jZ)},e[13]=v,e[14]=s,e[15]=S):S=e[15];let C=S,w;e[16]!==C||e[17]!==g.stage||e[18]!==x?(w=e=>{e||(g.stage===`setup`?C():x())},e[16]=C,e[17]=g.stage,e[18]=x,e[19]=w):w=e[19];let T;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[55] bg-scrim backdrop-blur-md`}),e[20]=T):T=e[20];let E;e[21]===i.onboarding.title?E=e[22]:(E=(0,$.jsx)(tt,{className:`sr-only`,children:i.onboarding.title}),e[21]=i.onboarding.title,e[22]=E);let D;e[23]===i.onboarding.subtitle?D=e[24]:(D=(0,$.jsx)(Ze,{className:`sr-only`,children:i.onboarding.subtitle}),e[23]=i.onboarding.subtitle,e[24]=D);let O;e[25]!==v||e[26]!==C||e[27]!==g.stage||e[28]!==x||e[29]!==s||e[30]!==d?(O=g.stage===`setup`?(0,$.jsx)(yX,{onComplete:async()=>{let e=await LD().catch(OZ);d(e),await s.refresh(),bX(e)||x()},onDismiss:C,canDismiss:!0}):(0,$.jsx)(`div`,{className:`xopc-onboarding-work-stage h-full overflow-hidden`,children:(0,$.jsx)(xZ,{embedded:!0,onRequestClose:x,onNavigateAway:v})}),e[25]=v,e[26]=C,e[27]=g.stage,e[28]=x,e[29]=s,e[30]=d,e[31]=O):O=e[31];let k;e[32]!==O||e[33]!==E||e[34]!==D?(k=(0,$.jsxs)($e,{children:[T,(0,$.jsxs)(et,{className:`xopc-onboarding-dialog app-chrome-shell fixed inset-0 z-[56] overflow-hidden outline-none`,onPointerDownOutside:AZ,onOpenAutoFocus:kZ,children:[E,D,O]})]}),e[32]=O,e[33]=E,e[34]=D,e[35]=k):k=e[35];let A;return e[36]!==g.open||e[37]!==k||e[38]!==w?(A=(0,$.jsx)(nt,{open:g.open,onOpenChange:w,children:k}),e[36]=g.open,e[37]=k,e[38]=w,e[39]=A):A=e[39],A}function OZ(){return null}function kZ(e){return e.preventDefault()}function AZ(e){return e.preventDefault()}function jZ(){}function MZ(){}function NZ(e){return e.language}function PZ(e){return e.conversationId}function FZ(e){let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`shrink-0`,children:n}),t[0]=n,t[1]=r),r}var IZ=e=>e.status===`queued`||e.status===`running`,LZ=new Set,RZ,zZ=Oe((e,t)=>({sources:[],starting:!1,async start(n){if(!t().starting){e({starting:!0,error:void 0});try{await q(J(`/api/user-model/refresh`),{method:`POST`,body:JSON.stringify(n?{sourceIds:[n]}:{})}),await t().poll()}catch(t){e({error:t instanceof Error?t.message:String(t)})}finally{e({starting:!1})}}},poll(){return RZ||(RZ=(async()=>{try{let n=await q(J(`/api/user-model/refresh`)),r=new Map(t().sources.map(e=>[e.id,e.status]));e({sources:n.sources,error:void 0}),n.sources.some(e=>!IZ(e)&&r.get(e.id)!==e.status)&&$t(`/api/user-model`);for(let e of n.sources)IZ(e)&&e.metadata.phase===`waiting_desktop`&&BZ(e)}catch(t){e({error:t instanceof Error?t.message:String(t)})}})().finally(()=>{RZ=void 0}),RZ)}}));async function BZ(e){let t=window.electronAPI?.understandingSources?.collect;if(!(!t||LZ.size>0)){LZ.add(e.id);try{let n;try{let r=(await t([e.adapterId])).find(t=>t.sourceId===e.adapterId);n=r?.status===`completed`?{items:r.items}:{items:[],error:r?.error??`Source collection failed. Check its permissions and retry.`}}catch{n={items:[],error:`Source collection was interrupted. Please retry.`}}await q(J(`/api/user-model/refresh/sources/${encodeURIComponent(e.id)}/collection`),{method:`POST`,body:JSON.stringify(n)}),await zZ.getState().poll()}catch(e){zZ.setState({error:e instanceof Error?e.message:String(e)})}finally{LZ.delete(e.id)}}}function VZ(){let e=(0,Q.c)(3),t=zZ(UZ),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=HZ;e();let n=window.setInterval(e,t?1500:3e4);return window.addEventListener(`understanding-refresh-updated`,e),window.addEventListener(`focus`,e),()=>{window.clearInterval(n),window.removeEventListener(`understanding-refresh-updated`,e),window.removeEventListener(`focus`,e)}},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function HZ(){zZ.getState().poll()}function UZ(e){return e.sources.some(WZ)}function WZ(e){return e.status===`queued`||e.status===`running`}var GZ=new Set([`queued`,`probing`,`analyzing`]),KZ=[`work-discovery-progress`,`work-discovery-completed`,`work-discovery-failed`,`work-discovery-canceled`];function qZ(){let e=(0,Q.c)(7),t=PX(tQ),n=PX(eQ),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[0]=r):r=e[0],(0,Z.useEffect)(QZ,r);let i,a;e[1]!==t||e[2]!==n?(i=()=>{if(!t||!n||!GZ.has(n))return;let e=!1,r=async()=>{try{let n=await WD(t);e||PX.getState().updateDirectoryRun(n)}catch{}};r();let i=window.setInterval(()=>void r(),1200);return()=>{e=!0,window.clearInterval(i)}},a=[t,n],e[1]=t,e[2]=n,e[3]=i,e[4]=a):(i=e[3],a=e[4]),(0,Z.useEffect)(i,a);let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],e[5]=o):o=e[5],(0,Z.useEffect)(JZ,o);let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(VZ,{}),e[6]=s):s=e[6],s}function JZ(){let e=YZ;for(let t of KZ)window.addEventListener(t,e);return()=>{for(let t of KZ)window.removeEventListener(t,e)}}function YZ(e){let t=e.detail?.runId;t&&WD(t).then(ZZ).catch(XZ)}function XZ(){}function ZZ(e){return PX.getState().updateDirectoryRun(e)}function QZ(){let e=!1;return LD().then(async t=>{let{state:n}=t;if(n.status!==`in_progress`||!n.activeRunId)return;let r=await WD(n.activeRunId);e||PX.getState().updateDirectoryRun(r)}).catch($Z),()=>{e=!0}}function $Z(){}function eQ(e){return e.directoryRun?.status}function tQ(e){return e.directoryRun?.id}var nQ=`workDiscovery`;function rQ(e){return new URLSearchParams(e).get(nQ)===`new`}function iQ(e){let t=new URLSearchParams(e);t.delete(nQ);let n=t.toString();return n?`?${n}`:``}var aQ=(0,Z.lazy)(()=>Ap().then(e=>({default:e.WorkDiscoveryOverlay}))),oQ=(0,Z.lazy)(()=>dp().then(e=>({default:e.TaskDetailModal})));function sQ(){let e=(0,Q.c)(3),t=l(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail;n?.conversationId&&t(`/chat/${encodeURIComponent(n.conversationId)}`)};return window.addEventListener(`navigate-to-chat`,e),()=>window.removeEventListener(`navigate-to-chat`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function cQ(){let e=(0,Q.c)(3),t=l(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{let e=e=>{let n=e.detail,r=typeof n?.path==`string`?n.path.trim():``;r&&t(r.startsWith(`/`)?r:`/${r}`)};return window.addEventListener(`extension-navigate`,e),()=>window.removeEventListener(`extension-navigate`,e)},r=[t],e[0]=t,e[1]=n,e[2]=r),(0,Z.useEffect)(n,r),null}function lQ(){let e=(0,Q.c)(3),t=Se(dQ),n=`${Se(uQ)}:${t??``}`,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(uJ,{children:(0,$.jsx)(fQ,{})}),e[0]=r):r=e[0];let i;return e[1]===n?i=e[2]:(i=(0,$.jsx)(od,{children:r},n),e[1]=n,e[2]=i),i}function uQ(e){return e.baseUrl}function dQ(e){return e.conversationId}function fQ(){let e=(0,Q.c)(111),t=Se(gQ),{pathname:n,search:r}=b(),i=l(),a;e[0]===n?a=e[1]:(a=n.startsWith(`/settings`),e[0]=n,e[1]=a);let o=a,s=n===`/onboarding/workspace`,c=Ee(hQ),u=Dm(),d=Ow(mQ),p;e[2]===n?p=e[3]:(p=n.startsWith(`/chat/task/`)?``:n.startsWith(`/chat/`)?n.slice(6):``,e[2]=n,e[3]=p);let m=p,h=m&&m!==`new`?decodeURIComponent(m):null,g;e[4]===h?g=e[5]:(g=e=>h?e.panes[h]?.open===!0:!1,e[4]=h,e[5]=g);let _=dL(g),v;e[6]!==n||e[7]!==r?(v=n===`/user-model`&&rQ(r),e[6]=n,e[7]=r,e[8]=v):v=e[8];let y=v,x;e[9]!==n||e[10]!==r?(x=n.startsWith(`/tasks/`)?null:new URLSearchParams(r).get(Vs),e[9]=n,e[10]=r,e[11]=x):x=e[11];let S=x,C;e[12]!==n||e[13]!==r?(C=Ws(n,r),e[12]=n,e[13]=r,e[14]=C):C=e[14];let w=C,[T,E]=(0,Z.useState)(y),D,O;e[15]===y?(D=e[16],O=e[17]):(D=()=>{y&&E(!0)},O=[y],e[15]=y,e[16]=D,e[17]=O),(0,Z.useEffect)(D,O);let k;e[18]!==i||e[19]!==n||e[20]!==r?(k=()=>{i({pathname:n,search:iQ(r)},{replace:!0})},e[18]=i,e[19]=n,e[20]=r,e[21]=k):k=e[21];let A=k,j;e[22]!==A||e[23]!==y?(j=()=>{E(!1),y&&A(),window.requestAnimationFrame(pQ)},e[22]=A,e[23]=y,e[24]=j):j=e[24];let M=j,N;e[25]!==i||e[26]!==w?(N=()=>{i(w,{replace:!0})},e[25]=i,e[26]=w,e[27]=N):N=e[27];let P=N;if(!t){let t=c===`zh`?`跳到主要内容`:`Skip to main content`,n;e[28]===t?n=e[29]:(n=(0,$.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:t}),e[28]=t,e[29]=n);let r,i;e[30]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(tH,{}),i=(0,$.jsx)(FU,{}),e[30]=r,e[31]=i):(r=e[30],i=e[31]);let a;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(xf,{})}),e[32]=a):a=e[32];let o;return e[33]===n?o=e[34]:(o=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[n,r,i,a]}),e[33]=n,e[34]=o),o}let F;e[35]===n?F=e[36]:(F=n.split(`/`)[1]||`root`,e[35]=n,e[36]=F);let I=F,L=I===`chat`||I===`notes`;if(s){let t,n,r,i,a,o,s;e[37]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(jU,{}),n=(0,$.jsx)(dq,{}),r=(0,$.jsx)(qZ,{}),i=(0,$.jsx)(zq,{}),a=(0,$.jsx)(FU,{}),o=(0,$.jsx)(tH,{}),s=eD()?(0,$.jsx)(`div`,{className:K(`w-full`,hd,pd),"aria-hidden":`true`}):null,e[37]=t,e[38]=n,e[39]=r,e[40]=i,e[41]=a,e[42]=o,e[43]=s):(t=e[37],n=e[38],r=e[39],i=e[40],a=e[41],o=e[42],s=e[43]);let c;return e[44]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[t,n,r,i,a,o,s,(0,$.jsx)(`main`,{id:`app-main-content`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,$.jsx)(f,{})})]}),e[44]=c):c=e[44],c}let R;e[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(jU,{}),e[45]=R):R=e[45];let z=c===`zh`?`跳到主要内容`:`Skip to main content`,B;e[46]===z?B=e[47]:(B=(0,$.jsx)(`a`,{href:`#app-main-content`,className:`sr-only z-[80] rounded-lg bg-surface-panel px-3 py-2 text-sm text-fg shadow-elevated focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:z}),e[46]=z,e[47]=B);let V,H,U,W,G,ee,te,ne,re,ie,ae,oe,se,ce;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(dq,{}),H=(0,$.jsx)(qZ,{}),U=(0,$.jsx)(zq,{}),W=(0,$.jsx)(FU,{}),G=(0,$.jsx)(sQ,{}),ee=(0,$.jsx)(cQ,{}),te=(0,$.jsx)(wG,{}),ne=(0,$.jsx)(VG,{}),re=(0,$.jsx)(JK,{}),ie=(0,$.jsx)(Xq,{}),ae=(0,$.jsx)(yJ,{}),oe=(0,$.jsx)(RR,{}),se=(0,$.jsx)(GR,{}),ce=(0,$.jsx)(DZ,{}),e[48]=V,e[49]=H,e[50]=U,e[51]=W,e[52]=G,e[53]=ee,e[54]=te,e[55]=ne,e[56]=re,e[57]=ie,e[58]=ae,e[59]=oe,e[60]=se,e[61]=ce):(V=e[48],H=e[49],U=e[50],W=e[51],G=e[52],ee=e[53],te=e[54],ne=e[55],re=e[56],ie=e[57],ae=e[58],oe=e[59],se=e[60],ce=e[61]);let le;e[62]!==P||e[63]!==w||e[64]!==S?(le=S?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(oQ,{taskId:S,backgroundPath:w,onClose:P})}):null,e[62]=P,e[63]=w,e[64]=S,e[65]=le):le=e[65];let ue;e[66]!==M||e[67]!==y||e[68]!==T?(ue=T?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(aQ,{requestedOpen:y,onExited:M})}):null,e[66]=M,e[67]=y,e[68]=T,e[69]=ue):ue=e[69];let de;e[70]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(tH,{}),e[70]=de):de=e[70];let fe;e[71]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(rH,{}),e[71]=fe):fe=e[71];let pe;e[72]===u?pe=e[73]:(pe=(0,$.jsx)(KU,{reminder:u}),e[72]=u,e[73]=pe);let me;e[74]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(VU,{}),e[74]=me):me=e[74];let he;e[75]===pe?he=e[76]:(he=(0,$.jsxs)(FZ,{children:[fe,pe,me]}),e[75]=pe,e[76]=he);let ge;e[77]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(rS,{}),e[77]=ge):ge=e[77];let _e;e[78]!==o||e[79]!==d?(_e=!o&&!d?(0,$.jsx)(tm,{}):null,e[78]=o,e[79]=d,e[80]=_e):_e=e[80];let ve;e[81]!==d||e[82]!==I||e[83]!==L||e[84]!==S?(ve=(0,$.jsx)(`main`,{id:`app-main-content`,className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:d!=null&&!S?(0,$.jsx)(tJ,{}):(0,$.jsx)(`div`,{className:K(`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,I!==`settings`&&`page-enter`,I===`settings`||L?`overflow-hidden`:`overflow-y-auto overscroll-contain [scrollbar-gutter:stable_both-edges]`),children:(0,$.jsx)(f,{})},I)}),e[81]=d,e[82]=I,e[83]=L,e[84]=S,e[85]=ve):ve=e[85];let ye;e[86]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(hJ,{}),e[86]=ye):ye=e[86];let be;e[87]!==o||e[88]!==n||e[89]!==d?(be=!o&&!n.startsWith(`/chat`)&&!d?(0,$.jsx)(La,{}):null,e[87]=o,e[88]=n,e[89]=d,e[90]=be):be=e[90];let xe;e[91]!==_e||e[92]!==ve||e[93]!==be?(xe=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[_e,ve,ye,be]}),e[91]=_e,e[92]=ve,e[93]=be,e[94]=xe):xe=e[94];let q;e[95]!==o||e[96]!==h||e[97]!==_||e[98]!==S?(q=o?null:_&&h&&!S?(0,$.jsx)(_R,{parentConversationId:h}):(0,$.jsx)(kw,{elevated:!!S}),e[95]=o,e[96]=h,e[97]=_,e[98]=S,e[99]=q):q=e[99];let Ce;e[100]!==xe||e[101]!==q?(Ce=(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[ge,(0,$.jsx)(`div`,{className:`app-main-surface relative flex min-h-0 min-w-0 flex-1 min-w-0 flex-col overflow-hidden bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-row overflow-hidden`,children:[xe,q]})})]}),e[100]=xe,e[101]=q,e[102]=Ce):Ce=e[102];let we;e[103]!==he||e[104]!==Ce?(we=(0,$.jsxs)(`div`,{className:`app-chrome-shell flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[de,he,Ce]}),e[103]=he,e[104]=Ce,e[105]=we):we=e[105];let Te;return e[106]!==B||e[107]!==le||e[108]!==ue||e[109]!==we?(Te=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden bg-surface-base`,children:[R,B,V,H,U,W,G,ee,te,ne,re,ie,ae,oe,se,ce,le,ue,we]}),e[106]=B,e[107]=le,e[108]=ue,e[109]=we,e[110]=Te):Te=e[110],Te}function pQ(){document.querySelector(`[data-work-discovery-trigger]`)?.focus({preventScroll:!0})}function mQ(e){return e.path}function hQ(e){return e.language}function gQ(e){return e.conversationId}var _Q={en:`https://xopc.ai/en#download`,zh:`https://xopc.ai/zh#download`};function vQ(e){if(e instanceof Error)return e.stack||e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yQ(e=Te()){return _Q[e]}function bQ(){let e=window.location.hash.replace(/^#\/?/,``).split(/[/?]/,1)[0];return`${window.location.origin}${window.location.pathname}${e?`#/${e}`:``}`}function xQ({error:e,source:t,componentStack:n,capturedAt:r=new Date}){let i=window.electronAPI?`Electron desktop app`:`Gateway web UI`,a=window.electronAPI?.platform??navigator.platform??`unknown`,o=Om.commit===`unknown`?`unknown`:Om.commit.slice(0,12),s=[`# xopc renderer error report`,``,`- xopc web version: ${Om.version}`,`- Commit: ${o}`,`- Build time: ${Om.buildTimeIso}`,`- Captured at: ${r.toISOString()}`,`- Source: ${t}`,`- Surface: ${i}`,`- Platform: ${a}`,`- Language: ${Te()}`,`- Page: ${bQ()}`,`- User agent: ${navigator.userAgent}`,``,`## Error`,``,"```text",vQ(e),"```"];return n?.trim()&&s.push(``,`## React component stack`,``,"```text",n.trim(),"```"),s.join(`
104
- `)}var SQ={en:{eyebrow:`xopc recovery`,title:`The app ran into a problem`,description:`This version may be incompatible with the current runtime. Download and install the latest desktop version from the official website, then open xopc again.`,download:`Download the latest version`,reload:`Reload`,details:`Technical details`,copyReport:`Collect and copy report`,reportIssue:`Report on GitHub`,copied:`The redacted diagnostic report was copied.`,copyFailed:`Could not copy the diagnostic report automatically.`,collecting:`Collecting diagnostics…`,collectFailed:"Could not collect diagnostics. Run `xopc support report` in a terminal instead.",githubTruncated:`The complete report was copied to the clipboard. Paste it into the issue or upload the downloaded diagnostics file.`,reportHint:`These raw technical details stay on this page. Public reports use the redacted diagnostic report.`,openFailed:`Could not open the system browser. Visit xopc.ai to download the latest version.`},zh:{eyebrow:`xopc 恢复模式`,title:`应用遇到问题,暂时无法继续`,description:`当前版本可能与运行环境不兼容。请前往官网下载并安装最新桌面版,然后重新打开 xopc。`,download:`去官网下载最新版`,reload:`重新加载`,details:`技术详情`,copyReport:`收集并复制报告`,reportIssue:`上报 GitHub`,copied:`已复制脱敏后的诊断报告。`,copyFailed:`无法自动复制诊断报告。`,collecting:`正在收集诊断信息…`,collectFailed:"诊断信息收集失败,请在终端运行 `xopc support report`。",githubTruncated:`完整报告已复制到剪贴板,请粘贴到 Issue 中,或上传下载的诊断文件。`,reportHint:`这里显示的是本地原始技术详情;公开提交时会使用自动脱敏后的诊断报告。`,openFailed:`无法打开系统浏览器,请访问 xopc.ai 下载最新版本。`}};async function CQ(e){let t=window.electronAPI?.shell?.openExternalUrl;if(t)try{let n=await t(e);return n.ok?null:n.error}catch(e){return e instanceof Error?e.message:String(e)}return window.location.assign(e),null}function wQ({error:e,source:t=`react`,componentStack:n}){let r=Te(),i=SQ[r],a=yQ(r),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m]=(0,Z.useState)(()=>new Date),h=(0,Z.useMemo)(()=>xQ({error:e,source:t,componentStack:n,capturedAt:m}),[m,n,e,t]),g=async()=>{let e=await CQ(a);s(e?`${i.openFailed} (${e})`:null)},_=async()=>{if(f)return f;d(!0),s(null);try{let e=(await Hq({problem:`Renderer error (${t})`,occurredAt:m.toISOString(),clientContext:{rendererError:h,surface:window.electronAPI?`electron`:`web`,userAgent:navigator.userAgent}})).report;return p(e),e}catch{return s(i.collectFailed),null}finally{d(!1)}},v=async()=>{let e=await _();if(!e)return!1;let t=await Yt(e.markdown);return l(t?`copied`:`failed`),t},y=async()=>{let e=await _();e&&(e.markdown.length>6e3&&await v(),s(await Gq(Wq(e,i.githubTruncated))?null:i.openFailed))};return(0,$.jsx)(`main`,{className:`flex min-h-dvh items-center justify-center bg-surface-base px-5 py-12 text-fg`,children:(0,$.jsxs)(`section`,{className:`w-full max-w-lg rounded-2xl border border-edge bg-surface-panel p-6 shadow-surface sm:p-8`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.18em] text-accent`,children:i.eyebrow}),(0,$.jsx)(`h1`,{className:`mt-3 text-2xl font-semibold tracking-tight`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:i.description}),(0,$.jsxs)(`div`,{className:`mt-6 flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(X,{className:`sm:flex-1`,variant:`primary`,onClick:()=>void g(),children:i.download}),(0,$.jsx)(X,{className:`sm:flex-1`,onClick:()=>window.location.reload(),children:i.reload})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(X,{className:`sm:flex-1`,variant:`ghost`,disabled:u,onClick:()=>void v(),children:u?i.collecting:i.copyReport}),(0,$.jsx)(X,{className:`sm:flex-1`,variant:`ghost`,disabled:u,onClick:()=>void y(),children:u?i.collecting:i.reportIssue})]}),c?(0,$.jsx)(`p`,{className:`mt-4 rounded-xl px-3 py-2 text-sm ${c===`copied`?`bg-accent-soft text-accent`:`bg-warning-soft text-warning`}`,role:`status`,children:c===`copied`?i.copied:i.copyFailed}):null,o?(0,$.jsx)(`p`,{className:`mt-4 rounded-xl bg-warning-soft px-3 py-2 text-sm text-warning`,role:`alert`,children:o}):null,(0,$.jsxs)(`details`,{className:`mt-6 border-t border-edge pt-4 text-xs text-fg-subtle`,open:!0,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none font-medium text-fg-muted`,children:i.details}),(0,$.jsx)(`p`,{className:`mt-2 leading-5 text-warning`,children:i.reportHint}),(0,$.jsx)(`pre`,{className:`mt-3 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-surface-base p-3 font-mono leading-5`,children:h})]})]})})}function TQ(){let e=(0,Q.c)(2),t=d(),n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(wQ,{error:t,source:`route`}),e[0]=t,e[1]=n),n}var EQ=class extends Z.Component{state={error:null,hasError:!1};static getDerivedStateFromError(e){return{error:e,hasError:!0}}componentDidCatch(e,t){console.error(`Uncaught renderer error`,e,t.componentStack),this.setState({componentStack:t.componentStack??void 0})}render(){return this.state.hasError?(0,$.jsx)(wQ,{componentStack:this.state.componentStack,error:this.state.error,source:`react`}):this.props.children}},DQ=(0,Z.memo)(function(e){let t=(0,Q.c)(19),{className:n}=e,r=Ee(OQ),i;t[0]===r?i=t[1]:(i=xe(r),t[0]=r,t[1]=i);let a=i.settingsMode,o=TW(kQ),s=TW(AQ),c;t[2]===n?c=t[3]:(c=K(`shrink-0 border-t border-edge-subtle/80 px-4 py-3`,n),t[2]=n,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)($i,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=l):l=t[4];let u;t[5]===a.toggleLabel?u=t[6]:(u=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-sm font-medium text-fg`,children:a.toggleLabel}),t[5]=a.toggleLabel,t[6]=u);let d;t[7]===s?d=t[8]:(d=e=>s(e.target.checked),t[7]=s,t[8]=d);let f;t[9]!==a.toggleAria||t[10]!==o||t[11]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5 shrink-0`,checked:o,onChange:d,"aria-label":a.toggleAria}),t[9]=a.toggleAria,t[10]=o,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==u||t[14]!==f?(p=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-xl bg-surface-hover/35 px-3 py-2.5 transition-colors hover:bg-surface-hover/55 dark:bg-surface-hover/20 dark:hover:bg-surface-hover/35`,children:[l,u,f]}),t[13]=u,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==c||t[17]!==p?(m=(0,$.jsx)(`div`,{className:c,children:p}),t[16]=c,t[17]=p,t[18]=m):m=t[18],m});function OQ(e){return e.language}function kQ(e){return e.mode===`advanced`}function AQ(e){return e.setShowAdvanced}var jQ={sessions:oe,logs:zr,settingsImports:oe,settingsOverview:Wn,settingsModels:ri,settingsVoice:hi,settingsSearch:ve,settingsAppearance:Ei,settingsKeyboardShortcuts:ti,settingsSystem:Zi,settingsDesktopPet:ji,settingsDesktopApp:Ti,settingsAgentBrowser:ce,settingsComputerUse:bi,settingsAgentDefaults:ri,settingsGateway:ce,settingsRuntimes:na,settingsDevices:ea,settingsHeartbeat:Yr,settingsTunnel:Bi,settingsShares:Yi};function MQ(e){let t=(0,Q.c)(3),{tab:n,className:r}=e,i=jQ[n],a;return t[0]!==i||t[1]!==r?(a=(0,$.jsx)(i,{className:r,strokeWidth:1.75,"aria-hidden":!0}),t[0]=i,t[1]=r,t[2]=a):a=t[2],a}function NQ(e){let t=(0,Q.c)(34),{navLinkClassName:n,showAdvanced:r}=e,i=r===void 0?!0:r,a=Ee(PQ),o;t[0]===a?o=t[1]:(o=xe(a),t[0]=a,t[1]=o);let s=o,c=ij(),l,u,d,f,p;if(t[2]!==s||t[3]!==n||t[4]!==i||t[5]!==c){p=Symbol.for(`react.early_return_sentinel`);bb0:{let e=FQ(c);if(!i){p=null;break bb0}t[11]===s.settingsNavGroups.extensions?f=t[12]:(f=(0,$.jsx)(`p`,{className:`px-4 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-fg-muted`,children:s.settingsNavGroups.extensions}),t[11]=s.settingsNavGroups.extensions,t[12]=f),l=`flex flex-col gap-0.5`;let r;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(ir,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=r):r=t[13];let a;t[14]===s.extensionDebug.nav?a=t[15]:(a=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s.extensionDebug.nav}),t[14]=s.extensionDebug.nav,t[15]=a),t[16]!==n||t[17]!==a?(u=(0,$.jsxs)(m,{to:`/settings/extensions/debug`,className:n,children:[r,a]}),t[16]=n,t[17]=a,t[18]=u):u=t[18];let o;t[19]===n?o=t[20]:(o=e=>{let{extension:t,panel:r}=e;return(0,$.jsxs)(m,{to:`/settings/ext/${t.id}/${r.id}`,className:n,children:[(0,$.jsx)(zi,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:r.title})]},`${t.id}:${r.id}`)},t[19]=n,t[20]=o),d=e.map(o)}t[2]=s,t[3]=n,t[4]=i,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p}else l=t[6],u=t[7],d=t[8],f=t[9],p=t[10];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let h;if(t[21]!==n||t[22]!==c){let e;t[24]===n?e=t[25]:(e=e=>(0,$.jsxs)(m,{to:`/settings/ext/${e.id}`,className:n,children:[(0,$.jsx)(zi,{className:`size-5 shrink-0 opacity-90`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})]},`${e.id}:config`),t[24]=n,t[25]=e),h=IQ(c).map(e),t[21]=n,t[22]=c,t[23]=h}else h=t[23];let g;t[26]!==l||t[27]!==u||t[28]!==d||t[29]!==h?(g=(0,$.jsxs)(`div`,{className:l,children:[u,d,h]}),t[26]=l,t[27]=u,t[28]=d,t[29]=h,t[30]=g):g=t[30];let _;return t[31]!==f||t[32]!==g?(_=(0,$.jsxs)(`div`,{children:[f,g]}),t[31]=f,t[32]=g,t[33]=_):_=t[33],_}function PQ(e){return e.language}function FQ(e){let t=[];for(let n of e){let e=n.ui?.contributions?.settingsPanels;if(e)for(let r of e)t.push({extension:n,panel:r})}return t.sort((e,t)=>{let n=e.panel.order??999,r=t.panel.order??999;return n===r?e.panel.title.localeCompare(t.panel.title):n-r}),t}function IQ(e){return e.filter(e=>(!!e.hasConfigSchema||ZA(e))&&!(Array.isArray(e.ui?.contributions?.settingsPanels)&&e.ui.contributions.settingsPanels.length>0))}function LQ(e,t){let n=globalThis.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)}function RQ(e){return globalThis.matchMedia(e).matches}function zQ(e,t){let n=(0,Q.c)(5),r=t===void 0?!1:t,i,a;n[0]===e?(i=n[1],a=n[2]):(i=t=>LQ(e,t),a=()=>RQ(e),n[0]=e,n[1]=i,n[2]=a);let o;return n[3]===r?o=n[4]:(o=()=>r,n[3]=r,n[4]=o),(0,Z.useSyncExternalStore)(i,a,o)}var BQ=`settingsBackPath`;function VQ(e){if(!e||typeof e!=`object`)return`/chat`;let t=e[BQ];if(typeof t!=`string`)return`/chat`;let n=t.trim();return!n.startsWith(`/`)||n.startsWith(`//`)?`/chat`:n}var HQ=`xopc-web-settings-rail-width-px`;function UQ(e){return Math.min(360,Math.max(192,Math.round(e)))}function WQ(){try{let e=globalThis.localStorage?.getItem(HQ);if(e==null)return UQ(228);let t=Number.parseInt(e,10);return UQ(Number.isFinite(t)?t:228)}catch{return UQ(228)}}function GQ(e){try{globalThis.localStorage?.setItem(HQ,String(e))}catch{}}var KQ=Oe((e,t)=>({widthPx:WQ(),setWidthPx:n=>{let r=UQ(n);t().widthPx!==r&&(e({widthPx:r}),queueMicrotask(()=>GQ(r)))}}));function qQ({isActive:e}){return K(`touch-target flex w-full shrink-0 items-center gap-2.5 rounded-xl px-4 py-2 text-sm font-medium leading-6 transition-colors duration-200 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,e?`bg-surface-active text-fg [&_svg]:text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`)}var JQ=K(`touch-target inline-flex max-w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium transition-colors duration-200 ease-out`,`text-fg-muted hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`sm:px-4`),YQ=K(`inline-flex size-11 shrink-0 items-center justify-center rounded-xl text-fg-muted transition-colors duration-200 ease-out`,`hover:bg-surface-hover hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,md);function XQ(e,t){return e.tabs.filter(e=>vW(e,t)?!uf.has(e)||An():!1)}function ZQ(e){let t=(0,Q.c)(26),{group:n,groupIndex:r,language:i,location:a,settingsMode:o}=e,s;t[0]===i?s=t[1]:(s=xe(i),t[0]=i,t[1]=s);let c=s,l,u,d,f;if(t[2]!==n||t[3]!==r||t[4]!==i||t[5]!==a||t[6]!==c||t[7]!==o){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=XQ(n,o);if(e.length===0){f=null;break bb0}let s=r===0&&`pt-0`,p;t[12]===s?p=t[13]:(p=K(`px-4 pb-1 pt-2 text-xs font-medium text-fg-muted`,s),t[12]=s,t[13]=p);let h=c.settingsNavGroups[n.id];t[14]!==p||t[15]!==h?(d=(0,$.jsx)(`p`,{className:p,children:h}),t[14]=p,t[15]=h,t[16]=d):d=t[16],l=`flex flex-col gap-0.5`;let g;t[17]!==i||t[18]!==a?(g=e=>(0,$.jsxs)(m,{to:_f(e),state:a.state,onMouseEnter:()=>Jp(_f(e)),onFocus:()=>Jp(_f(e)),className:t=>{let{isActive:n}=t;return qQ({isActive:n||bf(e,a.pathname)})},children:[(0,$.jsx)(MQ,{tab:e,className:`size-5 shrink-0 opacity-90`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:be(i,e)})]},e),t[17]=i,t[18]=a,t[19]=g):g=t[19],u=e.map(g)}t[2]=n,t[3]=r,t[4]=i,t[5]=a,t[6]=c,t[7]=o,t[8]=l,t[9]=u,t[10]=d,t[11]=f}else l=t[8],u=t[9],d=t[10],f=t[11];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[20]!==l||t[21]!==u?(p=(0,$.jsx)(`div`,{className:l,children:u}),t[20]=l,t[21]=u,t[22]=p):p=t[22];let h;return t[23]!==d||t[24]!==p?(h=(0,$.jsxs)(`div`,{children:[d,p]}),t[23]=d,t[24]=p,t[25]=h):h=t[25],h}var QQ=(0,Z.memo)(function(){let e=(0,Q.c)(105),t=Ee($Q),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n,i=b(),a=TW(e$),o=KQ(t$),s=KQ(n$),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),p=zQ(Cn),m=Df({runtime:Ef(),sidebarCollapsed:!1,mobileNavOpen:u}),h=p?m.sidebarLeadingInsetClass:``,g;e[2]===s?g=e[3]:(g=e=>{e.preventDefault();let t=e.currentTarget,n=t.parentElement;t.setPointerCapture(e.pointerId),l(!0);let r=e.clientX,i=KQ.getState().widthPx,a=e.pointerId,o=0,c=i,u=i,d=()=>{o=0,u=c,n?.style.setProperty(`--settings-rail-px`,`${u}px`)},f=e=>{c=UQ(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(d))},p=()=>{o!==0&&(window.cancelAnimationFrame(o),d());try{t.releasePointerCapture(a)}catch{}l(!1),s(u),window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),window.removeEventListener(`pointercancel`,p)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p),window.addEventListener(`pointercancel`,p)},e[2]=s,e[3]=g);let v=g,x;e[4]===i.state?x=e[5]:(x=VQ(i.state),e[4]=i.state,e[5]=x);let S=x,C=r.sidebar.backToApp,w;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(w=K(JQ,md),e[6]=w):w=e[6];let T;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Jn,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),e[7]=T):T=e[7];let E;e[8]===C?E=e[9]:(E=(0,$.jsx)(`span`,{children:C}),e[8]=C,e[9]=E);let D;e[10]!==C||e[11]!==S||e[12]!==E?(D=(0,$.jsxs)(y,{to:S,replace:!1,className:w,title:C,children:[T,E]}),e[10]=C,e[11]=S,e[12]=E,e[13]=D):D=e[13];let O=D,k;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(k=ff.map(r$),e[14]=k):k=e[14];let A=k,j;if(e[15]!==i.pathname||e[16]!==a){let t;e[18]===a?t=e[19]:(t=e=>XQ(e,a),e[18]=a,e[19]=t);let n;e[20]===i.pathname?n=e[21]:(n=e=>bf(e,i.pathname),e[20]=i.pathname,e[21]=n),j=A.flatMap(t).find(n),e[15]=i.pathname,e[16]=a,e[17]=j}else j=e[17];let M=j,N;e[22]!==i.pathname||e[23]!==a?(N=yW(i.pathname,a),e[22]=i.pathname,e[23]=a,e[24]=N):N=e[24];let P=!N,F;e[25]!==M||e[26]!==t||e[27]!==r.nav.settings?(F=M?be(t,M):r.nav.settings,e[25]=M,e[26]=t,e[27]=r.nav.settings,e[28]=F):F=e[28];let I=F,L;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>{d(!1)},e[29]=L):L=e[29];let R;e[30]!==i.pathname||e[31]!==i.search?(R=[i.pathname,i.search],e[30]=i.pathname,e[31]=i.search,e[32]=R):R=e[32],(0,Z.useEffect)(L,R);let z=r.nav.settings,B;e[33]!==t||e[34]!==i||e[35]!==a?(B=A.map((e,n)=>(0,$.jsx)(ZQ,{group:e,groupIndex:n,language:t,location:i,settingsMode:a},e.id)),e[33]=t,e[34]=i,e[35]=a,e[36]=B):B=e[36];let V=a===`advanced`,H;e[37]===V?H=e[38]:(H=(0,$.jsx)(NQ,{navLinkClassName:qQ,showAdvanced:V}),e[37]=V,e[38]=H);let U;e[39]!==B||e[40]!==H?(U=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[B,H]}),e[39]=B,e[40]=H,e[41]=U):U=e[41];let W;e[42]!==r.nav.settings||e[43]!==U?(W=(0,$.jsx)(`nav`,{className:`min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-4 pt-2`,"aria-label":z,children:U}),e[42]=r.nav.settings,e[43]=U,e[44]=W):W=e[44];let G;e[45]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(DQ,{}),e[45]=G):G=e[45];let ee;e[46]===W?ee=e[47]:(ee=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[W,G]}),e[46]=W,e[47]=ee);let te=ee,ne;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(Jn,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),e[48]=ne):ne=e[48];let re;e[49]!==C||e[50]!==S?(re=(0,$.jsx)(y,{to:S,className:YQ,title:C,"aria-label":C,children:ne}),e[49]=C,e[50]=S,e[51]=re):re=e[51];let ie;e[52]===r.nav.settings?ie=e[53]:(ie=(0,$.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-fg-subtle`,children:r.nav.settings}),e[52]=r.nav.settings,e[53]=ie);let ae;e[54]===I?ae=e[55]:(ae=(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:I}),e[54]=I,e[55]=ae);let oe;e[56]!==ie||e[57]!==ae?(oe=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[ie,ae]}),e[56]=ie,e[57]=ae,e[58]=oe):oe=e[58];let se;e[59]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>d(!0),e[59]=se):se=e[59];let ce;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(ci,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),e[60]=ce):ce=e[60];let le;e[61]!==r.nav.settings||e[62]!==u?(le=(0,$.jsx)(`button`,{type:`button`,className:YQ,onClick:se,"aria-label":r.nav.settings,"aria-expanded":u,children:ce}),e[61]=r.nav.settings,e[62]=u,e[63]=le):le=e[63];let ue;e[64]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(Ye,{className:`xopc-mobile-nav-overlay fixed inset-0 z-[75] bg-scrim/45 backdrop-blur-[1px] md:hidden`}),e[64]=ue):ue=e[64];let de;e[65]===r.nav.settings?de=e[66]:(de=(0,$.jsx)(tt,{className:`sr-only`,children:r.nav.settings}),e[65]=r.nav.settings,e[66]=de);let fe;e[67]===I?fe=e[68]:(fe=(0,$.jsx)(Ze,{className:`sr-only`,children:I}),e[67]=I,e[68]=fe);let pe;e[69]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,$.jsx)(ye,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),e[69]=pe):pe=e[69];let me;e[70]===r.nav.settings?me=e[71]:(me=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:YQ,"aria-label":r.nav.settings,children:pe})}),e[70]=r.nav.settings,e[71]=me);let he;e[72]!==O||e[73]!==me?(he=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 px-4 pb-2 pt-4`,children:[O,me]}),e[72]=O,e[73]=me,e[74]=he):he=e[74];let ge;e[75]!==te||e[76]!==de||e[77]!==fe||e[78]!==he?(ge=(0,$.jsxs)($e,{children:[ue,(0,$.jsxs)(et,{className:`xopc-mobile-nav-content app-chrome-sidebar fixed inset-y-0 left-0 z-[76] flex w-[min(20rem,calc(100vw-3rem))] flex-col bg-surface-rail shadow-float outline-none md:hidden`,children:[de,fe,he,te]})]}),e[75]=te,e[76]=de,e[77]=fe,e[78]=he,e[79]=ge):ge=e[79];let _e;e[80]!==u||e[81]!==ge?(_e=(0,$.jsx)(nt,{open:u,onOpenChange:d,children:ge}),e[80]=u,e[81]=ge,e[82]=_e):_e=e[82];let ve=c&&`settings-page-rail-resizing`,q;e[83]===ve?q=e[84]:(q=K(`app-chrome-sidebar relative hidden shrink-0 flex-col bg-surface-rail md:flex`,`md:h-full md:min-h-0 md:shrink-0 md:overflow-hidden`,`settings-page-rail`,ve),e[83]=ve,e[84]=q);let Se=`${o}px`,Ce;e[85]===Se?Ce=e[86]:(Ce={"--settings-rail-px":Se},e[85]=Se,e[86]=Ce);let we=Ce,Te=K(`flex shrink-0 items-center justify-between gap-2 pb-2 pt-4`,m.sidebarChromeDraggable&&`[-webkit-app-region:drag]`,h,p&&m.sidebarLeadingInsetClass?`pr-4`:`px-4`),De;e[87]!==O||e[88]!==Te?(De=(0,$.jsx)(`div`,{className:Te,children:O}),e[87]=O,e[88]=Te,e[89]=De):De=e[89];let Oe=r.sidebar.resizeHandleAria,J=c&&`bg-surface-hover/30 before:bg-edge/80! dark:before:bg-edge/85!`,ke;e[90]===J?ke=e[91]:(ke=K(`pointer-events-auto absolute right-0 top-0 z-10 hidden h-full w-2 shrink-0 cursor-col-resize md:block`,`before:content-[''] before:pointer-events-none before:absolute before:left-1/2 before:top-0 before:z-0 before:h-full before:w-px before:-translate-x-1/2`,`before:bg-transparent before:transition-[background-color] before:duration-150`,`hover:bg-surface-hover/20 hover:before:bg-edge/65 dark:hover:before:bg-edge/75`,J,`transition-[background-color] duration-150`,`touch-none select-none`,md),e[90]=J,e[91]=ke);let Ae;e[92]!==r.sidebar.resizeHandleAria||e[93]!==v||e[94]!==ke?(Ae=(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":Oe,onPointerDown:v,className:ke}),e[92]=r.sidebar.resizeHandleAria,e[93]=v,e[94]=ke,e[95]=Ae):Ae=e[95];let je;e[96]!==te||e[97]!==q||e[98]!==we||e[99]!==De||e[100]!==Ae?(je=(0,$.jsxs)(`div`,{className:q,style:we,children:[De,te,Ae]}),e[96]=te,e[97]=q,e[98]=we,e[99]=De,e[100]=Ae,e[101]=je):je=e[101];let Me;return e[102]!==i.pathname||e[103]!==P?(Me=(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overflow-x-hidden overscroll-contain bg-surface-panel scrollbar-gutter-both`,children:P?(0,$.jsx)(_,{to:`/settings/overview`,replace:!0}):(0,$.jsx)(`div`,{className:`settings-content-enter min-h-full`,children:(0,$.jsx)(f,{})},i.pathname)}),e[102]=i.pathname,e[103]=P,e[104]=Me):Me=e[104],(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden md:flex-row`,children:[(0,$.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-2 border-b border-edge-subtle bg-surface-panel px-3 py-2 md:hidden`,m.mainHeaderDraggable&&`[-webkit-app-region:drag]`),children:[re,oe,le]}),_e,je,Me]})});function $Q(e){return e.language}function e$(e){return e.mode}function t$(e){return e.widthPx}function n$(e){return e.setWidthPx}function r$(e){return An()&&e.id===`system`?{...e,tabs:[...e.tabs,...df.tabs]}:e}var i$=(0,Z.memo)(function(e){let t=(0,Q.c)(26),{children:n}=e,r=l(),i=b(),a=Ee(a$),o;t[0]===a?o=t[1]:(o=xe(a),t[0]=a,t[1]=o);let s=o,c;t[2]===i.state?c=t[3]:(c=VQ(i.state),t[2]=i.state,t[3]=c);let u=c,d=zQ(Cn),f,p;t[4]!==u||t[5]!==r?(f=()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),r(u))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},p=[r,u],t[4]=u,t[5]=r,t[6]=f,t[7]=p):(f=t[6],p=t[7]),(0,Z.useEffect)(f,p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=[],t[8]=m):m=t[8],(0,Z.useEffect)(o$,m);let h;t[9]!==u||t[10]!==r?(h=(0,$.jsx)(`div`,{role:`presentation`,className:`absolute inset-0 z-40 bg-scrim/55 backdrop-blur-[2px] dark:bg-black/50`,onClick:()=>r(u)}),t[9]=u,t[10]=r,t[11]=h):h=t[11];let g=h,_;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=K(`relative z-50 flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,`max-md:shadow-elevated`,`md:m-3 md:max-h-[calc(100dvh-1.5rem)] md:rounded-2xl md:border md:border-edge md:shadow-elevated`,`settings-sheet-enter`),t[12]=_):_=t[12];let v;t[13]===n?v=t[14]:(v=(0,$.jsx)(kn,{layer:`page`,children:n}),t[13]=n,t[14]=v);let y;t[15]!==s.nav.settings||t[16]!==v?(y=(0,$.jsx)(`div`,{className:_,role:`dialog`,"aria-modal":`true`,"aria-label":s.nav.settings,children:v}),t[15]=s.nav.settings,t[16]=v,t[17]=y):y=t[17];let x=y,S;t[18]!==x||t[19]!==g?(S=(0,$.jsxs)($.Fragment,{children:[g,x]}),t[18]=x,t[19]=g,t[20]=S):S=t[20];let C=S;if(d){let e;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(e=K(`fixed inset-0 flex min-h-0 flex-col bg-surface-base`,Tn),t[21]=e):e=t[21];let n;return t[22]===C?n=t[23]:(n=(0,Hn.createPortal)((0,$.jsx)(`div`,{className:e,children:C}),document.body),t[22]=C,t[23]=n),n}let w;return t[24]===C?w=t[25]:(w=(0,$.jsx)(`div`,{className:`relative flex min-h-0 min-h-[100dvh] flex-1 flex-col md:min-h-0`,children:C}),t[24]=C,t[25]=w),w});function a$(e){return e.language}function o$(){let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}}function s$(e){let t=(0,Q.c)(24),{sk:n,onPick:r,disabled:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(ta,{className:`size-4`,"aria-hidden":!0}),t[0]=a):a=t[0];let o;t[1]===n.findCapability?o=t[2]:(o=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm text-accent-fg`,children:[a,n.findCapability]}),t[1]=n.findCapability,t[2]=o);let s;t[3]===n.findWelcome?s=t[4]:(s=(0,$.jsx)(`h1`,{className:`text-xl font-semibold text-fg`,children:n.findWelcome}),t[3]=n.findWelcome,t[4]=s);let c;t[5]===n.findDescription?c=t[6]:(c=(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:n.findDescription}),t[5]=n.findDescription,t[6]=c);let l;if(t[7]!==i||t[8]!==r||t[9]!==n.findExamples){let e;t[11]!==i||t[12]!==r?(e=e=>(0,$.jsx)(X,{disabled:i,onClick:()=>r(e),children:e},e),t[11]=i,t[12]=r,t[13]=e):e=t[13],l=n.findExamples.map(e),t[7]=i,t[8]=r,t[9]=n.findExamples,t[10]=l}else l=t[10];let u;t[14]===l?u=t[15]:(u=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:l}),t[14]=l,t[15]=u);let d;t[16]===n.findBack?d=t[17]:(d=(0,$.jsx)(y,{to:`/capabilities/skills`,className:`text-sm text-accent-fg hover:underline`,children:n.findBack}),t[16]=n.findBack,t[17]=d);let f;return t[18]!==o||t[19]!==s||t[20]!==c||t[21]!==u||t[22]!==d?(f=(0,$.jsxs)(`section`,{className:`mx-auto flex max-w-xl flex-col items-start gap-4 py-8 sm:py-12`,children:[o,s,c,u,d]}),t[18]=o,t[19]=s,t[20]=c,t[21]=u,t[22]=d,t[23]=f):f=t[23],f}function c$(){return q(J(`/api/browser/status`))}function l$(){return q(J(`/api/browser/test`),{method:`POST`})}function u$(e=!1){return q(J(`/api/browser/extension/install`),{method:`POST`,body:JSON.stringify({force:e})})}function d$(e){return q(J(`/api/browser/extension/open`),{method:`POST`,body:JSON.stringify({action:e})})}async function f$(e,t){let n=await we(J(`/api/browser/playwright/install/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},signal:t});if(!n.ok||!n.body)throw Error(`Chromium install request failed (HTTP ${n.status}).`);let r=n.body.getReader(),i=new TextDecoder,a=``,o;try{for(;!o;){let t=await r.read();if(t.done)break;a+=i.decode(t.value,{stream:!0}),a=a.replace(/\r\n/g,`
105
- `);let n=a.split(`
106
-
107
- `);a=n.pop()??``;for(let t of n){let n=t.split(`
108
- `).find(e=>e.startsWith(`event:`))?.slice(6).trim(),r=t.split(`
109
- `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(``);r&&(n===`progress`&&e(JSON.parse(r)),n===`result`&&(o=JSON.parse(r)))}}}finally{r.releaseLock()}if(!o)throw Error(`Chromium installer ended without a result.`);return o}async function p$(){await q(J(`/api/browser/playwright/install/cancel`),{method:`POST`})}var m$=3e3,h$=3e4;function g$(e){return e?e.setupState?e.setupState:e.connected?`connected`:e.artifacts?e.artifacts.installed===!0?`installed_not_connected`:`not_installed`:`loading`:`loading`}function _$(e){let t=Se(e=>e.baseUrl),n=Se(e=>e.conversationId),r=Zt(e?[`chat-browser-extension-status`,t,n??`anonymous`]:null,c$,{revalidateOnFocus:!0,refreshInterval:e=>e?.payload.driverKind===`extension`&&e.payload.state===`ready`?h$:m$}),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),c=r.data?.payload,l=g$(c?.driverKind===`extension`?c.driverStatus:void 0),u=l===`installed_not_connected`||l===`connected`;return(0,Z.useEffect)(()=>{if(!e)return;let t=()=>void r.mutate();return window.addEventListener(`gateway-realtime-connected`,t),window.addEventListener(`realtime-gap`,t),window.addEventListener(`gateway-authenticated`,t),()=>{window.removeEventListener(`gateway-realtime-connected`,t),window.removeEventListener(`realtime-gap`,t),window.removeEventListener(`gateway-authenticated`,t)}},[e,r.mutate]),{status:c,setupState:l,installed:u,busy:i,error:o,prepareAndOpen:(0,Z.useCallback)(async()=>{a(!0),s(null);try{u||await u$(!1),await d$(`both`),await r.mutate()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[u,r.mutate])}}var v$=`xopc:browser-extension-nudge:v1`,y$=720*60*60*1e3;function b$(e=Date.now()){try{let t=Number(globalThis.localStorage?.getItem(v$));return Number.isFinite(t)&&t>0&&e-t<y$}catch{return!1}}function x$({enabled:e}){let t=xe(Ee(e=>e.language)).chat,[n,r]=(0,Z.useState)(()=>b$()),i=_$(e&&!n),a=i.status;return e&&!n&&a?.enabled===!0&&a.driverKind===`extension`&&a.localManagementAvailable===!0&&i.setupState!==`loading`&&i.setupState!==`connected`?(0,$.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base px-4 py-3 transition-opacity duration-200 motion-reduce:transition-none sm:flex-row sm:items-center sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-full bg-surface-inset text-fg`,"aria-hidden":!0,children:(0,$.jsx)(zi,{className:`size-5`,strokeWidth:1.75})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.installed?t.browserExtensionReconnectTitle:t.browserExtensionNudgeTitle}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:i.installed?t.browserExtensionReconnectBody:t.browserExtensionNudgeBody}),i.error?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-danger`,role:`alert`,children:i.error}):null]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1`,children:[(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`h-9 shrink-0 px-4`,disabled:i.busy,onClick:()=>void i.prepareAndOpen(),children:[i.busy?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`}):null,i.installed?t.browserExtensionNudgeReconnect:t.browserExtensionNudgeInstall]}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-subtle transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 motion-reduce:transition-none`,"aria-label":t.browserExtensionNudgeDismiss,onClick:()=>{try{globalThis.localStorage?.setItem(v$,String(Date.now()))}catch{}r(!0)},children:(0,$.jsx)(ye,{className:`size-4`})})]})]}):null}function S$(e){let t=`/api/sessions/${encodeURIComponent(e)}/connection-wait`,{data:n,mutate:r,isLoading:i}=Zt(t,async e=>(await q(J(e))).payload,{refreshInterval:e=>e?.wait?5e3:0,revalidateOnFocus:!0}),a=(0,Z.useRef)(n);a.current=n;let o=(0,Z.useRef)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(),d=(0,Z.useCallback)(async(e,n,i,s,l)=>{let d=a.current,f=d?.wait;if(!f||o.current)return;o.current=!0,c(!0),u(void 0);let p=e===`connect`?aY():null;try{let a=await q(J(`${t}/actions`),{method:`POST`,body:JSON.stringify({action:e,needKey:n,accountId:i,candidateRef:s,callbackUrl:l,waitId:f.id,expectedTranscriptId:d.transcriptId,expectedVersion:f.version,idempotencyKey:crypto.randomUUID()})}),o=a.payload.snapshot;if(await r(e=>!e||e.transcriptId!==o.transcriptId||o.revision>=e.revision?o:e,!1),a.payload.authorizationUrl){if(!await oY(a.payload.authorizationUrl,p))throw Error(`Unable to open the authorization window. Allow pop-ups, then retry.`)}else sY(p)}catch(e){sY(p),e.status!==409&&u(e instanceof Error?e.message:String(e)),await r()}finally{o.current=!1,c(!1)}},[t,r]);return(0,Z.useEffect)(()=>{let t=t=>{let n=t.detail;n?.conversationId===e&&(n.revision??1/0)>(a.current?.revision??0)&&r()};return window.addEventListener(`session-connection-wait-changed`,t),()=>window.removeEventListener(`session-connection-wait-changed`,t)},[e,r]),{wait:n?.wait,isLoading:i,busy:s,error:l,act:d}}var C$={zh:{waiting:`等待连接`,connect:`连接并继续`,reconnect:`重新连接`,details:`查看详情`,skip:`跳过连接`,cancel:`取消这个目标`,ready:`连接已就绪`,continue:`继续`,check:`我已完成授权`,authorizing:`等待完成授权`,queued:`已排队,准备继续`,scope:`确认后继续`,scopeHint:`这个目标已等待了一段时间。请确认仍要按下方原始要求继续;如需修改时间范围,请先在聊天中说明。未读等条件将以实际执行时为准。`,account:`选择账号`,all:`查看全部连接器`,close:`关闭`,intro:`完成连接后,将继续当前目标。你也可以继续发送消息。`,callbackHint:`远程 Gateway 无法接收本地回调时,粘贴浏览器地址栏中的完整回调 URL。`,callbackPlaceholder:`完整回调 URL`,callbackSubmit:`完成连接`,replace:`更换应用`,confirmReplace:`确认改用`,apps:`个应用需要连接`,preserved:`目标已保留`,retry:`重试检查`,toolsUnavailable:`应用工具暂不可用`,toolsHint:`账号已连接,当前无法使用任务所需工具。可以重试检查,无需重新授权。`},en:{waiting:`Waiting for connection`,connect:`Connect and continue`,reconnect:`Reconnect`,details:`Details`,skip:`Skip connection`,cancel:`Cancel this objective`,ready:`Connection ready`,continue:`Continue`,check:`Check authorization`,authorizing:`Waiting for authorization`,queued:`Queued to continue`,scope:`Confirm and continue`,scopeHint:`This objective has been waiting for a while. Confirm the original request below, or send a message to change the time range first. Conditions such as unread status are evaluated at execution time.`,account:`Choose an account`,all:`View all connectors`,close:`Close`,intro:`The current objective will continue after connecting. You can keep sending messages.`,callbackHint:`If a remote Gateway cannot receive the local callback, paste the complete callback URL from the browser address bar.`,callbackPlaceholder:`Complete callback URL`,callbackSubmit:`Complete connection`,replace:`Change app`,confirmReplace:`Confirm switch to`,apps:`apps need connecting`,preserved:`Objective preserved`,retry:`Retry check`,toolsUnavailable:`App tools unavailable`,toolsHint:`The account is connected, but the tools needed for this task are unavailable. Retry the check without reconnecting.`}},w$=`rounded-lg border border-edge px-3 py-1.5 text-sm text-fg hover:bg-surface-hover disabled:opacity-50`,T$=`rounded-lg bg-accent px-3 py-1.5 text-sm text-on-accent disabled:opacity-50`;function E$(e){let t=(0,Q.c)(133),{conversationId:n}=e,{wait:r,isLoading:i,busy:a,error:o,act:s}=S$(n),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={},t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),h=Ee(A$),g=C$[h];if(i){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(xn,{className:`mb-2 h-10 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(!r)return null;let _=r.needs[0],v=r.needs.length===1,y=r.phase===`queued`,b=r.needs.some(k$),x=y?g.queued:r.phase===`ready`?g.continue:r.phase===`review_scope`?g.scope:v&&_.phase===`connect`?h===`zh`?`连接 ${_.label} 并继续`:`Connect ${_.label} and continue`:v&&_.phase===`reconnect`?g.reconnect:v&&_.phase===`authorizing`?g.check:g.details,C;t[2]!==s||t[3]!==_||t[4]!==v||t[5]!==r.phase?(C=function(){r?.phase===`ready`?s(`continue`):r?.phase===`review_scope`?l(!0):v&&[`connect`,`reconnect`].includes(_.phase)?s(`connect`,_.key):v&&_.phase===`authorizing`?s(`check`):l(!0)},t[2]=s,t[3]=_,t[4]=v,t[5]=r.phase,t[6]=C):C=t[6];let w=C,T=b?g.toolsUnavailable:g.waiting,E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(le,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=E):E=t[7];let D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=()=>l(!0),t[8]=D):D=t[8];let O=b?g.toolsUnavailable:r.phase===`ready`?g.ready:v?`${g.waiting} · ${_.label}`:`${r.needs.length} ${g.apps}`,k;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(lr,{className:`ml-1 inline size-3`,"aria-hidden":!0}),t[9]=k):k=t[9];let j;t[10]===O?j=t[11]:(j=(0,$.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left text-sm text-fg`,onClick:D,children:[O,k]}),t[10]=O,t[11]=j);let M=a||y,N;t[12]===a?N=t[13]:(N=a&&(0,$.jsx)(ue,{className:`mr-1 inline size-3 animate-spin`,"aria-hidden":!0}),t[12]=a,t[13]=N);let P;t[14]!==x||t[15]!==w||t[16]!==N||t[17]!==M?(P=(0,$.jsxs)(`button`,{type:`button`,className:T$,disabled:M,onClick:w,children:[N,x]}),t[14]=x,t[15]=w,t[16]=N,t[17]=M,t[18]=P):P=t[18];let F=a||y,I;t[19]===s?I=t[20]:(I=()=>void s(`skip`),t[19]=s,t[20]=I);let L;t[21]!==g.skip||t[22]!==F||t[23]!==I?(L=(0,$.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-fg`,disabled:F,onClick:I,children:g.skip}),t[21]=g.skip,t[22]=F,t[23]=I,t[24]=L):L=t[24];let R;t[25]!==P||t[26]!==L||t[27]!==j?(R=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E,j,P,L]}),t[25]=P,t[26]=L,t[27]=j,t[28]=R):R=t[28];let z;t[29]!==s||t[30]!==o||t[31]!==g.retry?(z=o&&(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-fg-muted`,children:[o,` `,(0,$.jsx)(`button`,{type:`button`,className:`text-accent`,onClick:()=>void s(`check`),children:g.retry})]}),t[29]=s,t[30]=o,t[31]=g.retry,t[32]=z):z=t[32];let B;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[2px]`}),t[33]=B):B=t[33];let V;t[34]===g.preserved?V=t[35]:(V=(0,$.jsx)(tt,{className:`font-medium text-fg`,children:g.preserved}),t[34]=g.preserved,t[35]=V);let H;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(ye,{className:`size-4`}),t[36]=H):H=t[36];let U;t[37]===g.close?U=t[38]:(U=(0,$.jsx)(Qe,{"aria-label":g.close,children:H}),t[37]=g.close,t[38]=U);let W;t[39]!==V||t[40]!==U?(W=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[V,U]}),t[39]=V,t[40]=U,t[41]=W):W=t[41];let G=b?g.toolsHint:r.phase===`review_scope`?g.scopeHint:g.intro,ee;t[42]===G?ee=t[43]:(ee=(0,$.jsx)(Ze,{className:`text-sm text-fg-muted`,children:G}),t[42]=G,t[43]=ee);let te;t[44]===r.summary?te=t[45]:(te=(0,$.jsx)(`p`,{className:`whitespace-pre-wrap rounded-lg border border-edge p-3 text-sm text-fg`,children:r.summary}),t[44]=r.summary,t[45]=te);let ne;t[46]!==h||t[47]!==r.objectiveUpdatedAt?(ne=new Date(r.objectiveUpdatedAt).toLocaleString(h===`zh`?`zh-CN`:`en-US`),t[46]=h,t[47]=r.objectiveUpdatedAt,t[48]=ne):ne=t[48];let re;t[49]===ne?re=t[50]:(re=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ne}),t[49]=ne,t[50]=re);let ie;t[51]!==h||t[52]!==r.timeRange?(ie=r.timeRange&&(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[new Date(r.timeRange.from).toLocaleString(h,{timeZone:r.timeRange.timezone}),` – `,new Date(r.timeRange.to).toLocaleString(h,{timeZone:r.timeRange.timezone}),` (`,r.timeRange.timezone,`)`]}),t[51]=h,t[52]=r.timeRange,t[53]=ie):ie=t[53];let ae;if(t[54]!==s||t[55]!==a||t[56]!==p||t[57]!==y||t[58]!==u||t[59]!==g.account||t[60]!==g.authorizing||t[61]!==g.callbackHint||t[62]!==g.callbackPlaceholder||t[63]!==g.callbackSubmit||t[64]!==g.check||t[65]!==g.confirmReplace||t[66]!==g.connect||t[67]!==g.ready||t[68]!==g.reconnect||t[69]!==g.replace||t[70]!==g.retry||t[71]!==r.needs){let e;t[73]!==s||t[74]!==a||t[75]!==p||t[76]!==y||t[77]!==u||t[78]!==g.account||t[79]!==g.authorizing||t[80]!==g.callbackHint||t[81]!==g.callbackPlaceholder||t[82]!==g.callbackSubmit||t[83]!==g.check||t[84]!==g.confirmReplace||t[85]!==g.connect||t[86]!==g.ready||t[87]!==g.reconnect||t[88]!==g.replace||t[89]!==g.retry?(e=e=>(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[e.label,e.accountSelector?` · ${e.accountSelector}`:``]}),e.capabilityError?(0,$.jsx)(`button`,{type:`button`,disabled:a||y,className:w$,onClick:()=>void s(`check`),children:g.retry}):e.phase===`ready`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(S,{className:`mr-1 inline size-3`}),g.ready]}):e.phase===`authorizing`?(0,$.jsx)(`button`,{type:`button`,disabled:a,className:w$,onClick:()=>void s(`check`),children:g.check}):e.phase!==`blocked`&&e.phase!==`choose_account`?(0,$.jsx)(`button`,{type:`button`,disabled:a||y,className:T$,onClick:()=>void s(`connect`,e.key),children:e.phase===`reconnect`?g.reconnect:g.connect}):null]}),e.accounts.length>0&&(0,$.jsx)(A,{value:e.accountId??``,options:e.accounts.map(O$),placeholder:g.account,ariaLabel:`${e.label}: ${g.account}`,allowEmpty:!1,disabled:a||y,onChange:t=>void s(`select_account`,e.key,t)}),e.alternatives?.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(A,{value:u?.needKey===e.key?u.candidateRef:``,options:e.alternatives.map(D$),placeholder:g.replace,ariaLabel:`${e.label}: ${g.replace}`,disabled:a||y,allowEmpty:!1,onChange:t=>d({needKey:e.key,candidateRef:t,label:e.alternatives.find(e=>e.candidateRef===t).label})}),u?.needKey===e.key&&(0,$.jsxs)(`button`,{type:`button`,className:w$,disabled:a,onClick:()=>{s(`replace_source`,e.key,void 0,u.candidateRef),d(void 0)},children:[g.confirmReplace,` `,u.label]})]}):null,e.reason&&(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.reason}),e.phase===`authorizing`&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:g.authorizing}),(0,$.jsx)(`button`,{type:`button`,disabled:a,className:`text-accent`,onClick:()=>void s(`connect`,e.key),children:g.reconnect})]}),e.phase===`authorizing`&&e.target.type===`plugin-mcp`?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:g.callbackHint}),(0,$.jsx)(`input`,{type:`password`,autoComplete:`off`,value:p[e.key]??``,placeholder:g.callbackPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg`,onChange:t=>m(n=>({...n,[e.key]:t.target.value}))}),(0,$.jsx)(`button`,{type:`button`,className:w$,disabled:a||!p[e.key]?.trim(),onClick:()=>{let t=p[e.key].trim();m(t=>({...t,[e.key]:``})),s(`submit_callback`,e.key,void 0,void 0,t)},children:g.callbackSubmit})]}):null]},e.key),t[73]=s,t[74]=a,t[75]=p,t[76]=y,t[77]=u,t[78]=g.account,t[79]=g.authorizing,t[80]=g.callbackHint,t[81]=g.callbackPlaceholder,t[82]=g.callbackSubmit,t[83]=g.check,t[84]=g.confirmReplace,t[85]=g.connect,t[86]=g.ready,t[87]=g.reconnect,t[88]=g.replace,t[89]=g.retry,t[90]=e):e=t[90],ae=r.needs.map(e),t[54]=s,t[55]=a,t[56]=p,t[57]=y,t[58]=u,t[59]=g.account,t[60]=g.authorizing,t[61]=g.callbackHint,t[62]=g.callbackPlaceholder,t[63]=g.callbackSubmit,t[64]=g.check,t[65]=g.confirmReplace,t[66]=g.connect,t[67]=g.ready,t[68]=g.reconnect,t[69]=g.replace,t[70]=g.retry,t[71]=r.needs,t[72]=ae}else ae=t[72];let oe;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>l(!1),t[91]=oe):oe=t[91];let se;t[92]===g.all?se=t[93]:(se=(0,$.jsx)(`a`,{href:`#/capabilities/connectors`,className:`text-sm text-accent`,onClick:oe,children:g.all}),t[92]=g.all,t[93]=se);let ce;t[94]!==ee||t[95]!==te||t[96]!==re||t[97]!==ie||t[98]!==ae||t[99]!==se?(ce=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto p-5`,children:[ee,te,re,ie,ae,se]}),t[94]=ee,t[95]=te,t[96]=re,t[97]=ie,t[98]=ae,t[99]=se,t[100]=ce):ce=t[100];let de=a||y,fe;t[101]===s?fe=t[102]:(fe=()=>void s(`cancel`),t[101]=s,t[102]=fe);let pe;t[103]!==g.cancel||t[104]!==de||t[105]!==fe?(pe=(0,$.jsx)(`button`,{type:`button`,disabled:de,className:`text-sm text-fg-muted`,onClick:fe,children:g.cancel}),t[103]=g.cancel,t[104]=de,t[105]=fe,t[106]=pe):pe=t[106];let me;t[107]!==a||t[108]!==y||t[109]!==r.phase?(me=a||y||![`ready`,`review_scope`].includes(r.phase),t[107]=a,t[108]=y,t[109]=r.phase,t[110]=me):me=t[110];let he;t[111]!==s||t[112]!==r.phase?(he=()=>void s(r.phase===`review_scope`?`confirm_scope`:`continue`),t[111]=s,t[112]=r.phase,t[113]=he):he=t[113];let ge=r.phase===`review_scope`?g.scope:g.continue,_e;t[114]!==me||t[115]!==he||t[116]!==ge?(_e=(0,$.jsx)(`button`,{type:`button`,disabled:me,className:T$,onClick:he,children:ge}),t[114]=me,t[115]=he,t[116]=ge,t[117]=_e):_e=t[117];let ve;t[118]!==pe||t[119]!==_e?(ve=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-edge p-4`,children:[pe,_e]}),t[118]=pe,t[119]=_e,t[120]=ve):ve=t[120];let be;t[121]!==W||t[122]!==ce||t[123]!==ve?(be=(0,$.jsxs)($e,{children:[B,(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(90dvh,34rem)] w-[min(94vw,34rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[W,ce,ve]})]}),t[121]=W,t[122]=ce,t[123]=ve,t[124]=be):be=t[124];let xe;t[125]!==c||t[126]!==be?(xe=(0,$.jsx)(nt,{open:c,onOpenChange:l,children:be}),t[125]=c,t[126]=be,t[127]=xe):xe=t[127];let K;return t[128]!==R||t[129]!==z||t[130]!==T||t[131]!==xe?(K=(0,$.jsxs)(`section`,{className:`mb-2 rounded-xl border border-edge bg-surface-panel px-3 py-2`,"aria-label":T,children:[R,z,xe]}),t[128]=R,t[129]=z,t[130]=T,t[131]=xe,t[132]=K):K=t[132],K}function D$(e){return{value:e.candidateRef,label:e.label}}function O$(e){return{value:e.id,label:e.label}}function k$(e){return e.capabilityError}function A$(e){return e.language}var j$=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`range`,`reset`,`submit`]);function M$(e){if(!(e instanceof Element))return!1;if(e.closest(`textarea, select, [role="textbox"]`)||e instanceof HTMLElement&&e.isContentEditable)return!0;let t=e.closest(`input`);return t instanceof HTMLInputElement&&!j$.has(t.type)}function N$(){return!!document.querySelector(`dialog[open], [aria-modal="true"], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)}function P$(e,t){return t.disabled||t.editorHidden||e.defaultPrevented||M$(e.target)||M$(document.activeElement)?!1:!N$()}function F$(e){return e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.id!=`string`||typeof t.clientMessageId!=`string`||typeof t.content!=`string`||typeof t.version!=`number`||t.effectiveDelivery!==`next`&&t.effectiveDelivery!==`steer`||t.status!==`queued`&&t.status!==`interrupted`)return[];let n=Array.isArray(t.contextRefs)?t.contextRefs.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.kind!==`note`&&t.kind!==`file`&&t.kind!==`session`&&t.kind!==`browser_tab`&&t.kind!==`mcp_resource`||typeof t.sourceId!=`string`||typeof t.version!=`string`||typeof t.title!=`string`?[]:[{...typeof t.refId==`string`?{refId:t.refId}:{},kind:t.kind,sourceId:t.sourceId,expectedVersion:t.version,title:t.title,...t.kind===`file`&&(t.fileKind===`file`||t.fileKind===`directory`)?{fileKind:t.fileKind}:{}}]}):void 0;return[{id:t.id,clientMessageId:t.clientMessageId,text:t.content,attachments:Array.isArray(t.attachments)?t.attachments:void 0,thinkingLevel:typeof t.thinking==`string`?t.thinking:void 0,contextRefs:n?.length?n:void 0,version:t.version,delivery:t.effectiveDelivery,status:t.status}]})}var I$=(0,Z.memo)(function(e){let t=(0,Q.c)(38),{items:n,disabled:r,editingFollowUpId:i,onEditInComposer:a,onRemove:o,onMove:s,onReorder:c,onSteer:l,steeringBusyId:u}=e,d=Ee(L$),f;t[0]===d?f=t[1]:(f=xe(d),t[0]=d,t[1]=f);let p=f,m=R$,h;t[2]===c?h=t[3]:(h=e=>t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`);if(!n.startsWith(`xopc-followup:`))return;let r=Number.parseInt(n.slice(14),10);Number.isNaN(r)||r===e||c(r,e)},t[2]=c,t[3]=h);let g=h;if(n.length===0)return null;let _=p.chat.followUpQueueAria,v;t[4]===p.chat.followUpQueueHeading?v=t[5]:(v=(0,$.jsx)(`span`,{className:`text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted`,children:p.chat.followUpQueueHeading}),t[4]=p.chat.followUpQueueHeading,t[5]=v);let y;t[6]===n.length?y=t[7]:(y=(0,$.jsxs)(`span`,{className:`tabular-nums text-[0.65rem] text-fg-muted`,children:[n.length,`/`,10]}),t[6]=n.length,t[7]=y);let b;t[8]!==v||t[9]!==y?(b=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-0.5`,children:[v,y]}),t[8]=v,t[9]=y,t[10]=b):b=t[10];let x;t[11]!==r||t[12]!==i||t[13]!==n||t[14]!==p.chat.followUpQueueAttachmentOnly||t[15]!==p.chat.followUpQueueClickToEdit||t[16]!==p.chat.followUpQueueDrag||t[17]!==p.chat.followUpQueueEmptyPreview||t[18]!==p.chat.followUpQueueMoveDown||t[19]!==p.chat.followUpQueueMoveUp||t[20]!==p.chat.followUpQueueRemove||t[21]!==p.chat.followUpQueueSteerNow||t[22]!==p.chat.followUpStatusInterrupted||t[23]!==g||t[24]!==a||t[25]!==s||t[26]!==o||t[27]!==l||t[28]!==u?(x=n.map((e,t)=>{let c=e.status===`queued`,d=c||e.status===`interrupted`,f=n.filter(z$),h=f.findIndex(t=>t.id===e.id),_=d&&!e.attachments?.length&&!e.contextRefs?.length&&e.text.trim().length>0,v=u===e.id,y=e.status===`interrupted`?p.chat.followUpStatusInterrupted:null,b=os(e.text),x=new Map(e.contextRefs?.flatMap(B$)??[]),S=new Set(b?ss(b):[]),C=e.contextRefs?.filter(e=>!e.refId||!S.has(e.refId)),w=(b?cs(b,e=>x.get(e)):e.text).trim();return!w&&e.attachments?.length&&(w=e.attachments[0]?.name?.trim()||p.chat.followUpQueueAttachmentOnly),w||=p.chat.followUpQueueEmptyPreview,(0,$.jsxs)(`div`,{role:`listitem`,onDragOver:m,onDrop:r||!c?void 0:g(t),className:K(`flex h-7 items-center gap-1 rounded border px-1`,i===e.id?`border-accent/50 bg-accent-soft/20 dark:border-accent/50 dark:bg-accent-soft/10`:`border-edge-subtle/80 bg-surface-hover/25 dark:border-edge-subtle/90 dark:bg-surface-hover/15`),children:[(0,$.jsx)(`div`,{draggable:!r&&c,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,`xopc-followup:${t}`),e.dataTransfer.effectAllowed=`move`},className:K(`flex shrink-0 cursor-grab items-center active:cursor-grabbing`,(r||!c)&&`cursor-not-allowed opacity-40`),title:p.chat.followUpQueueDrag,children:(0,$.jsx)(Jr,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!c,title:p.chat.followUpQueueClickToEdit,"aria-label":p.chat.followUpQueueClickToEdit,className:K(`h-6 min-w-0 flex-1 truncate rounded px-1.5 text-left text-[0.75rem] leading-none text-fg hover:bg-surface-panel/60 dark:hover:bg-surface-panel/40`,yc.press,yc.focusRingPanel,`disabled:pointer-events-none disabled:opacity-50`),onClick:()=>a(e.id),children:e.attachments?.length?(0,$.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,$.jsx)(Br,{className:`size-3 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:w})]}):(0,$.jsx)(`span`,{className:`block truncate`,children:w})}),C?.length?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 rounded bg-accent-soft px-1.5 py-0.5 text-[0.625rem] text-accent-fg`,title:C.map(V$).join(`, `),children:[(0,$.jsx)(xi,{className:`size-3`,"aria-hidden":!0}),C.length]}):null,y?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-panel px-1.5 py-0.5 text-[0.625rem] text-fg-muted`,children:y}):null,(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-px`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:r||!c||h===0,className:K(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.press,yc.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:p.chat.followUpQueueMoveUp,"aria-label":p.chat.followUpQueueMoveUp,onClick:t=>{t.stopPropagation(),s(e.id,`up`)},children:(0,$.jsx)(ur,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!c||h>=f.length-1,className:K(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.press,yc.focusRingPanel,`disabled:pointer-events-none disabled:opacity-25`),title:p.chat.followUpQueueMoveDown,"aria-label":p.chat.followUpQueueMoveDown,onClick:t=>{t.stopPropagation(),s(e.id,`down`)},children:(0,$.jsx)(cr,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!_||v,className:K(`inline-flex size-6 items-center justify-center rounded text-accent-fg hover:bg-accent-soft/80`,yc.press,yc.focusRingPanel,`disabled:pointer-events-none disabled:opacity-35`),title:p.chat.followUpQueueSteerNow,"aria-label":p.chat.followUpQueueSteerNow,onClick:t=>{t.stopPropagation(),l(e.id)},children:(0,$.jsx)(ta,{className:K(`size-3.5`,v&&`animate-pulse`),"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,disabled:r||!d,className:K(`inline-flex size-6 items-center justify-center rounded text-fg-muted hover:bg-red-500/15 hover:text-red-600 dark:hover:text-red-400`,yc.press,yc.focusRingPanel),title:p.chat.followUpQueueRemove,"aria-label":p.chat.followUpQueueRemove,onClick:t=>{t.stopPropagation(),o(e.id)},children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id)}),t[11]=r,t[12]=i,t[13]=n,t[14]=p.chat.followUpQueueAttachmentOnly,t[15]=p.chat.followUpQueueClickToEdit,t[16]=p.chat.followUpQueueDrag,t[17]=p.chat.followUpQueueEmptyPreview,t[18]=p.chat.followUpQueueMoveDown,t[19]=p.chat.followUpQueueMoveUp,t[20]=p.chat.followUpQueueRemove,t[21]=p.chat.followUpQueueSteerNow,t[22]=p.chat.followUpStatusInterrupted,t[23]=g,t[24]=a,t[25]=s,t[26]=o,t[27]=l,t[28]=u,t[29]=x):x=t[29];let S;t[30]!==n||t[31]!==p.chat.followUpQueueAttachmentsNote?(S=n.some(H$)?(0,$.jsx)(`p`,{className:`px-1 pt-0.5 text-[0.65rem] leading-tight text-fg-muted`,children:p.chat.followUpQueueAttachmentsNote}):null,t[30]=n,t[31]=p.chat.followUpQueueAttachmentsNote,t[32]=S):S=t[32];let C;return t[33]!==p.chat.followUpQueueAria||t[34]!==b||t[35]!==x||t[36]!==S?(C=(0,$.jsxs)(`div`,{className:`space-y-0.5 px-2 py-1.5`,role:`list`,"aria-label":_,children:[b,x,S]}),t[33]=p.chat.followUpQueueAria,t[34]=b,t[35]=x,t[36]=S,t[37]=C):C=t[37],C});function L$(e){return e.language}function R$(e){e.preventDefault(),e.dataTransfer.dropEffect=`move`}function z$(e){return e.status===`queued`}function B$(e){return e.refId?[[e.refId,e.title]]:[]}function V$(e){return e.title}function H$(e){return e.attachments?.length}function U$(e){let t=(0,Q.c)(10),{refs:n,label:r,onRemove:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,$.jsxs)(`span`,{className:`inline-flex h-7 min-w-0 max-w-56 items-center gap-1.5 rounded-md border border-edge-subtle bg-accent-soft/50 px-2 text-xs text-fg`,children:[e.kind===`file`&&e.fileKind===`directory`?(0,$.jsx)(Gr,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`file`?(0,$.jsx)(zr,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(pi,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,$.jsx)(Gn,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,$.jsx)(Or,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(xi,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.title}),(0,$.jsx)(`button`,{type:`button`,className:`-mr-1 inline-flex size-5 shrink-0 items-center justify-center rounded text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":`${r}: ${e.title}`,onClick:()=>i(e.sourceId),children:(0,$.jsx)(ye,{className:`size-3`,"aria-hidden":!0})})]},e.sourceId),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]!==r||t[8]!==a?(o=(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-4 pt-2`,"aria-label":r,children:a}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o}function W$(e,t){let n=(0,Q.c)(13),r=Se(K$),i=Se(G$),a;n[0]!==i||n[1]!==e||n[2]!==r?(a=e?[`session-context`,i,r,e]:null,n[0]=i,n[1]=e,n[2]=r,n[3]=a):a=n[3];let o;n[4]===e?o=n[5]:(o=async()=>(await q(J(`/api/sessions/${encodeURIComponent(e)}/context-summary`))).summary,n[4]=e,n[5]=o);let s;n[6]===t?s=n[7]:(s={keepPreviousData:!1,revalidateOnFocus:t,revalidateOnReconnect:t,shouldRetryOnError:!1},n[6]=t,n[7]=s);let c=Zt(a,o,s),{mutate:l}=c,u,d;return n[8]!==e||n[9]!==l||n[10]!==t?(u=()=>{if(!t||!e)return;l();let n,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>{l()},150)},i=[`session-updated`,`run-completed`,`agent-run-ended`,`note-updated`,`task-changed-v2`,`gateway-realtime-connected`];for(let e of i)window.addEventListener(e,r);return()=>{window.clearTimeout(n);for(let e of i)window.removeEventListener(e,r)}},d=[t,e,l],n[8]=e,n[9]=l,n[10]=t,n[11]=u,n[12]=d):(u=n[11],d=n[12]),(0,Z.useEffect)(u,d),c}function G$(e){return e.baseUrl}function K$(e){return e.conversationId}var q$=`inline-flex h-8 min-w-0 shrink-0 items-center justify-center gap-1.5 rounded-full px-2.5 text-sm text-fg transition-[background-color,transform] hover:bg-surface-hover active:scale-95 disabled:pointer-events-none disabled:opacity-45 motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function J$(e){let t=(0,Q.c)(96),{conversationId:n,project:r,workspacePath:i,canChangeWorkspace:a,disabled:o,environmentPicker:s,onProjectChange:c,onWorkspaceChange:l}=e,u=Ee(Q$),d;t[0]===u?d=t[1]:(d=xe(u),t[0]=u,t[1]=d);let f=d,p=f.chat.composerContext,m=Se(Z$),h=Se(X$),[g,_]=(0,Z.useState)(``),[v]=qh(g,200),y;t[2]!==h||t[3]!==v||t[4]!==m?(y=[`composer-projects`,h,m,v],t[2]=h,t[3]=v,t[4]=m,t[5]=y):y=t[5];let b;t[6]===v?b=t[7]:(b=()=>hh({status:`active`,search:v,sortBy:`updatedAt`,sortOrder:`desc`,limit:50}),t[6]=v,t[7]=b);let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x={keepPreviousData:!1,shouldRetryOnError:!1},t[8]=x):x=t[8];let S=Zt(y,b,x),C=W$(n,!1),w=C.error?void 0:C.data?.environment,T;t[9]!==w?.rootPath||t[10]!==i?(T=i?.trim()||w?.rootPath||``,t[9]=w?.rootPath,t[10]=i,t[11]=T):T=t[11];let E=T,[D,O]=(0,Z.useState)(null),k;t[12]!==C||t[13]!==l?(k=async e=>{O(null);try{await l(e),await C.mutate()}catch(e){let t=e;O(t instanceof Error?t.message:String(t))}},t[12]=C,t[13]=l,t[14]=k):k=t[14];let j;t[15]!==E||t[16]!==k?(j={initialPath:E,onPicked:k},t[15]=E,t[16]=k,t[17]=j):j=t[17];let M=fx(j),N=a?`${p.chooseFolder}${E?`: ${E}`:``}`:r?p.projectFolder:p.lockedFolder,P;t[18]===w?P=t[19]:(P=w?.branch||(w?.detached?w.headSha?.slice(0,8):void 0),t[18]=w,t[19]=P);let F=P,I=p.label,L=r&&`bg-surface-hover`,R;t[20]===L?R=t[21]:(R=K(`flex min-w-0 max-w-full items-center rounded-full`,L),t[20]=L,t[21]=R);let z;t[22]!==o||t[23]!==f.chat.scopeRemoveProject||t[24]!==c||t[25]!==r?(z=r?(0,$.jsx)(`button`,{type:`button`,disabled:o,title:f.chat.scopeRemoveProject,"aria-label":f.chat.scopeRemoveProject,className:K(q$,`size-7 shrink-0 px-0 ml-0.5 text-fg-muted`),onClick:()=>c(null),children:(0,$.jsx)(ye,{className:`size-3.5`,"aria-hidden":!0})}):null,t[22]=o,t[23]=f.chat.scopeRemoveProject,t[24]=c,t[25]=r,t[26]=z):z=t[26];let B=r?.id??``,V=r?.name,H;t[27]!==S.data?.items||t[28]!==S.error?(H=S.error?[]:S.data?.items??[],t[27]=S.data?.items,t[28]=S.error,t[29]=H):H=t[29];let U;t[30]===H?U=t[31]:(U=H.map(Y$),t[30]=H,t[31]=U);let W=p.chooseProject,G=p.changeProject,ee=p.changeProject,te=p.noProject,ne=p.searchProjects,re=S.isLoading,ie=S.error?p.projectsFailed:S.data?.items.length===0?p.noProjects:void 0,ae=r&&`pl-1`,ce;t[32]===ae?ce=t[33]:(ce=K(q$,`h-8 w-auto max-w-44 gap-1 border-0 bg-transparent pr-2.5 text-sm [&>svg]:hidden [&>span]:text-fg`,ae),t[32]=ae,t[33]=ce);let le;t[34]!==c||t[35]!==r?.id?(le=e=>{e!==(r?.id??``)&&c(e||null)},t[34]=c,t[35]=r?.id,t[36]=le):le=t[36];let ue;t[37]!==p.changeProject||t[38]!==p.chooseProject||t[39]!==p.noProject||t[40]!==p.searchProjects||t[41]!==o||t[42]!==S.isLoading||t[43]!==g||t[44]!==B||t[45]!==V||t[46]!==U||t[47]!==ie||t[48]!==ce||t[49]!==le?(ue=(0,$.jsx)(A,{value:B,selectedLabel:V,options:U,placeholder:W,ariaLabel:G,title:ee,emptyLabel:te,disabled:o,side:`top`,align:`start`,searchPlaceholder:ne,searchValue:g,onSearchChange:_,loading:re,statusMessage:ie,triggerClassName:ce,contentClassName:`xopc-composer-config-popover w-max min-w-[min(12rem,calc(100vw-1.5rem))] max-w-[min(20rem,calc(100vw-1.5rem))] [&>input]:w-0 [&>input]:min-w-full`,onChange:le}),t[37]=p.changeProject,t[38]=p.chooseProject,t[39]=p.noProject,t[40]=p.searchProjects,t[41]=o,t[42]=S.isLoading,t[43]=g,t[44]=B,t[45]=V,t[46]=U,t[47]=ie,t[48]=ce,t[49]=le,t[50]=ue):ue=t[50];let de;t[51]!==R||t[52]!==z||t[53]!==ue?(de=(0,$.jsxs)(`div`,{className:R,children:[z,ue]}),t[51]=R,t[52]=z,t[53]=ue,t[54]=de):de=t[54];let fe=r?s:null,pe;t[55]!==w||t[56]!==s||t[57]!==r?(pe=!s&&r&&w&&(w.headSha||w.branch)?(0,$.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 items-center gap-1.5 rounded-full bg-surface-hover px-2.5 text-sm text-fg`,title:w.rootPath,children:[w.kind===`managed_worktree`?(0,$.jsx)(Qi,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}):(0,$.jsx)(ni,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),w.kind===`managed_worktree`?`Worktree`:`Local`]}):null,t[55]=w,t[56]=s,t[57]=r,t[58]=pe):pe=t[58];let me;t[59]!==p.retryProjects||t[60]!==S?(me=S.error?(0,$.jsx)(`button`,{type:`button`,className:K(q$,`size-7 px-0`),"aria-label":p.retryProjects,onClick:()=>void S.mutate(),children:(0,$.jsx)(Vi,{className:`size-3.5`,"aria-hidden":!0})}):null,t[59]=p.retryProjects,t[60]=S,t[61]=me):me=t[61];let he;t[62]!==a||t[63]!==C.isLoading||t[64]!==p.chooseFolder||t[65]!==o||t[66]!==M.pick||t[67]!==M.picking||t[68]!==r||t[69]!==E||t[70]!==N?(he=r?null:(0,$.jsxs)(`button`,{type:`button`,className:K(q$,`max-w-52`),disabled:o||!a||M.picking,title:N,"aria-label":p.chooseFolder,onClick:M.pick,children:[(0,$.jsx)(oe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),E?(0,$.jsx)(`span`,{className:`truncate`,children:ux(E)}):C.isLoading?(0,$.jsx)(xn,{className:`h-4 w-16`}):(0,$.jsx)(`span`,{children:p.chooseFolder})]}),t[62]=a,t[63]=C.isLoading,t[64]=p.chooseFolder,t[65]=o,t[66]=M.pick,t[67]=M.picking,t[68]=r,t[69]=E,t[70]=N,t[71]=he):he=t[71];let ge;t[72]!==F||t[73]!==w?(ge=F?(0,$.jsxs)(`span`,{className:`inline-flex h-8 min-w-0 max-w-44 items-center gap-1.5 px-2 text-sm text-fg`,title:`${F}${w?.headSha?` · ${w.headSha.slice(0,8)}`:``}`,children:[(0,$.jsx)(se,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:F})]}):null,t[72]=F,t[73]=w,t[74]=ge):ge=t[74];let _e;t[75]===D?_e=t[76]:(_e=D?(0,$.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:D}):null,t[75]=D,t[76]=_e);let ve;t[77]!==p.label||t[78]!==de||t[79]!==fe||t[80]!==pe||t[81]!==me||t[82]!==he||t[83]!==ge||t[84]!==_e?(ve=(0,$.jsxs)(`div`,{className:`mx-3 -mb-3 flex min-w-0 shrink-0 flex-wrap items-center gap-x-1 gap-y-1 rounded-t-2xl bg-surface-base px-2 pb-4 pt-1.5 sm:mx-4`,"aria-label":I,children:[de,fe,pe,me,he,ge,_e]}),t[77]=p.label,t[78]=de,t[79]=fe,t[80]=pe,t[81]=me,t[82]=he,t[83]=ge,t[84]=_e,t[85]=ve):ve=t[85];let be;t[86]!==f.chat.workingDirectory||t[87]!==M.confirmPick||t[88]!==M.hasNativePicker||t[89]!==M.modalOpen||t[90]!==M.setModalOpen||t[91]!==E?(be=M.hasNativePicker?null:(0,$.jsx)(Cx,{open:M.modalOpen,onOpenChange:M.setModalOpen,initialAbsolutePath:E||void 0,onConfirm:M.confirmPick,wd:f.chat.workingDirectory}),t[86]=f.chat.workingDirectory,t[87]=M.confirmPick,t[88]=M.hasNativePicker,t[89]=M.modalOpen,t[90]=M.setModalOpen,t[91]=E,t[92]=be):be=t[92];let q;return t[93]!==ve||t[94]!==be?(q=(0,$.jsxs)($.Fragment,{children:[ve,be]}),t[93]=ve,t[94]=be,t[95]=q):q=t[95],q}function Y$(e){return{value:e.id,label:e.name}}function X$(e){return e.baseUrl}function Z$(e){return e.conversationId}function Q$(e){return e.language}function $$(e){return e.map(e=>({type:e.type===`voice`?`voice`:(e.mimeType??``).startsWith(`image/`)?`image`:`document`,mimeType:e.mimeType??`application/octet-stream`,content:e.data??``,name:e.name??`file`,size:e.size??0,uri:e.uri,...typeof e.durationSeconds==`number`&&Number.isFinite(e.durationSeconds)&&e.durationSeconds>0?{durationSeconds:e.durationSeconds}:{}}))}var e1=100,t1=400,n1=900;function r1(e,t){switch(t.type){case`reset`:return{box:null,hoverPreview:null};case`set-box`:return{...e,box:t.box};case`set-hover`:return{...e,hoverPreview:t.hoverPreview}}}function i1(e,t){let n=t.trim().toLowerCase();if(!n)return[];let r=e.toLowerCase(),i=[],a=0;for(let e=0;e<r.length&&a<n.length;e++)r[e]===n[a]&&(i.push([e,e+1]),a++);return i}function a1(e){let t=(0,Q.c)(8),{name:n,query:r}=e,i;t[0]!==n||t[1]!==r?(i=i1(n,r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i;if(a.length===0){let e;return t[3]===n?e=t[4]:(e=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n}),t[3]=n,t[4]=e),e}let o;if(t[5]!==n||t[6]!==a){let e=[],r=0;a.forEach(t=>{let[i,a]=t;i>r&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r,i)},`pre-${i}`)),e.push((0,$.jsx)(`span`,{className:`font-semibold text-accent-fg`,children:n.slice(i,a)},`hl-${i}-${a}`)),r=a}),r<n.length&&e.push((0,$.jsx)(`span`,{className:`font-medium text-fg`,children:n.slice(r)},`tail`)),o=(0,$.jsx)($.Fragment,{children:e}),t[5]=n,t[6]=a,t[7]=o}else o=t[7];return o}var o1=(0,Z.memo)(function(e){let t=(0,Q.c)(42),{open:n,anchorRef:r,items:i,selectedIndex:a,loading:o,query:s,noResults:c,conversationId:l,recentLabel:u,sectionLabels:d,ariaLabel:f,onSelectItem:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m={box:null,hoverPreview:null},t[0]=m):m=t[0];let[h,g]=(0,Z.useReducer)(r1,m),_=h.box,v=h.hoverPreview,y=(0,Z.useRef)(null),b=(0,Z.useRef)(0),x=(0,Z.useRef)(null),S;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>{y.current&&=(clearTimeout(y.current),null)},t[1]=S):S=t[1];let C=S,w;t[2]===l?w=t[3]:(w=(e,t,n)=>{C(),b.current+=1;let r=b.current;if(e.kind!==`file`){g({type:`set-hover`,hoverPreview:null});return}let i=e.relativePath;if(!l?.trim()||e.isDirectory||e.isBrowseUp||!i){g({type:`set-hover`,hoverPreview:null});return}y.current=setTimeout(()=>{y.current=null,r===b.current&&BS(i,{conversationId:l}).then(e=>{let{content:i}=e,a=i.length>n1?`${i.slice(0,n1)}…`:i;r===b.current&&g({type:`set-hover`,hoverPreview:{text:a,x:t,y:n}})}).catch(()=>{r===b.current&&g({type:`set-hover`,hoverPreview:null})})},420)},t[2]=l,t[3]=w);let T=w,E,D;t[4]!==r||t[5]!==n?(E=()=>{if(!n){g({type:`reset`}),C(),b.current+=1;return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();g({type:`set-box`,box:{left:t.left,top:t.top,width:t.width}})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},D=[n,r],t[4]=r,t[5]=n,t[6]=E,t[7]=D):(E=t[6],D=t[7]),(0,Z.useLayoutEffect)(E,D);let O,k;if(t[8]!==i.length||t[9]!==n||t[10]!==a?(O=()=>{!n||a<0||a>=i.length||(x.current?.querySelector(`#at-mention-${a}`))?.scrollIntoView({block:`nearest`})},k=[n,a,i.length],t[8]=i.length,t[9]=n,t[10]=a,t[11]=O,t[12]=k):(O=t[11],k=t[12]),(0,Z.useLayoutEffect)(O,k),!n||typeof document>`u`||_===null)return null;let A=i.length,j=Math.min(_.width,t1),M;t[13]!==_.left||t[14]!==_.top||t[15]!==j?(M={position:`fixed`,left:_.left,top:_.top,width:j,transform:`translateY(calc(-100% - 8px))`,zIndex:e1},t[13]=_.left,t[14]=_.top,t[15]=j,t[16]=M):M=t[16];let N=a>=0&&a<A?`at-mention-${a}`:void 0,P;t[17]!==o||t[18]!==A?(P=o&&A===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 text-sm text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-4 shrink-0 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:`…`})]}):null,t[17]=o,t[18]=A,t[19]=P):P=t[19];let F;t[20]!==i||t[21]!==o||t[22]!==c||t[23]!==p||t[24]!==s||t[25]!==u||t[26]!==T||t[27]!==d||t[28]!==a||t[29]!==A?(F=!o&&A===0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-fg-muted`,children:c}):(0,$.jsxs)($.Fragment,{children:[i.map((e,t)=>{let n=i[t-1]?.kind,r=d[e.kind],o=e.kind===`file`&&e.isRecent;return(0,$.jsxs)(Z.Fragment,{children:[n===e.kind?null:(0,$.jsx)(`div`,{className:`border-t border-edge-subtle px-3 pb-1 pt-2 text-[0.65rem] font-medium uppercase tracking-wide text-fg-muted first:border-t-0`,children:r}),(0,$.jsxs)(`div`,{id:`at-mention-${t}`,role:`option`,"aria-selected":a===t,tabIndex:-1,className:K(`flex cursor-pointer items-start gap-2 px-3 py-2 text-left text-sm`,a===t?`bg-surface-hover text-fg`:`text-fg-subtle hover:bg-surface-hover/80`,o&&`border-l-2 border-l-accent/60`),onPointerDown:t=>{t.pointerType===`mouse`&&t.button!==0||(t.preventDefault(),p(e))},onPointerEnter:t=>T(e,t.clientX,t.clientY),onPointerLeave:()=>{C(),b.current+=1,g({type:`set-hover`,hoverPreview:null})},children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e.kind===`note`?(0,$.jsx)(xi,{className:`size-3.5 text-accent-fg`,"aria-hidden":!0}):e.kind===`session`?(0,$.jsx)(pi,{className:`size-3.5 text-violet-600 dark:text-violet-400`,"aria-hidden":!0}):e.kind===`skill`?(0,$.jsx)(ta,{className:`size-3.5 text-cyan-600 dark:text-cyan-400`,"aria-hidden":!0}):e.kind===`agent`?(0,$.jsx)(tr,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):e.kind===`browser_tab`?(0,$.jsx)(Gn,{className:`size-3.5 text-blue-600 dark:text-blue-400`,"aria-hidden":!0}):e.kind===`mcp_server`?(0,$.jsx)(Ri,{className:`size-3.5 text-orange-600 dark:text-orange-400`,"aria-hidden":!0}):e.kind===`mcp_resource`?(0,$.jsx)(Or,{className:`size-3.5 text-orange-600 dark:text-orange-400`,"aria-hidden":!0}):e.isBrowseUp?(0,$.jsx)(Gr,{className:`size-3.5 text-fg-muted`,"aria-hidden":!0}):e.isDirectory?(0,$.jsx)(Gr,{className:`size-3.5 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}):(0,$.jsx)(zr,{className:K(`size-3.5`,hS(e.name)),"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:(0,$.jsx)(a1,{name:e.name,query:s})}),o?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-accent-soft px-1 py-0 text-[0.65rem] text-accent-fg`,children:u}):null]}),(0,$.jsx)(`div`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:e.description||r})]})]})]},e.id)}),o&&A>0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-edge-subtle px-3 py-2 text-xs text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:`…`})]}):null]}),t[20]=i,t[21]=o,t[22]=c,t[23]=p,t[24]=s,t[25]=u,t[26]=T,t[27]=d,t[28]=a,t[29]=A,t[30]=F):F=t[30];let I;t[31]!==f||t[32]!==P||t[33]!==F||t[34]!==N?(I=(0,$.jsxs)(`div`,{ref:x,className:`max-h-[min(26rem,54vh)] overflow-y-auto`,role:`listbox`,"aria-label":f,"aria-activedescendant":N,children:[P,F]}),t[31]=f,t[32]=P,t[33]=F,t[34]=N,t[35]=I):I=t[35];let L;t[36]===v?L=t[37]:(L=v?(0,$.jsx)(`div`,{className:`pointer-events-none fixed z-[200] max-h-48 max-w-sm overflow-auto rounded-md border border-edge bg-surface-overlay p-2 font-mono text-[0.7rem] text-fg shadow-lg`,style:{left:Math.min(v.x+12,window.innerWidth-320),top:Math.min(v.y+12,window.innerHeight-200)},children:v.text}):null,t[36]=v,t[37]=L);let R;return t[38]!==I||t[39]!==L||t[40]!==M?(R=(0,Hn.createPortal)((0,$.jsxs)(`div`,{"data-composer-picker-panel":!0,className:`pointer-events-auto max-h-[min(28rem,60vh)] min-h-[2.5rem] overflow-hidden rounded-lg border border-edge bg-surface-overlay shadow-lg`,style:M,role:`presentation`,children:[I,L]}),document.body),t[38]=I,t[39]=L,t[40]=M,t[41]=R):R=t[41],R});function s1(e,t){let n=e=>{e!==!1&&t()};e instanceof Promise?e.then(n).catch(e=>{Yl(`error`,e instanceof Error?e.message:String(e))}):n(e)}var c1=new Set([`abort`,`stop`,`cancel`]);function l1(e){if(e.kind!==`command`)return!1;if(c1.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(c1.has(t.toLowerCase()))return!0;return!1}function u1(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var d1=(e,t)=>{let n=t.slashRange;if(!n)return;if(e.availability.status!==`available`){t.callbacks.onUnavailableSkill?.(e);return}let r=`/skill:${e.canonicalName} `,i=u1(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0})},f1=(e,t)=>{let n=t.slashRange;if(!n||n.start!==0)return;if(e.name.toLowerCase()===`review`&&t.callbacks.onReviewLauncher&&!t.runBusy&&t.pendingFollowUpsCount===0){let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start,focus:!0}),t.callbacks.onReviewLauncher();return}if(e.acceptsArgs===!0){let r=`/${e.name} `,i=u1(t.editor.valueRef.current,n.start,n.end,r),a=n.start+r.length;t.editor.resetEditor({nextText:i,caretOffset:a,focus:!0});return}let r=`/${e.name}`;if(t.runBusy||t.pendingFollowUpsCount>0){if(l1(e)){if(!t.callbacks.onAbort)return;t.callbacks.onAbort();let e=t.editor.valueRef.current,r=e.slice(0,n.start)+e.slice(n.end);t.editor.resetEditor({nextText:r,caretOffset:n.start});return}if(!t.callbacks.onAddPendingFollowUp||t.pendingFollowUpsCount>=t.maxPendingFollowUps)return;t.contextRefs.current.length?t.callbacks.onAddPendingFollowUp(r,void 0,t.contextRefs.current):t.callbacks.onAddPendingFollowUp(r,void 0),t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.contextRefs.clear(),t.editor.resetEditor();return}s1(t.contextRefs.current.length?t.callbacks.onSend(r,void 0,t.thinkingLevel,t.contextRefs.current):t.callbacks.onSend(r,void 0,t.thinkingLevel),()=>{t.callbacks.onUserTextCommitted?.(r),t.attachments.clearAttachments(),t.contextRefs.clear(),t.editor.resetEditor()})},p1=(e,t)=>{let n=t.slashRange;if(!n||n.start!==0||!t.callbacks.onChatAgentChange)return;let r=t.editor.valueRef.current,i=r.slice(n.end),a=r.slice(0,n.start)+(i.startsWith(` `)?i.slice(1):i);t.editor.resetEditor({nextText:a,caretOffset:n.start}),t.callbacks.onChatAgentChange(e.agentId)};function m1(e,t){switch(e.kind){case`skill`:d1(e,t);return;case`command`:f1(e,t);return;case`agent`:p1(e,t)}}var h1={new:10,help:11,list:12,clear:13,switch:14,models:15,usage:16,skills:17,settings:18,start:19,think:20,reasoning:21,verbose:22,status:23,tts:24},g1=new Set([`abort`,`archive`]);function _1(e){if(e.kind===`command`){let t=e.name.toLowerCase();if(h1[t]!==void 0)return 0;if(g1.has(t))return 2}return 1}function v1(e,t){let n=_1(e),r=_1(t);if(n!==r)return n-r;if(n===0){let n=h1[e.name.toLowerCase()]??999,r=h1[t.name.toLowerCase()]??999;if(n!==r)return n-r}let i=e.name.localeCompare(t.name);return i===0?e.id.localeCompare(t.id):i}function y1(e){if(e.kind!==`command`)return!1;if(c1.has(e.name.toLowerCase()))return!0;for(let t of e.aliases??[])if(c1.has(t.toLowerCase()))return!0;return!1}function b1(e,t){return e.kind!==`command`||e.acceptsArgs===!0||y1(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount>=t.maxPendingFollowUps}function x1(e,t){return e.kind!==`command`||e.acceptsArgs===!0||y1(e)||!(t.runBusy||t.pendingFollowUpsCount>0)?!1:t.pendingFollowUpsCount<t.maxPendingFollowUps}function S1(e){return e.includes(`/`)||/^[A-Za-z]:/u.test(e)?!0:/^(Users|home|var|tmp|etc|opt|private|Volumes|System|Applications|Library|usr|dev|bin|sbin|proc|sys)(\/|$)/iu.test(e)}function C1(e,t){if(t===0)return!1;let n=e[t-1];if(n===void 0||n===`.`||n===`:`||n===`/`)return!0;let r=e.slice(0,t);return/[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/u.test(r)}function w1(e,t){let n=e.length,r=Math.min(Math.max(t,0),n);if(r<1&&e===`/`&&(r=1),r<1)return null;let i=e.slice(0,r).match(/\/[^\s]*$/);if(!i||i.index===void 0)return null;let a=i.index;if(C1(e,a))return null;let o=i[0],s=o.slice(1);return S1(s)||o.startsWith(`/skill:`)?null:{start:i.index,end:r,query:s}}function T1(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.name.toLowerCase();if(r===n)return 0;for(let t of e.aliases??[])if(t.toLowerCase()===n)return 1;if(r.startsWith(n))return 2;for(let t of e.aliases??[])if(t.toLowerCase().startsWith(n))return 3;if(r.includes(n))return 4;for(let t of e.aliases??[])if(t.toLowerCase().includes(n))return 5;if(e.description.toLowerCase().includes(n))return 100;if(e.category.toLowerCase().includes(n))return 101;if(e.kind===`skill`&&(e.source??``).toLowerCase().includes(n))return 102;if(e.kind===`skill`){for(let t of e.searchTerms??[])if(t.toLowerCase().includes(n))return 103}return null}function E1(e,t){return t===0?0:Math.min(e,t-1)}function D1(e,t){let{query:n,value:r,commandsAllowed:i,agentsAllowed:a}=t,o=n.trim()===``,s=oT(r),c=[];for(let t of e){if(t.kind===`command`&&!i||t.kind===`agent`&&!a||t.kind===`skill`&&s.has(t.canonicalName)||t.kind===`skill`&&o&&t.availability.status!==`available`)continue;let e=T1(t,n);e!==null&&c.push({item:t,rank:e})}c.sort((e,t)=>{let n=e.item.kind===`skill`&&e.item.availability.status!==`available`;return n===(t.item.kind===`skill`&&t.item.availability.status!==`available`)?e.rank===t.rank?v1(e.item,t.item):e.rank-t.rank:n?1:-1});let l=c.map(e=>e.item),u=[],d=l.filter(e=>e.kind===`skill`),f=l.filter(e=>e.kind===`command`),p=l.filter(e=>e.kind===`agent`);d.length>0&&u.push({kind:`skill`,items:d}),f.length>0&&u.push({kind:`command`,items:f}),p.length>0&&u.push({kind:`agent`,items:p});let m=[];for(let e of u)m.push(...e.items);return{sections:u,flatItems:m}}function O1(e,t,n){let r=(0,Q.c)(47),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(0),c=Ee(j1);n?.isComposing;let l;r[0]!==t||r[1]!==n?.isComposing||r[2]!==e?(l=n?.isComposing?null:w1(e,t),r[0]=t,r[1]=n?.isComposing,r[2]=e,r[3]=l):l=r[3];let u=l,d=!!(u&&!n?.suppress),f,p;r[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=e=>{let t=e.detail;t&&typeof t==`object`&&`section`in t&&(t.section===`skills`||t.section===`agents`)&&s(A1)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},p=[],r[4]=f,r[5]=p):(f=r[4],p=r[5]),(0,Z.useEffect)(f,p);let m;r[6]!==c||r[7]!==n?.conversationId||r[8]!==n?.currentAgentId?(m=async()=>{let[e,t,r]=await Promise.allSettled([ZT(),QT(n?.currentAgentId,n?.conversationId),Mg()]),i=[];t.status===`rejected`&&i.push(`skill`),e.status===`rejected`&&i.push(`command`),r.status===`rejected`&&i.push(`agent`);let a=(e.status===`fulfilled`?e.value:[]).map(k1),o=(t.status===`fulfilled`?t.value.skills:[]).map(e=>{let t=PT(e,c);return{kind:`skill`,id:`skill:${e.name}`,name:t.displayName,canonicalName:e.name,description:t.description,aliases:t.aliases,searchTerms:t.searchTerms,category:`skill`,source:e.source,availability:{status:e.availableForCurrentAgent?`available`:e.unavailableReason??`agent-denied`,reason:e.unavailableReason??void 0}}}),s=xe(c).agentsSettings,l=r.status===`fulfilled`?r.value:null,u=l&&l.items.length>1?l.items.map(e=>({kind:`agent`,id:`agent:${e.id}`,agentId:e.id,name:WW(e,s),description:GW(e,s),category:`agent`,...e.avatar?{avatar:e.avatar}:{},aliases:[e.id,...e.name?[e.name]:[]]})):[];return{items:[...o,...a,...u],failedKinds:i}},r[6]=c,r[7]=n?.conversationId,r[8]=n?.currentAgentId,r[9]=m):m=r[9];let h=n?.currentAgentId,g=n?.conversationId,_;r[10]!==c||r[11]!==o||r[12]!==h||r[13]!==g?(_=[c,h,g,o],r[10]=c,r[11]=o,r[12]=h,r[13]=g,r[14]=_):_=r[14];let v;r[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],r[15]=v):v=r[15];let y;r[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],r[16]=y):y=r[16];let b,x;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(x={items:v,failedKinds:y},b=[],r[17]=b,r[18]=x):(b=r[17],x=r[18]);let S;r[19]===Symbol.for(`react.memo_cache_sentinel`)?(S=[],r[19]=S):S=r[19];let C;r[20]===Symbol.for(`react.memo_cache_sentinel`)?(C={items:b,failedKinds:S},r[20]=C):C=r[20];let w;r[21]===d?w=r[22]:(w={enabled:d,initial:x,errorData:C},r[21]=d,r[22]=w);let T=Am(m,_,w),E=T.data.items,D=T.error==null?null:T.error instanceof Error?T.error.message:String(T.error),O=u?.query??``,k=u!==null&&u.start===0,A=k,j;r[23]!==A||r[24]!==E||r[25]!==k||r[26]!==O||r[27]!==e?(j=D1(E,{query:O,value:e,commandsAllowed:k,agentsAllowed:A}),r[23]=A,r[24]=E,r[25]=k,r[26]=O,r[27]=e,r[28]=j):j=r[28];let{sections:M,flatItems:N}=j,P=u?O:``,F=(0,Z.useRef)(P);F.current!==P&&(F.current=P,i!==0&&a(0));let I;r[29]!==N.length||r[30]!==i?(I=E1(i,N.length),r[29]=N.length,r[30]=i,r[31]=I):I=r[31];let L=I,R;r[32]===N.length?R=r[33]:(R=e=>{N.length!==0&&a(t=>e===`down`?(t+1)%N.length:(t-1+N.length)%N.length)},r[32]=N.length,r[33]=R);let z=R,B;return r[34]!==A||r[35]!==k||r[36]!==N||r[37]!==T.data.failedKinds||r[38]!==T.loading||r[39]!==D||r[40]!==z||r[41]!==d||r[42]!==O||r[43]!==L||r[44]!==M||r[45]!==u?(B={open:d,slashRange:u,commandsAllowed:k,agentsAllowed:A,sections:M,flatItems:N,selectedIndex:L,query:O,loading:T.loading,failedKinds:T.data.failedKinds,loadError:D,onNavigate:z,setSelectedIndex:a},r[34]=A,r[35]=k,r[36]=N,r[37]=T.data.failedKinds,r[38]=T.loading,r[39]=D,r[40]=z,r[41]=d,r[42]=O,r[43]=L,r[44]=M,r[45]=u,r[46]=B):B=r[46],B}function k1(e){return{kind:`command`,id:`cmd:${e.id}`,name:e.name,description:e.description,category:e.category,aliases:e.aliases,acceptsArgs:e.acceptsArgs,acceptsContext:e.acceptsContext,examples:e.examples}}function A1(e){return e+1}function j1(e){return e.language}var M1=new Map,N1=`xopc-agent-avatar-updated`;function P1(e){return M1.get(e)??0}var F1=`xopc:custom`,I1=`xopc:dicebear:`,L1=[`adventurer`,`bottts`,`lorelei`,`thumbs`,`fun-emoji`],R1=[...L1,`pixel-art`];function z1(e){return R1.includes(e)}function B1(e){if(!e.startsWith(I1))return null;let t=e.slice(14),n=t.indexOf(`:`);if(n<=0)return null;let r=t.slice(0,n),i=t.slice(n+1);return!z1(r)||!i.trim()?null:{styleId:r,seed:i}}function V1(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t}function H1(e,t=128){let n=V1(e)%360,r=(e.trim().charAt(0)||`A`).toUpperCase(),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}"><rect width="100%" height="100%" rx="${t/2}" fill="hsl(${n} 58% 42%)"/><text x="50%" y="54%" text-anchor="middle" dominant-baseline="middle" font-family="Inter, system-ui, sans-serif" font-size="${Math.round(t*.42)}" font-weight="700" fill="white">${r}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(i)}`}function U1(e,t,n,r){let i=t?.trim()??``,a=H1(e,n);if(!i)return{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:a};if(i===`xopc:custom`){let t=J(`/api/agents/${encodeURIComponent(e)}/avatar`),n=new URLSearchParams;r>0&&n.set(`v`,String(r));let i=n.toString();return{kind:`authenticated`,url:i?`${t}?${i}`:t,fallbackSrc:a}}if(/^https?:\/\//i.test(i))return{kind:`sync`,src:i};let o=B1(i);return o?{kind:`dicebear`,styleId:o.styleId,seed:o.seed,fallbackSrc:a}:{kind:`dicebear`,styleId:`adventurer`,seed:e,fallbackSrc:a}}function W1(e){let t=Se(e=>e.conversationId),n=e.token===void 0?t:e.token,{agentId:r,avatar:i,size:a=44}=e,[,o]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{let e=e=>{e.detail?.agentId===r&&o(e=>e+1)};return window.addEventListener(N1,e),()=>window.removeEventListener(N1,e)},[r]);let c=P1(r),l=(0,Z.useMemo)(()=>U1(r,i,a,c),[r,i,n,a,c]),u=l.kind===`sync`?l.src:l.fallbackSrc,[d,f]=(0,Z.useState)(u);return(0,Z.useEffect)(()=>{f(u)},[u]),(0,Z.useEffect)(()=>{if(l.kind!==`authenticated`||(f(l.fallbackSrc),!n))return;let e=new AbortController,t;return fetch(l.url,{credentials:`same-origin`,signal:e.signal,redirect:`error`}).then(async n=>{if(!n.ok)return;let r=await n.blob();e.signal.aborted||(t=URL.createObjectURL(r),f(t))}).catch(()=>{}),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[l,n]),(0,Z.useEffect)(()=>{if(l.kind!==`dicebear`)return;let e=!1;return s(async()=>{let{dicebearToDataUri:e}=await import(`./agent-avatar-dicebear-Bs1qnnhD.js`);return{dicebearToDataUri:e}},__vite__mapDeps([157,1])).then(({dicebearToDataUri:t})=>{e||f(t(l.styleId,l.seed,a))}),()=>{e=!0}},[l,a]),(0,$.jsx)(`img`,{src:d,alt:``,width:a,height:a,className:K(`rounded-full object-cover bg-surface-hover`,e.className),draggable:!1,onError:()=>{f(H1(r,a))}})}var G1=100,K1=560;function q1(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);if(r>=0)return(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]});let i=[],a=0,o=0;for(let t of e){let e=n[a],r=`${String(o)}-${t}`;e!==void 0&&t.toLowerCase()===e?(i.push((0,$.jsx)(`span`,{className:`text-accent-fg`,children:t},r)),a+=1):i.push((0,$.jsx)(Z.Fragment,{children:t},r)),o+=1}return(0,$.jsx)($.Fragment,{children:i})}function J1(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase().indexOf(n);return r<0?e:(0,$.jsxs)($.Fragment,{children:[e.slice(0,r),(0,$.jsx)(`span`,{className:`text-accent-fg`,children:e.slice(r,r+n.length)}),e.slice(r+n.length)]})}var Y1=(0,Z.memo)(function(e){let t=(0,Q.c)(46),{item:n,index:r,selectedIndex:i,showHighlight:a,filterQuery:o,currentAgentId:s,currentBadgeLabel:c,runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d,queueBadgeLabel:f,queueFullBadgeLabel:p,queueFullTooltip:m,skillUnavailableLabel:h,skillAgentDeniedLabel:g,skillSourceLabels:_,onSelectItem:v}=e,y=n.kind===`skill`,b=n.kind===`agent`,x;t[0]!==b||t[1]!==y||t[2]!==n.agentId||t[3]!==n.avatar?(x=b?(0,$.jsx)(W1,{agentId:n.agentId,avatar:n.avatar,size:18,className:`size-[18px] shrink-0`}):y?(0,$.jsx)(ta,{className:`size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}):(0,$.jsx)(Ca,{className:`size-4 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),t[0]=b,t[1]=y,t[2]=n.agentId,t[3]=n.avatar,t[4]=x):x=t[4];let S=x,C;t[5]!==o||t[6]!==b||t[7]!==n.name||t[8]!==a?(C=b?a?(0,$.jsx)($.Fragment,{children:q1(n.name,o)}):(0,$.jsx)(`span`,{className:`text-fg`,children:n.name}):a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-fg`,children:`/`}),q1(n.name,o)]}):(0,$.jsxs)(`span`,{className:`text-fg`,children:[`/`,n.name]}),t[5]=o,t[6]=b,t[7]=n.name,t[8]=a,t[9]=C):C=t[9];let w=C,T=b&&s!=null&&s.length>0&&n.agentId===s,E=y&&n.availability.status!==`available`,D,O;if(t[10]!==n||t[11]!==d||t[12]!==u||t[13]!==l){let e={runBusy:l,pendingFollowUpsCount:u,maxPendingFollowUps:d};O=x1(n,e),D=b1(n,e),t[10]=n,t[11]=d,t[12]=u,t[13]=l,t[14]=D,t[15]=O}else D=t[14],O=t[15];let k=D,A=null;if(T){let e;t[16]===c?e=t[17]:(e=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-accent-soft px-1 py-px text-[0.6rem] font-medium leading-none text-accent-fg`,"aria-label":c,children:c}),t[16]=c,t[17]=e),A=e}else if(E){let e=n.availability.reason??`unavailable`,r=n.availability.status===`agent-denied`?g:h,i;t[18]!==e||t[19]!==r?(i=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":e,children:r}),t[18]=e,t[19]=r,t[20]=i):i=t[20],A=i}else if(y&&n.source){let e=_[n.source]??n.source,r;t[21]===e?r=t[22]:(r=(0,$.jsx)(`span`,{className:`ml-2 shrink-0 text-[11px] font-normal text-fg-muted`,children:e}),t[21]=e,t[22]=r),A=r}else if(k){let e;t[23]===p?e=t[24]:(e=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-red-100 px-1 py-px text-[0.6rem] font-medium leading-none text-red-700 dark:bg-red-900/40 dark:text-red-300`,"aria-label":p,children:p}),t[23]=p,t[24]=e),A=e}else if(O){let e;t[25]===f?e=t[26]:(e=(0,$.jsx)(`span`,{className:`ml-1 shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-medium leading-none text-fg-muted`,"aria-label":f,children:f}),t[25]=f,t[26]=e),A=e}let j=i===r,M=`palette-${r}`,N;t[27]!==o||t[28]!==n.description||t[29]!==a?(N=n.description?a?J1(n.description,o):n.description:null,t[27]=o,t[28]=n.description,t[29]=a,t[30]=N):N=t[30];let P=k?m:void 0,F;t[31]!==n||t[32]!==v?(F=()=>v(n),t[31]=n,t[32]=v,t[33]=F):F=t[33];let I;return t[34]!==S||t[35]!==k||t[36]!==n||t[37]!==w||t[38]!==a||t[39]!==j||t[40]!==M||t[41]!==N||t[42]!==P||t[43]!==F||t[44]!==A?(I=(0,$.jsx)(Z1,{item:n,icon:S,selected:j,id:M,nameLine:w,descriptionLine:N,dimCategoryBadge:a,trailingBadge:A,disabled:k,disabledTooltip:P,onSelect:F}),t[34]=S,t[35]=k,t[36]=n,t[37]=w,t[38]=a,t[39]=j,t[40]=M,t[41]=N,t[42]=P,t[43]=F,t[44]=A,t[45]=I):I=t[45],I}),X1=(0,Z.memo)(function(e){let t=(0,Q.c)(53),{open:n,anchorRef:r,sections:i,flatItems:a,loading:o,failedKinds:s,selectedIndex:c,noResults:l,sectionLoadFailedLabel:u,query:d,skillsLabel:f,commandsLabel:p,agentsLabel:m,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E,panelRef:D}=e,[O,k]=(0,Z.useState)(null),A,j;t[0]!==r||t[1]!==n?(A=()=>{if(!n){k(null);return}let e=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect();k({left:t.left,top:t.top,width:t.width})};e();let t=r.current,i=t&&typeof ResizeObserver<`u`?new ResizeObserver(()=>{e()}):null;return t&&i&&i.observe(t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{t&&i&&i.disconnect(),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},j=[n,r],t[0]=r,t[1]=n,t[2]=A,t[3]=j):(A=t[2],j=t[3]),(0,Z.useLayoutEffect)(A,j);let M,N;if(t[4]!==a.length||t[5]!==n||t[6]!==c?(M=()=>{!n||a.length===0||document.getElementById(`palette-${c}`)?.scrollIntoView?.({block:`nearest`})},N=[a.length,n,c],t[4]=a.length,t[5]=n,t[6]=c,t[7]=M,t[8]=N):(M=t[7],N=t[8]),(0,Z.useEffect)(M,N),!n||typeof document>`u`||O===null)return null;let P=a.length,F=a[c],I=Math.min(O.width,K1),L;t[9]===d?L=t[10]:(L=d.trim(),t[9]=d,t[10]=L);let R=L,z=R.length>0,B;t[11]!==m||t[12]!==p||t[13]!==f?(B={skill:f,command:p,agent:m},t[11]=m,t[12]=p,t[13]=f,t[14]=B):B=t[14];let V=B,H;t[15]!==h||t[16]!==g||t[17]!==R||t[18]!==y||t[19]!==E||t[20]!==v||t[21]!==b||t[22]!==x||t[23]!==S||t[24]!==_||t[25]!==c||t[26]!==z||t[27]!==w||t[28]!==T||t[29]!==C?(H={selectedIndex:c,showHighlight:z,filterQuery:R,currentAgentId:h,currentBadgeLabel:g,runBusy:_,pendingFollowUpsCount:v,maxPendingFollowUps:y,queueBadgeLabel:b,queueFullBadgeLabel:x,queueFullTooltip:S,skillUnavailableLabel:C,skillAgentDeniedLabel:w,skillSourceLabels:T,onSelectItem:E},t[15]=h,t[16]=g,t[17]=R,t[18]=y,t[19]=E,t[20]=v,t[21]=b,t[22]=x,t[23]=S,t[24]=_,t[25]=c,t[26]=z,t[27]=w,t[28]=T,t[29]=C,t[30]=H):H=t[30];let U=H,W;if(t[31]!==s||t[32]!==o||t[33]!==l||t[34]!==U||t[35]!==V||t[36]!==u||t[37]!==i||t[38]!==P){let e=new Map(i.map(Q1)),n=[`skill`,`command`,`agent`].filter(t=>e.has(t)||s.includes(t)),r=0;W=o&&P===0?(0,$.jsx)(`div`,{className:`space-y-2 p-2.5`,"aria-busy":`true`,children:Array.from({length:6},$1)}):P===0&&s.length===0?(0,$.jsx)(`div`,{className:`p-2.5 text-xs leading-normal text-fg-muted`,children:l}):n.map((t,n)=>{let i=e.get(t)?.items??[],a=r;r+=i.length;let o=`palette-section-${t}`;return(0,$.jsxs)(`div`,{role:`group`,"aria-labelledby":o,className:K(n>0&&`border-t border-edge-subtle`),children:[(0,$.jsxs)(`div`,{id:o,className:`sticky top-0 z-10 flex items-center justify-between bg-surface-overlay px-2.5 py-2 text-[0.65rem] font-medium uppercase leading-none tracking-wide text-fg-muted`,children:[(0,$.jsx)(`span`,{children:V[t]}),(0,$.jsx)(`span`,{className:`tabular-nums`,"aria-hidden":!0,children:i.length})]}),s.includes(t)?(0,$.jsx)(`div`,{className:`px-2.5 pb-2 text-[11px] leading-relaxed text-fg-muted`,children:u}):i.map((e,t)=>(0,$.jsx)(Y1,{item:e,index:a+t,...U},e.id))]},t)}),t[31]=s,t[32]=o,t[33]=l,t[34]=U,t[35]=V,t[36]=u,t[37]=i,t[38]=P,t[39]=W}else W=t[39];let G=W,ee;t[40]!==O.left||t[41]!==O.top||t[42]!==I?(ee={position:`fixed`,left:O.left,top:O.top,width:I,transform:`translateY(calc(-100% - 8px))`,zIndex:G1},t[40]=O.left,t[41]=O.top,t[42]=I,t[43]=ee):ee=t[43];let te=`${f}, ${p}, ${m}`,ne=F?`${V[F.kind]}: ${F.name}`:``,re;t[44]===ne?re=t[45]:(re=(0,$.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:ne}),t[44]=ne,t[45]=re);let ie;return t[46]!==G||t[47]!==o||t[48]!==D||t[49]!==te||t[50]!==re||t[51]!==ee?(ie=(0,Hn.createPortal)((0,$.jsx)(Fn,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!1,children:(0,$.jsxs)(`div`,{ref:D,className:`pointer-events-auto max-h-[min(32rem,60vh)] min-h-8 overflow-y-auto rounded-md border border-edge bg-surface-overlay text-xs leading-4 shadow-lg`,style:ee,role:`listbox`,"aria-label":te,"aria-busy":o,children:[re,G]})}),document.body),t[46]=G,t[47]=o,t[48]=D,t[49]=te,t[50]=re,t[51]=ee,t[52]=ie):ie=t[52],ie}),Z1=(0,Z.memo)(function(e){let t=(0,Q.c)(39),{item:n,icon:r,selected:i,id:a,nameLine:o,descriptionLine:s,dimCategoryBadge:c,trailingBadge:l,disabled:u,disabledTooltip:d,onSelect:f}=e,p;t[0]===n.description?p=t[1]:(p=n.description.trim(),t[0]=n.description,t[1]=p);let m=p,h=m.length>0&&s!=null,g=m.length>0,_=n.description,v=n.category&&n.kind!==`skill`&&!c&&!(n.kind===`agent`&&l),y;t[2]===o?y=t[3]:(y=(0,$.jsx)(`span`,{className:`min-w-0 max-w-[min(12rem,46%)] shrink-0 truncate font-semibold text-fg`,children:o}),t[2]=o,t[3]=y);let b;t[4]!==n.category||t[5]!==v?(b=v?(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-surface-hover px-1 py-px text-[0.6rem] font-normal leading-none text-fg-muted`,children:n.category}):null,t[4]=n.category,t[5]=v,t[6]=b):b=t[6];let x;t[7]!==s||t[8]!==h?(x=h?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-normal leading-tight text-fg-muted`,children:s}):null,t[7]=s,t[8]=h,t[9]=x):x=t[9];let S;t[10]!==y||t[11]!==b||t[12]!==x?(S=(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1`,children:[y,b,x]}),t[10]=y,t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S,w=u?`cursor-not-allowed opacity-50 text-fg-muted`:i?`cursor-pointer bg-surface-hover text-fg`:`cursor-pointer text-fg-subtle hover:bg-surface-hover/80`,T;t[14]===w?T=t[15]:(T=K(`flex min-h-11 w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-sm leading-5 sm:min-h-9`,w),t[14]=w,t[15]=T);let E=T,D;t[16]!==u||t[17]!==f?(D=e=>{u||e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),f())},t[16]=u,t[17]=f,t[18]=D):D=t[18];let O=D,k;t[19]===r?k=t[20]:(k=(0,$.jsx)(`span`,{className:`shrink-0 [&_svg]:align-middle`,children:r}),t[19]=r,t[20]=k);let A;t[21]!==k||t[22]!==C||t[23]!==l?(A=(0,$.jsxs)($.Fragment,{children:[k,C,l]}),t[21]=k,t[22]=C,t[23]=l,t[24]=A):A=t[24];let j=A,M=u&&d?d:g?_:null,N=u||void 0,P;t[25]!==a||t[26]!==O||t[27]!==E||t[28]!==j||t[29]!==i||t[30]!==N?(P=(0,$.jsx)(`div`,{id:a,role:`option`,"aria-selected":i,"aria-disabled":N,tabIndex:-1,className:E,onPointerDown:O,children:j}),t[25]=a,t[26]=O,t[27]=E,t[28]=j,t[29]=i,t[30]=N,t[31]=P):P=t[31];let F=P;if(M!==null){let e;t[32]===F?e=t[33]:(e=(0,$.jsx)(Mn,{asChild:!0,children:F}),t[32]=F,t[33]=e);let n;t[34]===M?n=t[35]:(n=(0,$.jsx)(Pn,{children:(0,$.jsx)(In,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,className:`!z-[10000] max-h-[min(12rem,40vh)] max-w-sm overflow-y-auto rounded-md border border-edge bg-surface-overlay px-2 py-1.5 text-left text-[11px] leading-snug text-fg shadow-lg select-text [max-width:min(20rem,90vw)]`,"data-slash-palette-tooltip":``,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:M})})}),t[34]=M,t[35]=n);let r;return t[36]!==e||t[37]!==n?(r=(0,$.jsxs)(Nn,{delayDuration:0,children:[e,n]}),t[36]=e,t[37]=n,t[38]=r):r=t[38],r}return F});function Q1(e){return[e.kind,e]}function $1(e,t){return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,$.jsx)(xn,{className:`size-4 shrink-0`}),(0,$.jsx)(xn,{className:`h-3 w-28`}),(0,$.jsx)(xn,{className:`h-3 flex-1`})]},t)}var e0=[],t0=null,n0=!1,r0=Promise.resolve(),i0=0;function a0(e){if(e0[0]?.text===e.text){e.id>0&&(e0[0]=e);return}e0=[e,...e0].slice(0,100)}function o0(e){let t=e0.findIndex(t=>t.id===0&&t.text===e.text);if(t>=0){e0[t]=e;return}a0(e)}function s0(){return e0.map(e=>e.text)}function c0(e=!1){if(n0&&!e)return Promise.resolve();if(t0)return t0;let t=i0,n=!1;return t0=q(`/api/composer-history`).then(e=>{i0===t?(e0=e.items.slice(0,100),n0=!0):n=!0}).catch(()=>{}).finally(()=>{t0=null,n&&r0.then(()=>c0(!0))}),t0}function l0(e){let t=e.trim();t&&(i0+=1,a0({id:0,text:t,createdAt:Date.now()}),r0=r0.then(async()=>{o0((await q(`/api/composer-history`,{method:`POST`,body:JSON.stringify({text:t})})).item)}).catch(()=>{}))}function u0(e){if(!e||typeof e!=`object`)return;let t=e;typeof t.id!=`number`||typeof t.text!=`string`||typeof t.createdAt!=`number`||(i0+=1,o0({id:t.id,text:t.text,createdAt:t.createdAt}))}function d0(){i0+=1,e0=[]}function f0(e){let t=(0,Q.c)(16),{conversationId:n,editorRef:r,valueRef:i,resetEditor:a,onWireInput:o}=e,s=(0,Z.useRef)(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s.current=null},t[0]=c):c=t[0];let l=c,u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l()},t[1]=u):u=t[1];let d;t[2]===n?d=t[3]:(d=[n,l],t[2]=n,t[3]=d),(0,Z.useEffect)(u,d);let f,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{c0();let e=e=>{u0(e.detail),l()},t=()=>{d0(),l()},n=p0;return window.addEventListener(`composer-history-appended`,e),window.addEventListener(`composer-history-cleared`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`composer-history-appended`,e),window.removeEventListener(`composer-history-cleared`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},p=[l],t[4]=f,t[5]=p):(f=t[4],p=t[5]),(0,Z.useEffect)(f,p);let m;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>{os(e)||l0(e),l()},t[6]=m):m=t[6];let h=m,g;t[7]===o?g=t[8]:(g=(e,t)=>{s.current=null,o(e,t)},t[7]=o,t[8]=g);let _=g,v;t[9]!==r||t[10]!==a||t[11]!==i?(v=e=>{let t=s0();if(t.length===0)return!1;let n=s.current,o=r.current,c=o?sT(o):0,l=i.current;if(e===`up`){if(n==null){if(c!==0)return!1;s.current={index:0,stash:l};let e=t[0];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(n.index>=t.length-1)return!0;n.index+=1;let e=t[n.index];return e?(a({nextText:e,caretOffset:e.length,focus:!0}),!0):!1}if(n==null)return!1;if(--n.index,n.index<0){let e=n.stash;return s.current=null,a({nextText:e,caretOffset:e.length,focus:!0}),!0}let u=t[n.index];return u?(a({nextText:u,caretOffset:u.length,focus:!0}),!0):!1},t[9]=r,t[10]=a,t[11]=i,t[12]=v):v=t[12];let y=v,b;return t[13]!==_||t[14]!==y?(b={onUserTextCommitted:h,onWireInputClearWalk:_,tryInputHistoryArrow:y},t[13]=_,t[14]=y,t[15]=b):b=t[15],b}function p0(){c0(!0)}function m0(e){if(e.voiceActive)return e.cancelVoiceInput(),null;let t=e.getTextValue(),n=e.getContextRefs();if(!t.trim()&&e.getAttachmentCount()===0&&n.length===0)return null;let r=e.wireAttachmentsPayload();return structuredClone({text:t,attachments:r,contextRefs:n})}function h0(e){let t=(0,Z.useRef)(e);t.current=e;let{chat:n,runBusy:r,voiceActive:i,cancelVoiceInput:a,editingFollowUpId:o,getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u,getThinkingLevel:d,onSend:f,onAddPendingFollowUp:p,onSteeringInterrupt:m,onCommitEditFollowUp:h,onPendingFollowUpRemove:g,pendingFollowUpsCount:_,resetEditor:v,clearAttachments:y,clearContextRefs:b,clearEditFollowUpRef:x,onUserTextCommitted:S}=e,C={getTextValue:s,getAttachmentCount:c,wireAttachmentsPayload:l,getContextRefs:u},w=(0,Z.useRef)(!1);return{send:(0,Z.useCallback)(()=>{if(r)return;let e=m0({voiceActive:i,cancelVoiceInput:a,...C});e&&s1(f(e.text,e.attachments.length>0?e.attachments:void 0,d(),e.contextRefs.length>0?e.contextRefs:void 0,{onDispatched:()=>{}}),()=>{S?.(e.text);let n=t.current;n.getTextValue()!==e.text||JSON.stringify(n.wireAttachmentsPayload())!==JSON.stringify(e.attachments)||JSON.stringify(n.getContextRefs())!==JSON.stringify(e.contextRefs)||(v(),y(),b())})},[r,i,a,f,d,S,v,y,b,s,c,l,u]),flushSteeringDraft:(0,Z.useCallback)(async()=>{if(!r&&_===0)return;let e=m0({voiceActive:i,cancelVoiceInput:a,...C});if(e){if(o){h(o,e.text,e.attachments.length>0?e.attachments:void 0,d(),e.contextRefs.length>0?e.contextRefs:void 0),S?.(e.text),x(),v(),y(),b();return}if(p&&!w.current){if(_>=10){Yl(`warning`,n.followUpQueueMaxReached,{max:10});return}w.current=!0;try{await p(e.text,e.attachments.length>0?e.attachments:void 0,e.contextRefs.length>0?e.contextRefs:void 0),S?.(e.text),v(),y(),b()}catch(e){Yl(`error`,n.followUpQueueSubmitFailed,{message:e instanceof Error?e.message:String(e)})}finally{w.current=!1}}}},[r,i,a,o,_,p,h,d,n.followUpQueueMaxReached,n.followUpQueueSubmitFailed,x,S,v,y,b,s,c,l,u]),interruptDraft:(0,Z.useCallback)(()=>{if(!r||!m)return;let e=m0({voiceActive:i,cancelVoiceInput:a,...C});e&&(m(e.text,e.attachments.length>0?e.attachments:void 0,e.contextRefs.length>0?e.contextRefs:void 0),S?.(e.text),o&&(x(),g(o)),v(),y(),b())},[r,i,a,o,g,m,S,x,v,y,b,s,c,l,u])}}function g0(e){let t=(0,Q.c)(6),{active:n,anchors:r,ignoreSelector:i,onDismiss:a}=e,o,s;t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a?(o=()=>{if(!n)return;let e=e=>{let t=e.target;if(t instanceof Node){for(let e of r){let n=e.current;if(n&&n.contains(t))return}i&&t instanceof Element&&t.closest(i)||a()}};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},s=[n,r,i,a],t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s):(o=t[4],s=t[5]),(0,Z.useEffect)(o,s)}var _0=20,v0=`xopc.atMention.recent:`;function y0(e){return`${v0}${e.trim()}`}function b0(e){let t=e?.trim();if(!t||typeof localStorage>`u`)return[];try{let e=localStorage.getItem(y0(t));if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0).slice(0,_0):[]}catch{return[]}}function x0(e,t){let n=e?.trim(),r=t.trim();if(!(!n||!r||typeof localStorage>`u`))try{let e=[r,...b0(n).filter(e=>e!==r)].slice(0,_0);localStorage.setItem(y0(n),JSON.stringify(e))}catch{}}var S0=150,C0=[`file`,`note`,`session`,`browser_tab`,`skill`,`agent`,`mcp_server`,`mcp_resource`];function w0(e){let t={items:[],loading:e,error:null};return{file:{...t},note:{...t},session:{...t},skill:{...t},agent:{...t},browser_tab:{...t},mcp_server:{...t},mcp_resource:{...t}}}function T0(e,t){let n=Math.min(Math.max(t,0),e.length);if(n<1)return null;let r=e.slice(0,n).match(/@((?:\\.|[^\s])*)$/);if(!r||r.index===void 0)return null;let i=r.index;return i>0&&/[a-zA-Z0-9_]/.test(e[i-1])?null:{start:i,end:n,query:(r[1]??``).replace(/\\([\\\s])/gu,`$1`)}}function E0(e){return e.replace(/[\\\s]/gu,e=>`\\${e}`)}function D0(e){let t=e.trim();return t.length>0&&t.endsWith(`/`)&&!t.startsWith(`mcp:`)&&!/^https?:\/\//i.test(t)}function O0(e){return e.replace(/\/+$/,``).trim()}function k0(e){let t=e.replace(/\/+$/,``);if(!t)return``;let n=t.lastIndexOf(`/`);return n<=0?``:t.slice(0,n)}function A0(e,t){return t===0?0:Math.min(e,t-1)}function j0(e){return{id:`file:${e.id}`,kind:`file`,name:e.name,description:e.path,relativePath:e.path,isDirectory:e.isDirectory,fileRef:{sourceId:e.id,expectedVersion:e.revision}}}function M0(e,t,n){let r=(0,Q.c)(44),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(R0),c=(0,Z.useRef)(0),l=Ee(L0),u;bb0:{if(n.isComposing||n.slashPaletteOpen){u=null;break bb0}if(n.precomputedAtRange!==void 0){u=n.precomputedAtRange;break bb0}let i;r[0]!==t||r[1]!==e?(i=T0(e,t),r[0]=t,r[1]=e,r[2]=i):i=r[2],u=i}let d=u,f=d!==null,[p]=qh(f?d.query:``,S0),m=f?p:``,h;r[3]===n.conversationId?h=r[4]:(h=n.conversationId?.trim()??``,r[3]=n.conversationId,r[4]=h);let g=h,_;r[5]===n.selectedContextKeys?_=r[6]:(_=[...n.selectedContextKeys??new Set].sort().join(`\0`),r[5]=n.selectedContextKeys,r[6]=_);let v=_,y;r[7]!==g||r[8]!==m||r[9]!==l||r[10]!==n||r[11]!==f||r[12]!==v?(y=()=>{let e=c.current+=1;if(!f){s(w0(!1));return}if(!g){s(w0(!!n.prepareSession)),n.prepareSession&&n.prepareSession().catch(()=>{c.current===e&&s(w0(!1))});return}let t={conversationId:g,currentAgentId:n.currentAgentId,language:l,selectedContextKeys:new Set(v?v.split(`\0`):[]),recentPaths:new Set(b0(g))};if(/^mcp:[^/]+\//u.test(m)){let n=w0(!1);n.mcp_resource={items:[],loading:!0,error:null},s(n),tG.find(I0).search(m,t).then(t=>{c.current===e&&s(e=>({...e,mcp_resource:{items:t,loading:!1,error:null}}))}).catch(t=>{c.current===e&&s(e=>({...e,mcp_resource:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))});return}if(D0(m)){let t=w0(!1);t.file={items:[],loading:!0,error:null},s(t);let r=O0(m);XW(r,{conversationId:g,agentId:n.currentAgentId}).then(t=>{if(c.current!==e)return;let n={id:`browse-up:${r}`,kind:`file`,name:`..`,description:k0(r)||`/`,relativePath:``,isDirectory:!0,isBrowseUp:!0};s(e=>({...e,file:{items:[n,...t.map(j0)],loading:!1,error:null}}))}).catch(t=>{c.current===e&&s(e=>({...e,file:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))});return}s(w0(!0));for(let n of tG)n.search(m,t).then(t=>{c.current===e&&s(e=>({...e,[n.kind]:{items:t,loading:!1,error:null}}))}).catch(t=>{c.current===e&&s(e=>({...e,[n.kind]:{items:[],loading:!1,error:t instanceof Error?t.message:String(t)}}))})},r[7]=g,r[8]=m,r[9]=l,r[10]=n,r[11]=f,r[12]=v,r[13]=y):y=r[13];let b;r[14]!==g||r[15]!==m||r[16]!==l||r[17]!==n.currentAgentId||r[18]!==n.prepareSession||r[19]!==f||r[20]!==v?(b=[f,g,m,l,n.currentAgentId,n.prepareSession,v],r[14]=g,r[15]=m,r[16]=l,r[17]=n.currentAgentId,r[18]=n.prepareSession,r[19]=f,r[20]=v,r[21]=b):b=r[21],(0,Z.useEffect)(y,b);let x;r[22]===o?x=r[23]:(x=C0.map(e=>({kind:e,...o[e]})),r[22]=o,r[23]=x);let S=x,C=f?S.flatMap(F0):[],w;r[24]!==f||r[25]!==S?(w=f&&S.some(P0),r[24]=f,r[25]=S,r[26]=w):w=r[26];let T=w,E;r[27]===S?E=r[28]:(E=S.flatMap(N0),r[27]=S,r[28]=E);let D=E,O=!T&&C.length===0?D[0]??null:null,k=`${d?.start??``}:${d?.end??``}:${m}`,A;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>a(0),r[29]=A):A=r[29];let j;r[30]===k?j=r[31]:(j=[k],r[30]=k,r[31]=j),(0,Z.useEffect)(A,j);let M=A0(i,C.length),N;r[32]===C.length?N=r[33]:(N=e=>{C.length!==0&&a(t=>e===`down`?(t+1)%C.length:(t-1+C.length)%C.length)},r[32]=C.length,r[33]=N);let P=N,F=d?.query??``,I;return r[34]!==d||r[35]!==O||r[36]!==C||r[37]!==T||r[38]!==P||r[39]!==f||r[40]!==M||r[41]!==S||r[42]!==F?(I={open:f,atRange:d,sections:S,items:C,selectedIndex:M,query:F,loading:T,error:O,onNavigate:P,setSelectedIndex:a},r[34]=d,r[35]=O,r[36]=C,r[37]=T,r[38]=P,r[39]=f,r[40]=M,r[41]=S,r[42]=F,r[43]=I):I=r[43],I}function N0(e){return e.error?[e.error]:[]}function P0(e){return e.loading}function F0(e){return e.items}function I0(e){return e.kind===`mcp_resource`}function L0(e){return e.language}function R0(){return w0(!1)}function z0(e){return e.kind===`note`?{refId:crypto.randomUUID(),kind:`note`,sourceId:e.noteRef.sourceId,expectedVersion:e.noteRef.expectedVersion,title:e.name}:e.kind===`file`&&!e.isBrowseUp&&e.fileRef?{refId:crypto.randomUUID(),kind:`file`,sourceId:e.fileRef.sourceId,expectedVersion:e.fileRef.expectedVersion,title:e.name,fileKind:e.isDirectory?`directory`:`file`}:e.kind===`session`?{refId:crypto.randomUUID(),kind:`session`,sourceId:e.sessionRef.sourceId,expectedVersion:e.sessionRef.expectedVersion,title:e.name}:e.kind===`browser_tab`?{refId:crypto.randomUUID(),kind:`browser_tab`,sourceId:e.tabRef.sourceId,expectedVersion:e.tabRef.expectedVersion,title:e.name}:e.kind===`mcp_resource`?{refId:crypto.randomUUID(),kind:`mcp_resource`,sourceId:e.resourceRef.sourceId,expectedVersion:e.resourceRef.expectedVersion,title:e.name}:null}function B0(e){let{conversationId:t,editorValue:n,editorCursor:r,isComposing:i,runBusy:a,thinkingLevel:o,editorRef:s,valueRef:c,resetEditor:l,clearAttachments:u,onSend:d,onUserTextCommitted:f,onChatAgentChange:p,currentAgentId:m,prepareSession:h,contextRefs:g,onAddContextRef:_,onUnavailableSkill:v,onReviewLauncher:y,onAddPendingFollowUp:b,onAbort:x,pendingFollowUpsCount:S,maxPendingFollowUps:C,clearContextRefs:w,commandPalettePanelRef:T}=e,E=(0,Z.useMemo)(()=>T0(n,r),[n,r]),D=O1(n,r,{suppress:E!=null,isComposing:i,currentAgentId:m,conversationId:t}),O=M0(n,r,{conversationId:t,currentAgentId:m,slashPaletteOpen:D.open,isComposing:i,precomputedAtRange:E,selectedContextKeys:new Set(g.map(e=>`${e.kind}:${e.sourceId}`)),prepareSession:h}),k=D.open||O.open||E!=null,A=(0,Z.useCallback)(()=>({slashRange:D.slashRange,runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C,thinkingLevel:o,editor:{valueRef:c,resetEditor:l},attachments:{clearAttachments:u},contextRefs:{current:g,clear:w},callbacks:{onSend:d,onUserTextCommitted:f,onChatAgentChange:p,onAddPendingFollowUp:b,onAbort:x,onUnavailableSkill:v,onReviewLauncher:y}}),[D.slashRange,a,S,C,o,c,l,u,g,w,d,f,p,b,x,v,y]),j=(0,Z.useCallback)(e=>{m1(e,A())},[A]),M=(0,Z.useCallback)(e=>{let n=O.atRange;if(!n)return;let r=z0(e);if(r){let i=_(r);if(!i?.refId)return;let a=`${is(i.refId)} `;l({nextText:u1(c.current,n.start,n.end,a),caretOffset:n.start+a.length,focus:!0}),t&&e.kind===`file`&&x0(t,e.relativePath);return}if(e.kind===`skill`){let t=`/skill:${e.canonicalName} `;l({nextText:u1(c.current,n.start,n.end,t),caretOffset:n.start+t.length,focus:!0});return}if(e.kind===`agent`){l({nextText:u1(c.current,n.start,n.end,``),caretOffset:n.start,focus:!0}),p?.(e.agentId);return}if(e.kind===`mcp_server`){let t=`@mcp:${encodeURIComponent(e.serverId)}/`;l({nextText:u1(c.current,n.start,n.end,t),caretOffset:n.start+t.length,focus:!0});return}if(e.kind!==`file`||!e.isDirectory)return;let i=`@${E0(e.isBrowseUp?(()=>{let e=k0(O0(n.query));return e?`${e}/`:``})():`${e.relativePath.replace(/\/+$/,``)}/`)}`;l({nextText:u1(c.current,n.start,n.end,i),caretOffset:n.start+i.length,focus:!0})},[O.atRange,_,t,p,c,l]),N=(0,Z.useRef)(null);N.current=O.open?O.atRange:D.open?D.slashRange:null;let P=c,F=(0,Z.useCallback)(()=>{let e=N.current;if(!e)return;let t=P.current;l({nextText:t.slice(0,e.start)+t.slice(e.end),caretOffset:e.start})},[l,P]),I=(0,Z.useMemo)(()=>[s,T],[s,T]);g0({active:D.open||O.open,anchors:I,ignoreSelector:`[data-composer-picker-panel], [data-slash-palette-tooltip]`,onDismiss:F});let L=(0,Z.useRef)(O);L.current=O;let R=(0,Z.useRef)(D);R.current=D;let z=(0,Z.useRef)(i);z.current=i;let B=(0,Z.useRef)(j);B.current=j;let V=(0,Z.useRef)(M);V.current=M;let H=(0,Z.useRef)({runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C});H.current={runBusy:a,pendingFollowUpsCount:S,maxPendingFollowUps:C};let U=(0,Z.useMemo)(()=>({name:`at-mention`,isActive:()=>{let e=L.current;return e.open&&e.atRange!=null&&!z.current},handleKey:e=>{let t=L.current;if(!t.atRange)return!1;if(e.key===`Escape`){e.preventDefault();let n=t.atRange,r=P.current;return l({nextText:u1(r,n.start,n.end,``),caretOffset:n.start,focus:!0}),!0}if(t.items.length===0)return!1;if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let n=t.items[t.selectedIndex];return n&&V.current(n),!0}return!1}}),[l,P]),W=(0,Z.useMemo)(()=>({name:`slash-palette`,isActive:()=>R.current.open&&!z.current,handleKey:e=>{let t=R.current;if(t.flatItems.length>0){if(e.key===`ArrowDown`)return e.preventDefault(),t.onNavigate(`down`),!0;if(e.key===`ArrowUp`)return e.preventDefault(),t.onNavigate(`up`),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){e.preventDefault();let n=t.flatItems[t.selectedIndex];return!n||b1(n,H.current)||B.current(n),!0}}if(e.key===`Escape`){e.preventDefault();let n=t.slashRange;if(n){let e=P.current;l({nextText:u1(e,n.start,n.end,``),caretOffset:n.start,focus:!0})}return!0}return!1}}),[l,P]);return{palette:D,atPicker:O,shouldSyncSelection:k,adapters:(0,Z.useMemo)(()=>[U,W],[U,W]),applyPalette:j,applyAtMention:M}}function V0(e){return/^[A-Za-z0-9._/@:-]+$/.test(e)?e:JSON.stringify(e)}function H0(e,t){let n=t?.trim();return n?`${e} --instructions ${V0(n)}`:e}function U0(e){if(e.preset===`base`){if(!e.baseBranch?.trim())throw Error(`Missing base branch.`);return H0(`/review --base ${V0(e.baseBranch.trim())}`,e.instructions)}if(e.preset===`commit`){if(!e.commitSha?.trim())throw Error(`Missing commit SHA.`);return H0(`/review --commit ${V0(e.commitSha.trim())}`,e.instructions)}return e.preset,H0(`/review --uncommitted`,e.instructions)}async function W0(e){let t=await we(J(`/api/review/context?${new URLSearchParams({conversationId:e}).toString()}`)),n=await t.json().catch(()=>({}));if(!t.ok||!n.ok||!n.payload)throw Error(je(t.status,t.statusText,n.error?.message));return n.payload}function G0(e,t){let n=e?.status;if(!n)return``;if(n.isClean)return t.statusClean;let r=[];return n.changedFiles>0&&r.push(t.statusChanged.replace(`{{count}}`,String(n.changedFiles))),n.untrackedFiles>0&&r.push(t.statusUntracked.replace(`{{count}}`,String(n.untrackedFiles))),r.join(`, `)}function K0(e,t){let n=t.trim().toLowerCase(),r=[...(e?.branches??[]).filter(e=>!e.current)].sort((t,n)=>t.name===e?.defaultBaseBranch&&n.name!==e.defaultBaseBranch?-1:n.name===e?.defaultBaseBranch&&t.name!==e.defaultBaseBranch?1:t.name.localeCompare(n.name));return n?r.filter(e=>e.name.toLowerCase().includes(n)):r}function q0(e,t){let n=t.trim().toLowerCase(),r=e?.commits??[];return n?r.filter(e=>`${e.sha} ${e.shortSha} ${e.subject}`.toLowerCase().includes(n)):r}function J0(e){let t=(0,Q.c)(15),{icon:n,title:r,description:i,disabled:a,onClick:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=K(`flex min-h-16 w-full items-center gap-3 rounded-lg border border-edge bg-surface-panel px-3 py-2.5 text-left`,`hover:border-accent/45 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:cursor-not-allowed disabled:opacity-50`,yc.transition),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,$.jsx)(`span`,{className:`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:r}),t[3]=r,t[4]=l);let u;t[5]===i?u=t[6]:(u=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:i}),t[5]=i,t[6]=u);let d;t[7]!==l||t[8]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==o||t[12]!==c||t[13]!==d?(f=(0,$.jsxs)(`button`,{type:`button`,disabled:a,className:s,onClick:o,children:[c,d]}),t[10]=a,t[11]=o,t[12]=c,t[13]=d,t[14]=f):f=t[14],f}function Y0(e){let t=(0,Q.c)(89),{open:n,conversationId:r,disabled:i,chat:a,onClose:o,onSendCommand:s}=e,c=a.reviewLauncher,[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`presets`),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),x;t[0]!==r||t[1]!==c.noSession?(x=()=>{if(!r){u(null),m(c.noSession);return}f(!0),m(null),W0(r).then(e=>u(e)).catch(e=>{u(null),m(e instanceof Error?e.message:String(e))}).finally(()=>f(!1))},t[0]=r,t[1]=c.noSession,t[2]=x):x=t[2];let S=x,C,w;t[3]!==S||t[4]!==n?(C=()=>{n&&(g(`presets`),v(``),b(``),S())},w=[S,n],t[3]=S,t[4]=n,t[5]=C,t[6]=w):(C=t[5],w=t[6]),(0,Z.useEffect)(C,w);let T;t[7]!==l||t[8]!==_?(T=K0(l,_),t[7]=l,t[8]=_,t[9]=T):T=t[9];let E=T,D;t[10]!==l||t[11]!==_?(D=q0(l,_),t[10]=l,t[11]=_,t[12]=D):D=t[12];let O=D,k;t[13]!==l||t[14]!==c?(k=G0(l,c),t[13]=l,t[14]=c,t[15]=k):k=t[15];let A=k,j;t[16]!==y||t[17]!==o||t[18]!==s?(j=(e,t)=>{s(U0({preset:e,baseBranch:t?.branch,commitSha:t?.commit,instructions:y})),o()},t[16]=y,t[17]=o,t[18]=s,t[19]=j):j=t[19];let M=j,N=h===`base`?c.baseTitle:h===`commit`?c.commitTitle:h===`custom`?c.customTitle:c.title,P;t[20]===o?P=t[21]:(P=e=>!e&&o(),t[20]=o,t[21]=P);let F;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[22]=F):F=t[22];let I;t[23]!==c.back||t[24]!==h?(I=h===`presets`?null:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.back,onClick:()=>{g(`presets`),v(``)},children:(0,$.jsx)(Jn,{className:`size-4`})}),t[23]=c.back,t[24]=h,t[25]=I):I=t[25];let L;t[26]===N?L=t[27]:(L=(0,$.jsx)(tt,{className:`truncate text-sm font-semibold text-fg`,children:N}),t[26]=N,t[27]=L);let R=l?.cwd??c.description,z;t[28]===R?z=t[29]:(z=(0,$.jsx)(Ze,{className:`truncate text-xs text-fg-muted`,children:R}),t[28]=R,t[29]=z);let B;t[30]!==L||t[31]!==z?(B=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[L,z]}),t[30]=L,t[31]=z,t[32]=B):B=t[32];let V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(ye,{className:`size-4`}),t[33]=V):V=t[33];let H;t[34]!==c.close||t[35]!==o?(H=(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":c.close,onClick:o,children:V}),t[34]=c.close,t[35]=o,t[36]=H):H=t[36];let U;t[37]!==I||t[38]!==B||t[39]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-3`,children:[I,B,H]}),t[37]=I,t[38]=B,t[39]=H,t[40]=U):U=t[40];let W;t[41]!==E||t[42]!==O||t[43]!==l||t[44]!==i||t[45]!==p||t[46]!==y||t[47]!==S||t[48]!==d||t[49]!==c.customDescription||t[50]!==c.customPlaceholder||t[51]!==c.defaultBadge||t[52]!==c.errorTitle||t[53]!==c.loading||t[54]!==c.localBadge||t[55]!==c.noBranches||t[56]!==c.noCommits||t[57]!==c.presetBase||t[58]!==c.presetBaseDescription||t[59]!==c.presetBaseDescriptionNoDefault||t[60]!==c.presetCommit||t[61]!==c.presetCommitDescription||t[62]!==c.presetCustom||t[63]!==c.presetCustomDescription||t[64]!==c.presetUncommitted||t[65]!==c.remoteBadge||t[66]!==c.retry||t[67]!==c.searchBranches||t[68]!==c.searchCommits||t[69]!==_||t[70]!==M||t[71]!==A||t[72]!==h?(W=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:d?(0,$.jsxs)(`div`,{className:`flex h-full min-h-56 items-center justify-center text-sm text-fg-muted`,children:[(0,$.jsx)(Vi,{className:`mr-2 size-4 animate-spin`}),c.loading]}):p?(0,$.jsxs)(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:c.errorTitle}),(0,$.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:p}),(0,$.jsxs)(X,{type:`button`,className:`mt-4 h-9 rounded-lg`,variant:`secondary`,onClick:S,children:[(0,$.jsx)(Vi,{className:`size-4`}),c.retry]})]}):h===`presets`?(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(J0,{icon:(0,$.jsx)(se,{className:`size-4`}),title:c.presetBase,description:l?.defaultBaseBranch?c.presetBaseDescription.replace(`{{branch}}`,l.defaultBaseBranch):c.presetBaseDescriptionNoDefault,disabled:i,onClick:()=>g(`base`)}),(0,$.jsx)(J0,{icon:(0,$.jsx)(ai,{className:`size-4`}),title:c.presetUncommitted,description:A,disabled:i,onClick:()=>M(`uncommitted`)}),(0,$.jsx)(J0,{icon:(0,$.jsx)(Kr,{className:`size-4`}),title:c.presetCommit,description:c.presetCommitDescription.replace(`{{count}}`,String(l?.commits.length??0)),disabled:i,onClick:()=>g(`commit`)}),(0,$.jsx)(J0,{icon:(0,$.jsx)(ai,{className:`size-4`}),title:c.presetCustom,description:c.presetCustomDescription,disabled:i,onClick:()=>g(`custom`)})]}):h===`base`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(X0,{value:_,placeholder:c.searchBranches,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:E.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noBranches}):E.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`base`,{branch:e.name}),children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.name===l?.defaultBaseBranch?c.defaultBadge:e.remote?c.remoteBadge:c.localBadge})]},e.name))})]}):h===`commit`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(X0,{value:_,placeholder:c.searchCommits,onChange:v}),(0,$.jsx)(`div`,{className:`grid gap-1`,children:O.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-edge-subtle px-3 py-6 text-center text-sm text-fg-muted`,children:c.noCommits}):O.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,disabled:i,onClick:()=>M(`commit`,{commit:e.sha}),children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:e.shortSha}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.subject}),e.date?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.date.slice(0,10)}):null]},e.sha))})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`textarea`,{className:`h-40 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-disabled focus:border-accent focus:ring-2 focus:ring-accent/25`,value:y,placeholder:c.customPlaceholder,onChange:e=>b(e.target.value)}),(0,$.jsx)(`div`,{className:`text-xs text-fg-muted`,children:c.customDescription})]})}),t[41]=E,t[42]=O,t[43]=l,t[44]=i,t[45]=p,t[46]=y,t[47]=S,t[48]=d,t[49]=c.customDescription,t[50]=c.customPlaceholder,t[51]=c.defaultBadge,t[52]=c.errorTitle,t[53]=c.loading,t[54]=c.localBadge,t[55]=c.noBranches,t[56]=c.noCommits,t[57]=c.presetBase,t[58]=c.presetBaseDescription,t[59]=c.presetBaseDescriptionNoDefault,t[60]=c.presetCommit,t[61]=c.presetCommitDescription,t[62]=c.presetCustom,t[63]=c.presetCustomDescription,t[64]=c.presetUncommitted,t[65]=c.remoteBadge,t[66]=c.retry,t[67]=c.searchBranches,t[68]=c.searchCommits,t[69]=_,t[70]=M,t[71]=A,t[72]=h,t[73]=W):W=t[73];let G;t[74]!==i||t[75]!==c.cancel||t[76]!==c.runReview||t[77]!==o||t[78]!==M||t[79]!==h?(G=h===`custom`?(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:o,children:c.cancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:i,onClick:()=>M(`custom`),children:c.runReview})]}):null,t[74]=i,t[75]=c.cancel,t[76]=c.runReview,t[77]=o,t[78]=M,t[79]=h,t[80]=G):G=t[80];let ee;t[81]!==U||t[82]!==W||t[83]!==G?(ee=(0,$.jsxs)($e,{children:[F,(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(86vh,34rem)] w-[min(100vw-2rem,40rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[U,W,G]})]}),t[81]=U,t[82]=W,t[83]=G,t[84]=ee):ee=t[84];let te;return t[85]!==n||t[86]!==ee||t[87]!==P?(te=(0,$.jsx)(nt,{open:n,onOpenChange:P,children:ee}),t[85]=n,t[86]=ee,t[87]=P,t[88]=te):te=t[88],te}function X0(e){let t=(0,Q.c)(7),{value:n,placeholder:r,onChange:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(ve,{className:`size-4 shrink-0 text-fg-muted`}),t[0]=a):a=t[0];let o;t[1]===i?o=t[2]:(o=e=>i(e.target.value),t[1]=i,t[2]=o);let s;return t[3]!==r||t[4]!==o||t[5]!==n?(s=(0,$.jsxs)(`label`,{className:`flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm text-fg focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/25`,children:[a,(0,$.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-disabled`,value:n,placeholder:r,onChange:o})]}),t[3]=r,t[4]=o,t[5]=n,t[6]=s):s=t[6],s}function Z0(e){let t=e.mimeType||`application/octet-stream`,n=e.type===`voice`||t.startsWith(`audio/`)?`voice`:e.type===`pasted_text`?`pasted_text`:t.startsWith(`image/`)?`image`:`document`;return{id:e.id,type:n,name:e.name||`file`,mimeType:t,size:e.size??0,content:e.data??``,data:e.data,uri:e.uri,durationSeconds:e.durationSeconds}}var Q0=(0,Z.memo)(function({placeholder:e,disabled:t,sending:n,streaming:r,conversationId:i,composerContext:a,pageContextPreview:o,contextRefs:s,setContextRefs:c,thinkingLevel:l,modelSupportsThinking:d,onThinkingChange:f,onSend:p,onAbort:m,onAddPendingFollowUp:h,onSteeringInterrupt:g,pendingFollowUps:_,editingFollowUpId:v,onBeginEditFollowUp:y,onCancelEditFollowUp:b,onCommitEditFollowUp:x,onPendingFollowUpRemove:S,onPendingFollowUpMove:C,onPendingFollowUpReorder:w,onPendingFollowUpSteer:T,steeringFollowUpId:E,welcomeDraftSeed:D,welcomeSuggestion:O,onAcceptWelcomeSuggestion:k,sessionModel:A,showModelSelector:j,onModelChange:M,modelDisabled:N,onChatAgentChange:P,currentAgentId:F,voiceAgentName:I,voiceTaskId:L,prepareVoiceSession:R,prepareContextSession:z,editingUserTurnId:B,onCancelUserMessageEdit:V}){let H=ad(),U=(0,Z.useRef)(!1);t||=H.conversationId===i&&H.active;let W=xe(Ee(e=>e.language)),[G,ee]=u();(0,Z.useEffect)(()=>{ZT()},[]);let te=(0,Z.useRef)(!1),ne=(0,Z.useRef)(null),re=(0,Z.useRef)(null),ie=(0,Z.useRef)(null),ae=(0,Z.useRef)(!1),[oe,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(null),[fe,pe]=(0,Z.useState)(!1),me=(0,Z.useRef)(p),he=(0,Z.useRef)(l);me.current=p,he.current=l,(0,Z.useEffect)(()=>{if(!i||ue===i){le(null);return}let e=!1;return tE(i).then(t=>{e||le(t.required&&!t.trusted&&t.decision===null?t:null)}).catch(()=>{e||le(null)}),()=>{e=!0}},[i,ue]);let ge=(0,Z.useCallback)(()=>{!i||fe||(pe(!0),nE(i,!0).then(()=>{le(null)}).catch(e=>{Yl(`error`,W.chat.commandPalette.workspaceTrustFailed,{error:e instanceof Error?e.message:String(e)})}).finally(()=>pe(!1)))},[W.chat.commandPalette,i,fe]),_e=FD({chat:W.chat}),ve=(0,Z.useRef)(s);ve.current=s;let ye=(0,Z.useCallback)(e=>{let t=s.find(t=>t.refId===e);return t?{title:t.title,kind:t.kind,fileKind:t.fileKind}:void 0},[s]),be=(0,Z.useCallback)(e=>{let t=e?.contextRefs??[];if(ve.current=t,c(t),e?.attachments){_e.setAttachments(e.attachments.map(Z0));return}_e.clearAttachments()},[_e.clearAttachments,_e.setAttachments,c]),q=(0,Z.useCallback)(e=>{let t=ve.current,n=t.find(t=>t.kind===e.kind&&t.sourceId===e.sourceId);if(n){if(n.refId)return n;let r={...n,refId:e.refId},i=t.map(e=>e===n?r:e);return ve.current=i,c(i),r}if(t.length>=5)return Yl(`warning`,W.chat.commandPalette.contextLimitReached,{max:5}),null;let r=[...t,e];return ve.current=r,c(r),e},[W.chat.commandPalette.contextLimitReached,c]),Se=(0,Z.useCallback)(e=>{let t=e.availability.status===`agent-denied`?W.chat.commandPalette.skillAgentDeniedReason:W.chat.commandPalette.skillDisabledReason,n=AD(W.chat.commandPalette.skillUnavailableMessage,{name:e.name,agent:F||`main`,reason:t});if(e.availability.status===`agent-denied`&&window.confirm(`${n}\n\n${W.chat.commandPalette.skillAddToAllowlistConfirm}`)){$T(F,e.canonicalName,i).catch(e=>{window.alert(e instanceof Error?e.message:String(e))});return}window.alert(n)},[F,W.chat.commandPalette,i]),Ce=uE({disabled:t,agentId:F,conversationId:i,autoFocusKey:i,welcomeDraftSeed:D,onExternalTextReplace:be,shouldSyncSelectionRef:te,resolveContextRef:ye}),we=G.get(`attachmentHandoff`);(0,Z.useEffect)(()=>{if(!we)return;let e=yE(we);ee(e=>{let t=new URLSearchParams(e);return t.delete(`attachmentHandoff`),t},{replace:!0}),e&&_e.processFiles([e]).then(()=>Ce.editorRef.current?.focus({preventScroll:!0}))},[we,_e.processFiles,Ce.editorRef,i,ee]);let{onUserTextCommitted:Te,onWireInputClearWalk:De,tryInputHistoryArrow:Oe}=f0({conversationId:i,editorRef:Ce.editorRef,valueRef:Ce.valueRef,resetEditor:Ce.resetEditor,onWireInput:Ce.onWireInput}),J=(0,Z.useCallback)((e,t)=>{De(e,t);let n=os(e),r=new Set(n?ss(n):[]),i=ve.current,a=i.filter(e=>!e.refId||r.has(e.refId));a.length!==i.length&&(ve.current=a,c(a))},[De,c]),ke=n||r;ae.current=ke;let Ae=(0,Z.useCallback)(()=>{ae.current||se(!0)},[]),je=(0,Z.useCallback)(e=>{s1(me.current(e,void 0,he.current,s),()=>{Te?.(e),c([])})},[s,Te,c]),Me=B0({conversationId:i,editorValue:Ce.value,editorCursor:Ce.cursor,isComposing:Ce.isComposing,runBusy:ke,thinkingLevel:l,editorRef:Ce.editorRef,valueRef:Ce.valueRef,resetEditor:Ce.resetEditor,clearAttachments:_e.clearAttachments,onSend:p,onUserTextCommitted:Te,onChatAgentChange:P,currentAgentId:F,prepareSession:z,contextRefs:s,onAddContextRef:q,onUnavailableSkill:Se,onReviewLauncher:Ae,onAddPendingFollowUp:h,onAbort:m,pendingFollowUpsCount:_.length,maxPendingFollowUps:10,clearContextRefs:()=>c([]),commandPalettePanelRef:ne});te.current=Me.shouldSyncSelection;let Ne=rd({disabled:t||H.active,chat:W.chat,onTranscript:e=>{let t=Ce.valueRef.current,n=DG(t,e);Ce.resetEditor({nextText:n,caretOffset:n.length,focus:!0})}}),{phase:Pe,voiceActive:Fe,startVoiceInput:Ie,cancelVoiceInput:Le,confirmVoiceInput:Re}=Ne;(0,Z.useEffect)(()=>{let e=e=>{if(!P$(e,{disabled:t,editorHidden:Fe&&Pe!==`error`}))return;let n=AT(e.clipboardData);n&&(e.preventDefault(),Ce.focusForExternalPaste(),jT(n,{processFiles:_e.processFiles,processPastedText:_e.processPastedText,insertText:e=>document.execCommand(`insertText`,!1,e),onUnsupportedFiles:()=>Yl(`warning`,W.chat.clipboardFileTypeUnsupported)}))};return window.addEventListener(`paste`,e),()=>window.removeEventListener(`paste`,e)},[_e.processFiles,_e.processPastedText,t,Ce.focusForExternalPaste,W.chat.clipboardFileTypeUnsupported,Fe,Pe]),(0,Z.useEffect)(()=>{let e=e=>{let n=e?.detail?.target;if(!(n&&n!==`chat`)&&(e?.preventDefault(),!t)){if(Pe===`recording`){Re();return}(Pe===`idle`||Pe===`error`)&&(Ce.editorRef.current?.focus({preventScroll:!0}),Ie())}},n=e=>{let t=e.detail?.target;t&&t!==`chat`||!Fe||(e.preventDefault(),Le(),Ce.editorRef.current?.focus({preventScroll:!0}))};window.addEventListener(AG,e),window.addEventListener(jG,n);let r=window.setTimeout(()=>{if(LG()){if(t){FG();return}e()}},0);return()=>{window.clearTimeout(r),window.removeEventListener(AG,e),window.removeEventListener(jG,n)}},[Le,Re,t,Ce.editorRef,Ie,Fe,Pe]);let ze=(0,Z.useCallback)(()=>{ie.current=null},[]),Be=h0({chat:W.chat,runBusy:ke,voiceActive:Ne.voiceActive,cancelVoiceInput:Ne.cancelVoiceInput,editingFollowUpId:v,getTextValue:()=>Ce.valueRef.current,getAttachmentCount:()=>_e.attachmentsRef.current.length,wireAttachmentsPayload:_e.wireAttachmentsPayload,getContextRefs:()=>s,getThinkingLevel:()=>he.current,onSend:p,onAddPendingFollowUp:h,onSteeringInterrupt:g,onCommitEditFollowUp:x,onPendingFollowUpRemove:S,pendingFollowUpsCount:_.length,resetEditor:()=>{Ce.resetEditor()},clearAttachments:_e.clearAttachments,clearContextRefs:()=>c([]),clearEditFollowUpRef:ze,onUserTextCommitted:Te});(0,Z.useLayoutEffect)(()=>{if(!v){ie.current&&=(_e.clearAttachments(),c([]),Ce.resetEditor(),null);return}if(v===ie.current)return;let e=_.find(e=>e.id===v);if(!e){b();return}ie.current=v,e.thinkingLevel!=null&&d&&f(e.thinkingLevel),_e.setAttachments($$(e.attachments??[])),c(e.contextRefs??[]),Ce.resetEditor({nextText:e.text,focus:!0})},[_e.clearAttachments,_e.setAttachments,Ce.resetEditor,v,b,f,_,d,c]);let Ve=(0,Z.useCallback)(e=>{y(e)},[y]),He=(0,Z.useRef)({});He.current={adapters:Me.adapters,send:Be.send,runBusy:ke,pendingFollowUpsCount:_.length,flushSteeringDraft:Be.flushSteeringDraft,interruptDraft:Be.interruptDraft,editingFollowUpId:v,onCancelEditFollowUp:b,attachmentsLen:_e.attachments.length,contextRefsLen:s.length,isComposing:Ce.isComposing,valueRef:Ce.valueRef,adjustHeight:Ce.adjustHeight,editorRef:Ce.editorRef,tryInputHistoryArrow:Oe,acceptEmptySuggestion:!ke&&O&&k?()=>(k(O),!0):void 0};let Ue=ke,We=!!Ce.value.trim()||_e.attachments.length>0||s.length>0,Ge=We&&!!g,Ke=zQ(`(hover: hover) and (pointer: fine)`),qe=!Ue&&!v&&O?`${O.prompt}${Ke?` · ${W.chat.welcomeSpotlight.acceptSuggestionHint}`:``}`:null;return(0,$.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-col`,children:[i?(0,$.jsx)(E$,{conversationId:i},i):null,a?(0,$.jsx)(J$,{...a,conversationId:i,disabled:(a.disabled??t)||n||r}):null,(0,$.jsxs)(oD,{dragging:_e.isDragging,onDragOver:e=>{(e.dataTransfer?.types.includes(`Files`)||gw(e.dataTransfer))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,_e.setIsDragging(!0))},onDragLeave:e=>{e.relatedTarget===null&&_e.setIsDragging(!1)},onDrop:async e=>{e.preventDefault(),_e.setIsDragging(!1);let t=e.dataTransfer?.files;if(t?.length){await _e.processFiles(Array.from(t));return}let n=_w(e.dataTransfer);if(n)try{let e=await US(n.path,{conversationId:n.conversationId,agentId:n.agentId,projectId:n.projectId}),t=h_(n.name),r=e.type&&e.type!==`application/octet-stream`?e.type:t;await _e.processFiles([new File([e],n.name,{type:r})])}catch{Yl(`error`,W.chat.attachmentLoadFailed,{name:n.name})}},children:[_e.isDragging?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-accent-soft/80 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,children:W.chat.dropFiles}):null,B?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-edge-subtle bg-accent-soft/40 px-4 py-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{children:W.chat.userMessageEditing}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:V,children:W.chat.userMessageEditCancel})]}):null,_.length>0?(0,$.jsx)(`div`,{className:`max-h-[min(30vh,11rem)] shrink-0 overflow-y-auto overflow-x-hidden border-b border-edge-subtle/80 [scrollbar-gutter:stable] dark:border-edge-subtle/70`,children:(0,$.jsx)(I$,{items:_,disabled:t,editingFollowUpId:v,onEditInComposer:Ve,onRemove:S,onMove:C,onReorder:w,onSteer:T,steeringBusyId:E})}):null,(0,$.jsx)(iD,{attachments:_e.attachments,conversationId:i,topPadded:_.length>0,onRemove:_e.removeAttachment}),(0,$.jsx)(U$,{refs:s.filter(e=>!e.refId),label:W.chat.commandPalette.contextLabel,onRemove:e=>c(t=>t.filter(t=>t.sourceId!==e))}),o,(0,$.jsxs)(`div`,{className:`flex min-h-0 shrink-0 flex-col`,children:[(0,$.jsx)(`input`,{ref:re,type:`file`,multiple:!0,className:`hidden`,onChange:async e=>{let t=e.target.files;t&&await _e.processFiles(Array.from(t)),e.target.value=``}}),(0,$.jsxs)(`div`,{className:K(`relative px-3 pb-0 pt-1 sm:px-4`,_e.attachments.length>0&&`pt-2`),children:[(0,$.jsx)(o1,{open:Me.atPicker.open,anchorRef:Ce.editorRef,items:Me.atPicker.items,selectedIndex:Me.atPicker.selectedIndex,loading:Me.atPicker.loading,query:Me.atPicker.query,noResults:Me.atPicker.error??W.chat.atMention.noResults,conversationId:i,recentLabel:W.chat.atMention.recentBadge,sectionLabels:{file:W.chat.atMention.files,note:W.chat.atMention.notes,session:W.chat.atMention.chats,skill:W.chat.atMention.skills,agent:W.chat.atMention.agents,browser_tab:W.chat.atMention.browserTabs,mcp_server:W.chat.atMention.mcpServers,mcp_resource:W.chat.atMention.mcpResources},ariaLabel:W.chat.atMention.placeholder,onSelectItem:Me.applyAtMention}),(0,$.jsx)(X1,{open:Me.palette.open,anchorRef:Ce.editorRef,panelRef:ne,sections:Me.palette.loadError?[]:Me.palette.sections,flatItems:Me.palette.loadError?[]:Me.palette.flatItems,loading:Me.palette.loading,failedKinds:Me.palette.failedKinds,selectedIndex:Me.palette.selectedIndex,noResults:Me.palette.loadError??W.chat.commandPalette.noResults,sectionLoadFailedLabel:W.chat.commandPalette.sectionLoadFailed,query:Me.palette.query,skillsLabel:W.chat.commandPalette.skillsSection,commandsLabel:W.chat.commandPalette.commandsSection,agentsLabel:W.chat.commandPalette.agentsSection,currentAgentId:F,currentBadgeLabel:W.chat.commandPalette.currentBadge,runBusy:ke,pendingFollowUpsCount:_.length,maxPendingFollowUps:10,queueBadgeLabel:W.chat.commandPalette.queueBadge,queueFullBadgeLabel:W.chat.commandPalette.queueFullBadge,queueFullTooltip:W.chat.commandPalette.queueFullTooltip,skillUnavailableLabel:W.chat.commandPalette.skillUnavailableBadge,skillAgentDeniedLabel:W.chat.commandPalette.skillAgentDeniedBadge,skillSourceLabels:{builtin:W.chat.commandPalette.sourceBuiltin,workspace:W.chat.commandPalette.sourceWorkspace,global:W.chat.commandPalette.sourceGlobal,extra:W.chat.commandPalette.sourceExtra},onSelectItem:Me.applyPalette}),Ne.voiceActive?(0,$.jsx)(kG,{phase:Ne.phase,elapsedLabel:Ne.elapsedLabel,audioLevel:Ne.audioLevel,partialTranscript:Ne.partialTranscript,finalTranscript:Ne.finalTranscript,error:Ne.error,settingsRequired:Ne.settingsRequired,disabled:t,chat:W.chat,onCancel:Ne.cancelVoiceInput,onConfirm:Ne.confirmVoiceInput,onRetry:Ne.retryVoiceInput}):null,(0,$.jsx)(dE,{editorRef:Ce.editorRef,disabled:t,hidden:Ne.voiceActive&&Ne.phase!==`error`,ariaLabel:e??W.chat.inputPlaceholder,placeholder:e??qe??(Ue?v?W.chat.inputPlaceholderSteeringEdit:W.chat.inputPlaceholderSteering:W.chat.inputPlaceholder),onWireInput:J,adjustHeight:Ce.adjustHeight,processFiles:_e.processFiles,processPastedText:_e.processPastedText,setIsComposing:Ce.setIsComposing,kbdRef:He,chatMessages:W.chat})]}),(0,$.jsx)(PD,{disabled:t,sending:n,streaming:r,runBusy:Ue,chat:W.chat,hasDraft:We,showSteeringInterrupt:Ge,attachmentCount:_e.attachments.length,maxAttachments:10,onPickFiles:()=>re.current?.click(),thinkingLevel:l,onThinkingChange:f,voiceActive:Ne.voiceActive,onStartVoiceInput:Ne.startVoiceInput,voiceConversationEnabled:!!(i||R)&&!Ue,onStartVoiceConversation:()=>{if(!U.current){if(i){H.open({conversationId:i,name:I||F||`xopc`,taskId:L});return}R&&(U.current=!0,R().then(e=>H.open({conversationId:e,name:I||F||`xopc`,taskId:L})).catch(e=>Yl(`error`,e instanceof Error?e.message:W.chat.callFailed)).finally(()=>{U.current=!1}))}},onSend:Be.send,onAbort:m,onInterrupt:Be.interruptDraft,sessionModel:A,showModelSelector:j,onModelChange:M,modelDisabled:N})]}),(0,$.jsx)(Y0,{open:oe,conversationId:i,disabled:t||Ue,chat:W.chat,onClose:()=>se(!1),onSendCommand:je}),(0,$.jsx)(uS,{open:ce!==null,title:W.chat.commandPalette.workspaceTrustTitle,description:AD(W.chat.commandPalette.workspaceTrustDescription,{path:ce?.workspacePath??``}),confirmLabel:fe?W.chat.commandPalette.workspaceTrustSaving:W.chat.commandPalette.workspaceTrustConfirm,cancelLabel:W.chat.commandPalette.workspaceTrustCancel,onConfirm:ge,onCancel:()=>{le(null),de(i)}})]})]})});function $0(e){let t=(0,Q.c)(42),{draft:n,onRemove:r,disabled:i,waiting:a}=e,o=i===void 0?!1:i,s=a===void 0?!1:a,c=Ee(t2),l;t[0]===c?l=t[1]:(l=xe(c),t[0]=c,t[1]=l);let u=l.chat.pageContext,d=u.label,f;t[2]!==n.title||t[3]!==u.preview?(f=(0,$.jsxs)(`summary`,{className:`cursor-pointer break-words rounded text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u.preview,`: `,n.title]}),t[2]=n.title,t[3]=u.preview,t[4]=f):f=t[4];let p;t[5]===u.frozen?p=t[6]:(p=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:u.frozen}),t[5]=u.frozen,t[6]=p);let m;t[7]===n.envelope.resourceRefs?m=t[8]:(m=n.envelope.resourceRefs.map(e2).join(`, `),t[7]=n.envelope.resourceRefs,t[8]=m);let h;t[9]===m?h=t[10]:(h=(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]===n.preview?g=t[12]:(g=(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.preview}),t[11]=n.preview,t[12]=g);let _;t[13]!==n.truncated||t[14]!==u.truncated?(_=n.truncated?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:u.truncated}):null,t[13]=n.truncated,t[14]=u.truncated,t[15]=_):_=t[15];let v;t[16]!==n.envelope.selection||t[17]!==u.draft||t[18]!==u.selection?(v=n.envelope.selection?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-2 text-xs font-medium text-fg`,children:n.envelope.selection.draft?u.draft:u.selection}),(0,$.jsx)(`pre`,{className:`mt-1 max-h-36 overflow-y-auto whitespace-pre-wrap break-words font-sans text-sm text-fg`,children:n.envelope.selection.text})]}):null,t[16]=n.envelope.selection,t[17]=u.draft,t[18]=u.selection,t[19]=v):v=t[19];let y;t[20]!==_||t[21]!==v||t[22]!==f||t[23]!==p||t[24]!==h||t[25]!==g?(y=(0,$.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[f,p,h,g,_,v]}),t[20]=_,t[21]=v,t[22]=f,t[23]=p,t[24]=h,t[25]=g,t[26]=y):y=t[26];let b=`${u.remove}: ${n.title}`,x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),t[27]=x):x=t[27];let S;t[28]!==o||t[29]!==r||t[30]!==b?(S=(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:o,"aria-label":b,className:`inline-flex size-8 shrink-0 items-center justify-center rounded 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:x}),t[28]=o,t[29]=r,t[30]=b,t[31]=S):S=t[31];let C;t[32]!==y||t[33]!==S?(C=(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[y,S]}),t[32]=y,t[33]=S,t[34]=C):C=t[34];let w;t[35]!==u.pending||t[36]!==s?(w=s?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,role:`status`,children:u.pending}):null,t[35]=u.pending,t[36]=s,t[37]=w):w=t[37];let T;return t[38]!==u.label||t[39]!==C||t[40]!==w?(T=(0,$.jsxs)(`section`,{className:`mx-4 mt-2 min-w-0 rounded-lg border border-edge bg-surface-hover p-3`,"aria-label":d,children:[C,w]}),t[38]=u.label,t[39]=C,t[40]=w,t[41]=T):T=t[41],T}function e2(e){return`${e.kind} · ${e.id} · v${e.revision}`}function t2(e){return e.language}function n2(){let e=crypto.randomUUID(),t=crypto.randomUUID(),n=0,r=Oe(()=>({drafts:{}}));return{store:r,capture(r){return{envelope:Lt({version:1,clientInstanceId:e,tabId:t,sequence:++n,surface:`web`,capturedAt:Date.now(),resourceRefs:r.resourceRefs,selection:r.selection}),title:r.title,preview:r.text.slice(0,16e3),truncated:r.text.length>16e3}},put(e,t){let n=r.getState().drafts;return n[e]||Object.keys(n).length>=20?!1:(r.setState({drafts:{...n,[e]:structuredClone(t)}}),!0)},remove(e,t){let n=r.getState().drafts;if(n[e]!==t)return;let i={...n};delete i[e],r.setState({drafts:i})}}}var r2=n2();function i2(e,t,n){return JSON.stringify([e,t??null,n])}function a2(e){let t=(0,Q.c)(30),{selection:n}=e,r=Ee(o2)===`zh`,{mode:i,options:a,checking:o,checkFailed:s,failure:c,busy:l,changeMode:u,retry:d}=n,f=s?r?`无法检查运行环境,请重试。`:`Could not check the environment. Retry.`:a?.worktreeUnavailableReason===`workspace_unavailable`?r?`项目目录不可用,请在项目设置中检查路径。`:`Project directory unavailable. Check its path in project settings.`:null;if(!s&&a?.worktreeUnavailableReason===`git_commit_required`){let e;return t[0]===c?e=t[1]:(e=c?(0,$.jsx)(`p`,{role:`alert`,className:`w-full px-2 py-1 text-xs text-danger`,children:c}):null,t[0]=c,t[1]=e),e}let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ni,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=p):p=t[2];let m=p,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Qi,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=h):h=t[3];let g=h,_=r?`运行位置`:`Work in`,v;t[4]!==l||t[5]!==u||t[6]!==s||t[7]!==_||t[8]!==i||t[9]!==a||t[10]!==r?(v=!a&&!s?(0,$.jsx)(xn,{className:`h-8 w-36 rounded-full`}):(0,$.jsx)(A,{ariaLabel:r?`新会话运行位置`:`New session environment`,placeholder:_,title:r?`Local 指 xopc Gateway 所在机器;首次发送时创建所选环境。`:`Local means the machine running xopc Gateway. The selected environment is created on first send.`,triggerIcon:l?(0,$.jsx)(ue,{className:`size-4 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):i===`managed_worktree`?g:m,triggerClassName:`h-8 w-auto max-w-full justify-start gap-1.5 rounded-full border-0 bg-surface-hover px-2.5 hover:bg-surface-active [&>svg:last-child]:hidden`,contentClassName:`xopc-composer-config-popover w-max min-w-0 max-w-[calc(100vw-1.5rem)]`,side:`top`,allowEmpty:!1,value:i,disabled:l||s,options:[{value:`local_checkout`,label:`Local`,icon:m,group:_,disabled:!a?.localAvailable},{value:`managed_worktree`,label:`New local worktree`,icon:g,group:_,disabled:!a||!!a.worktreeUnavailableReason}],onChange:e=>u(e)}),t[4]=l,t[5]=u,t[6]=s,t[7]=_,t[8]=i,t[9]=a,t[10]=r,t[11]=v):v=t[11];let y;t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==i||t[16]!==a?.worktreeUnavailableReason||t[17]!==f||t[18]!==d||t[19]!==r?(y=f||c||i===`managed_worktree`&&a?.worktreeUnavailableReason?(0,$.jsx)(X,{variant:`ghost`,className:`size-8 rounded-full p-0`,disabled:l||o,onClick:d,"aria-label":r?`重新检查环境`:`Recheck environment`,children:(0,$.jsx)(Vi,{className:`size-3.5 `+(o?`animate-spin motion-reduce:animate-none`:``),"aria-hidden":!0})}):null,t[12]=l,t[13]=o,t[14]=c,t[15]=i,t[16]=a?.worktreeUnavailableReason,t[17]=f,t[18]=d,t[19]=r,t[20]=y):y=t[20];let b;t[21]===f?b=t[22]:(b=f?(0,$.jsx)(`p`,{role:`status`,className:`w-full px-2 py-1 text-xs leading-5 text-fg-muted`,children:f}):null,t[21]=f,t[22]=b);let x;t[23]===c?x=t[24]:(x=c?(0,$.jsx)(`p`,{role:`alert`,className:`max-h-20 w-full overflow-y-auto break-words px-2 py-1 text-xs leading-5 text-danger`,children:c}):null,t[23]=c,t[24]=x);let S;return t[25]!==v||t[26]!==y||t[27]!==b||t[28]!==x?(S=(0,$.jsxs)($.Fragment,{children:[v,y,b,x]}),t[25]=v,t[26]=y,t[27]=b,t[28]=x,t[29]=S):S=t[29],S}function o2(e){return e.language}function s2({preparation:e,conversationId:t,ready:n,onSend:r}){let i=Se(e=>e.conversationId),a=Se(e=>e.baseUrl),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(r);m.current=r;let{data:h,error:g,isValidating:_,mutate:v}=Zt(e?[`project-environment-options`,a,i,e.project.id]:null,async()=>(await q(J(`/api/projects/${encodeURIComponent(e.project.id)}/environment-options`))).options,{keepPreviousData:!1,revalidateOnFocus:!1,shouldRetryOnError:!1}),y=h?.localAvailable&&h.worktreeUnavailableReason!==`git_commit_required`&&h.worktreeUnavailableReason!==`workspace_unavailable`?o?.preparation===e?o.mode:e?Ts(lh(),e.project.id)??`local_checkout`:`local_checkout`:`local_checkout`,b=!!(!g&&h?.localAvailable&&(y===`local_checkout`||!h.worktreeUnavailableReason)),x=(0,Z.useCallback)(e=>{let t=f.current;f.current=null,d(null),t?.resolve(e?t.conversationId:null)},[]);(0,Z.useEffect)(()=>{if(u){if(u.baseUrl!==a||u.token!==i){x(!1);return}u.conversationId&&(t===u.conversationId?n&&x(!0):e!==u.preparation&&x(!1))}},[u,t,n,e,x,a,i]),(0,Z.useEffect)(()=>()=>{f.current?.resolve(null),f.current=null},[]);let S=(0,Z.useCallback)(async()=>{if(!e)return t;let n=f.current;if(n)return n.preparation===e?n.completion:null;if(!b||_)return null;l(null);let r,o=new Promise(e=>{r=e}),s={preparation:e,baseUrl:a,token:i,conversationId:null,completion:o,resolve:r};return f.current=s,d(s),Promise.resolve().then(()=>e.create(y)).then(t=>{if(f.current!==s)return;mh(e.project.id,y);let n={...s,conversationId:t};f.current=n,d(n)}).catch(t=>{f.current===s&&(l({preparation:e,message:t instanceof Error?t.message:String(t)}),v(),x(!1))}),o},[b,a,x,_,y,v,e,t,i]);return{mode:y,options:h,checking:_,checkFailed:!!g,allowed:b,busy:!!(u&&(u.preparation===e||u.conversationId&&u.conversationId===t)),failure:c?.preparation===e?c.message:null,changeMode:t=>{!e||f.current||(s({preparation:e,mode:t}),l(null))},retry:()=>void v(),prepareSession:S,send:async(...t)=>{if(e){if(p.current)return!1;p.current=!0;try{if(!await S())return!1;t[2]=void 0}finally{p.current=!1}}return m.current(...t)}}}function c2(e,t){let n=(0,Q.c)(9),r=Se(u2),i=Se(l2),a;n[0]!==i||n[1]!==e||n[2]!==t||n[3]!==r?(a=e||t?[`chat-project-scope`,i,r,e,t]:null,n[0]=i,n[1]=e,n[2]=t,n[3]=r,n[4]=a):a=n[4];let o;n[5]!==e||n[6]!==t?(o=async()=>{let n=e?(await $h(e)).projectId:t;return n?gh(n):null},n[5]=e,n[6]=t,n[7]=o):o=n[7];let s;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(s={keepPreviousData:!1,shouldRetryOnError:!1},n[8]=s):s=n[8];let{data:c,error:l}=Zt(a,o,s);return l?null:c??null}function l2(e){return e.baseUrl}function u2(e){return e.conversationId}function d2(e,t){let n=WW(e,t),r=GW(e,t);return`${e.id} ${n} ${r}`.toLowerCase()}function f2(e,t,n){let r=t.trim().toLowerCase();if(!r)return e;let i=r.split(/\s+/).filter(Boolean);return e.filter(e=>{let t=d2(e,n);return i.every(e=>t.includes(e))})}function p2(e){let t=(0,Q.c)(57),{items:n,value:r,disabled:i,placeholder:a,searchPlaceholder:o,noMatches:s,compact:c,contentSide:l,contentAlign:u,className:d,onChange:f}=e,p=l===void 0?`bottom`:l,m=u===void 0?`end`:u,h=Ee(h2),g;t[0]===h?g=t[1]:(g=xe(h),t[0]=h,t[1]=g);let _=g.agentsSettings,[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(``),T;t[2]!==_||t[3]!==n||t[4]!==b?(T=f2(n,b,_),t[2]=_,t[3]=n,t[4]=b,t[5]=T):T=t[5];let E=T,O,k,A;if(t[6]!==_||t[7]!==n||t[8]!==a||t[9]!==r){let e;t[13]===r?e=t[14]:(e=e=>e.id===r,t[13]=r,t[14]=e),k=n.find(e),O=k?WW(k,_):r||a,A=k?[WW(k,_),GW(k,_)].filter(Boolean).join(` — `):void 0,t[6]=_,t[7]=n,t[8]=a,t[9]=r,t[10]=O,t[11]=k,t[12]=A}else O=t[10],k=t[11],A=t[12];let j=A??a,M=c&&`min-w-0 max-w-[min(calc(15ch+3rem),calc(100vw-8rem))] py-1.5 text-[13px]`,N;t[15]!==d||t[16]!==M?(N=K(Cd,`items-center gap-2 rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-2 text-left text-sm font-normal text-fg`,yc.transition,`hover:border-edge hover:bg-surface-hover/45`,bd,yd,`disabled:cursor-not-allowed disabled:opacity-50`,`dark:border-edge-subtle dark:hover:bg-surface-hover/55`,M,d),t[15]=d,t[16]=M,t[17]=N):N=t[17];let P;t[18]!==k?.avatar||t[19]!==r?(P=r?(0,$.jsx)(W1,{agentId:r,avatar:k?.avatar,size:28,className:`shrink-0`}):null,t[18]=k?.avatar,t[19]=r,t[20]=P):P=t[20];let F=c?`max-w-[15ch] shrink`:`flex-1`,I;t[21]===F?I=t[22]:(I=K(`min-w-0 truncate text-left`,F),t[21]=F,t[22]=I);let L;t[23]!==O||t[24]!==I?(L=(0,$.jsx)(`span`,{className:I,children:O}),t[23]=O,t[24]=I,t[25]=L):L=t[25];let R;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(w,{className:`size-4 shrink-0 text-fg-subtle opacity-70`,"aria-hidden":!0}),t[26]=R):R=t[26];let z;t[27]!==i||t[28]!==L||t[29]!==j||t[30]!==N||t[31]!==P?(z=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:j,className:N,children:[P,L,R]})}),t[27]=i,t[28]=L,t[29]=j,t[30]=N,t[31]=P,t[32]=z):z=t[32];let B;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(B=K(C,`z-50 w-[var(--radix-popover-trigger-width)] min-w-[12rem] rounded-lg border border-edge bg-surface-panel shadow-md`,yc),t[33]=B):B=t[33];let V;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(V=e=>x(e.target.value),t[34]=V):V=t[34];let H;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(H=K(`w-full rounded-md border border-edge bg-surface-panel px-2.5 py-1.5 text-sm text-fg placeholder:text-fg-muted`,bd),t[35]=H):H=t[35];let U;t[36]!==b||t[37]!==o?(U=(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge p-2`,children:(0,$.jsx)(`input`,{type:`search`,value:b,onChange:V,placeholder:o,className:H,"aria-label":o})}),t[36]=b,t[37]=o,t[38]=U):U=t[38];let W;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(W=K(D,`max-h-64 p-1`),t[39]=W):W=t[39];let G;t[40]!==_||t[41]!==E||t[42]!==s||t[43]!==f||t[44]!==r?(G=E.length===0?(0,$.jsx)(`li`,{className:`p-2 text-sm text-fg-muted`,children:s}):E.map(e=>{let t=e.id===r,n=WW(e,_),i=GW(e,_),a=i.length>0?i:void 0;return(0,$.jsx)(`li`,{role:`option`,"aria-selected":t,children:(0,$.jsxs)(`button`,{type:`button`,className:K(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg`,t?`bg-surface-hover`:`hover:bg-surface-hover`),onClick:()=>{f(e.id),y(!1),x(``)},children:[(0,$.jsx)(S,{className:K(`size-4 shrink-0`,t?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,$.jsx)(W1,{agentId:e.id,avatar:e.avatar,size:32,className:`shrink-0`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate font-medium leading-tight`,title:n,children:n}),i?(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs leading-tight text-fg-muted`,title:a,children:i}):null]})]})},e.id)}),t[40]=_,t[41]=E,t[42]=s,t[43]=f,t[44]=r,t[45]=G):G=t[45];let ee;t[46]===G?ee=t[47]:(ee=(0,$.jsx)(`ul`,{"data-select-scroll-region":!0,className:W,role:`listbox`,children:G}),t[46]=G,t[47]=ee);let te;t[48]!==m||t[49]!==p||t[50]!==U||t[51]!==ee?(te=(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{side:p,align:m,sideOffset:4,collisionPadding:8,className:B,onOpenAutoFocus:m2,children:[U,ee]})}),t[48]=m,t[49]=p,t[50]=U,t[51]=ee,t[52]=te):te=t[52];let ne;return t[53]!==v||t[54]!==z||t[55]!==te?(ne=(0,$.jsxs)(hn,{open:v,onOpenChange:y,children:[z,te]}),t[53]=v,t[54]=z,t[55]=te,t[56]=ne):ne=t[56],ne}function m2(e){return e.preventDefault()}function h2(e){return e.language}function g2(e,t){let n=e.map(e=>({...e,drafts:[]}));for(let e of t){if(e.kind!==`note`)continue;let t=n.find(t=>t.id===e.sourceId);t?t.drafts.push(e):n.push({kind:`note`,id:e.sourceId,title:e.title,origins:[],drafts:[e]})}return n}function _2(e){return e===`zh`?{title:`会话上下文`,work:`当前工作`,sources:`关联资料`,environment:`执行环境`,emptyWork:`未关联项目或执行任务`,emptySources:`未关联资料`,emptyEnvironment:`会话创建后显示`,session:`会话来源`,task:`任务关联`,draft:`待发送`,untitled:`未命名 Note`,unavailable:`不可用或无权访问`,failed:`部分信息暂不可用,请刷新重试`,refresh:`刷新`,more:`仅显示前 20 项,更多资料请打开任务查看`,local:`Local · 本地目录`,worktree:`Local · Worktree`,detached:`游离 HEAD`,unavailableEnvironment:`目录不存在或环境尚未就绪`,copyEnvironmentPath:`复制环境路径`,copied:`已复制`,hint:`关联资料不代表模型已读取;待发送资料仅用于下一条消息。`}:{title:`Session context`,work:`Current work`,sources:`Sources`,environment:`Environment`,emptyWork:`No project or execution task`,emptySources:`No linked sources`,emptyEnvironment:`Available after the session is created`,session:`Session source`,task:`Task reference`,draft:`Pending send`,untitled:`Untitled Note`,unavailable:`Unavailable or restricted`,failed:`Some details are unavailable. Refresh to retry.`,refresh:`Refresh`,more:`Showing the first 20 sources. Open the task for more.`,local:`Local · Directory`,worktree:`Local · Worktree`,detached:`Detached HEAD`,unavailableEnvironment:`Directory missing or environment not ready`,copyEnvironmentPath:`Copy environment path`,copied:`Copied`,hint:`Linked sources do not mean the model has read them. Pending sources apply to the next message.`}}var v2=`flex min-w-0 items-center gap-3 rounded-lg px-2 py-2.5 text-sm text-fg transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,y2=`rounded-lg p-2 text-xs text-fg-muted transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`;function b2({conversationId:e,draftRefs:t=[],project:n,...r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(!1),c=Ee(e=>e.language),l=_2(c),u=b(),d=`${u.pathname}${u.search}`,{data:f,error:p,isLoading:m,isValidating:h,mutate:g}=W$(e,i),_=p?void 0:f,v=_?.work.project??(!e&&n?{id:n.id,title:n.name}:void 0),x=_?.work.task,C=g2(_?.sources??[],t),w=_?.environment,T=[v?.title,x?.title,C.length?`${l.sources} ${C.length}${_?.sourcesHasMore?`+`:``}`:null,w?.kind===`managed_worktree`?`Worktree`:null].filter(Boolean).join(` · `)||l.title,E=()=>a(!1),D=C.some(e=>!e.unavailable&&e.origins.some(e=>e.kind===`session`));return(0,$.jsxs)(hn,{open:i,onOpenChange:a,children:[(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":l.title,title:T,className:`group inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-[background-color,color,transform] duration-150 hover:bg-surface-hover hover:text-fg active:scale-95 data-[state=open]:bg-surface-hover data-[state=open]:text-fg motion-reduce:transition-none motion-reduce:transform-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsx)(oi,{className:`size-4 transition-transform duration-200 group-data-[state=open]:scale-110 motion-reduce:transform-none motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":!0})})}),(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{align:`end`,sideOffset:8,collisionPadding:12,"aria-label":l.title,className:`xopc-session-context-popover z-50 flex h-[min(28rem,var(--radix-popover-content-available-height))] w-[min(21rem,calc(100vw-1.5rem))] flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover`,children:[(0,$.jsx)(`h2`,{className:`sr-only`,children:l.title}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-3 py-4`,children:[p||_?.unavailableSections.length?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:l.failed}):null,m?(0,$.jsx)(`div`,{className:`space-y-4`,"aria-label":l.title,"aria-busy":`true`,children:[0,1,2,3].map(e=>(0,$.jsx)(xn,{className:`h-8 w-full`},e))}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm text-fg-subtle`,children:l.environment}),e?(0,$.jsx)(`button`,{type:`button`,className:y2,"aria-label":l.refresh,disabled:h,onClick:()=>void g(),children:(0,$.jsx)(Vi,{className:`size-3.5 ${h?`animate-spin motion-reduce:animate-none`:``}`,"aria-hidden":!0})}):null]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 px-2 py-2.5`,children:[(0,$.jsx)(yi,{className:`mt-0.5 size-4 shrink-0 text-fg`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg`,children:w.kind===`managed_worktree`?l.worktree:l.local}),(0,$.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-start gap-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 break-all text-xs leading-5 text-fg-muted`,children:w.rootPath}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-subtle transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":o?l.copied:l.copyEnvironmentPath,title:o?l.copied:l.copyEnvironmentPath,onClick:()=>{w?.rootPath&&Yt(w.rootPath).then(e=>{e&&(s(!0),window.setTimeout(()=>s(!1),1200))})},children:o?(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-3.5`,"aria-hidden":!0})})]}),w.available?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:l.unavailableEnvironment})]})]}),w.branch||w.headSha?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2 py-2.5 text-sm text-fg`,children:[(0,$.jsx)(se,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`break-all`,children:[w.branch||(w.detached?l.detached:``),` `,w.headSha?.slice(0,8)]})]}):null]}):(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:e?l.unavailable:l.emptyEnvironment}),e&&v&&n?.workspaceRoot&&!p?(0,$.jsx)(y,{className:v2,to:Gg(v.id),state:{forceNewChat:!0,agentId:r.agentId,temporary:r.temporary},onClick:E,children:c===`zh`?`在另一环境新建会话`:`New session in another environment`}):null]}),(0,$.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`h3`,{className:`mb-1 px-2 text-sm text-fg-subtle`,children:l.work}),v?(0,$.jsxs)(y,{className:v2,to:te(`/projects/${encodeURIComponent(v.id)}`,d),onClick:E,children:[(0,$.jsx)(Ur,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,title:v.title,children:v.title})]}):null,x?(0,$.jsxs)(y,{className:v2,to:Us(d,x.id),onClick:E,children:[(0,$.jsx)(sa,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,title:x.title,children:x.title}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-fg-muted`,children:x.phase})]}):null,!v&&!x?(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:p||_?.unavailableSections.includes(`work`)?l.unavailable:l.emptyWork}):null,v&&r.onLeaveProject?(0,$.jsx)(`button`,{type:`button`,className:y2,onClick:()=>{E(),r.onLeaveProject?.()},children:r.leaveProjectLabel}):null]}),(0,$.jsxs)(`section`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`h3`,{className:`mb-1 px-2 text-sm text-fg-subtle`,children:[l.sources,` `,C.length||``]}),C.map(e=>{let t=[...e.origins.map(e=>`${e.kind===`session`?l.session:l.task}${e.version?` · ${e.version}`:``}`),...e.drafts.map(e=>`${l.draft} · ${e.expectedVersion}`)],n=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zr,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:e.unavailable?l.unavailable:e.title||l.untitled}),(0,$.jsx)(`span`,{className:`block break-words text-xs text-fg-subtle`,children:t.join(` / `)})]})]});return e.unavailable?(0,$.jsx)(`div`,{className:`flex gap-2 px-2 py-2 text-sm text-fg-muted`,children:n},e.id):(0,$.jsx)(y,{className:`${v2} items-start`,to:te(`/notes/${encodeURIComponent(e.id)}`,d),onClick:E,children:n},e.id)}),C.length?null:(0,$.jsx)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:p||_?.unavailableSections.includes(`sources`)?l.unavailable:l.emptySources}),_?.sourcesHasMore?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:l.more}):null,D&&r.onDraftSourceNote?(0,$.jsx)(`button`,{type:`button`,className:y2,onClick:()=>{E(),r.onDraftSourceNote?.()},children:r.draftSourceNoteLabel}):null]})]})]}),(0,$.jsx)(`p`,{className:`shrink-0 border-t border-edge-subtle px-4 py-3 text-xs leading-5 text-fg-subtle`,children:l.hint})]})})]})}function x2(e){let t=(0,Q.c)(61),{conversationId:n,workspacePath:r,canChangeWorkspace:i,disabled:a,available:o,onWorkspaceChange:s}=e,c=o===void 0?!0:o,l=Ee(E2),u;t[0]===l?u=t[1]:(u=xe(l),t[0]=l,t[1]=u);let d=u,f=Dw(T2),p=Dw(w2),m=dL(C2),[h,g]=(0,Z.useState)(null),_,v;t[2]!==d.chat.workingDirectory.notSet||t[3]!==r?(_=r?.trim()??``,v=_?ux(_):d.chat.workingDirectory.notSet,t[2]=d.chat.workingDirectory.notSet,t[3]=r,t[4]=_,t[5]=v):(_=t[4],v=t[5]);let y=v,b;t[6]===s?b=t[7]:(b=async e=>{try{await s(e)}catch(e){let t=e;g(t instanceof Error?t.message:String(t))}},t[6]=s,t[7]=b);let x=b,S;t[8]!==x||t[9]!==_?(S={initialPath:_,onPicked:x},t[8]=x,t[9]=_,t[10]=S):S=t[10];let C=fx(S),w=a||C.picking,T;t[11]!==n||t[12]!==f||t[13]!==m?(T=()=>{n&&m(n,!1),f(n??``)},t[11]=n,t[12]=f,t[13]=m,t[14]=T):T=t[14];let E=T,D=!c,O=p&&`bg-surface-hover text-fg`,k=!c&&`cursor-not-allowed opacity-50`,A;t[15]!==O||t[16]!==k?(A=K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,O,k),t[15]=O,t[16]=k,t[17]=A):A=t[17];let j=`${d.workspace.openFiles}: ${_||y}`,M=`${d.workspace.openFiles}: ${y}`,N;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(oe,{className:`size-4 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=N):N=t[18];let P;t[19]!==E||t[20]!==A||t[21]!==j||t[22]!==M||t[23]!==D||t[24]!==p?(P=(0,$.jsx)(`button`,{type:`button`,disabled:D,className:A,title:j,"aria-label":M,"aria-pressed":p,onClick:E,children:N}),t[19]=E,t[20]=A,t[21]=j,t[22]=M,t[23]=D,t[24]=p,t[25]=P):P=t[25];let F;t[26]!==i||t[27]!==C.pick||t[28]!==d.chat.workingDirectory.chooseFolder||t[29]!==w?(F=i?(0,$.jsx)(`button`,{type:`button`,disabled:w,className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,w&&`cursor-not-allowed opacity-50`),title:d.chat.workingDirectory.chooseFolder,"aria-label":d.chat.workingDirectory.chooseFolder,onClick:C.pick,children:(0,$.jsx)(Hr,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,t[26]=i,t[27]=C.pick,t[28]=d.chat.workingDirectory.chooseFolder,t[29]=w,t[30]=F):F=t[30];let I;t[31]!==P||t[32]!==F?(I=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-0.5`,children:[P,F]}),t[31]=P,t[32]=F,t[33]=I):I=t[33];let L;t[34]!==C.confirmPick||t[35]!==C.hasNativePicker||t[36]!==C.modalOpen||t[37]!==C.setModalOpen||t[38]!==d.chat.workingDirectory||t[39]!==_?(L=C.hasNativePicker?null:(0,$.jsx)(Cx,{open:C.modalOpen,onOpenChange:C.setModalOpen,initialAbsolutePath:_||void 0,onConfirm:C.confirmPick,wd:d.chat.workingDirectory}),t[34]=C.confirmPick,t[35]=C.hasNativePicker,t[36]=C.modalOpen,t[37]=C.setModalOpen,t[38]=d.chat.workingDirectory,t[39]=_,t[40]=L):L=t[40];let R=h!==null,z;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{e||g(null)},t[41]=z):z=t[41];let B;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),t[42]=B):B=t[42];let V;t[43]===d.chat.workingDirectory.applyErrorTitle?V=t[44]:(V=(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:d.chat.workingDirectory.applyErrorTitle}),t[43]=d.chat.workingDirectory.applyErrorTitle,t[44]=V);let H;t[45]===h?H=t[46]:(H=h?(0,$.jsx)(Ze,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-fg-muted`,children:h}):null,t[45]=h,t[46]=H);let U;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>g(null),t[47]=U):U=t[47];let W;t[48]===d.chat.workingDirectory.applyErrorClose?W=t[49]:(W=(0,$.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-edge-subtle pt-3`,children:(0,$.jsx)(X,{type:`button`,onClick:U,children:d.chat.workingDirectory.applyErrorClose})}),t[48]=d.chat.workingDirectory.applyErrorClose,t[49]=W);let G;t[50]!==V||t[51]!==H||t[52]!==W?(G=(0,$.jsxs)($e,{children:[B,(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[81] w-[min(100%-2rem,26rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover`,onOpenAutoFocus:S2,children:[V,H,W]})]}),t[50]=V,t[51]=H,t[52]=W,t[53]=G):G=t[53];let ee;t[54]!==R||t[55]!==G?(ee=(0,$.jsx)(nt,{open:R,onOpenChange:z,children:G}),t[54]=R,t[55]=G,t[56]=ee):ee=t[56];let te;return t[57]!==I||t[58]!==L||t[59]!==ee?(te=(0,$.jsxs)($.Fragment,{children:[I,L,ee]}),t[57]=I,t[58]=L,t[59]=ee,t[60]=te):te=t[60],te}function S2(e){return e.preventDefault()}function C2(e){return e.setOpen}function w2(e){return e.open}function T2(e){return e.openForSession}function E2(e){return e.language}function D2(e){return e===`darwin`?`⌘J`:`Ctrl+J`}function O2(e,t){return e.repeat||e.altKey||e.shiftKey||e.key.toLowerCase()!==`j`?!1:t===`darwin`?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function k2(e){return e?e===`darwin`:typeof navigator>`u`?!1:navigator.platform?.includes(`Mac`)??navigator.userAgent.includes(`Mac`)}function A2(e){return k2(e)?`⌘⇧B`:`Ctrl+Shift+B`}function j2(e){return k2(e)?[`⌘`,`Shift`,`B`]:[`Ctrl`,`Shift`,`B`]}function M2(e){return k2(e)?`Meta+Shift+B`:`Control+Shift+B`}function N2(e,t){return e.repeat||e.altKey||!e.shiftKey||e.key.toLowerCase()!==`b`?!1:k2(t)?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}var P2=[];function F2(e,t){return e[t]??P2}var I2=0;function L2(){return globalThis.crypto?.randomUUID?.()??`terminal-${Date.now()}-${++I2}`}function R2(e){let t=typeof window>`u`?640:Math.max(180,Math.floor(window.innerHeight*.65));return Math.min(640,t,Math.max(180,Math.round(e)))}var z2=Oe((e,t)=>({openByConversationId:{},tabsByConversationId:{},activeTabKeyByConversationId:{},height:300,open:n=>{let r=t();if(r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:!0}});return}let i=L2();e({openByConversationId:{...r.openByConversationId,[n]:!0},tabsByConversationId:{...r.tabsByConversationId,[n]:[{key:i}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:i}})},toggle:n=>{let r=t(),i=!r.openByConversationId[n];if(!i||r.tabsByConversationId[n]?.length){e({openByConversationId:{...r.openByConversationId,[n]:i}});return}r.open(n)},close:t=>e(e=>({openByConversationId:{...e.openByConversationId,[t]:!1}})),addTerminal:n=>{let r=t(),i=r.tabsByConversationId[n]??[];if(i.length>=8)return r.activeTabKeyByConversationId[n]??i[0].key;let a=L2();return e({tabsByConversationId:{...r.tabsByConversationId,[n]:[...i,{key:a}]},activeTabKeyByConversationId:{...r.activeTabKeyByConversationId,[n]:a}}),a},closeTerminal:(t,n)=>e(e=>{let r=e.tabsByConversationId[t]??[],i=r.findIndex(e=>e.key===n);if(i<0)return e;let a=r.filter(e=>e.key!==n),o=e.activeTabKeyByConversationId[t],s=o===n?a[Math.min(i,a.length-1)]?.key:o;return{tabsByConversationId:{...e.tabsByConversationId,[t]:a},activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:s}}}),setActiveTerminal:(t,n)=>e(e=>(e.tabsByConversationId[t]??[]).some(e=>e.key===n)?{activeTabKeyByConversationId:{...e.activeTabKeyByConversationId,[t]:n}}:e),setHeight:t=>e({height:R2(t)})}));function B2({conversationId:e}){let t=Ee(e=>e.language),n=t===`zh`?H2:U2,[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),[p,m]=(0,Z.useState)(864e5),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)([]),[C,w]=(0,Z.useState)(`hosted`),[T,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(!r||a||s)return;let t=!1;return u(!0),f(null),Promise.all([ew(e),tw(e),rw()]).then(async([n,r,i])=>{if(t)return;o(n),D(i);let a=i?await UC().catch(()=>null):null;if(t)return;A(a?.publishing.allowed===!0);let s=i?await nw(e).catch(()=>[]):[];if(t)return;let l=[...s,...r].find(e=>!e.revoked&&!e.expired);l&&c(l)}).catch(e=>{t||f(e instanceof Error?e.message:String(e))}).finally(()=>{t||u(!1)}),()=>{t=!0}},[r,a,s,e]);let j=()=>{o(null),c(null),f(null),u(!1),v(``),b(!1),S([]),A(!1)},M=async()=>{if(!(!a||l)){u(!0),f(null);try{c(await(C===`hosted`?aw:iw)(e,{expectedTranscriptId:a.transcriptId,expectedCutoffSeq:a.cutoffSeq,expectedMetadataUpdatedAt:a.metadataUpdatedAt,ttlMs:p,maxViews:h,description:_.trim()||void 0,includeToolActivities:y,attachmentIds:x}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},N=async()=>{if(!(!s||l)){u(!0),f(null);try{let t=await ew(e);o(t),c(await(s.delivery===`hosted`?sw:ow)(e,s.id,{expectedTranscriptId:t.transcriptId,expectedCutoffSeq:t.cutoffSeq,expectedMetadataUpdatedAt:t.metadataUpdatedAt}))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},P=async()=>{if(!(!s||l)){u(!0),f(null);try{s.delivery===`hosted`?await cw(e,s.id):await ZC(s.id),i(!1),j()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}}};return(0,$.jsxs)(nt,{open:r,onOpenChange:e=>{i(e),e||j()},children:[(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,title:n.share,"aria-label":n.share,children:(0,$.jsx)(ui,{className:`size-4`})})}),(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(et,{className:K(`xopc-dialog-content fixed left-1/2 top-1/2 z-[71] flex h-[min(35rem,calc(100dvh-2rem))] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,`overflow-hidden rounded-xl border border-edge bg-surface-overlay outline-none`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:s?n.created:n.title}),(0,$.jsx)(Ze,{className:`mt-0.5 text-xs text-fg-muted`,children:s?n.createdHint:n.hint})]}),(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`touch-target flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":n.close,children:(0,$.jsx)(ye,{className:`size-4`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[l&&!a&&!s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(ue,{className:`size-4 animate-spin`}),n.loading]}):s?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.fileName}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.snapshotMessages.replace(`{{count}}`,String(s.messageCount))}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[s.delivery===`hosted`?n.hosted:n.local,` · `,n.revision.replace(`{{revision}}`,String(s.snapshotRevision)),` · `,n.sharedAttachments.replace(`{{count}}`,String(s.attachmentCount))]})]}),(0,$.jsx)(AC,{shareUrl:s.shareUrl,lanUrl:s.lanUrl,reachability:s.reachability}),(0,$.jsx)(PC,{reachability:s.reachability,reachabilityHint:s.reachabilityHint}),(0,$.jsxs)(`a`,{href:s.shareUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,children:[n.open,(0,$.jsx)(I,{className:`size-3.5`})]})]}):a?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset p-3`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.snapshotMessages.replace(`{{count}}`,String(a.messageCount))}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:new Date(a.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge`,children:[(0,$.jsx)(`summary`,{className:`touch-target cursor-pointer px-3 py-2.5 text-xs font-medium text-fg transition-colors hover:bg-surface-hover`,children:n.reviewContent}),(0,$.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-y-auto border-t border-edge p-3`,children:a.messages.map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`mb-1 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-6 text-fg`,children:e.markdown})]},e.id))})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-accent/20 bg-accent-soft px-3 py-2.5 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Xi,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:n.scope})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:n.delivery}),(0,$.jsxs)(E,{value:C,disabled:l,onChange:e=>w(e.target.value),children:[(0,$.jsx)(O,{value:`hosted`,children:n.hosted}),(0,$.jsx)(O,{value:`local`,children:n.local})]})]}),C===`hosted`&&!T?(0,$.jsx)(iY,{providerId:`xopc-share`,displayName:n.hosted,connected:!1,onConnected:()=>{D(!0),UC().then(e=>A(e.publishing.allowed)).catch(()=>A(!1))}}):null,C===`hosted`&&T&&!k?(0,$.jsx)(`p`,{className:`rounded-lg border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning`,children:n.hostedDisabled}):null,a.toolActivities.length?(0,$.jsxs)(`label`,{className:`flex items-start gap-2 rounded-lg border border-edge bg-surface-inset px-3 py-2.5 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:y,disabled:l,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:n.includeTools.replace(`{{count}}`,String(a.toolActivities.length))}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:n.toolDisclosure})]})]}):null,a.attachmentCandidates.length?(0,$.jsxs)(`fieldset`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`legend`,{className:`px-1 text-xs font-medium text-fg`,children:n.attachments}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.attachmentDisclosure}),(0,$.jsx)(`div`,{className:`space-y-2`,children:a.attachmentCandidates.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:x.includes(e.id),disabled:l,onChange:t=>S(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id)),className:`size-4 rounded border-edge`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.fileName}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:V2(e.size)})]},e.id))})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:n.ttl}),(0,$.jsxs)(E,{value:p,disabled:l,onChange:e=>m(Number(e.target.value)),children:[(0,$.jsx)(O,{value:36e5,children:n.oneHour}),(0,$.jsx)(O,{value:864e5,children:n.oneDay}),(0,$.jsx)(O,{value:6048e5,children:n.sevenDays}),(0,$.jsx)(O,{value:2592e6,children:n.thirtyDays})]})]}),(0,$.jsxs)(`label`,{className:`space-y-1.5 text-xs font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:n.maxViews}),(0,$.jsxs)(E,{value:h??`unlimited`,disabled:l,onChange:e=>g(e.target.value===`unlimited`?null:Number(e.target.value)),children:[(0,$.jsx)(O,{value:`unlimited`,children:n.unlimited}),(0,$.jsx)(O,{value:1,children:`1`}),(0,$.jsx)(O,{value:10,children:`10`}),(0,$.jsx)(O,{value:50,children:`50`})]})]})]}),(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-xs font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:n.description}),(0,$.jsx)(`input`,{value:_,disabled:l,onChange:e=>v(e.target.value),className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm font-normal text-fg outline-none focus-visible:border-accent/50 focus-visible:ring-2 focus-visible:ring-accent/20`})]}),(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:n.publicWarning})]}):null,d?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:d}):null]}),(0,$.jsx)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge bg-surface-overlay px-4 py-3`,children:s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{type:`button`,variant:`ghost`,disabled:l,onClick:()=>c(null),children:n.newShare}),(0,$.jsxs)(X,{type:`button`,variant:`ghost`,disabled:l,onClick:()=>void P(),children:[(0,$.jsx)(pa,{className:`size-4`}),n.revoke]}),(0,$.jsxs)(X,{type:`button`,disabled:l||s.delivery===`hosted`&&!k,onClick:()=>void N(),children:[l?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(Vi,{className:`size-4`}),n.refresh]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,children:n.cancel})}),(0,$.jsxs)(X,{type:`button`,disabled:!a||l||a.messageCount===0||C===`hosted`&&(!T||!k),onClick:()=>void M(),children:[l?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):null,n.create]})]})})]})]})]})}function V2(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var H2={share:`分享会话`,title:`分享会话`,hint:`创建当前会话的只读快照`,created:`分享已创建`,createdHint:`复制链接后即可发送给其他人`,close:`关闭`,loading:`正在准备预览…`,snapshotMessages:`当前快照包含 {{count}} 条公开消息`,scope:`默认仅包含用户与助手的可见文本;系统提示、推理、工具参数、命令文本、输出和路径始终不会公开。`,ttl:`有效期`,maxViews:`最大访问次数`,includeTools:`包含 {{count}} 条工具活动`,toolDisclosure:`只公开工具名称和成功/失败状态,不公开参数与结果。`,attachments:`附件`,attachmentDisclosure:`附件默认不公开,请逐个选择。`,oneHour:`1 小时`,oneDay:`24 小时`,sevenDays:`7 天`,thirtyDays:`30 天`,unlimited:`不限`,description:`说明(可选)`,publicWarning:`任何获得链接的人都可以查看这份快照。后续会话消息不会自动加入。`,cancel:`取消`,create:`创建分享`,revoke:`撤销分享`,refresh:`更新到当前会话`,open:`打开分享页面`,revision:`快照版本 {{revision}}`,sharedAttachments:`{{count}} 个附件`,newShare:`新建分享`,delivery:`分享方式`,hosted:`XOPC 托管分享`,local:`本机 Gateway 分享`,hostedDisabled:`管理员已暂停你的公网分享能力。已有托管链接当前不可访问,但仍可撤销。`,reviewContent:`检查将要公开的内容`,you:`你`,assistant:`助手`},U2={share:`Share conversation`,title:`Share conversation`,hint:`Create a read-only snapshot of this conversation`,created:`Share created`,createdHint:`Copy the link and send it to anyone`,close:`Close`,loading:`Preparing preview…`,snapshotMessages:`This snapshot contains {{count}} public messages`,scope:`Only visible user and assistant text is included by default. System prompts, reasoning, tool arguments, command text, output, and paths always stay private.`,ttl:`Expires after`,maxViews:`Maximum views`,includeTools:`Include {{count}} tool activities`,toolDisclosure:`Only tool names and success/failure states are shared; arguments and results stay private.`,attachments:`Attachments`,attachmentDisclosure:`Attachments stay private unless selected individually.`,oneHour:`1 hour`,oneDay:`24 hours`,sevenDays:`7 days`,thirtyDays:`30 days`,unlimited:`Unlimited`,description:`Description (optional)`,publicWarning:`Anyone with the link can view this snapshot. Later conversation messages are not added automatically.`,cancel:`Cancel`,create:`Create share`,revoke:`Revoke share`,refresh:`Update to current conversation`,open:`Open shared page`,revision:`Snapshot revision {{revision}}`,sharedAttachments:`{{count}} attachments`,newShare:`New share`,delivery:`Delivery`,hosted:`XOPC Hosted Share`,local:`Local Gateway Share`,hostedDisabled:`An administrator has paused public sharing for your account. Existing hosted links are unavailable, but can still be revoked.`,reviewContent:`Review the content to publish`,you:`You`,assistant:`Assistant`},W2=`(max-width: 767px)`,G2=(0,Z.memo)(function(e){let t=(0,Q.c)(115),{chatHeadline:n,chatAgents:r,showChatAgentSelector:i,chatAgentId:a,onChatAgentChange:o,chatAgentDisabled:s,conversationId:c,hasMessages:l,workspacePath:u,userContextMode:d,canChangeWorkspace:f,workspaceDisabled:m,onWorkspaceChange:h,prepareTerminalSession:g,terminalDisabled:_,showContextControls:v,onFindOpen:b,projectId:x,context:S}=e,C=l===void 0?!1:l,w=d===void 0?`enabled`:d,T=f===void 0?!1:f,E=m===void 0?!1:m,D=_===void 0?!1:_,O=v===void 0?!0:v,k=Ee(K2),{conversationId:A}=p(),j=A&&A!==`new`?decodeURIComponent(A):null,M;t[0]!==c||t[1]!==j?(M=c?.trim()||j,t[0]=c,t[1]=j,t[2]=M):M=t[2];let N=M,{data:P,error:F,mutate:I}=W$(N??null,!1),L=!F&&(!P||!!P.environment?.available),R;t[3]===k?R=t[4]:(R=xe(k),t[3]=k,t[4]=R);let z=R,B=Kf(q2),V;t[5]===N?V=t[6]:(V=e=>N?e.panes[N]?.open===!0:!1,t[5]=N,t[6]=V);let H=dL(V),U=dL(J2),W;t[7]===N?W=t[8]:(W=e=>N?!!e.openByConversationId[N]:!1,t[7]=N,t[8]=W);let G=z2(W),ee=z2(Y2),te=z2(X2),[ne,re]=(0,Z.useState)(!1),ie=ep(Z2),ae=em(Q2),oe=em($2),se=window.electronAPI?.platform,ce;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(ce=D2(se),t[9]=ce):ce=t[9];let le=ce,de;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(de=A2(se),t[10]=de):de=t[10];let fe=de,pe;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(pe=M2(se),t[11]=pe):pe=t[11];let me=pe,he=!!(O&&window.electronAPI?.terminal&&(N||g)),_e;t[12]!==N||t[13]!==te||t[14]!==g||t[15]!==he||t[16]!==D||t[17]!==ne||t[18]!==ee?(_e=()=>{if(!(!he||D||ne)){if(N){ee(N);return}g&&(re(!0),g().then(e=>{e&&te(e)}).finally(()=>re(!1)))}},t[12]=N,t[13]=te,t[14]=g,t[15]=he,t[16]=D,t[17]=ne,t[18]=ee,t[19]=_e):_e=t[19];let ye=_e,be;t[20]!==N||t[21]!==C||t[22]!==U?(be=()=>{!N||!C||U(N,dL.getState().panes[N]?.open!==!0)},t[20]=N,t[21]=C,t[22]=U,t[23]=be):be=t[23];let q=be,Se=zQ(W2),Ce;t[24]!==ie||t[25]!==B?(Ce=Df({runtime:Ef(),sidebarCollapsed:B,mobileNavOpen:ie}),t[24]=ie,t[25]=B,t[26]=Ce):Ce=t[26];let we=Se?!ie:Ce.collapsedNewChatVisible,Te,De;t[27]===oe?(Te=t[28],De=t[29]):(Te=()=>()=>oe(),De=[oe],t[27]=oe,t[28]=Te,t[29]=De),(0,Z.useLayoutEffect)(Te,De);let Oe,J;t[30]!==ye||t[31]!==he?(Oe=()=>{if(!he)return;let e=e=>{O2(e,se)&&(e.preventDefault(),ye())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},J=[ye,he,se],t[30]=ye,t[31]=he,t[32]=Oe,t[33]=J):(Oe=t[32],J=t[33]),(0,Z.useEffect)(Oe,J);let ke,Ae;t[34]!==N||t[35]!==q||t[36]!==C?(ke=()=>{if(!N||!C)return;let e=e=>{N2(e,se)&&(e.preventDefault(),q())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},Ae=[N,q,C,se],t[34]=N,t[35]=q,t[36]=C,t[37]=ke,t[38]=Ae):(ke=t[37],Ae=t[38]),(0,Z.useEffect)(ke,Ae);let je;t[39]!==N||t[40]!==T||t[41]!==s||t[42]!==a||t[43]!==r||t[44]!==n||t[45]!==S||t[46]!==q||t[47]!==ye||t[48]!==C||t[49]!==z.chat.agentNoMatches||t[50]!==z.chat.agentPlaceholder||t[51]!==z.chat.agentSearchPlaceholder||t[52]!==z.chat.find.input||t[53]!==z.chat.temporarySession||t[54]!==z.chat.temporarySessionHint||t[55]!==z.chat.terminal.open||t[56]!==z.sideChat||t[57]!==z.sidebar.newTask||t[58]!==o||t[59]!==b||t[60]!==h||t[61]!==x||t[62]!==I||t[63]!==ae||t[64]!==i||t[65]!==O||t[66]!==we||t[67]!==H||t[68]!==he||t[69]!==D||t[70]!==G||t[71]!==ne||t[72]!==w||t[73]!==L||t[74]!==E||t[75]!==u?(je=()=>{ae({className:`bg-surface-panel`,startExtra:we?(0,$.jsx)(y,{to:Gg(x),state:{forceNewChat:!0,agentId:a,temporary:w===`temporary`},className:K(`inline-flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-panel text-sm font-medium leading-none text-fg transition-colors hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,md),title:z.sidebar.newTask,children:(0,$.jsx)(ge,{className:`size-4 shrink-0 text-accent-fg`,strokeWidth:2,"aria-hidden":!0})}):null,main:(0,$.jsx)(`div`,{className:`w-full min-w-0 max-w-(--max-width-chat-frame) px-3 sm:px-5 xl:px-6`,children:(0,$.jsx)(`h1`,{className:K(`min-w-0 truncate text-[0.9375rem] font-semibold leading-5 tracking-tight text-fg`,we?`text-left md:text-center`:`text-left`),title:n,children:n})}),end:(0,$.jsxs)(`div`,{className:K(`flex min-w-0 max-w-[min(32rem,calc(100vw-8rem))] shrink-0 items-center justify-end gap-2`,md),children:[i?(0,$.jsx)(`div`,{className:`min-w-0 w-fit shrink-0`,children:(0,$.jsx)(p2,{items:r,value:a,disabled:s,placeholder:z.chat.agentPlaceholder,searchPlaceholder:z.chat.agentSearchPlaceholder,noMatches:z.chat.agentNoMatches,compact:!0,contentSide:`bottom`,contentAlign:`end`,onChange:o})}):null,w===`temporary`?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-2 py-1 text-xs font-medium text-fg-muted`,title:z.chat.temporarySessionHint,children:z.chat.temporarySession}):null,C&&b?(0,$.jsx)(`button`,{type:`button`,className:`rounded-md 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`,title:`${z.chat.find.input} (${se===`darwin`?`⌘F`:`Ctrl+F`})`,"aria-label":z.chat.find.input,"aria-keyshortcuts":`Meta+F Control+F`,onClick:b,children:(0,$.jsx)(ve,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}):null,N&&C?(0,$.jsx)(B2,{conversationId:N},`share:${N}`):null,he?(0,$.jsx)(`button`,{type:`button`,className:K(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,G&&`bg-surface-hover text-fg`),title:`${z.chat.terminal.open} (${le})`,"aria-label":z.chat.terminal.open,"aria-pressed":G,disabled:D||ne,onClick:ye,children:ne?(0,$.jsx)(ue,{className:`size-4 animate-spin`}):(0,$.jsx)(na,{className:`size-4`})}):null,O?(0,$.jsx)(b2,{...S,agentId:a,temporary:w===`temporary`,conversationId:N??null},`context:${N??S?.project?.id??`new`}`):null,O&&(N||x)&&h?(0,$.jsx)(x2,{conversationId:N,workspacePath:N?u:S?.project?.workspaceRoot,available:L,canChangeWorkspace:T,disabled:E,onWorkspaceChange:async e=>{await h(e),await I()}},`workspace:${N??x}`):null,N&&C?(0,$.jsx)(`button`,{type:`button`,className:K(`rounded-md p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg`,H&&`bg-surface-hover text-fg`),title:`${H?z.sideChat.closePaneAria:z.sideChat.openPaneAria} (${fe})`,"aria-label":H?z.sideChat.closePaneAria:z.sideChat.openPaneAria,"aria-keyshortcuts":me,"aria-controls":`app-side-chat-panel`,"aria-expanded":H,onClick:q,children:(0,$.jsx)(Oi,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null]})})},t[39]=N,t[40]=T,t[41]=s,t[42]=a,t[43]=r,t[44]=n,t[45]=S,t[46]=q,t[47]=ye,t[48]=C,t[49]=z.chat.agentNoMatches,t[50]=z.chat.agentPlaceholder,t[51]=z.chat.agentSearchPlaceholder,t[52]=z.chat.find.input,t[53]=z.chat.temporarySession,t[54]=z.chat.temporarySessionHint,t[55]=z.chat.terminal.open,t[56]=z.sideChat,t[57]=z.sidebar.newTask,t[58]=o,t[59]=b,t[60]=h,t[61]=x,t[62]=I,t[63]=ae,t[64]=i,t[65]=O,t[66]=we,t[67]=H,t[68]=he,t[69]=D,t[70]=G,t[71]=ne,t[72]=w,t[73]=L,t[74]=E,t[75]=u,t[76]=je):je=t[76];let Me;return t[77]!==N||t[78]!==T||t[79]!==s||t[80]!==a||t[81]!==r||t[82]!==n||t[83]!==S||t[84]!==q||t[85]!==ye||t[86]!==C||t[87]!==z.chat.agentNoMatches||t[88]!==z.chat.agentPlaceholder||t[89]!==z.chat.agentSearchPlaceholder||t[90]!==z.chat.find.input||t[91]!==z.chat.temporarySession||t[92]!==z.chat.temporarySessionHint||t[93]!==z.chat.terminal.open||t[94]!==z.sidebar.newTask||t[95]!==o||t[96]!==b||t[97]!==h||t[98]!==x||t[99]!==I||t[100]!==ae||t[101]!==U||t[102]!==i||t[103]!==O||t[104]!==we||t[105]!==H||t[106]!==he||t[107]!==D||t[108]!==G||t[109]!==ne||t[110]!==w||t[111]!==L||t[112]!==E||t[113]!==u?(Me=[n,r,i,a,o,s,we,z.chat.agentPlaceholder,z.chat.agentSearchPlaceholder,z.chat.agentNoMatches,z.chat.temporarySession,z.chat.temporarySessionHint,z.chat.find.input,z.chat.terminal.open,le,fe,me,z.sidebar.newTask,x,S,G,he,D,O,ne,N,C,b,H,U,u,L,I,w,T,E,h,ye,q,ae],t[77]=N,t[78]=T,t[79]=s,t[80]=a,t[81]=r,t[82]=n,t[83]=S,t[84]=q,t[85]=ye,t[86]=C,t[87]=z.chat.agentNoMatches,t[88]=z.chat.agentPlaceholder,t[89]=z.chat.agentSearchPlaceholder,t[90]=z.chat.find.input,t[91]=z.chat.temporarySession,t[92]=z.chat.temporarySessionHint,t[93]=z.chat.terminal.open,t[94]=z.sidebar.newTask,t[95]=o,t[96]=b,t[97]=h,t[98]=x,t[99]=I,t[100]=ae,t[101]=U,t[102]=i,t[103]=O,t[104]=we,t[105]=H,t[106]=he,t[107]=D,t[108]=G,t[109]=ne,t[110]=w,t[111]=L,t[112]=E,t[113]=u,t[114]=Me):Me=t[114],(0,Z.useLayoutEffect)(je,Me),null});function K2(e){return e.language}function q2(e){return e.collapsed}function J2(e){return e.setOpen}function Y2(e){return e.toggle}function X2(e){return e.open}function Z2(e){return e.mobileNavOpen}function Q2(e){return e.setPageHeader}function $2(e){return e.clearPageHeader}var e4=(0,Z.memo)(function(){let e=(0,Q.c)(13),t=Ee(t4),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n,i=Cy(n4),a=Cy(r4);if(i===`idle`)return null;if(i===`error`&&a){let t;e[2]===a?t=e[3]:(t=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),e[2]=a,e[3]=t);let n;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=K(`shrink-0 rounded-xl border border-red-200 bg-white px-2.5 py-1 text-xs font-medium text-red-700`,`hover:bg-red-50 dark:border-red-800 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/70`,yc.transition,yc.press,yc.focusRingPanel),e[4]=n):n=e[4];let i;e[5]===r.connection.reconnect?i=e[6]:(i=(0,$.jsx)(`button`,{type:`button`,className:n,onClick:i4,children:r.connection.reconnect}),e[5]=r.connection.reconnect,e[6]=i);let o;return e[7]!==t||e[8]!==i?(o=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-red-100 bg-red-50 px-4 py-2 text-sm text-red-600 dark:border-red-900/40 dark:bg-red-950/50 dark:text-red-400`,children:[t,i]}),e[7]=t,e[8]=i,e[9]=o):o=e[9],o}if(i===`connecting`||i===`reconnecting`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{className:`inline-block size-3 animate-spin rounded-full border-2 border-amber-500 border-t-transparent`,"aria-hidden":!0}),e[10]=t):t=e[10];let n=i===`reconnecting`?r.connection.reconnecting:r.connection.connecting,a;return e[11]===n?a=e[12]:(a=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-amber-100 bg-amber-50 px-4 py-2 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/50 dark:text-amber-200`,children:[t,(0,$.jsx)(`span`,{children:n})]}),e[11]=n,e[12]=a),a}return null});function t4(e){return e.language}function n4(e){return e.connectionState}function r4(e){return e.error}function i4(){return Py()}function a4(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function o4(e){let t=(0,Q.c)(4),{status:n}=e;if(n===`completed`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-full bg-fg-muted text-surface-panel`,children:(0,$.jsx)(S,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0})}),t[0]=e):e=t[0],e}if(n===`in_progress`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(hr,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}),t[1]=e):e=t[1],e}if(n===`cancelled`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Qn,{className:`mt-0.5 size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(xr,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[3]=r):r=t[3],r}function s4(e,t){return e?`${a4(e.files.length===1?t.filesChangedOne:t.filesChangedOther,{count:e.files.length})} · +${e.added} -${e.removed}`:null}function c4(e){let t=(0,Q.c)(61),{plan:n,changeSummary:r,isStreaming:i,labels:a}=e,o=n.currentIndex==null?void 0:n.items[n.currentIndex-1],s;t[0]===n.items?s=t[1]:(s=n.items.every(d4),t[0]=n.items,t[1]=s);let c=s,l=n.items.every(u4),u;t[2]!==a.completedProgress||t[3]!==n.completedCount||t[4]!==n.totalCount?(u=a4(a.completedProgress,{completed:n.completedCount,total:n.totalCount}),t[2]=a.completedProgress,t[3]=n.completedCount,t[4]=n.totalCount,t[5]=u):u=t[5];let d=u,f=a.ended;if(c)f=a.finished;else if(o){let e=n.currentIndex??1,r;t[6]!==a.stepProgress||t[7]!==n.totalCount||t[8]!==e?(r=a4(a.stepProgress,{current:e,total:n.totalCount}),t[6]=a.stepProgress,t[7]=n.totalCount,t[8]=e,t[9]=r):r=t[9],f=r}else !l&&i&&(f=a.planned);let p;t[10]!==r||t[11]!==a?(p=s4(r,a),t[10]=r,t[11]=a,t[12]=p):p=t[12];let m=p,h=o?.title,g;t[13]!==m||t[14]!==f||t[15]!==h?(g=[f,h,m].filter(Boolean),t[13]=m,t[14]=f,t[15]=h,t[16]=g):g=t[16];let _=g.join(` · `),v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(`inline-flex min-h-9 max-w-full items-center gap-2 rounded-pill border border-edge-subtle bg-surface-panel px-3 py-1.5 text-sm text-fg shadow-surface`,yc.transition,`hover:border-edge hover:bg-surface-hover/60`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[17]=v):v=t[17];let y=`${a.heading}: ${_}`,b;t[18]!==o||t[19]!==c?(b=c?(0,$.jsx)(S,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:2,"aria-hidden":!0}):o?(0,$.jsx)(hr,{className:`size-4 shrink-0 text-accent`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ai,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=o,t[19]=c,t[20]=b):b=t[20];let x;t[21]===f?x=t[22]:(x=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:f}),t[21]=f,t[22]=x);let C;t[23]===o?C=t[24]:(C=o?(0,$.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,children:[`· `,o.title]}):null,t[23]=o,t[24]=C);let w;t[25]===m?w=t[26]:(w=m?(0,$.jsxs)(`span`,{className:`hidden shrink-0 tabular-nums text-fg-subtle sm:inline`,children:[`· `,m]}):null,t[25]=m,t[26]=w);let T;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(cr,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[27]=T):T=t[27];let E;t[28]!==C||t[29]!==w||t[30]!==y||t[31]!==b||t[32]!==x?(E=(0,$.jsx)(vn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:v,"aria-label":y,children:[b,x,C,w,T]})}),t[28]=C,t[29]=w,t[30]=y,t[31]=b,t[32]=x,t[33]=E):E=t[33];let D;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(ai,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[34]=D):D=t[34];let O;t[35]===a.heading?O=t[36]:(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[D,(0,$.jsx)(`span`,{children:a.heading})]}),t[35]=a.heading,t[36]=O);let k;t[37]===n.explanation?k=t[38]:(k=n.explanation?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:n.explanation}):null,t[37]=n.explanation,t[38]=k);let A;t[39]!==O||t[40]!==k?(A=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[39]=O,t[40]=k,t[41]=A):A=t[41];let j;t[42]===d?j=t[43]:(j=(0,$.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-fg-subtle`,children:d}),t[42]=d,t[43]=j);let M;t[44]!==A||t[45]!==j?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[A,j]}),t[44]=A,t[45]=j,t[46]=M):M=t[46];let N=a.heading,P;t[47]===n.items?P=t[48]:(P=n.items.map(l4),t[47]=n.items,t[48]=P);let F;t[49]!==a.heading||t[50]!==P?(F=(0,$.jsx)(`ol`,{className:`max-h-[min(22rem,55vh)] overflow-y-auto px-4 py-3`,"aria-label":N,children:P}),t[49]=a.heading,t[50]=P,t[51]=F):F=t[51];let I;t[52]===m?I=t[53]:(I=m?(0,$.jsx)(`div`,{className:`border-t border-edge-subtle px-4 py-2 text-right text-xs tabular-nums text-fg-subtle`,children:m}):null,t[52]=m,t[53]=I);let L;t[54]!==M||t[55]!==F||t[56]!==I?(L=(0,$.jsx)(gn,{children:(0,$.jsxs)(yn,{side:`top`,align:`center`,sideOffset:8,collisionPadding:16,className:`z-50 w-[min(28rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[M,F,I]})}),t[54]=M,t[55]=F,t[56]=I,t[57]=L):L=t[57];let R;return t[58]!==E||t[59]!==L?(R=(0,$.jsx)(`div`,{className:`flex w-full justify-center pb-2 pt-1`,children:(0,$.jsxs)(hn,{children:[E,L]})}),t[58]=E,t[59]=L,t[60]=R):R=t[60],R}function l4(e){return(0,$.jsxs)(`li`,{className:K(`flex gap-3 py-2 text-sm leading-relaxed text-fg-muted`,e.status===`in_progress`&&`font-medium text-fg`,e.status===`cancelled`&&`text-fg-disabled`),children:[(0,$.jsx)(o4,{status:e.status}),(0,$.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:e.title})]},e.id)}function u4(e){return e.status===`completed`||e.status===`cancelled`}function d4(e){return e.status===`completed`}function f4(e){let t=v4(e.source,e.explanation,e.items.map(e=>({...e})));return t&&t.items.some(e=>e.status===`pending`||e.status===`in_progress`)?t:null}var p4=new Set([`pending`,`in_progress`,`completed`,`cancelled`]);function m4(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function h4(e){return e.trim().toLowerCase().replace(/-/g,`_`).split(`__`).at(-1)??``}function g4(e){let t=m4(e.details);return t&&Object.keys(t).length>0?t:Yk(e.result).details}function _4(e){let t=typeof e==`string`?e.trim():``;return p4.has(t)?t:null}function v4(e,t,n){if(n.length===0)return null;let r=n.findIndex(e=>e.status===`in_progress`);return{source:e,explanation:t,items:n,currentIndex:r>=0?r+1:void 0,completedCount:n.filter(e=>e.status===`completed`).length,totalCount:n.length}}function y4(e){if(!Array.isArray(e.plan))return null;let t=e.plan.flatMap((e,t)=>{let n=m4(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`update-plan-${t}`,i=typeof n?.step==`string`?n.step.trim():``,a=_4(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]});return v4(`update_plan`,typeof e.explanation==`string`&&e.explanation.trim()?e.explanation.trim():void 0,t)}function b4(e){return Array.isArray(e.items)?v4(`todo`,void 0,e.items.flatMap((e,t)=>{let n=m4(e),r=typeof n?.id==`string`&&n.id.trim()?n.id.trim():`todo-${t}`,i=typeof n?.content==`string`?n.content.trim():``,a=_4(n?.status);return i&&a?[{id:r,title:i,status:a}]:[]})):null}function x4(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.type!==`tool_use`||n.status===`error`)continue;let r=h4(n.name),i=g4(n);if(i){if(r===`update_plan`)return{found:!0,plan:y4(i)};if(r===`todo`)return{found:!0,plan:b4(i)}}}return{found:!1,plan:null}}function S4(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:0}function C4(e){let t=new Set,n=0,r=0;for(let i of e){if(i.type!==`tool_use`||i.status===`error`||h4(i.name)!==`apply_patch`)continue;let e=g4(i);if(e){if(Array.isArray(e.files))for(let n of e.files)typeof n==`string`&&n.trim()&&t.add(n.trim());if(t.size===0&&Array.isArray(e.changes))for(let n of e.changes){let e=m4(n),r=typeof e?.moveTo==`string`?e.moveTo:typeof e?.path==`string`?e.path:``;r.trim()&&t.add(r.trim())}n+=S4(e.added),r+=S4(e.removed)}}return t.size>0||n>0||r>0?{files:[...t],added:n,removed:r}:null}function w4(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`assistant`)continue;let r=x4(n.content??[]);if(!r.found)continue;if(!r.plan||!r.plan.items.some(e=>e.status===`pending`||e.status===`in_progress`))return null;let i=e.slice(t).flatMap(e=>e.role===`assistant`?e.content??[]:[]);return{plan:r.plan,changeSummary:C4(i)}}return null}function T4(e,t){if(!t)return null;let n=-1;for(let t=e.length-1;t>=0;--t)if(e[t]?.role===`user`){n=t;break}return w4(e.slice(n+1))}function E4(e){let t=(0,Q.c)(61),{open:n,query:r,activeIndex:i,resultCount:a,searching:o,truncated:s,limitedToLoaded:c,inputRef:l,labels:u,onQueryChange:d,onPrevious:f,onNext:p,onClose:m}=e,h=o===void 0?!1:o,g=s===void 0?!1:s,_=c===void 0?!1:c;if(!n)return null;let v;t[0]===r?v=t[1]:(v=r.trim(),t[0]=r,t[1]=v);let y=!!v,b;t[2]!==i||t[3]!==y||t[4]!==u.noResults||t[5]!==u.resultCount||t[6]!==u.searching||t[7]!==a||t[8]!==h||t[9]!==g?(b=h?u.searching:y&&a===0?u.noResults:y?u.resultCount.replace(`{{current}}`,String(i+1)).replace(`{{total}}`,`${a}${g?`+`:``}`):``,t[2]=i,t[3]=y,t[4]=u.noResults,t[5]=u.resultCount,t[6]=u.searching,t[7]=a,t[8]=h,t[9]=g,t[10]=b):b=t[10];let x=b,S;t[11]!==x||t[12]!==y||t[13]!==u.loadedOnly||t[14]!==_?(S=_&&y?[x,u.loadedOnly].filter(Boolean).join(` · `):x,t[11]=x,t[12]=y,t[13]=u.loadedOnly,t[14]=_,t[15]=S):S=t[15];let C=S,w=h||a===0,T=u.input,E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ve,{className:`size-4 shrink-0 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[16]=E):E=t[16];let D;t[17]===d?D=t[18]:(D=e=>d(e.target.value),t[17]=d,t[18]=D);let O;t[19]!==p||t[20]!==f?(O=e=>{e.nativeEvent.isComposing||e.key===`Enter`&&(e.preventDefault(),e.shiftKey?f():p())},t[19]=p,t[20]=f,t[21]=O):O=t[21];let k;t[22]!==l||t[23]!==u.input||t[24]!==r||t[25]!==O||t[26]!==D?(k=(0,$.jsx)(`input`,{ref:l,value:r,type:`search`,autoComplete:`off`,spellCheck:!1,"aria-label":u.input,className:`h-12 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-fg-subtle`,placeholder:u.input,onChange:D,onKeyDown:O}),t[22]=l,t[23]=u.input,t[24]=r,t[25]=O,t[26]=D,t[27]=k):k=t[27];let A;t[28]===h?A=t[29]:(A=h?(0,$.jsx)(ue,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[28]=h,t[29]=A);let j;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(j=K(`inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel,yc.press),t[30]=j):j=t[30];let M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(ye,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[31]=M):M=t[31];let N;t[32]!==u.close||t[33]!==m?(N=(0,$.jsx)(`button`,{type:`button`,onClick:m,className:j,"aria-label":u.close,children:M}),t[32]=u.close,t[33]=m,t[34]=N):N=t[34];let P;t[35]!==k||t[36]!==A||t[37]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 px-3`,children:[E,k,A,N]}),t[35]=k,t[36]=A,t[37]=N,t[38]=P):P=t[38];let F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(F=K(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel,yc.press,yc.disabled),t[39]=F):F=t[39];let I;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(ur,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[40]=I):I=t[40];let L;t[41]!==u.previous||t[42]!==w||t[43]!==f?(L=(0,$.jsx)(`button`,{type:`button`,disabled:w,onClick:f,className:F,"aria-label":u.previous,children:I}),t[41]=u.previous,t[42]=w,t[43]=f,t[44]=L):L=t[44];let R;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(R=K(`inline-flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,yc.focusRingPanel,yc.press,yc.disabled),t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(cr,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[46]=z):z=t[46];let B;t[47]!==u.next||t[48]!==w||t[49]!==p?(B=(0,$.jsx)(`button`,{type:`button`,disabled:w,onClick:p,className:R,"aria-label":u.next,children:z}),t[47]=u.next,t[48]=w,t[49]=p,t[50]=B):B=t[50];let V;t[51]===C?V=t[52]:(V=(0,$.jsx)(`span`,{className:`ml-auto px-2 text-sm tabular-nums text-fg-muted`,"aria-live":`polite`,"aria-atomic":`true`,children:C}),t[51]=C,t[52]=V);let H;t[53]!==L||t[54]!==B||t[55]!==V?(H=(0,$.jsxs)(`div`,{className:`flex h-11 items-center border-t border-edge-subtle px-1.5`,children:[L,B,V]}),t[53]=L,t[54]=B,t[55]=V,t[56]=H):H=t[56];let U;return t[57]!==u.input||t[58]!==P||t[59]!==H?(U=(0,$.jsxs)(`section`,{"data-chat-find-bar":!0,role:`search`,"aria-label":T,className:`absolute right-3 top-3 z-30 w-[min(25rem,calc(100%-1.5rem))] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,children:[P,H]}),t[57]=u.input,t[58]=P,t[59]=H,t[60]=U):U=t[60],U}async function D4(e,t,n={}){let r=await we(J(`${n.taskId?`/api/tasks/${encodeURIComponent(n.taskId)}/conversation/find`:`/api/sessions/${encodeURIComponent(e)}/find`}?${new URLSearchParams({q:t,limit:`1000`})}`),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.json();if(i.ok!==!0||!Array.isArray(i.matches)||typeof i.total!=`number`)throw Error(`Invalid chat find response`);return{query:typeof i.query==`string`?i.query:t,total:i.total,truncated:i.truncated===!0,matches:i.matches.filter(e=>Number.isInteger(e?.displayIndex)&&e.displayIndex>=0&&Number.isInteger(e?.occurrence)&&e.occurrence>=0)}}var O4=`chat-find-match`,k4=`chat-find-active`,A4=`chat-find-highlight-styles`;function j4(){let e=globalThis.CSS,t=globalThis.Highlight;return!e?.highlights||!t?null:{registry:e.highlights,Highlight:t}}function M4(){if(document.getElementById(A4))return;let e=document.createElement(`style`);e.id=A4,e.textContent=`
110
- ::highlight(${O4}) {
111
- color: inherit;
112
- background-color: color-mix(in srgb, var(--color-warning) 38%, transparent);
113
- }
114
- ::highlight(${k4}) {
115
- color: inherit;
116
- background-color: color-mix(in srgb, var(--color-warning) 78%, transparent);
117
- text-decoration: underline 2px var(--color-fg);
118
- }
119
- `,document.head.appendChild(e)}function N4(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!e.textContent||!t||t.closest(`button, [hidden], [aria-hidden="true"], .sr-only, script, style`)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=n.nextNode();for(;r;)t.push(r),r=n.nextNode();return t}function P4(e,t,n){let r=e.find(e=>e.end>t),i=[...e].reverse().find(e=>e.start<n);if(!r||!i)return null;let a=document.createRange();return a.setStart(r.node,t-r.start),a.setEnd(i.node,n-i.start),a}function F4(e,t){let n=t.toLowerCase(),r=e.toLowerCase();if(!n)return[];let i=[],a=0;for(;a<=r.length-n.length;){let e=r.indexOf(n,a);if(e<0)break;i.push({start:e,end:e+n.length}),a=e+Math.max(n.length,1)}return i}function I4(e,t){let n=t.trim();if(!n)return[];let r=[],i=e.querySelectorAll(`[data-chat-message-index]`);for(let e of i){let t=e.dataset.chatMessageIndex,i=t?Number.parseInt(t,10):NaN;if(!Number.isFinite(i))continue;let a=0;for(let t of e.querySelectorAll(`[data-chat-find-text]`)){let e=N4(t),o=[],s=``;for(let t of e){let e=t.textContent??``,n=s.length;s+=e,o.push({node:t,start:n,end:s.length})}for(let e of F4(s,n)){let t=P4(o,e.start,e.end);t&&(r.push({messageIndex:i,occurrence:a,range:t}),a+=1)}}}return r}function L4(e,t){let n=j4();if(!n||(M4(),n.registry.delete(O4),n.registry.delete(k4),e.length===0))return;n.registry.set(O4,new n.Highlight(...e.map(e=>e.range)));let r=e[t];r&&n.registry.set(k4,new n.Highlight(r.range))}function R4(){let e=j4();e?.registry.delete(O4),e?.registry.delete(k4)}function z4(e,t,n=96){let r=t.range.getBoundingClientRect(),i=e.getBoundingClientRect(),a=i.top+n,o=i.bottom-24;r.top>=a&&r.bottom<=o||e.scrollTo({top:Math.max(0,e.scrollTop+r.top-a),behavior:window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})}function B4(e,t){return t===0?0:(e+t)%t}function V4(e){return`${e.displayIndex}:${e.occurrence}`}function H4(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r?.messageIndex===e.messageIndex&&r.occurrence===e.occurrence&&r.range.startContainer===e.range.startContainer&&r.range.startOffset===e.range.startOffset&&r.range.endContainer===e.range.endContainer&&r.range.endOffset===e.range.endOffset})}function U4(e){let t=(0,Q.c)(66),{conversationId:n,taskId:r,messages:i,displayOffset:a,viewportRef:o,onRevealDisplayIndex:s}=e,[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=[],t[0]=f):f=t[0];let[p,m]=(0,Z.useState)(f),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=[],t[1]=h):h=t[1];let[g,_]=(0,Z.useState)(h),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(0),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(n),k=(0,Z.useDeferredValue)(u),A;if(t[2]!==a||t[3]!==p||t[4]!==g){let e=new Map(g.map(J4));for(let t of p){let n={displayIndex:a+t.messageIndex,occurrence:t.occurrence};e.set(V4(n),n)}A=[...e.values()].sort(q4),t[2]=a,t[3]=p,t[4]=g,t[5]=A}else A=t[5];let j=A,M;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{requestAnimationFrame(()=>{E.current?.focus(),E.current?.select()})},t[6]=M):M=t[6];let N=M,P;t[7]===c?P=t[8]:(P=()=>{if(!c){D.current=document.activeElement instanceof HTMLElement?document.activeElement:null,l(!0);return}N()},t[7]=c,t[8]=P);let F=P,I,L;t[9]===c?(I=t[10],L=t[11]):(I=()=>{c&&N()},L=[N,c],t[9]=c,t[10]=I,t[11]=L),(0,Z.useLayoutEffect)(I,L);let R;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{l(!1),d(``),m([]),_([]),y(!1),x(!1),C(!1),T(0),R4(),D.current?.focus(),D.current=null},t[12]=R):R=t[12];let z=R,B;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>{d(e),T(0)},t[13]=B):B=t[13];let V=B,H;t[14]===j.length?H=t[15]:(H=e=>{T(t=>B4(t+e,j.length))},t[14]=j.length,t[15]=H);let U=H,W,G;t[16]!==U||t[17]!==c||t[18]!==F?(W=()=>{let e=e=>{let t=e.metaKey||e.ctrlKey;if(t&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`f`){if(document.querySelector(`[role="dialog"][data-state="open"]`))return;e.preventDefault(),F();return}if(c){if(t&&!e.altKey&&e.key.toLowerCase()===`g`){e.preventDefault(),U(e.shiftKey?-1:1);return}e.key===`Escape`&&(e.preventDefault(),z())}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},G=[z,U,c,F],t[16]=U,t[17]=c,t[18]=F,t[19]=W,t[20]=G):(W=t[19],G=t[20]),(0,Z.useEffect)(W,G);let ee;t[21]!==k||t[22]!==c||t[23]!==o?(ee=()=>{let e=o.current;if(!c||!e||!k.trim()){m(K4),R4();return}let t=I4(e,k);m(e=>H4(e,t)?e:t)},t[21]=k,t[22]=c,t[23]=o,t[24]=ee):ee=t[24];let te;t[25]!==k||t[26]!==i||t[27]!==c||t[28]!==o?(te=[k,i,c,o],t[25]=k,t[26]=i,t[27]=c,t[28]=o,t[29]=te):te=t[29],(0,Z.useLayoutEffect)(ee,te);let ne,re;t[30]!==n||t[31]!==k||t[32]!==c||t[33]!==r?(ne=()=>{let e=k.trim();if(!c||!n||!e){_([]),y(!1),x(!1),C(!1);return}let t=new AbortController;_([]),y(!1),x(!1),C(!0);let i=window.setTimeout(()=>{D4(n,e,{taskId:r,signal:t.signal}).then(e=>{_(e.matches),y(e.truncated)}).catch(e=>{e?.name!==`AbortError`&&(_([]),y(!1),x(!0))}).finally(()=>{t.signal.aborted||C(!1)})},150);return()=>{window.clearTimeout(i),t.abort()}},re=[n,k,c,r],t[30]=n,t[31]=k,t[32]=c,t[33]=r,t[34]=ne,t[35]=re):(ne=t[34],re=t[35]),(0,Z.useEffect)(ne,re);let ie,ae;t[36]===j.length?(ie=t[37],ae=t[38]):(ie=()=>{T(e=>Math.min(e,Math.max(0,j.length-1)))},ae=[j.length],t[36]=j.length,t[37]=ie,t[38]=ae),(0,Z.useEffect)(ie,ae);let oe,se;t[39]!==w||t[40]!==j||t[41]!==a||t[42]!==p||t[43]!==s||t[44]!==o?(oe=()=>{let e=j[w],t=o.current;if(!t||!e){L4(p,-1);return}let n=e.displayIndex-a,r=p.findIndex(t=>t.messageIndex===n&&t.occurrence===e.occurrence);L4(p,r),r>=0?z4(t,p[r]):s(e.displayIndex)},se=[w,j,a,p,s,o],t[39]=w,t[40]=j,t[41]=a,t[42]=p,t[43]=s,t[44]=o,t[45]=oe,t[46]=se):(oe=t[45],se=t[46]),(0,Z.useLayoutEffect)(oe,se);let ce;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ce=[],t[47]=ce):ce=t[47],(0,Z.useEffect)(W4,ce);let le,ue;t[48]!==n||t[49]!==c?(le=()=>{O.current!==n&&(O.current=n,c&&z())},ue=[z,n,c],t[48]=n,t[49]=c,t[50]=le,t[51]=ue):(le=t[50],ue=t[51]),(0,Z.useEffect)(le,ue);let de,fe;t[52]===U?(de=t[53],fe=t[54]):(de=()=>U(-1),fe=()=>U(1),t[52]=U,t[53]=de,t[54]=fe);let pe;return t[55]!==w||t[56]!==j.length||t[57]!==b||t[58]!==c||t[59]!==u||t[60]!==v||t[61]!==S||t[62]!==F||t[63]!==de||t[64]!==fe?(pe={open:c,query:u,inputRef:E,activeIndex:w,resultCount:j.length,truncated:v,limitedToLoaded:b,searching:S,setQuery:V,show:F,close:z,previous:de,next:fe},t[55]=w,t[56]=j.length,t[57]=b,t[58]=c,t[59]=u,t[60]=v,t[61]=S,t[62]=F,t[63]=de,t[64]=fe,t[65]=pe):pe=t[65],pe}function W4(){return G4}function G4(){return R4()}function K4(e){return e.length===0?e:[]}function q4(e,t){return e.displayIndex-t.displayIndex||e.occurrence-t.occurrence}function J4(e){return[V4(e),e]}function Y4(e){let t=String(e??``).trim();return!t||t===`new`?null:t}function X4(e){let t=String(e.streamConversationId??``).trim(),n=Y4(e.routeConversationId);return!t||!n?!1:t===n}function Z4(e){let t=Y4(e.routeConversationId);return t?e.cacheConversationId===t:!1}function Q4(e){let t=String(e.chatId??``).trim();if(!t)return!1;let n=Y4(e.routeConversationId);return n?n===t:!1}function $4(e,t){return e?`new`:t??null}function e3(e,t){if(!(e||!t))return decodeURIComponent(t)}function t3(e){if(!e.viewConversationId||e.conversationId!==e.viewConversationId)return[];if(!e.streamingMsg)return e.messages;let t=e.messages[e.messages.length-1];if(t?.role===`assistant`&&e.streamingMsg.role===`assistant`){let n=L_([t,e.streamingMsg]);return[...e.messages.slice(0,-1),...n]}return[...e.messages,e.streamingMsg]}function n3(e,t){let n=e[e.length-1];return n?.role!==`assistant`||n.turnId!==t?null:{messagesWithoutTail:e.slice(0,-1),tail:n}}function r3(e){e()}async function i3(e){let t=String(e??``).trim();if(!t)return{active:!1};let n=await we(J(vo(t)));if(!n.ok)throw Error(`Active run lookup failed (${n.status})`);return po(await n.json())}async function a3(e){let t=String(e??``).trim();if(!t)return null;let n=Uy(t);try{let e=await i3(t);return e.active&&e.runId?(Wy(t,e.runId),e.runId):(n&&qy(t,n),null)}catch{}return Uy(t)}var o3=3e4,s3=null;function c3(e){s3={sessions:[...e],fetchedAt:Date.now()}}function l3(e){let t=e.key.trim();if(!t)return;let n=new Date().toISOString();s3={sessions:[{...e,key:t,messageCount:e.messageCount??0,updatedAt:e.updatedAt??n},...(s3?.sessions??[]).filter(e=>e.key.trim()!==t)],fetchedAt:Date.now()}}function u3(){return s3?Date.now()-s3.fetchedAt>o3?(s3=null,null):s3.sessions:null}var d3=`webchat`;function f3(e){if(!e||typeof e!=`object`)throw Error(`Invalid session agent config response`);let t=e;if(t.ok!==!0||!t.payload||typeof t.payload!=`object`)throw Error(`Invalid session agent config response`);let n=t.payload,r=n.workspaceSource,i=n.activityDetail,a=i&&typeof i==`object`?i:null,o=e=>e===`off`||e===`on`||e===`stream`;if(typeof n.thinkingLevel!=`string`||typeof n.model!=`string`||typeof n.reasoningLevel!=`string`||typeof n.effectiveWorkspacePath!=`string`||typeof n.workingDirectoryLocked!=`boolean`||n.userContextMode!==`enabled`&&n.userContextMode!==`off`&&n.userContextMode!==`temporary`||r!==`execution_environment`&&r!==`project`&&r!==`session_override`&&r!==`agent_default_root`&&r!==`agent_workspace`)throw Error(`Invalid session agent config response`);return{thinkingLevel:n.thinkingLevel,configVersion:typeof n.configVersion==`number`?n.configVersion:void 0,fixedModel:n.fixedModel===!0,model:n.model,reasoningLevel:n.reasoningLevel,activityDetail:a&&o(a.default)&&(a.override===null||o(a.override))&&o(a.effective)&&(a.source===`session`||a.source==="default")?{default:a.default,override:a.override,effective:a.effective,source:a.source}:{default:o(n.reasoningLevel)?n.reasoningLevel:`on`,override:o(n.reasoningLevel)?n.reasoningLevel:null,effective:o(n.reasoningLevel)?n.reasoningLevel:`on`,source:o(n.reasoningLevel)?`session`:`default`},effectiveWorkspacePath:n.effectiveWorkspacePath,workingDirectoryLocked:n.workingDirectoryLocked,userContextMode:n.userContextMode,workspaceSource:r}}var p3=new Map,m3=new Map,h3=50,g3=500,_3=new Map;async function v3(e){let t=await e.json().catch(()=>({}));return typeof t.error==`string`?t.error:t.error?.message??`HTTP ${e.status}`}var y3=class{async forkSessionAtTurn(e,t){let n=await we(J(go(e)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({lastTurnId:t})});if(!n.ok)throw Error(await v3(n));return ao(await n.json())}async loadSessions(){let e=[],t=0;for(let n=0;n<100;n++){let n=await Yh({channel:d3,limit:100,offset:t});for(let t of n.items)e.push({key:t.key,agentId:t.agentId,transcriptId:t.transcriptId,name:t.name,updatedAt:t.updatedAt,messageCount:t.messageCount,sourceChannel:t.sourceChannel,sourceChatId:t.sourceChatId,projectId:t.projectId,customData:t.customData,routing:t.routing});if(!n.hasMore)break;t+=100}let n=e.sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());return c3(n),n}async loadSessionAgentConfig(e){let t=p3.get(e);if(t)return t;let n=(async()=>{let t=await we(J(`/api/sessions/${encodeURIComponent(e)}/agent-config`));if(!t.ok)throw Error(`HTTP ${t.status}`);return f3(await t.json())})().finally(()=>{p3.delete(e)});return p3.set(e,n),n}async patchSessionAgentConfig(e,t){let n=await we(J(`/api/sessions/${encodeURIComponent(e)}/agent-config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}return f3(await n.json())}async patchTaskConversationModel(e,t,n,r){let i=await we(J(`/api/tasks/${encodeURIComponent(e)}/conversation/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({model:t,thinkingLevel:n,configVersion:r})});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}return f3(await i.json())}fetchSessionActiveRun(e){return i3(e)}async loadSession(e,t=0,n,r){let i=`${r??e}\0${t}\0${n??``}`,a=m3.get(i);if(a)return a;let o=(async()=>{let i=async(t,n)=>{let i=await jn(J(r?`/api/tasks/${encodeURIComponent(r)}/conversation/history?${new URLSearchParams({limit:String(h3),...n?{before:n}:{offset:String(t)}}).toString()}`:_o(e,{limit:h3,before:n,offset:n?void 0:t})));if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText}`);return io(await i.json())},a=await i(t,n),o=a.session.messages,s=U_(o),c=a.pagination.hasMore,l=a.pagination.nextBeforeCursor,u=typeof a.session.name==`string`&&a.session.name.trim()?a.session.name.trim():void 0;for(;t===0&&!n&&c&&l&&o.length<g3&&s[0]?.role===`assistant`;){a=await i(0,l);let e=a.session.messages;if(e.length===0)break;o=[...e,...o],s=U_(o),c=a.pagination.hasMore,l=a.pagination.nextBeforeCursor}return{messages:s,hasMore:c,name:u,nextBeforeCursor:l}})().finally(()=>{m3.delete(i)});return m3.set(i,o),o}async loadTimeline(e,t){let n=t??e,r=_3.get(n);if(r)return r;let i=(async()=>{let n=await jn(J(t?`/api/tasks/${encodeURIComponent(t)}/conversation/timeline`:`/api/sessions/${encodeURIComponent(e)}/timeline`));if(!n.ok)throw Error(`HTTP ${n.status}: ${n.statusText}`);let r=await n.json();if(r.ok!==!0||!Array.isArray(r.items))throw Error(`Invalid session timeline response`);return r.items})().finally(()=>{_3.delete(n)});return _3.set(n,i),i}async createSession(e){let t={channel:`webchat`},n=e?.agentId?.trim();n&&(t.agentId=n.toLowerCase());let r=e?.projectId?.trim();r&&(t.projectId=r),e?.temporary===!0&&(t.temporary=!0),e?.initialAgentConfig&&(t.initialAgentConfig=e.initialAgentConfig),e?.executionMode&&(t.executionMode=e.executionMode);let i=await we(J(`/api/sessions`),{method:`POST`,body:JSON.stringify(t)});if(!i.ok)throw Error(await v3(i));return(await i.json()).session}async resetSession(e){let t=e.trim();if(!t)throw Error(`Session key is required`);let n=await we(J(`/api/sessions/${encodeURIComponent(t)}/reset`),{method:`POST`});if(!n.ok)throw Error(await v3(n));return lo(await n.json())}async ensureSessionExists(e){let t=e.trim();if(!t)throw Error(`Session key is required`);let n=await we(J(`/api/sessions/resolve`),{method:`POST`,body:JSON.stringify({conversationId:t})});if(!n.ok)throw Error(await v3(n))}async fetchSessionName(e){let t=await jn(J(`/api/sessions/${encodeURIComponent(e)}?offset=0&limit=1`));if(!t.ok)return;let n=(await t.json()).session?.name;return typeof n==`string`&&n.trim()?n.trim():void 0}updateUrl(e){let t=`#/chat/${encodeURIComponent(e)}`;if(location.hash!==t){let e=window.history.state,n=e&&typeof e==`object`&&!Array.isArray(e)?{...e}:e;history.replaceState(n,``,t)}}parseSessionFromHash(){let e=location.hash.slice(1),t=e.match(/^\/chat\/(.+)$/)||e.match(/^chat\/(.+)$/),n=t?decodeURIComponent(t[1]):null;return n&&n!==`new`?n:null}async deleteMessages(e,t){let n=await we(J(`/api/sessions/${encodeURIComponent(e)}/messages`),{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}}};function b3(e){return e===`on`||e===`stream`||e===`off`?e:`on`}function x3(e,t){let n=String(e??``).trim();if(!n)return;let r=qb.getState(),i=r.sessions[n]?.configVersion;i!==void 0&&(t.configVersion===void 0||t.configVersion<i)||r.patchSessionMeta(n,{model:t.model,configVersion:t.configVersion,thinkingLevel:t.thinkingLevel||`medium`,reasoningLevel:b3(t.activityDetail?.default??t.reasoningLevel??void 0),effectiveWorkspacePath:t.effectiveWorkspacePath??``,workspaceSource:t.workspaceSource??`agent_default_root`,userContextMode:t.userContextMode??`enabled`})}function S3(e){e.sendingRef.current=!1,e.streamingRef.current=!1}function C3(e){return e.isNewRoute?`creating-session`:e.sessionRoutePending||e.showSessionLoading||e.sessionContentLoading?`loading-history`:e.messageCount===0?`ready-empty`:`ready-conversation`}function w3(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=n.clarification&&typeof n.clarification==`object`?n.clarification:n;if(r.status!==void 0&&r.status!==`open`||t&&typeof r.conversationId==`string`&&r.conversationId!==t)return null;let i=typeof r.id==`string`?r.id:r.requestId,a=r.question,o=r.kind===`approval`?`approval`:`input`,s=Array.isArray(r.choices)?r.choices.filter(e=>typeof e==`string`&&!!e.trim()):void 0;return typeof i!=`string`||!i.trim()||typeof a!=`string`||!a.trim()?null:{requestId:i.trim(),kind:o,question:a.trim(),choices:s&&s.length>=2?s:void 0,suggestedAnswer:typeof r.suggestedAnswer==`string`&&r.suggestedAnswer.trim()?r.suggestedAnswer.trim():void 0,version:typeof r.version==`number`?r.version:1,createdAt:typeof r.createdAt==`number`?r.createdAt:Date.now(),expiresAt:typeof r.expiresAt==`number`?r.expiresAt:void 0}}function T3(e){let{conversationId:t,decodedKey:n,conversationIdRef:r,sendingRef:i,streamingRef:a,modelSupportsThinking:o,thinkingLevel:s,shouldApplyStreamUpdate:c}=e,[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),[_,v]=(0,Z.useState)([]),y=(0,Z.useRef)([]),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),w=(0,Z.useRef)(null),T=(0,Z.useRef)(-1);h.current=l,y.current=_,w.current=S;let E=(0,Z.useCallback)(e=>{if(!e||typeof e!=`object`)return;let t=e;if(t.conversationId!==r.current||typeof t.revision!=`number`||!Array.isArray(t.inputs)||t.revision<T.current)return;let n=F$(t.inputs);T.current=t.revision,y.current=n,v(n),w.current&&!n.some(e=>e.id===w.current)&&C(null)},[r]),D=(0,Z.useCallback)(async e=>{let t=await we(J(`/api/sessions/${encodeURIComponent(e)}/input-state`)).catch(()=>null);!t?.ok||r.current!==e||E((await t.json().catch(()=>null))?.payload)},[E,r]),O=(0,Z.useCallback)(async e=>{let t=await we(J(`/api/sessions/${encodeURIComponent(e)}/clarification`)).catch(()=>null);if(!t?.ok||r.current!==e)return;let n=await t.json().catch(()=>null);m(null),u(w3(n?.payload,e)),g.current=null},[r]);(0,Z.useEffect)(()=>{T.current=-1,y.current=[],v([]),C(null),u(null),!(!t||t!==n)&&(D(t),O(t))},[n,O,D,t]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail;E(t);let n=r.current;n&&t&&typeof t==`object`&&t.conversationId===n&&O(n)},t=e=>{let t=r.current;if(!t)return;let n=e.detail;if(n&&typeof n==`object`){let e=n.conversationId;if(typeof e==`string`&&e!==t)return}m(null),u(w3(n,t)),g.current=null},n=()=>{let e=r.current;e&&(D(e),O(e))};return window.addEventListener(`session-input-state`,e),window.addEventListener(`clarification-updated`,t),window.addEventListener(`gateway-realtime-connected`,n),()=>{window.removeEventListener(`session-input-state`,e),window.removeEventListener(`clarification-updated`,t),window.removeEventListener(`gateway-realtime-connected`,n)}},[E,O,D,r]),(0,Z.useEffect)(()=>{if(!l?.expiresAt)return;let e=Math.max(0,l.expiresAt-Date.now())+250,t=window.setTimeout(()=>{let e=r.current;e&&O(e)},e);return()=>window.clearTimeout(t)},[l?.expiresAt,O,r]);let k=(0,Z.useCallback)(()=>{m(null),u(null)},[]),A=(0,Z.useCallback)(e=>{let t=String(e??``).trim();t&&r.current===t&&(m(null),u(null))},[r]),j=(0,Z.useCallback)(()=>{m(null),u(null)},[]),M=(0,Z.useCallback)(()=>{C(null)},[]),N=(0,Z.useCallback)(()=>{m(null),u(null),C(null)},[]),P=(0,Z.useCallback)(e=>t=>{c(e)&&(i.current=!1,a.current=!1,qb.getState().setSessionFlags(e,{sending:!1,streaming:!1}),qb.getState().setSessionProgress(e,null),m(null),u(t),g.current=null)},[c,i,a]),F=(0,Z.useCallback)(async(e,t,n)=>{let i=e.trim();if(!i&&!t?.length&&!n?.length)return;if(y.current.length>=10)throw Error(`At most 10 pending messages are allowed`);let a=o?s:`off`,c=r.current;if(!c)throw Error(`No active session`);let l=await Cv(),u=await we(J(`/api/sessions/${encodeURIComponent(c)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({configVersion:qb.getState().sessions[c]?.configVersion,clientMessageId:crypto.randomUUID(),delivery:`next`,content:i||e,attachments:t?.length?t:void 0,thinking:a,contextRefs:n?.map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r})),origin:l})}),d=await u.json().catch(()=>null);if(!u.ok){let e=typeof d?.error==`string`?d.error:d?.error?.message;throw Error(e??`Message was not accepted`)}if(!d?.payload?.state)throw Error(`Gateway returned an invalid input state`);E(d.payload.state)},[E,o,r,s]),I=(0,Z.useCallback)(e=>{C(e)},[]),L=(0,Z.useCallback)(()=>{C(null)},[]),R=(0,Z.useCallback)((e,t,n,i,a)=>{let c=t.trim(),l=y.current,u=l.findIndex(t=>t.id===e);if(u<0){C(null);return}if(!c&&!n?.length&&!a?.length){let t=r.current;t&&we(J(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${l[u].version}`),{method:`DELETE`}).then(async e=>E((await e.json().catch(()=>null))?.payload)).catch(()=>{D(t)}),C(null);return}let d=o?i??s:`off`;C(null);let f=r.current;f&&we(J(`/api/sessions/${encodeURIComponent(f)}/inputs/${encodeURIComponent(e)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:l[u].version,content:c||t,attachments:n?.length?n:void 0,thinking:d,contextRefs:(a??[]).map(({refId:e,kind:t,sourceId:n,expectedVersion:r})=>({refId:e,kind:t,sourceId:n,expectedVersion:r}))})}).then(async e=>{E((await e.json().catch(()=>null))?.payload)}).catch(()=>{D(f)})},[E,o,D,r,s]),z=(0,Z.useCallback)(e=>{w.current===e&&C(null);let t=r.current,n=y.current.find(t=>t.id===e);!t||!n||we(J(`/api/sessions/${encodeURIComponent(t)}/inputs/${encodeURIComponent(e)}?version=${n.version}`),{method:`DELETE`}).then(async e=>{E((await e.json().catch(()=>null))?.payload)}).catch(()=>{D(t)})},[E,D,r]),B=(0,Z.useCallback)((e,t)=>{let n=y.current.filter(e=>e.status===`queued`),i=n.findIndex(t=>t.id===e);if(i<0)return;let a=t===`up`?i-1:i+1,o=r.current,s=n[i];!o||!s||a<0||a>=n.length||we(J(`/api/sessions/${encodeURIComponent(o)}/inputs/${encodeURIComponent(s.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:s.version,position:a})}).then(async e=>E((await e.json().catch(()=>null))?.payload)).catch(()=>{D(o)})},[E,D,r]),V=(0,Z.useCallback)((e,t)=>{let n=r.current,i=y.current[e],a=y.current[t],o=y.current.filter(e=>e.status===`queued`),s=a?o.findIndex(e=>e.id===a.id):-1;!n||i?.status!==`queued`||a?.status!==`queued`||s<0||we(J(`/api/sessions/${encodeURIComponent(n)}/inputs/${encodeURIComponent(i.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({version:i.version,position:s})}).then(async e=>{E((await e.json().catch(()=>null))?.payload)}).catch(()=>{D(n)})},[E,D,r]),H=(0,Z.useCallback)(async e=>{let t=r.current;if(!t)return;let n=y.current.find(t=>t.id===e);if(!(!n?.text.trim()||n.attachments?.length||n.contextRefs?.length)){x(e);try{let r=await we(J(`/api/sessions/${encodeURIComponent(t)}/inputs`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientMessageId:crypto.randomUUID(),delivery:`steer`,content:n.text.trim()})});r.ok&&(E((await r.json().catch(()=>null))?.payload?.state),z(e))}catch{}finally{x(null)}}},[E,z,r]),U=(0,Z.useCallback)(async(e,t)=>{let n=h.current;if(!n)return;let i=`${n.requestId}\n${n.version}\n${e}\n${t??``}`;g.current?.signature!==i&&(g.current={signature:i,idempotencyKey:crypto.randomUUID()});let a=g.current.idempotencyKey;f(!0),m(null);try{let i=await we(J(`/api/clarifications/${encodeURIComponent(n.requestId)}/responses`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:e,answer:t,expectedVersion:n.version,idempotencyKey:a})});if(!i.ok){m((await i.json().catch(()=>({}))).error?.message??i.statusText??`Clarify failed`);let e=r.current;e&&(i.status===409||i.status===410)&&O(e);return}g.current=null,u(null),m(null)}finally{f(!1)}},[O,r]);return{clarifyPrompt:l,clarifySubmitting:d,clarifySubmitError:p,clarifyPromptRef:h,pendingFollowUps:_,pendingFollowUpsRef:y,steeringFollowUpId:b,editingFollowUpId:S,addPendingFollowUp:F,beginEditFollowUp:I,cancelEditFollowUp:L,commitEditFollowUp:R,removePendingFollowUp:z,movePendingFollowUp:B,reorderPendingFollowUp:V,steerPendingFollowUp:H,submitClarifyAnswer:(0,Z.useCallback)(e=>U(`answer`,e),[U]),letAgentDecideClarification:(0,Z.useCallback)(()=>U(`agent_decide`),[U]),cancelClarification:(0,Z.useCallback)(()=>U(`cancel`),[U]),clearVisibleClarify:k,dismissClarify:j,dismissClarifyForSession:A,clearPendingFollowUps:M,dismissClarifyAndClearPending:N,makeOnClarifyRequest:P}}function E3(e){let t=(0,Q.c)(60),{navigate:n,conversationIdRef:r,conversationId:i,isNewRoute:a,locationState:o,locationSearch:s}=e,c=Se(A3),l;t[0]===i?l=t[1]:(l=i?.trim()??``,t[0]=i,t[1]=l);let u=l,d;t[2]===c?d=t[3]:(d=c?[`gateway-chat-agents`,c]:null,t[2]=c,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:p,mutate:m}=Zt(d,Mg,f),h;t[5]!==u||t[6]!==c?(h=c&&u?[`gateway-chat-session-agent`,c,u]:null,t[5]=u,t[6]=c,t[7]=h):h=t[7];let g;t[8]===u?g=t[9]:(g=()=>$h(u),t[8]=u,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},t[10]=_):_=t[10];let{data:v}=Zt(h,g,_),y;t[11]===v?.routing?.agentId?y=t[12]:(y=v?.routing?.agentId?.trim().toLowerCase()??``,t[11]=v?.routing?.agentId,t[12]=y);let b=y,x,S;t[13]===m?(x=t[14],S=t[15]):(x=()=>{let e=e=>{tn(e.detail)||m()};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},S=[m],t[13]=m,t[14]=x,t[15]=S),(0,Z.useEffect)(x,S);let[C,w]=(0,Z.useState)(k3),T=(0,Z.useRef)(p??null),E;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(E=lh().selectedAgentId??null,t[16]=E):E=t[16];let D=(0,Z.useRef)(E),O,k;t[17]===p?(O=t[18],k=t[19]):(O=()=>{T.current=p??null},k=[p],t[17]=p,t[18]=O,t[19]=k),(0,Z.useEffect)(O,k);let A,j;t[20]===C?(A=t[21],j=t[22]):(A=()=>{D.current=C},j=[C],t[20]=C,t[21]=A,t[22]=j),(0,Z.useEffect)(A,j);let M,N;t[23]===p?(M=t[24],N=t[25]):(M=()=>{if(!p)return;let e=new Set(p.items.map(O3));w(t=>t==null||t===``||!e.has(t)?p.defaultId:t)},N=[p],t[23]=p,t[24]=M,t[25]=N),(0,Z.useEffect)(M,N);let P;t[26]!==r||t[27]!==b?(P=()=>{if(r.current&&b)return b;let e=T.current,t=(D.current??``).trim().toLowerCase();if(!e)return t||void 0;let n=new Set(e.items.map(D3));return t&&n.has(t)?t:e.defaultId},t[26]=r,t[27]=b,t[28]=P):P=t[28];let F=P,I;t[29]!==r||t[30]!==v?.projectId||t[31]!==b||t[32]!==a||t[33]!==s||t[34]!==o||t[35]!==n?(I=e=>{let t=e.trim().toLowerCase();w(t),dh(t),(r.current?b||D.current:null)!==t&&n(a?`/chat/new${s}`:Gg(v?.projectId),{replace:!1,state:{...a&&o&&typeof o==`object`?o:{},agentId:t}})},t[29]=r,t[30]=v?.projectId,t[31]=b,t[32]=a,t[33]=s,t[34]=o,t[35]=n,t[36]=I):I=t[36],v?.projectId;let L=I,R,z;t[37]===L?(R=t[38],z=t[39]):(R=()=>{let e=e=>{let t=e.detail?.agentId;typeof t!=`string`||!t.trim()||L(t)};return window.addEventListener(`xopc-set-chat-agent`,e),()=>window.removeEventListener(`xopc-set-chat-agent`,e)},z=[L],t[37]=L,t[38]=R,t[39]=z),(0,Z.useEffect)(R,z);let B,V;t[40]!==i||t[41]!==b?(B=()=>{if(!i)return;let e=b;!e||D.current===e||(D.current=e,w(e),dh(e))},V=[b,i],t[40]=i,t[41]=b,t[42]=B,t[43]=V):(B=t[42],V=t[43]),(0,Z.useLayoutEffect)(B,V);let H,U;t[44]!==i||t[45]!==v?(H=()=>{!i||!v||ph(v.projectId)},U=[v,i],t[44]=i,t[45]=v,t[46]=H,t[47]=U):(H=t[46],U=t[47]),(0,Z.useLayoutEffect)(H,U);let W,G;t[48]!==a||t[49]!==o?(W=()=>{if(!a)return;let e=o,t=typeof e?.agentId==`string`?e.agentId.trim().toLowerCase():``;t&&(D.current=t,w(t),dh(t))},G=[a,o],t[48]=a,t[49]=o,t[50]=W,t[51]=G):(W=t[50],G=t[51]),(0,Z.useLayoutEffect)(W,G);let ee=b||C||p?.defaultId||`main`,te=(p?.items.length??0)>1,ne=v?.projectId??null,re;return t[52]!==p||t[53]!==ee||t[54]!==L||t[55]!==F||t[56]!==te||t[57]!==ne||t[58]!==c?(re={token:c,chatAgentsData:p,resolveAgentIdForPost:F,onChatAgentChange:L,displayAgentId:ee,showChatAgentSelector:te,currentSessionProjectId:ne},t[52]=p,t[53]=ee,t[54]=L,t[55]=F,t[56]=te,t[57]=ne,t[58]=c,t[59]=re):re=t[59],re}function D3(e){return e.id}function O3(e){return e.id}function k3(){return lh().selectedAgentId??null}function A3(e){return e.conversationId}var j3=`main`,M3=/^[a-z0-9][a-z0-9_-]{0,63}$/i,N3=/[^a-z0-9_-]+/g,P3=/^-+/,F3=/-+$/;function I3(e){let t=(e??``).trim();if(!t)return j3;let n=t.toLowerCase();return M3.test(t)?n:n.replace(N3,`-`).replace(P3,``).replace(F3,``).slice(0,64)||j3}function L3(e){let t=e?.sourceBinding;return!!(t&&typeof t==`object`)}function R3(e){return e?.trim()||void 0}function z3(e,t){let n=e.key?.trim();if(!n||e.sourceChannel?.trim().toLowerCase()!==`webchat`||e.customData?.genericNewChatShell!==!0||L3(e.customData)||(e.messageCount??0)!==0||(Yb(n)?.messages.length??0)!==0)return!1;let r=e.agentId?.trim().toLowerCase();if(!r||r!==I3(t.agentId))return!1;let i=R3(t.projectId),a=R3(e.projectId);return!((i?a!==i:a)||Zb(n))}function B3(e,t){let n={...t,agentId:I3(t.agentId)};return e.filter(e=>z3(e,n)).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]??null}function V3(e,t){let n=t.trim();return e.find(e=>e.key.trim()===n)}function H3(e,t,n,r){if(!t?.length)return e;let i=new Map(e.map(e=>[e.key.trim(),e]));for(let e of t){let t=e.key.trim();!t||i.has(t)||z3(e,{agentId:n,projectId:r})&&i.set(t,e)}return[...i.values()].toSorted((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}async function U3(e,t,n){let r=u3();try{return H3(await e.loadSessions(),r,t,n)}catch{return r?.filter(e=>z3(e,{agentId:t,projectId:n}))??[]}}async function W3(e){let t=I3(e.agentId),n=e.projectId?.trim()||void 0,r=e.currentConversationId?.trim()||null;if(e.forceNew||e.temporary||e.executionMode){let r=await e.sessionMgr.createSession({agentId:t,...n?{projectId:n}:{},...e.temporary?{temporary:!0}:{},...e.initialAgentConfig?{initialAgentConfig:e.initialAgentConfig}:{},...e.executionMode?{executionMode:e.executionMode}:{}});return{kind:`create`,conversationId:r.key,session:r}}let i=await U3(e.sessionMgr,t,n);if(r){let e=V3(i,r);if(e&&z3(e,{agentId:t,projectId:n}))return{kind:`noop`,conversationId:r}}let a=B3(i,{agentId:t,projectId:n});if(a&&a.key.trim()!==r)return{kind:`reuse`,conversationId:a.key,session:a};let o=await e.sessionMgr.createSession({agentId:t,projectId:n,...e.initialAgentConfig?{initialAgentConfig:e.initialAgentConfig}:{}});return{kind:`create`,conversationId:o.key,session:o}}var G3=new Map,K3=0;function q3(e){let t=Se.getState(),n=Os(t.baseUrl,{agentId:e.agentId?.trim()||`main`,projectId:e.projectId??null}),r=JSON.stringify([n,t.conversationId,e.forceNew===!0,e.temporary===!0,e.executionMode,e.search]),i=G3.get(r);if(i)return i.target.opts=e,i.target.generation=++K3,i.promise;let a={opts:e,generation:++K3},o=e=>{if(a.generation!==K3)return;let t=a.opts;t.onOpened(e),(t.routeConversationId?.trim()||null)!==e&&t.navigateToSession(e,t.replaceNavigate??!1,t.search)},s=(async()=>{let t=e.agentId??void 0,n=await W3({sessionMgr:e.sessionMgr,agentId:t?.trim()||`main`,projectId:e.projectId,currentConversationId:e.currentConversationId,forceNew:e.forceNew,temporary:e.temporary,initialAgentConfig:e.initialAgentConfig,executionMode:e.executionMode});if(n.kind!==`create`&&e.initialAgentConfig&&await e.sessionMgr.patchSessionAgentConfig(n.conversationId,e.initialAgentConfig),n.kind===`noop`||n.kind===`reuse`)return o(n.conversationId),n.conversationId;let{conversationId:r,session:i}=n;return e.executionMode||l3({key:r,agentId:i.agentId,customData:i.customData,transcriptId:i.transcriptId,name:i.name,messageCount:0,updatedAt:i.updatedAt||new Date().toISOString(),sourceChannel:i.sourceChannel,sourceChatId:i.sourceChatId,projectId:i.projectId,routing:i.routing}),o(r),r})().finally(()=>{G3.delete(r)});return G3.set(r,{promise:s,target:a}),s}var J3={current:null},Y3={current:null};function X3(e){return!!(e&&typeof e==`object`&&e.forceNewChat===!0)}function Z3(e){let t=b(),{conversationId:n}=p(),r=e?!1:t.pathname.endsWith(`/new`),i=r&&X3(t.state),a=e??e3(r,n),o=$4(r,a),s=Y4(o),c=r?null:a??null,l=(0,Z.useRef)(o);return l.current=o,J3.current=c,!r&&a&&(Y3.current=a),(0,Z.useLayoutEffect)(()=>{qb.getState().focusedConversationId!==c&&qb.getState().setFocusedConversationId(c)},[c]),{isNewRoute:r,forceNewChat:i,decodedKey:a,routedConversationId:o,viewConversationId:s,routedFocusedConversationId:c,routeConversationIdRef:l,locationKey:t.key,locationSearch:t.search,locationState:t.state}}var Q3={get current(){return Y3.current}},$3={get current(){return J3.current},set current(e){J3.current=e,qb.getState().setFocusedConversationId(e)}};function e6(e){let{token:t,isNewRoute:n,forceNewChat:r,temporary:i=!1,requestedAgentId:a,decodedKey:o,locationKey:s,locationSearch:c,sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_}=e,v=(0,Z.useRef)(0),y=Se(e=>e.baseUrl),[b,x]=(0,Z.useState)(null),S=n?c:``,C=n?`new:${s}`:o?`session:${o}`:`fallback:${s}`,w=(0,Z.useRef)({isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:S});w.current={isNewRoute:n,forceNewChat:r,temporary:i,requestedAgentId:a,decodedKey:o,newRouteLocationSearch:S};let T=(0,Z.useRef)({sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_});return T.current={sessionMgrRef:l,resolveAgentIdForPost:u,navigateToSession:d,loadSessionById:f,tryResumeAgentRun:p,restoreLiveCacheIfNeeded:m,adoptEmptySession:h,applyAgentConfig:g,patchInitUi:_},(0,Z.useEffect)(()=>{let e=w.current,n=T.current;if(!t){n.patchInitUi({loading:!1});return}let r=++v.current,i=!1,a=()=>!i&&r===v.current,o=e=>{a()&&n.sessionMgrRef.current.loadSessionAgentConfig(e).then(t=>{a()&&n.applyAgentConfig(e,t)}).catch(()=>{})},s=async()=>{if(!a())return Promise.resolve();let r=lh(),i=n.resolveAgentIdForPost(),s=Ds({origin:`web-route`,project:Wg(e.newRouteLocationSearch),agentId:e.requestedAgentId??i,forceNew:e.forceNewChat,temporary:e.temporary},{defaultAgentId:i??`main`,selectedAgentId:r.selectedAgentId,lastChatScope:r.lastChatScope}),c=s.projectId?await gh(s.projectId):null;if(!a())return;!e.requestedAgentId&&c?.defaultAgentId&&(s.agentId=c.defaultAgentId);let l=Cs(r,s.agentId),u=(t,r)=>q3({sessionMgr:n.sessionMgrRef.current,agentId:s.agentId,currentConversationId:Q3.current,routeConversationId:null,forceNew:s.forceNew,temporary:s.temporary,projectId:s.projectId,executionMode:t,initialAgentConfig:r??(l?{model:l.modelRef,...l.thinkingLevel?{thinkingLevel:l.thinkingLevel}:{}}:void 0),navigateToSession:(...e)=>{a()&&n.navigateToSession(...e)},replaceNavigate:!0,search:Ug(e.newRouteLocationSearch),onOpened:e=>{a()&&(n.adoptEmptySession(e,null),o(e))}});if(c?.workspaceRoot?.trim()){x({requestKey:C,token:t,baseUrl:y,project:c,agentId:s.agentId,temporary:s.temporary,create:(e,t)=>a()?u(e,t):Promise.reject(Error(`New chat request changed`))});return}await u()},c=(e,t)=>{if(!a())return Promise.resolve();n.restoreLiveCacheIfNeeded(e);let r=Yb(e)?.messages??t??Xb(e);return n.tryResumeAgentRun(e,r)},l=e=>a()?Yb(e)?.historyStatus===`ready`?(o(e),c(e,Xb(e))):n.loadSessionById(e,0).then(t=>{if(a())return c(e,t??Xb(e))}):Promise.resolve(),u=()=>a()?n.sessionMgrRef.current.loadSessions().then(e=>{if(!a())return;let t=e.filter(e=>(e.messageCount??0)>0)[0]??e[0];if(t)return a()?n.loadSessionById(t.key,0).then(e=>{if(!a())return;n.restoreLiveCacheIfNeeded(t.key);let r=Yb(t.key)?.messages??e??Xb(t.key);return n.sessionMgrRef.current.parseSessionFromHash()||n.navigateToSession(t.key,!0),n.tryResumeAgentRun(t.key,r)}):void 0;if(!a())return;let r=n.resolveAgentIdForPost();return q3({sessionMgr:n.sessionMgrRef.current,agentId:r,currentConversationId:null,routeConversationId:null,navigateToSession:n.navigateToSession,onOpened:e=>{n.adoptEmptySession(e,null),o(e)}}).then(()=>void 0)}):Promise.resolve();return(()=>{let t=e.decodedKey===void 0&&!e.isNewRoute;n.patchInitUi({loading:t,error:null}),(e.isNewRoute?s():e.decodedKey?l(e.decodedKey):u()).then(()=>{a()&&n.patchInitUi({loading:!1})}).catch(e=>{i?a()&&n.patchInitUi({loading:!1}):n.patchInitUi({error:e instanceof Error?e.message:`Chat init failed`,loading:!1})})})(),()=>{i=!0}},[t,y,C]),n&&b?.requestKey===C&&b.token===t&&b.baseUrl===y?b:null}function t6(e){let t=Se(e=>e.conversationId),n=Se(e=>e.baseUrl),[r,i]=(0,Z.useState)(null),{data:a,error:o}=Zt(e?[`prepared-session-model`,n,t,e.create]:null,async()=>{let t=Cs(lh(),e.agentId),[n,r]=await Promise.all([Ln(),t?.modelRef??rG(e.agentId).then(e=>e.config.models.chat.primary)]),i=n.filter(e=>e.id===r||e.id.endsWith(`/${r}`)),a=n.find(e=>e.id===r)??(i.length===1?i[0]:void 0);return{models:n,selection:{model:a?.id??r,thinkingLevel:a?.thinking?Fs(a.thinking,t?.thinkingLevel,t?.thinkingByModel?.[a.id]):t?.thinkingLevel??`medium`}}},{revalidateOnFocus:!1}),s=r?.preparation===e?r?.selection:a?.selection,c=a?.models.find(e=>e.id===s?.model),l=!!(s?.model&&c),u=r?.preparation===e,d=(0,Z.useRef)({preparation:e,selection:s,ready:l,explicitlySelected:u});d.current={preparation:e,selection:s,ready:l,explicitlySelected:u};let f=(0,Z.useMemo)(()=>e&&{...e,create:async t=>{let n=d.current;if(n.preparation!==e||!n.ready||!n.selection)throw Error(`Model configuration is not ready`);let r=n.selection,i=await e.create(t,r);return n.explicitlySelected&&fh(e.agentId,{modelRef:r.model,thinkingLevel:r.thinkingLevel}),i}},[e]),p=async(t,n)=>{if(!e||!a)throw Error(`Model configuration is not ready`);let r=a.models.find(e=>e.id===t);if(!r)throw Error(`Model is unavailable`);let o=Cs(lh(),e.agentId)?.thinkingByModel?.[t];i({preparation:e,selection:{model:t,thinkingLevel:r.thinking?Fs(r.thinking,n??s?.thinkingLevel,n===void 0?o:void 0):n??s?.thinkingLevel??`medium`}})};return{preparation:f,model:s?.model??``,thinkingLevel:s?.thinkingLevel??`medium`,modelSupportsThinking:!!c?.reasoning,ready:l,error:o,onModelChange:e=>p(e),onThinkingChange:e=>p(s?.model??``,e)}}async function n6(e){let t=e.trim();if(!t)return!1;try{return!!(await Ln()).find(e=>e.id===t)?.reasoning}catch{return!1}}function r6(e){let{sessionMgrRef:t,routeConversationIdRef:n,sendingRef:r,streamingRef:i,loadingSessionRef:a,messagesLenRef:o,thinkingSupportGenRef:s,navigateToSession:c,resolveAgentIdForPost:l,detachForNewConversation:u,conversationId:d,sessionAgentId:f,currentProjectId:p,taskId:m,hasMore:h}=e,g=()=>qb.getState(),_=(0,Z.useRef)(Promise.resolve(void 0)),v=(0,Z.useRef)(null),y=(0,Z.useRef)(0),b=(0,Z.useCallback)(e=>{let t=g().focusedConversationId;if(!e.trim())return++s.current===s.current&&t&&g().patchSessionMeta(t,{modelSupportsThinking:!1}),Promise.resolve();let n=++s.current;return n6(e).then(t=>{if(n!==s.current)return;let r=g().focusedConversationId;r&&g().sessions[r]?.model===e&&g().patchSessionMeta(r,{modelSupportsThinking:t})})},[s]),x=(0,Z.useCallback)(async e=>{try{let n=await t.current.loadSessionAgentConfig(e);x3(e,n),b(n.model)}catch{}},[t,b]),S=(0,Z.useCallback)(()=>{let e=g().focusedConversationId;if(!e||(g().sessions[e]?.name)?.trim())return;let n=++y.current,r=[700,900,900,1e3,1e3],i=a=>{a>=5||n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||window.setTimeout(()=>{n===y.current&&g().focusedConversationId===e&&(g().sessions[e]?.name?.trim()||t.current.fetchSessionName(e).then(t=>{if(n===y.current){if(t){g().patchSessionMeta(e,{name:t});return}i(a+1)}}).catch(()=>{i(a+1)}))},r[a]??900))};i(0)},[t]),C=(0,Z.useCallback)(e=>Q4({chatId:e,routeConversationId:n.current}),[n]),w=(0,Z.useCallback)((e,t)=>{let n=g().getSessionSnapshot(e);n&&(n.streaming||n.sending||n.streamingMsg)?(g().mergeCommittedFromServer(e,t.messages,t.hasMore),t.name!==void 0&&g().patchSessionMeta(e,{name:t.name||null})):g().setCommittedSnapshot(e,{messages:t.messages,hasMore:t.hasMore,name:t.name}),C(e)&&(v.current=t.nextBeforeCursor??null)},[C]),T=(0,Z.useCallback)(async(e,r=0,i)=>{let o=async(e,r,i)=>{let s=r===0&&!i;a.current=!0;let u=s&&jb(g().sessions[e]?.historyStatus);u&&g().setSessionHistoryStatus(e,`loading`);try{let{messages:n,hasMore:a,name:o,nextBeforeCursor:c}=await t.current.loadSession(e,r,i,m);if(s){if(g().setCommittedSnapshot(e,{messages:n,hasMore:a,name:o??null}),!C(e))return n;v.current=c??null;let r=await t.current.loadSessionAgentConfig(e);return C(e)?(x3(e,r),b(r.model),n):n}if(v.current=c??null,!C(e))return;g().prependHistoryMessages(e,n,a);return}catch(a){if(r===0&&!i){v.current=null;let r=a instanceof Error?a.message:`Failed to load session`;g().setShellError(/^HTTP 404\b/.test(r)?JSON.stringify(Zg(r)):`Failed to load session`);let i=Y4(n.current);if(i&&i===e)return;let s=await t.current.loadSessions().catch(()=>[]),u=s.filter(e=>(e.messageCount??0)>0)[0]??s[0];if(u)return c(u.key,!0),await o(u.key,0,null);{v.current=null;let e=l();q3({sessionMgr:t.current,agentId:e,currentConversationId:null,routeConversationId:null,navigateToSession:c,replaceNavigate:!0,onOpened:e=>{g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})}}return}finally{a.current=!1,u&&g().sessions[e]?.historyStatus===`loading`&&g().setSessionHistoryStatus(e,`ready`)}},s=_.current,u,d=new Promise(e=>{u=e});_.current=s.then(()=>d),await s;try{return await o(e,r,i)}finally{u()}},[n,C,r,i,a,c,b,l,t,m]),E=(0,Z.useCallback)(async()=>{let e=g().focusedConversationId;if(!(!e||g().loadingMore||!h)){g().setLoadingMore(!0);try{await T(e,o.current,v.current)}finally{g().setLoadingMore(!1)}}},[h,T,o]),D=(0,Z.useCallback)(async(e,n)=>{if(!d)throw Error(`No active session`);let r=g().sessions[d];if(r?.modelConfigSaving)throw Error(`Model configuration is being saved`);g().patchSessionMeta(d,{modelConfigSaving:!0});try{if(g().setShellError(null),n===void 0){let t=(await Ln()).find(t=>t.id===e);if(t?.thinking){let i=Cs(lh(),f)?.thinkingByModel?.[e];n=Fs(t.thinking,r?.thinkingLevel,i)}}let i=m?await t.current.patchTaskConversationModel(m,e,n,r?.configVersion):await t.current.patchSessionAgentConfig(d,{model:e,thinkingLevel:n,configVersion:r?.configVersion});x3(d,i),fh(f,{modelRef:i.model,thinkingLevel:i.thinkingLevel}),b(i.model)}catch(e){let n=e instanceof Error?e.message:`Failed to update model configuration`;g().setShellError(n);let r=await t.current.loadSessionAgentConfig(d).catch(()=>null);throw r&&x3(d,r),e}finally{g().patchSessionMeta(d,{modelConfigSaving:!1})}},[d,f,m,t,b]);return{refreshModelThinkingSupport:b,pollSessionNameAfterTurn:S,applyLoadedSessionSnapshot:w,loadSessionById:T,loadMoreMessages:E,onSessionModelChange:D,onSessionThinkingLevelChange:(0,Z.useCallback)(async e=>{let t=d?g().sessions[d]?.model:void 0;t&&await D(t,e)},[d,D]),onSessionWorkingDirectoryChange:(0,Z.useCallback)(async e=>{let n=e.trim();if(!(!d||!n))try{g().setShellError(null),await t.current.patchSessionAgentConfig(d,{workingDirectory:n}),await x(d)}catch(e){throw g().setShellError(e instanceof Error?e.message:`Failed to update working directory`),e}},[x,d,t]),createNewSession:(0,Z.useCallback)(async e=>{g().setShellError(null);let n=l(),r=Cs(lh(),n??`main`);await q3({sessionMgr:t.current,agentId:n,currentConversationId:d,routeConversationId:d,forceNew:e?.forceNew,temporary:e?.temporary,executionMode:e?.executionMode,projectId:e?.projectId===void 0?p:e.projectId,initialAgentConfig:r?{model:r.modelRef,...r.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{}}:void 0,navigateToSession:c,onOpened:e=>{u(),v.current=null,g().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:null}),x(e)}})},[u,c,l,p,d,t,x]),resetCurrentSession:(0,Z.useCallback)(async()=>{if(d){g().setShellError(null);try{await t.current.resetSession(d),u(),v.current=null,g().setCommittedSnapshot(d,{messages:[],hasMore:!1,name:null}),x(d)}catch(e){g().setShellError(e instanceof Error?e.message:`Failed to reset session`)}}},[x,d,u,t])}}function i6(e){return new Promise(t=>{Promise.resolve().then(()=>e(()=>t(!0))).then(()=>t(!1),()=>t(!1))})}function a6(e,t,n){return e.map(e=>{if(e.clientSubmissionId!==t)return e;if(n===`failed`)return{...e,deliveryStatus:`failed`};let r={...e};return delete r.clientSubmissionId,delete r.deliveryStatus,delete r.pendingAppContext,r})}function o6(e){return e!==`suspended`}function s6(e){let{chatId:t,shouldApplyStreamUpdate:n,beforeAssistantDelta:r,reconcileHydratedAssistantText:i,setStreamingOnStreamStart:a,clearResumeRunIdOnBackgroundTerminal:o,clearResumeRunIdOnVisibleError:s,setError:c,sessionMgrRef:l,applyLoadedSessionSnapshot:u,finalizeMessage:d,fq:f}=e,p=()=>qb.getState(),m=()=>l.current.loadSession(t,0).then(e=>u(t,e)).catch(()=>{}),h=new Map,g,_=()=>{if(g!==void 0&&(window.clearTimeout(g),g=void 0),h.size===0)return;let e=Array.from(h.entries());h.clear(),r(),p().mutateSessionStreaming(t,t=>{for(let[n,r]of e)wb(t.content,n,r)})},v=(e,t)=>{h.set(e,`${h.get(e)??``}${t}`),g===void 0&&(g=window.setTimeout(_,120))},y=e=>{p().clearStreamingState(t),o&&ib.setResumeRunId(t,null),p().setSessionFlags(t,{sending:!1,streaming:!1}),p().setSessionProgress(t,null),o6(e)&&f.dismissClarifyForSession(t),m()};return{onReplayGap:m,onUserMessage:e=>{n(t)&&p().appendUserMessageIfMissing(t,e)},onWorkflowRunStarted:()=>{window.dispatchEvent(new CustomEvent(`workflow-run-started-from-chat`,{detail:{conversationId:t}}))},onStreamStart:e=>{tx(t),r(),p().updateSessionMessages(t,t=>gv(t,e)),p().mutateSessionStreaming(t,t=>{t.turnId=e}),p().setSessionFlags(t,{streaming:!0})},onToken:(e,a,o)=>{r(),p().mutateSessionStreaming(t,t=>{vb(t.content,e,a,{offset:o,reconcileHydratedSegment:i})}),n(t)&&p().setSessionFlags(t,{streaming:!0})},onAssistantMessageEnd:(e,n,i)=>{r(),p().mutateSessionStreaming(t,t=>{yb(t.content,e,n),i&&(t.usage=i)})},onThinking:(e,n)=>{r(),p().mutateSessionStreaming(t,t=>{!n&&e===``?pb(t.content):mb(t.content,e,n)})},onThinkingEnd:()=>{r(),p().mutateSessionStreaming(t,e=>{hb(e.content)})},onToolStart:(e,n,i,a,o)=>{r(),p().mutateSessionStreaming(t,t=>{Eb(t.content,e,n,i,a,o)}),p().setSessionFlags(t,{streaming:!0})},onToolEnd:(e,n,i,a,o,s)=>{r(),p().mutateSessionStreaming(t,t=>{Db(t.content,e,n,i,a,o,s)})},onToolUpdate:(e,n,i)=>{r(),p().mutateSessionStreaming(t,t=>{Ob(t.content,e,n,i)})},onTaskPlanUpdated:e=>{p().setSessionTaskPlan(t,e)},onTurnOutcome:e=>{r(),p().mutateSessionStreaming(t,t=>{t.outcome=e})},onReview:({review:e})=>{r(),p().mutateSessionStreaming(t,t=>{xb(t.content,e)}),n(t)&&p().setSessionFlags(t,{streaming:!0})},onReviewStart:e=>{r(),p().mutateSessionStreaming(t,t=>{Cb(t.content,e)}),n(t)&&p().setSessionFlags(t,{streaming:!0})},onReviewDelta:({reviewId:e,delta:t})=>{v(e,t)},onReviewEnd:({reviewId:e,status:n,message:i})=>{_(),r(),p().mutateSessionStreaming(t,t=>{Tb(t.content,e,n,i)})},onProgress:e=>{p().setSessionProgress(t,e)},onTtsAudio:e=>{n(t)&&p().appendAttachmentToCurrentAssistant(t,{name:e.name,mimeType:e.mimeType,type:`voice`,uri:e.uri,size:0},{attachTo:e.attachTo,messageId:e.messageId})},onCompaction:e=>{if(!n(t))return;let r=xe(Ee.getState().language).chat;if(e.status===`started`)p().setSessionProgress(t,{stage:`compaction`,message:r.compactingContext,timestamp:Date.now()});else if(e.status===`completed`){let n=e.tokensBefore&&e.tokensAfter?` (${r.contextTokensFreed.replace(`{{count}}`,String(Math.round((e.tokensBefore-e.tokensAfter)/1e3)))})`:``;p().setSessionProgress(t,{stage:`compaction`,message:`${r.contextCompacted}${n}`,timestamp:Date.now()})}else p().setSessionProgress(t,null)},onClarifyRequest:f.makeOnClarifyRequest(t),onSessionConfigUpdated:()=>{p().patchSessionMeta(t,{modelConfigSaving:!0}),l.current.loadSessionAgentConfig(t).then(e=>x3(t,e)).catch(()=>{}).finally(()=>p().patchSessionMeta(t,{modelConfigSaving:!1}))},onResult:({status:e})=>{_();let r=n(t);if(ib.takeUserAborted(t)||e===`cancelled`){ix(t),r?d(t,e):y(e);return}if(e===`error`){if(rx(t,!r),!r){y(e);return}d(t,e),m();return}if(e===`suspended`?ax(t):nx(t,!r),!r){y(e);return}d(t,e)},onError:e=>{_();let r=n(t);if(rx(t,!r),!r){y(`error`);return}p().clearStreamingState(t),s&&ib.setResumeRunId(t,null),p().setSessionFlags(t,{sending:!1,streaming:!1}),p().setSessionProgress(t,null),c(e),f.dismissClarifyForSession(t)}}}function c6(e){return Yb(e)?.streamingMsg??null}var l6=80;function u6(e){let t=e.trim();(t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`))&&(t=t.slice(1,-1).trim());let n=t.indexOf(`
120
- `);return n!==-1&&(t=t.slice(0,n).trim()),t.length>l6&&(t=t.slice(0,l6-1).trimEnd()+`…`),t}function d6(e){let t=e.trimStart();if(!/^##\s+Skill:\s*\S+/i.test(t))return e;let n=/(?:^|\r?\n)\*\*Arguments\*\*:\s*/gi,r=-1;for(;n.exec(t)!==null;)r=n.lastIndex;if(r!==-1){let e=t.slice(r).trim();if(e)return e}return(t.split(/\r?\n/)[0]?.trim()??``).replace(/^##\s+Skill:\s*/i,``).trim()}function f6(e){let t=e.trimStart().match(/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/i);return t&&(t[2]?.trim()||t[1]?.trim())||e}function p6(e){let t=f6(d6(ov([{type:`text`,text:e}]))).split(/\n/)[0]?.trim();if(!t)return null;let n=u6(t);return n.length>0?n:null}function m6(e,t){let n=e.trim(),r=t.trim();!n||!r||window.dispatchEvent(new CustomEvent(`session-updated`,{detail:{key:n,name:r},bubbles:!0}))}var h6=new Set([`new`,`reset`,`restart`]),g6=new Set([...h6,`clear`,`archive`]);function _6(e){let t=e.trim(),n=/^\/([^\s@]+)(?:@[^\s]+)?(?:\s+([\s\S]*))?$/.exec(t);return n?{name:n[1].toLowerCase(),args:n[2]?.trim()??``}:null}function v6(e){let t=_6(e);return!!(t&&h6.has(t.name)&&!t.args)}function y6(e){let t=_6(e);return!!(t&&g6.has(t.name))}function b6(e){let{conversationId:t,taskId:n,thinkingLevel:r,modelSupportsThinking:i,conversationIdRef:a,sendingRef:o,streamingRef:s,sessionMgrRef:c,sendMessageRef:l,shouldApplyStreamUpdate:u,fq:d,applyLoadedSessionSnapshot:f,loadSessionById:p,resetCurrentSession:m,pollSessionNameAfterTurn:h}=e,g=()=>qb.getState(),_=e=>g().setShellError(e),v=()=>g().setShellError(null),y=(0,Z.useCallback)((e,t)=>{let n=e??a.current;if(n&&!u(n))return;let r=n?c6(n):null,i=null;if(r){let e=sb(r,Date.now());hb(e.content),gb(e.content),Sb(e.content),e.completedAt=Date.now(),i=cb(e)}i&&ob(i)&&n?g().finalizeStreamingTurn(n,i):n&&g().clearStreamingState(n),o.current=!1,s.current=!1,n&&ib.resetRunTracking(n),(!t||o6(t))&&d.dismissClarify(),h();let c=a.current;c&&window.setTimeout(()=>{a.current===c&&(o.current||s.current||p(c,0))},400)},[o,s,a,d.dismissClarify,d.pendingFollowUpsRef,h,p,u]),b=(0,Z.useCallback)(async(e,t)=>{if(!u(e))return;let r=await a3(e);if(!r){let t=ib.getResumeRunId(e);t&&ib.reconcileInactive(e,t),g().clearStreamingState(e),ix(e);return}if(ib.isTrackingRun(e,r))return;let i=t??Xb(e),a=Yb(e)?.hasMore??!1;try{let t=await c.current.loadSession(e,0,void 0,n);g().mergeCommittedFromServer(e,t.messages,t.hasMore),i=t.messages,a=t.hasMore}catch{}ib.setUserAborted(e,!1),ib.setResumeRunId(e,r),o.current=!0,s.current=!0,g().seedSessionIfEmpty(e,i,!0,!0,a),g().setSessionFlags(e,{sending:!0,streaming:!0}),g().setSessionProgress(e,null),tx(e);let l=!1,m=()=>{if(l||!u(e))return;l=!0;let t=n3(Xb(e),r);t&&g().applyHydratedTail(e,t.messagesWithoutTail,cb(t.tail))},h=()=>{g().clearStreamingState(e),ib.getResumeRunId(e)===r&&ib.setResumeRunId(e,null),u(e)&&(o.current=!1,s.current=!1)};try{let t=s6({chatId:e,shouldApplyStreamUpdate:u,beforeAssistantDelta:m,reconcileHydratedAssistantText:!0,setStreamingOnStreamStart:!1,clearResumeRunIdOnBackgroundTerminal:!0,clearResumeRunIdOnVisibleError:!0,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:y,fq:d});await ib.senderFor(e).resume(r,e,t)||(ix(e),h(),await p(e,0).catch(()=>void 0))}catch(t){t.name!==`AbortError`&&console.error(`[chat] resume failed:`,t),ix(e),h()}finally{ib.releaseIdleSender(e)}},[o,s,u,c,f,y,p,n]),x=(0,Z.useCallback)(async(e,t,c,u)=>{if(!e.trim()&&!t?.length&&!u?.length)return;let f=a.current;if(!f||!o.current&&!s.current&&!ib.isStreamingFor(f))return;let p=e.trim();if(n&&y6(p)){_(`A task has one continuous conversation.`);return}if(v6(p)&&!t?.length){await m();return}d.dismissClarifyAndClearPending();let h=i?c??r:`off`;ib.setUserAborted(f,!0),ib.abort(f),o.current=!1,s.current=!1,y(f),queueMicrotask(()=>{l.current(e,t,h,u)})},[o,s,a,d.dismissClarifyAndClearPending,i,r,y,l,m,n]),S=(0,Z.useCallback)(async(e,a,l,h,b,x,S,C)=>{if(!t||!u(t)||!e.trim()&&!a?.length&&!h?.length||o.current||s.current||ib.isStreamingFor(t))return!1;let w=e.trim();if(n&&y6(w))return _(`A task has one continuous conversation.`),!1;if(v6(w)&&!a?.length){await m();return}let T=i?l??r:`off`,E=t,D=crypto.randomUUID(),O=Xb(E),k=C?O.filter(e=>e.clientSubmissionId!==C):O,A=b?k.findIndex(e=>e.role===`user`&&e.turnId===b):-1;if(b&&A<0)return!1;ib.setUserAborted(E,!1),o.current=!0,s.current=!1,v(),d.dismissClarify();let j=A>=0?k.slice(0,A):k,M=os(e)??void 0,N=new Map(h?.flatMap(e=>e.refId?[[e.refId,e.title]]:[])??[]),P=M?cs(M,e=>N.get(e)):e,F=[...j,{role:`user`,content:P?[{type:`text`,text:P}]:[],userTurnDocument:M,deliveryStatus:`sending`,clientSubmissionId:D,pendingAppContext:x===void 0?void 0:structuredClone(x),attachments:a,contextRefs:h?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,version:e.expectedVersion,title:e.title,fileKind:e.fileKind})),timestamp:Date.now()}];S?.(D);let I=Yb(E);if(g().initSessionSnapshot(E,{...I??{...rb(),historyStatus:`ready`,hasMore:!1,streamingMsg:null,progress:null,taskPlan:null,sending:!1,streaming:!1},messages:F,hasMore:I?.hasMore??!1,streamingMsg:null,progress:null,sending:!0,streaming:!1}),tx(E),!I?.name?.trim()&&P.trim()){let e=p6(P.trim());e&&(g().patchSessionMeta(E,{name:e}),m6(E,e))}let L=e=>{g().updateSessionMessages(E,t=>a6(t,D,e))};return i6(async t=>{let r=!1;try{await c.current.ensureSessionExists(E);let i=s6({chatId:E,shouldApplyStreamUpdate:u,beforeAssistantDelta:()=>{},reconcileHydratedAssistantText:!1,setStreamingOnStreamStart:!0,clearResumeRunIdOnBackgroundTerminal:!1,clearResumeRunIdOnVisibleError:!1,setError:_,sessionMgrRef:c,applyLoadedSessionSnapshot:f,finalizeMessage:y,fq:d});i.onInputAccepted=()=>{r=!0,L(`accepted`),t()},await ib.senderFor(E).send(e,E,a,T,i,n,b,h,x)}catch(e){e.name===`AbortError`?ix(E):(g().clearStreamingState(E),ix(E),u(E)&&_(x&&e instanceof Error?e.message:JSON.stringify(Xg())),b&&p(E,0))}finally{r||L(`failed`),u(E)&&(o.current=!1,s.current=!1),g().setSessionFlags(E,{sending:!1}),ib.releaseIdleSender(E)}})},[t,r,i,o,s,u,c,f,y,d.dismissClarify,m,n,p]);return{finalizeMessage:y,tryResumeAgentRun:b,sendMessage:S,replaceLatestUserTurn:(0,Z.useCallback)((e,t,n,r,i)=>S(t,n,r,i,e),[S]),interruptAndSend:x,abort:(0,Z.useCallback)(()=>{let e=a.current;e&&(ib.setUserAborted(e,!0),d.dismissClarifyAndClearPending(),ib.abort(e),e&&ix(e),o.current=!1,s.current=!1,y(e),e&&window.setTimeout(()=>{p(e,0)},300))},[d.dismissClarifyAndClearPending,o,s,y,a,p]),deleteMessageRound:(0,Z.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=Xb(t),r=n[e];if(!r||!lv(r.role))return;if(r.deliveryStatus===`failed`){let r=[...n];r.splice(e,1),g().updateSessionMessages(t,()=>r);return}let i=uv(n,e);if(i===null)return;let l=dv(n,e),u=[...n];u.splice(e,l),g().updateSessionMessages(t,()=>u),c.current.deleteMessages(t,{userRoundIndex:i}).catch(()=>{p(t,0)})},[a,o,s,c,p]),retryUserMessageRound:(0,Z.useCallback)(e=>{let t=a.current;if(!t||o.current||s.current)return;let n=Xb(t),r=n[e];if(!r||!lv(r.role))return;for(let t=e+1;t<n.length;t++){let e=n[t];if(e&&lv(e.role))return}let i=r.userTurnDocument?ls(r.userTurnDocument):ov(r.content),c=cv(r.attachments);if(!i.trim()&&!c?.length&&!r.contextRefs?.length)return;let u=r.contextRefs?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind})),d=r.deliveryStatus===`failed`?r.clientSubmissionId:void 0;!d&&!r.turnId||l.current(i,c,void 0,u,r.turnId,r.pendingAppContext,void 0,d).catch(()=>{p(t,0)})},[a,o,s,p,l])}}function x6(e){let t=(0,Q.c)(11),{conversationId:n,conversationIdRef:r,sessionMgrRef:i,loadSessionById:a,loadTimelineById:o,applyAgentConfig:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],t[0]=c):c=t[0],(0,Z.useEffect)(C6,c);let l,u;t[1]!==n||t[2]!==a||t[3]!==o?(l=()=>{let e=e=>{let t=e.detail;!t?.key||t.key!==n||(a(n,0),o(n))};return window.addEventListener(`session-transcript-updated`,e),()=>window.removeEventListener(`session-transcript-updated`,e)},u=[n,a,o],t[1]=n,t[2]=a,t[3]=o,t[4]=l,t[5]=u):(l=t[4],u=t[5]),(0,Z.useEffect)(l,u);let d,f;t[6]!==s||t[7]!==r||t[8]!==i?(d=()=>{let e=e=>{if(tn(e.detail))return;let t=r.current;t&&i.current.loadSessionAgentConfig(t).then(e=>{s(t,e)}).catch(S6)};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},f=[r,i,s],t[6]=s,t[7]=r,t[8]=i,t[9]=d,t[10]=f):(d=t[9],f=t[10]),(0,Z.useEffect)(d,f)}function S6(){}function C6(){let e=w6;return window.addEventListener(`session-updated`,e),()=>window.removeEventListener(`session-updated`,e)}function w6(e){let t=e.detail;!t?.key||t.name===void 0||qb.getState().patchSessionMeta(t.key,{name:t.name||null})}function T6(e){let t=l(),{isNewRoute:n,forceNewChat:r,decodedKey:i,viewConversationId:a,routedFocusedConversationId:o,routeConversationIdRef:s,locationKey:c,locationSearch:u,locationState:d}=Z3(e?.fixedConversationId),f=(0,Z.useRef)(new y3),p=(0,Z.useRef)(!1),m=(0,Z.useRef)(!1),h=(0,Z.useRef)(!1),g=(0,Z.useRef)(0),_=(0,Z.useRef)(!1),[v,y]=(0,Z.useState)([]),b=(0,Z.useRef)(async()=>{}),x=(0,Z.useRef)(0),S=o,C=qb(e=>e.initLoading),w=qb(e=>e.loadingMore),T=qb(e=>e.shellError),E=a,D=qb(e=>E?e.sessions[E]:void 0),O=E?Jb(D):!1,k=O?D?.streaming??!1:!1,A=O?D?.sending??!1:!1,j=O?D?.progress??null:null,M=O?D?.taskPlan??null:null,N=D?.hasMore??!1,P=D?.name??null,F=D?.model??``,I=Zt(zn,Ln,{revalidateOnFocus:!1}),L=D?.configVersion!==void 0&&!!I.data?.some(e=>e.id===F),R=D?.modelConfigSaving??!1,z=D?.thinkingLevel??`medium`,B=D?.reasoningLevel??`on`,V=D?.modelSupportsThinking??!1,H=D?.effectiveWorkspacePath??``,U=D?.workspaceSource??`agent_default_root`,W=D?.userContextMode??`enabled`;(0,Z.useEffect)(()=>{!E||A||k||f.current.loadSessionAgentConfig(E).then(e=>x3(E,e)).catch(()=>void 0)},[E,A,k]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail.conversationId;f.current.loadSessionAgentConfig(t).then(e=>x3(t,e)).catch(()=>void 0)};return window.addEventListener(`session-model-config-stale`,e),()=>window.removeEventListener(`session-model-config-stale`,e)},[]),(0,Z.useEffect)(()=>{x.current=D?.messages.length??0},[D?.messages.length]),(0,Z.useEffect)(()=>{m.current=A,h.current=k},[A,k]);let{token:G,chatAgentsData:ee,resolveAgentIdForPost:te,onChatAgentChange:ne,displayAgentId:re,showChatAgentSelector:ie,currentSessionProjectId:ae}=E3({navigate:t,conversationIdRef:$3,conversationId:S,isNewRoute:n,locationState:d,locationSearch:u}),oe=i!==void 0&&S!==i,se=!!(i&&D?.historyStatus===`loading`&&!oe),ce=(0,Z.useMemo)(()=>C&&(S==null||i===void 0),[C,S,i]),le=C3({isNewRoute:n,sessionRoutePending:oe,showSessionLoading:ce,sessionContentLoading:se,messageCount:D?.messages.length??0}),ue=(0,Z.useCallback)((e,n=!1,r)=>{let i=r??``;t({pathname:`/chat/${encodeURIComponent(e)}`,search:i},{replace:n})},[t]),de=(0,Z.useCallback)(e=>X4({streamConversationId:e,routeConversationId:s.current}),[s]),fe=(0,Z.useCallback)(()=>{S3({sendingRef:m,streamingRef:h})},[]),pe=T3({conversationId:S,decodedKey:i,conversationIdRef:$3,sendingRef:m,streamingRef:h,modelSupportsThinking:V,thinkingLevel:z,shouldApplyStreamUpdate:de}),me=(0,Z.useCallback)(()=>{pe.clearVisibleClarify();let e=$3.current;e&&ib.resetRunTracking(e),r3(fe)},[pe.clearVisibleClarify,$3,fe]),{refreshModelThinkingSupport:he,pollSessionNameAfterTurn:ge,applyLoadedSessionSnapshot:_e,loadSessionById:ve,loadMoreMessages:ye,onSessionModelChange:be,onSessionThinkingLevelChange:xe,onSessionWorkingDirectoryChange:K,createNewSession:q,resetCurrentSession:Se}=r6({sessionMgrRef:f,routeConversationIdRef:s,sendingRef:m,streamingRef:h,loadingSessionRef:p,messagesLenRef:x,thinkingSupportGenRef:g,navigateToSession:ue,resolveAgentIdForPost:te,detachForNewConversation:me,conversationId:S,sessionAgentId:re,currentProjectId:ae,hasMore:N,taskId:e?.taskId}),Ce=(0,Z.useCallback)(e=>{if(!Z4({cacheConversationId:e,routeConversationId:s.current}))return!1;let t=Yb(e);return!t||!Jb(t)&&!Hy(e)&&!ib.isStreamingFor(e)?!1:(m.current=t.sending,h.current=t.streaming,!0)},[s]),{tryResumeAgentRun:we,sendMessage:Te,replaceLatestUserTurn:Ee,interruptAndSend:De,abort:Oe,deleteMessageRound:J,retryUserMessageRound:ke}=b6({conversationId:S,taskId:e?.taskId,thinkingLevel:z,modelSupportsThinking:V,conversationIdRef:$3,sendingRef:m,streamingRef:h,sessionMgrRef:f,sendMessageRef:b,shouldApplyStreamUpdate:de,fq:pe,applyLoadedSessionSnapshot:_e,loadSessionById:ve,resetCurrentSession:Se,pollSessionNameAfterTurn:ge});(0,Z.useEffect)(()=>{n&&me()},[n,me]);let Ae=(0,Z.useMemo)(()=>t3({viewConversationId:a,conversationId:E,messages:D?.messages??[],streamingMsg:O?D?.streamingMsg??null:null}),[a,E,D?.messages,D?.streamingMsg,O]),je=(0,Z.useCallback)((e,t)=>{qb.getState().setCommittedSnapshot(e,{messages:[],hasMore:!1,name:t}),fe()},[fe]),Me=(0,Z.useCallback)((e,t)=>{x3(e,t),he(t.model)},[he]),Ne=(0,Z.useCallback)(e=>{let t=qb.getState();e.loading!==void 0&&t.setInitLoading(e.loading),e.error!==void 0&&t.setShellError(e.error)},[]),Pe=(0,Z.useCallback)(async t=>{try{let n=await f.current.loadTimeline(t,e?.taskId);if(s.current!==t)return;y(n)}catch{s.current===t&&y([])}},[s,e?.taskId]);(0,Z.useEffect)(()=>{if(n||!S){y([]);return}Pe(S)},[S,n,Pe]),x6({conversationId:S,conversationIdRef:$3,sendingRef:m,streamingRef:h,sessionMgrRef:f,loadSessionById:ve,loadTimelineById:Pe,applyAgentConfig:Me});let Fe=e6({token:G,isNewRoute:n,forceNewChat:r,temporary:d?.temporary===!0,requestedAgentId:typeof d?.agentId==`string`?d.agentId:void 0,decodedKey:i,locationKey:c,locationSearch:u,sessionMgrRef:f,resolveAgentIdForPost:te,navigateToSession:ue,loadSessionById:ve,tryResumeAgentRun:we,restoreLiveCacheIfNeeded:Ce,adoptEmptySession:je,applyAgentConfig:Me,patchInitUi:Ne}),Ie=t6(Fe);return(0,Z.useEffect)(()=>{Fe&&Ie.error&&qb.getState().setShellError(Ie.error instanceof Error?Ie.error.message:`Failed to load model configuration`)},[Fe,Ie.error]),(0,Z.useEffect)(()=>{let e=e=>{let t=e.detail,n=t?.conversationId,r=t?.runId;!n||!r?.trim()||(Wy(n,r),ib.setResumeRunId(n,r),de(n)&&(ib.isTrackingRun(n,r)||queueMicrotask(()=>{de(n)&&(ib.isTrackingRun(n,r)||we(n,Xb(n)))})))};return window.addEventListener(`run-started`,e),()=>window.removeEventListener(`run-started`,e)},[we,de]),(0,Z.useEffect)(()=>{let e=k||A,t=_.current;if(_.current=e,!t||e)return;let n=$3.current;n&&queueMicrotask(()=>{!n||!de(n)||ib.isStreamingFor(n)||Hy(n)&&we(n,Xb(n))})},[k,A,we,de]),b.current=Te,{auth:{hasToken:!!G},session:{projectPreparation:Ie.preparation,conversationId:S,sessionName:P,decodedKey:i,sessionRoutePending:oe,sessionContentLoading:se,showSessionLoading:ce,conversationPhase:le,loading:C,sessionModel:Fe?Ie.model:F,modelConfigReady:Fe?Ie.ready:L,modelConfigSaving:R,thinkingLevel:Fe?Ie.thinkingLevel:z,onSessionThinkingLevelChange:Fe?Ie.onThinkingChange:xe,onSessionWorkingDirectoryChange:K,reasoningLevel:B,modelSupportsThinking:Fe?Ie.modelSupportsThinking:V,effectiveWorkspacePath:H,workspaceSource:U,userContextMode:Fe?.temporary?`temporary`:W,hasMore:N,loadingMore:w,loadMoreMessages:ye,onSessionModelChange:Fe?Ie.onModelChange:be,createNewSession:q,sessionManager:f.current},messages:{items:Ae},timeline:{items:v,refresh:Pe},stream:{error:T,streaming:k,sending:A,progress:j,taskPlan:M,sendMessage:Te,replaceLatestUserTurn:Ee,abort:Oe,interruptAndSend:De,deleteMessageRound:J,retryUserMessageRound:ke},followUp:{addPendingFollowUp:pe.addPendingFollowUp,pendingFollowUps:pe.pendingFollowUps,editingFollowUpId:pe.editingFollowUpId,beginEditFollowUp:pe.beginEditFollowUp,cancelEditFollowUp:pe.cancelEditFollowUp,commitEditFollowUp:pe.commitEditFollowUp,removePendingFollowUp:pe.removePendingFollowUp,movePendingFollowUp:pe.movePendingFollowUp,reorderPendingFollowUp:pe.reorderPendingFollowUp,steerPendingFollowUp:pe.steerPendingFollowUp,steeringFollowUpId:pe.steeringFollowUpId},clarify:{clarifyPrompt:pe.clarifyPrompt,clarifySubmitting:pe.clarifySubmitting,clarifySubmitError:pe.clarifySubmitError,submitClarifyAnswer:pe.submitClarifyAnswer,letAgentDecideClarification:pe.letAgentDecideClarification,cancelClarification:pe.cancelClarification},agents:{chatAgents:ee,displayAgentId:Fe?.agentId??re,showChatAgentSelector:ie,onChatAgentChange:ne}}}function E6(e){let t=(0,Q.c)(8),n=Se(D6),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`chat-session-meta`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>{let e=await $h(i),t=e.customData?.workflowRunId,n=typeof t==`string`&&t.trim()?t.trim():null,r=typeof e.sessionType==`string`&&e.sessionType.trim()?e.sessionType.trim():null,a=typeof e.routing?.agentId==`string`&&e.routing.agentId.trim()?e.routing.agentId.trim():null,o=e.customData?.sourceBinding,s=o&&typeof o==`object`?o:null,c=s?.kind===`note`&&typeof s.sourceId==`string`&&s.sourceId.trim()?s.sourceId.trim():null,l=typeof e.parentConversationId==`string`&&e.parentConversationId.trim()?e.parentConversationId.trim():null,u=e.customData?.forkedFromSessionName;return{identity:{sourceChannel:e.sourceChannel,sessionType:e.sessionType,customData:e.customData},workflowRunId:n,ownerAgentId:a,sessionType:r,sourceNoteId:c,sourceNoteTitle:null,parentConversationId:l,forkedFromSessionName:typeof u==`string`&&u.trim()?u.trim():null}},t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],Zt(a,o,s)}function D6(e){return e.conversationId}function O6(e,t){if(!e)return``;let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(0,t-3)).trimEnd()}...`}function k6(e,t){return O6(av(e??``),t)}function A6(e,t){return Kc(e,t)}function j6(e){return e===`context`||e===`branch`||e===`compaction`?e:null}function M6(e){return O6(e.preview||e.title,72)||e.kind}function N6(e,t){let n=[],r=null,i=0;for(let a of e){if(a.displayIndex!==void 0&&(i=a.displayIndex),a.kind===`turn`&&a.role===`user`){let e=a.turn||n.length+1;r={id:a.id,messageIndex:a.displayIndex??i,ordinal:e,title:t.turn.replace(`{{count}}`,String(e)),preview:k6(a.preview||a.title,88)||t.messageFallback,...a.timestamp===void 0?{}:{timestamp:a.timestamp},tools:[],events:[]},n.push(r);continue}if(!r)continue;if(a.kind===`tool`||a.kind===`file`||a.kind===`command`){let e=a.meta?.toolName||a.title||a.kind,n=a.kind===`file`||a.kind===`command`?a.title:A6(e,t),i=`${a.id}:${e}`;r.tools.some(e=>e.key===i)||r.tools.push({key:i,label:n,running:a.status===`running`});continue}let e=j6(a.kind);if(!e)continue;let o=`${a.id}:${a.kind}`;r.events.some(e=>e.key===o)||r.events.push({key:o,label:M6(a),tone:e})}return n}function P6(e,t){return(e===1?t.toolCount_one:t.toolCount_other).replace(`{{count}}`,String(e))}function F6(e,t){let n=e[0]?.id;for(let r of e)r.messageIndex<=t&&(n=r.id);return n}function I6(e){let t=(0,Q.c)(53),{turn:n,active:r,labels:i,currentLabel:a,onSelect:o}=e,s,c,l,u,d,f,p,m;if(t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==o||t[4]!==n.events||t[5]!==n.preview||t[6]!==n.timestamp||t[7]!==n.title||t[8]!==n.tools){let e=n.tools.slice(0,2),h=n.events.slice(0,Math.max(0,3-e.length)),g=Math.max(0,n.tools.length-e.length)+Math.max(0,n.events.length-h.length);d=`button`;let _=r&&`bg-accent-soft/70`;t[17]===_?f=t[18]:(f=K(`flex w-full min-w-0 items-start gap-3 border-b border-edge-subtle px-4 py-3 text-left transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_),t[17]=_,t[18]=f),p=o;let v=r&&`border-accent bg-accent`,y;t[19]===v?y=t[20]:(y=K(`mt-1 size-2.5 shrink-0 rounded-full border border-edge-strong bg-surface-panel`,v),t[19]=v,t[20]=y),t[21]===y?m=t[22]:(m=(0,$.jsx)(`span`,{className:y,"aria-hidden":!0}),t[21]=y,t[22]=m),s=`min-w-0 flex-1`;let b;t[23]===n.preview?b=t[24]:(b=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:n.preview}),t[23]=n.preview,t[24]=b);let x;t[25]!==r||t[26]!==a?(x=r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent px-1.5 py-0.5 text-[10px] font-medium text-on-accent`,children:a}):null,t[25]=r,t[26]=a,t[27]=x):x=t[27],t[28]!==b||t[29]!==x?(c=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[b,x]}),t[28]=b,t[29]=x,t[30]=c):c=t[30];let S;t[31]===n.title?S=t[32]:(S=(0,$.jsx)(`span`,{children:n.title}),t[31]=n.title,t[32]=S);let C;t[33]===n.timestamp?C=t[34]:(C=n.timestamp?(0,$.jsx)(`time`,{suppressHydrationWarning:!0,dateTime:new Date(n.timestamp).toISOString(),children:RI(n.timestamp)}):null,t[33]=n.timestamp,t[34]=C);let w;t[35]!==i||t[36]!==n.tools.length?(w=n.tools.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(Sa,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),P6(n.tools.length,i)]}):null,t[35]=i,t[36]=n.tools.length,t[37]=w):w=t[37],t[38]!==S||t[39]!==C||t[40]!==w?(l=(0,$.jsxs)(`span`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[S,C,w]}),t[38]=S,t[39]=C,t[40]=w,t[41]=l):l=t[41],u=e.length>0||n.events.length>0?(0,$.jsxs)(`span`,{className:`mt-2 flex min-w-0 flex-wrap gap-1.5`,children:[e.map(R6),h.map(L6),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[`+`,g]}):null]}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o,t[4]=n.events,t[5]=n.preview,t[6]=n.timestamp,t[7]=n.title,t[8]=n.tools,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=m}else s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16];let h;t[42]!==s||t[43]!==c||t[44]!==l||t[45]!==u?(h=(0,$.jsxs)(`span`,{className:s,children:[c,l,u]}),t[42]=s,t[43]=c,t[44]=l,t[45]=u,t[46]=h):h=t[46];let g;return t[47]!==d||t[48]!==f||t[49]!==p||t[50]!==m||t[51]!==h?(g=(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:d,className:f,onClick:p,children:[m,h]})}),t[47]=d,t[48]=f,t[49]=p,t[50]=m,t[51]=h,t[52]=g):g=t[52],g}function L6(e){return(0,$.jsxs)(`span`,{className:`inline-flex max-w-[10rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function R6(e){return(0,$.jsxs)(`span`,{className:K(`inline-flex max-w-[9rem] items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,e.running&&`text-accent-fg`),children:[(0,$.jsx)(Sa,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function z6(e){let t=(0,Q.c)(39),{items:n,activeMessageIndex:r,labels:i,openLabel:a,closeLabel:o,currentLabel:s,onSelectMessage:c}=e,l;t[0]!==n||t[1]!==i?(l=N6(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l,[d,f]=(0,Z.useState)(!1);if(u.length<4)return null;let p;t[3]!==r||t[4]!==u?(p=F6(u,r),t[3]=r,t[4]=u,t[5]=p):p=t[5];let m=p,h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(Zr,{className:`size-[1.125rem]`,strokeWidth:1.8,"aria-hidden":!0}),t[6]=h):h=t[6];let g;t[7]===a?g=t[8]:(g=(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-full p-0 sm:size-9 xl:hidden`,"aria-label":a,title:a,children:h})}),t[7]=a,t[8]=g);let _;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim/60 backdrop-blur-[1px] xl:hidden`}),t[9]=_):_=t[9];let v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(v=K(`xopc-dialog-content-pane fixed inset-x-2 bottom-[max(.5rem,env(safe-area-inset-bottom))] z-[90] flex h-[min(72dvh,34rem)] flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,`sm:left-auto sm:right-3 sm:w-[min(24rem,calc(100vw-1.5rem))]`,`md:bottom-[max(1rem,env(safe-area-inset-bottom))] md:right-4 md:h-[min(calc(100dvh-6rem),40rem)]`,`xl:hidden`),t[10]=v):v=t[10];let y;t[11]===i.title?y=t[12]:(y=(0,$.jsx)(tt,{className:`min-w-0 truncate text-base font-semibold text-fg`,children:i.title}),t[11]=i.title,t[12]=y);let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(ye,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===o?x=t[15]:(x=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":o,children:b})}),t[14]=o,t[15]=x);let S;t[16]!==y||t[17]!==x?(S=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-3 border-b border-edge-subtle px-3.5 py-3`,children:[y,x]}),t[16]=y,t[17]=x,t[18]=S):S=t[18];let C;if(t[19]!==m||t[20]!==s||t[21]!==i||t[22]!==c||t[23]!==u){let e;t[25]!==m||t[26]!==s||t[27]!==i||t[28]!==c?(e=e=>(0,$.jsx)(I6,{turn:e,active:e.id===m,labels:i,currentLabel:s,onSelect:()=>{c(e.messageIndex),f(!1)}},e.id),t[25]=m,t[26]=s,t[27]=i,t[28]=c,t[29]=e):e=t[29],C=u.map(e),t[19]=m,t[20]=s,t[21]=i,t[22]=c,t[23]=u,t[24]=C}else C=t[24];let w;t[30]===C?w=t[31]:(w=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(`ol`,{className:`min-w-0`,children:C})}),t[30]=C,t[31]=w);let T;t[32]!==S||t[33]!==w?(T=(0,$.jsxs)($e,{children:[_,(0,$.jsxs)(et,{className:v,"aria-describedby":void 0,children:[S,w]})]}),t[32]=S,t[33]=w,t[34]=T):T=t[34];let E;return t[35]!==d||t[36]!==T||t[37]!==g?(E=(0,$.jsxs)(nt,{open:d,onOpenChange:f,children:[g,T]}),t[35]=d,t[36]=T,t[37]=g,t[38]=E):E=t[38],E}function B6(e){let{active:t,scrubbing:n,distance:r}=e;return n?r===0?`w-7 bg-fg`:r===1?`w-5 bg-fg-muted`:r===2?`w-4 bg-edge-strong/70`:t?`w-3.5 bg-accent`:`w-2.5 bg-edge-strong/45`:t?`w-3.5 bg-accent`:`w-2.5 bg-edge-strong/45`}function V6(e){let t=(0,Q.c)(40),{turn:n,labels:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n.events||t[2]!==n.preview||t[3]!==n.timestamp||t[4]!==n.title||t[5]!==n.tools){let e=n.tools.slice(0,3),p=Math.max(0,n.tools.length-e.length),m=n.events.slice(0,Math.max(0,3-e.length));i=p+Math.max(0,n.events.length-m.length);let h=n.tools.length>0||n.events.length>0?[...e.map(G6),...m.map(W6),...i>0?[`+${i}`]:[]].join(` · `):n.title;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(l=K(`pointer-events-auto absolute right-12 top-1/2 z-[100] w-[min(25rem,calc(100vw-8rem))] -translate-y-1/2`,`rounded-2xl border border-edge bg-surface-panel/95 p-3 text-left shadow-popover backdrop-blur`),t[15]=l):l=t[15],t[16]===n.timestamp?u=t[17]:(u=n.timestamp?(0,$.jsx)(`div`,{className:`mb-1 flex min-w-0 justify-end text-xs`,children:(0,$.jsx)(`time`,{suppressHydrationWarning:!0,className:`shrink-0 tabular-nums text-fg-disabled`,dateTime:new Date(n.timestamp).toISOString(),children:RI(n.timestamp)})}):null,t[16]=n.timestamp,t[17]=u),t[18]===n.preview?d=t[19]:(d=(0,$.jsx)(`div`,{className:`min-w-0 text-sm font-semibold leading-5 text-fg`,children:(0,$.jsx)(`span`,{className:`line-clamp-1`,children:n.preview})}),t[18]=n.preview,t[19]=d),t[20]===h?f=t[21]:(f=(0,$.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:h}),t[20]=h,t[21]=f),a=`mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 text-sm text-fg-subtle`,t[22]!==r||t[23]!==n.title||t[24]!==n.tools.length?(o=n.tools.length>0?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(Sa,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:P6(n.tools.length,r)})]}):(0,$.jsx)(`span`,{children:n.title}),t[22]=r,t[23]=n.title,t[24]=n.tools.length,t[25]=o):o=t[25],s=e.map(U6),c=m.map(H6),t[0]=r,t[1]=n.events,t[2]=n.preview,t[3]=n.timestamp,t[4]=n.title,t[5]=n.tools,t[6]=i,t[7]=a,t[8]=o,t[9]=s,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f}else i=t[6],a=t[7],o=t[8],s=t[9],c=t[10],l=t[11],u=t[12],d=t[13],f=t[14];let p;t[26]===i?p=t[27]:(p=i>0?(0,$.jsxs)(`span`,{children:[`+`,i]}):null,t[26]=i,t[27]=p);let m;t[28]!==a||t[29]!==o||t[30]!==s||t[31]!==c||t[32]!==p?(m=(0,$.jsxs)(`div`,{className:a,children:[o,s,c,p]}),t[28]=a,t[29]=o,t[30]=s,t[31]=c,t[32]=p,t[33]=m):m=t[33];let h;return t[34]!==m||t[35]!==l||t[36]!==u||t[37]!==d||t[38]!==f?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f,m]}),t[34]=m,t[35]=l,t[36]=u,t[37]=d,t[38]=f,t[39]=h):h=t[39],h}function H6(e){return(0,$.jsxs)(`span`,{className:K(`inline-flex min-w-0 max-w-[10rem] items-center gap-1.5`,e.tone===`branch`&&`text-accent`,e.tone===`compaction`&&`text-fg-muted`),children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current opacity-70`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function U6(e){return(0,$.jsxs)(`span`,{className:K(`inline-flex min-w-0 max-w-[9rem] items-center gap-1.5`,e.running&&`text-accent`),children:[(0,$.jsx)(Sa,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.key)}function W6(e){return e.label}function G6(e){return e.label}function K6(e){let t=(0,Q.c)(44),{items:n,activeMessageIndex:r,labels:i,onSelectMessage:a}=e,o;t[0]!==n||t[1]!==i?(o=N6(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=o,[c,l]=(0,Z.useState)(null),u=(0,Z.useRef)(null),d,f;if(t[3]===c?(d=t[4],f=t[5]):(d=()=>{if(!c)return;let e=()=>{l(null)},t=t=>{let n=t.target;n instanceof Node&&(u.current?.contains(n)||e())},n=t=>{t.key===`Escape`&&e()};return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},f=[c],t[3]=c,t[4]=d,t[5]=f),(0,Z.useEffect)(d,f),s.length<4)return null;let p;if(t[6]!==r||t[7]!==s){p=s[0]?.id;for(let e of s)e.messageIndex<=r&&(p=e.id);t[6]=r,t[7]=s,t[8]=p}else p=t[8];let m=c??p,h;t[9]!==c||t[10]!==s?(h=c?s.find(e=>e.id===c):null,t[9]=c,t[10]=s,t[11]=h):h=t[11];let g=h,_=c!==null,v;if(t[12]!==m||t[13]!==s){let e;t[15]===m?e=t[16]:(e=e=>e.id===m,t[15]=m,t[16]=e),v=s.findIndex(e),t[12]=m,t[13]=s,t[14]=v}else v=t[14];let y=Math.max(0,v),b=i.title,x,S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{l(null)},S=e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&l(null)},t[17]=x,t[18]=S):(x=t[17],S=t[18]);let C;t[19]===p?C=t[20]:(C=()=>l(e=>e??p??null),t[19]=p,t[20]=C);let w;if(t[21]!==a||t[22]!==_||t[23]!==m||t[24]!==y||t[25]!==s){let e;t[27]!==a||t[28]!==_||t[29]!==m||t[30]!==y?(e=(e,t)=>{let n=e.id===m,r=Math.abs(t-y);return(0,$.jsx)(`li`,{className:`group relative flex h-3.5 w-full shrink-0 items-center justify-end`,onMouseEnter:()=>l(e.id),onFocus:()=>l(e.id),children:(0,$.jsx)(`button`,{type:`button`,className:K(`flex h-3.5 w-full items-center justify-end rounded-sm pr-1.5`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),onClick:()=>a(e.messageIndex),"aria-label":`${e.title}: ${e.preview}`,children:(0,$.jsx)(`span`,{className:K(`block h-0.5 rounded-full transition-[width,background-color] duration-150 ease-out`,B6({active:n,scrubbing:_,distance:r}),`group-hover:bg-fg`),"aria-hidden":!0})})},e.id)},t[27]=a,t[28]=_,t[29]=m,t[30]=y,t[31]=e):e=t[31],w=s.map(e),t[21]=a,t[22]=_,t[23]=m,t[24]=y,t[25]=s,t[26]=w}else w=t[26];let T;t[32]!==w||t[33]!==C?(T=(0,$.jsx)(`div`,{className:`chat-timeline-scroll flex min-h-0 w-full flex-col`,children:(0,$.jsx)(`ol`,{className:`my-auto flex w-full shrink-0 flex-col items-end py-1`,onMouseEnter:C,children:w})}),t[32]=w,t[33]=C,t[34]=T):T=t[34];let E;t[35]!==i||t[36]!==g?(E=g?(0,$.jsx)(V6,{turn:g,labels:i}):null,t[35]=i,t[36]=g,t[37]=E):E=t[37];let D;t[38]!==T||t[39]!==E?(D=(0,$.jsxs)(`div`,{className:`relative z-[90] flex h-full min-h-0 w-full flex-col justify-center overflow-visible`,children:[T,E]}),t[38]=T,t[39]=E,t[40]=D):D=t[40];let O;return t[41]!==i.title||t[42]!==D?(O=(0,$.jsx)(`aside`,{ref:u,className:`hidden h-full min-h-0 max-h-full w-12 shrink-0 items-center overflow-visible py-4 xl:flex`,"aria-label":b,onMouseLeave:x,onBlur:S,children:D}),t[41]=i.title,t[42]=D,t[43]=O):O=t[43],O}function q6(e,t){return e===`running`||e===`queued`?t.runLinkRunning:e===`succeeded`?t.runLinkCompleted:t.runLinkFinished}var J6=(0,Z.memo)(function(e){let t=(0,Q.c)(29),{link:n,className:r}=e,i=xe(Ee(Y6)).workflows,a=l(),o;t[0]!==n.definitionId||t[1]!==n.goal?(o=n.goal.trim()||n.definitionId,t[0]=n.definitionId,t[1]=n.goal,t[2]=o):o=t[2];let s=o,c;t[3]!==n.ownerAgentId||t[4]!==n.runId||t[5]!==a?(c=()=>a(cN(n.runId,{ownerAgentId:n.ownerAgentId})),t[3]=n.ownerAgentId,t[4]=n.runId,t[5]=a,t[6]=c):c=t[6];let u;t[7]===r?u=t[8]:(u=K(`flex w-full items-start gap-3 rounded-2xl border border-edge bg-surface-panel px-4 py-3 text-left`,`transition-colors hover:bg-surface-hover/60`,yc.focusRingPanel,r),t[7]=r,t[8]=u);let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:(0,$.jsx)(se,{className:`size-4`,"aria-hidden":!0})}),t[9]=d):d=t[9];let f=q6(n.status,i),p;t[10]===f?p=t[11]:(p=(0,$.jsx)(`span`,{className:`block text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:f}),t[10]=f,t[11]=p);let m;t[12]===n.definitionId?m=t[13]:(m=(0,$.jsx)(`span`,{className:`mt-1 block text-sm font-semibold text-fg`,children:n.definitionId}),t[12]=n.definitionId,t[13]=m);let h;t[14]===s?h=t[15]:(h=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm text-fg-muted`,children:s}),t[14]=s,t[15]=h);let g;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Xn,{className:`size-3.5`,"aria-hidden":!0}),t[16]=g):g=t[16];let _;t[17]===i.taskOpenDetails?_=t[18]:(_=(0,$.jsxs)(`span`,{className:`mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-fg`,children:[i.taskOpenDetails,g]}),t[17]=i.taskOpenDetails,t[18]=_);let v;t[19]!==m||t[20]!==h||t[21]!==_||t[22]!==p?(v=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[p,m,h,_]}),t[19]=m,t[20]=h,t[21]=_,t[22]=p,t[23]=v):v=t[23];let y;return t[24]!==v||t[25]!==c||t[26]!==u||t[27]!==d?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:c,className:u,children:[d,v]}),t[24]=v,t[25]=c,t[26]=u,t[27]=d,t[28]=y):y=t[28],y});function Y6(e){return e.language}async function X6(){return(await q(J(`/api/workflows/definitions`))).definitions??[]}async function Z6(e){return(await q(J(`/api/workflows/project-presets?${new URLSearchParams({projectId:e}).toString()}`))).presets??[]}async function Q6(e,t,n){return(await q(J(`/api/workflows/project-presets/${encodeURIComponent(t)}`),{method:`PUT`,body:JSON.stringify({projectId:e,contextRefs:n})})).preset}async function $6(e,t){let n=new URLSearchParams({projectId:e});await q(J(`/api/workflows/project-presets/${encodeURIComponent(t)}?${n.toString()}`),{method:`DELETE`})}async function e8(e,t,n){return q(J(`/api/workflows/definitions/validate`),{method:`POST`,body:JSON.stringify({name:e,graph:t,manifest:n})})}async function t8(e){return(await q(J(`/api/workflows/definitions/generate`),{method:`POST`,body:JSON.stringify(e)})).draft}async function n8(e,t,n,r){let i=r===0;return(await q(J(i?`/api/workflows/definitions`:`/api/workflows/definitions/${encodeURIComponent(e)}`),{method:i?`POST`:`PUT`,body:JSON.stringify({name:e,graph:t,manifest:n,expectedRevision:r})})).definition}async function r8(e){return(await q(J(`/api/workflows/definitions/${encodeURIComponent(e)}/revisions`))).revisions??[]}async function i8(e,t){return(await q(J(`/api/workflows/definitions/${encodeURIComponent(e)}/revisions/${t}`))).definition}async function a8(e,t,n){return(await q(J(`/api/workflows/definitions/${encodeURIComponent(e)}/revisions/${t}/restore`),{method:`POST`,body:JSON.stringify({expectedRevision:n})})).definition}async function o8(e){return(await q(J(`/api/workflows/drafts`),{method:`POST`,body:JSON.stringify(e)})).draft}async function s8(e){await q(J(`/api/workflows/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}function c8(e,t){let n=t?.ownerAgentId?.trim();n&&e.set(`agentId`,n)}async function l8(e=50,t){let n=new URLSearchParams({limit:String(e)});c8(n,t);let r=t?.taskId?.trim();r&&n.set(`taskId`,r);let i=t?.projectId?.trim();return i&&n.set(`projectId`,i),(await q(J(`/api/workflows/runs?${n.toString()}`))).runs??[]}async function u8(e,t){let n=new URLSearchParams;c8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await q(J(`/api/workflows/runs/${encodeURIComponent(e)}${r}`))).view}async function d8(e,t){let n=new URLSearchParams;c8(n,t);let r=n.size>0?`?${n.toString()}`:``;return(await q(J(`/api/workflows/runs/${encodeURIComponent(e)}/comparison${r}`))).comparison}async function f8(e,t,n){let r=new URLSearchParams;c8(r,n);let i=r.size>0?`?${r.toString()}`:``,a=await we(J(`/api/workflows/runs/${encodeURIComponent(e)}/artifacts/${encodeURIComponent(t)}${i}`),{headers:{Accept:`*/*`}});if(!a.ok){let e=await a.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(je(a.status,a.statusText,t))}return a.blob()}async function p8(e){return q(J(`/api/workflows/runs`),{method:`POST`,body:JSON.stringify(e)})}async function m8(e,t){let n=new URLSearchParams;c8(n,t);let r=n.size>0?`?${n.toString()}`:``;await q(J(`/api/workflows/runs/${encodeURIComponent(e)}/cancel${r}`),{method:`POST`})}async function h8(e,t){let n=new URLSearchParams;c8(n,t);let r=n.size>0?`?${n.toString()}`:``,i=t?.projectId?.trim();return q(J(`/api/workflows/runs/${encodeURIComponent(e)}/retry${r}`),{method:`POST`,body:JSON.stringify(i?{projectId:i}:{})})}async function g8(e,t,n){let r=new URLSearchParams;c8(r,n);let i=r.size>0?`?${r.toString()}`:``;return q(J(`/api/workflows/runs/${encodeURIComponent(e)}/replay${i}`),{method:`POST`,body:JSON.stringify({scope:t})})}function _8(e,t){let n=Number.parseInt(e,10);return Number.isFinite(n)?n:t+1}function v8(e){let t=new Map(e.phases.map(e=>[e.id,e.title])),n=e.phases.find(e=>e.status===`running`),r=e.agents.map((e,n)=>({id:_8(e.id,n),label:e.label,phase:e.phaseId?t.get(e.phaseId):void 0,prompt:e.prompt??``,invocation:e.invocation,conversationId:e.conversationId,transcriptMessageCount:e.transcriptMessageCount,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0,currentStep:e.currentStep,steps:e.steps?.map(e=>({id:e.id,kind:e.kind,toolName:e.toolName,label:e.label,detail:e.detail,status:e.status,resultPreview:e.resultPreview,error:e.error,startedAtMs:e.startedAtMs,durationMs:e.startedAtMs!=null&&e.completedAtMs!=null?e.completedAtMs-e.startedAtMs:void 0}))})),{metrics:i}=e.run;return{runId:e.run.id,name:e.run.definitionId,description:e.run.goal||e.run.title,phases:e.phases.map(e=>e.title),currentPhase:n?.title,logs:e.logs.map(e=>e.message),agents:r,agentCount:i.agentCount,runningCount:Math.max(0,i.agentCount-i.doneAgentCount-i.errorAgentCount-i.skippedAgentCount),doneCount:i.doneAgentCount,errorCount:i.errorAgentCount,skippedCount:i.skippedAgentCount,durationMs:i.durationMs,result:e.run.result}}function y8(e){return e===`succeeded`?`border-emerald-500/30 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 text-destructive`:e===`cancelled`?`border-warning/40 text-warning`:`border-accent/40 text-accent`}var b8=(0,Z.memo)(function(e){let t=(0,Q.c)(241),{view:n,onAbortCurrentTurn:r}=e,i=kN(Ee(x8)),a=i.live,o;t[0]===n?o=t[1]:(o=v8(n),t[0]=n,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=Mj(s),t[2]=s,t[3]=c);let l=c,u;t[4]===n.run.status?u=t[5]:(u=YM.has(n.run.status),t[4]=n.run.status,t[5]=u);let d=u,[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(`overview`),[g,_]=(0,Z.useState)(null),[,v]=(0,Z.useState)(0),b;t[6]!==d||t[7]!==v?(b=()=>{if(!d)return;let e=window.setInterval(()=>v(S8),1e3);return()=>window.clearInterval(e)},t[6]=d,t[7]=v,t[8]=b):b=t[8];let x;t[9]===d?x=t[10]:(x=[d],t[9]=d,t[10]=x),(0,Z.useEffect)(b,x);let S=d&&n.run.startedAtMs?Date.now()-n.run.startedAtMs:n.run.metrics.durationMs??s.durationMs??0,C;t[11]===S?C=t[12]:(C=S?Pj(S):``,t[11]=S,t[12]=C);let w=C,T=a.progress(s.doneCount,s.agentCount),E=s.currentPhase||a.activeFallback,D;t[13]!==n.run.definitionId||t[14]!==n.run.goal||t[15]!==n.run.title?(D=n.run.goal.trim()||n.run.title||n.run.definitionId,t[13]=n.run.definitionId,t[14]=n.run.goal,t[15]=n.run.title,t[16]=D):D=t[16];let O=D,k=n.run.metadata?.agentId,A,j,M,N,P,F,L,R,z,B,V,H,U,W,G,ee;if(t[17]!==m||t[18]!==E||t[19]!==f||t[20]!==w||t[21]!==d||t[22]!==i||t[23]!==a.agents||t[24]!==a.close||t[25]!==a.currentState||t[26]!==a.details||t[27]!==a.elapsed||t[28]!==a.logs||t[29]!==a.openRun||t[30]!==a.overview||t[31]!==a.result||t[32]!==a.runId||t[33]!==a.status||t[34]!==a.stop||t[35]!==a.title||t[36]!==r||t[37]!==k||t[38]!==T||t[39]!==l||t[40]!==g||t[41]!==h||t[42]!==p||t[43]!==_||t[44]!==s||t[45]!==O||t[46]!==n.logs||t[47]!==n.run.error||t[48]!==n.run.id||t[49]!==n.run.status){let e=n.logs.map(C8).filter(Boolean),o;t[66]!==d||t[67]!==r||t[68]!==k||t[69]!==n.run.id?(o=()=>{d&&m8(n.run.id,{ownerAgentId:k}).catch(w8),r?.()},t[66]=d,t[67]=r,t[68]=k,t[69]=n.run.id,t[70]=o):o=t[70],N=o;let c;t[71]===a.overview?c=t[72]:(c={id:`overview`,label:a.overview},t[71]=a.overview,t[72]=c);let u;t[73]===a.agents?u=t[74]:(u={id:`agents`,label:a.agents},t[73]=a.agents,t[74]=u);let v;t[75]===a.logs?v=t[76]:(v={id:`logs`,label:a.logs},t[75]=a.logs,t[76]=v);let b;t[77]===a.result?b=t[78]:(b={id:`result`,label:a.result},t[77]=a.result,t[78]=b);let x;t[79]!==c||t[80]!==u||t[81]!==v||t[82]!==b?(x=[c,u,v,b],t[79]=c,t[80]=u,t[81]=v,t[82]=b,t[83]=x):x=t[83];let S=x;U=`mb-6`;let C;t[84]===p?C=t[85]:(C=()=>p(!0),t[84]=p,t[85]=C);let D;t[86]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(se,{className:`size-4`,"aria-hidden":!0}),t[86]=D):D=t[86];let te;t[87]===d?te=t[88]:(te=d?(0,$.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-surface-panel bg-accent motion-safe:animate-pulse`}):null,t[87]=d,t[88]=te);let ne;t[89]===te?ne=t[90]:(ne=(0,$.jsxs)(`span`,{className:`relative flex size-8 shrink-0 items-center justify-center rounded-full bg-accent-soft text-accent-fg`,children:[D,te]}),t[89]=te,t[90]=ne);let re=a.status[n.run.status],ie;t[91]===re?ie=t[92]:(ie=(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:re}),t[91]=re,t[92]=ie);let ae;t[93]===n.run.status?ae=t[94]:(ae=K(`rounded-full border px-1.5 py-0.5`,y8(n.run.status)),t[93]=n.run.status,t[94]=ae);let oe;t[95]!==T||t[96]!==ae?(oe=(0,$.jsx)(`span`,{className:ae,children:T}),t[95]=T,t[96]=ae,t[97]=oe):oe=t[97];let ce;t[98]===E?ce=t[99]:(ce=(0,$.jsx)(`span`,{className:`truncate`,children:E}),t[98]=E,t[99]=ce);let le;t[100]!==w||t[101]!==a.elapsed?(le=w?(0,$.jsxs)(`span`,{children:[a.elapsed,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:w})]}):null,t[100]=w,t[101]=a.elapsed,t[102]=le):le=t[102];let ue;t[103]!==ie||t[104]!==oe||t[105]!==ce||t[106]!==le?(ue=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px] text-fg-muted`,children:[ie,oe,ce,le]}),t[103]=ie,t[104]=oe,t[105]=ce,t[106]=le,t[107]=ue):ue=t[107];let de;t[108]===O?de=t[109]:(de=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-sm font-medium leading-tight text-fg`,children:O}),t[108]=O,t[109]=de);let fe;t[110]!==ue||t[111]!==de?(fe=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[ue,de]}),t[110]=ue,t[111]=de,t[112]=fe):fe=t[112];let pe;t[113]!==C||t[114]!==ne||t[115]!==fe?(pe=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg text-left outline-none hover:bg-surface-hover/70 focus-visible:ring-2 focus-visible:ring-accent`,onClick:C,children:[ne,fe]}),t[113]=C,t[114]=ne,t[115]=fe,t[116]=pe):pe=t[116];let me;t[117]!==N||t[118]!==d||t[119]!==a.stop?(me=d?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`hidden h-8 px-2 text-xs sm:inline-flex`,onClick:N,children:[(0,$.jsx)(yr,{className:`size-3.5`,"aria-hidden":!0}),a.stop]}):null,t[117]=N,t[118]=d,t[119]=a.stop,t[120]=me):me=t[120];let he;t[121]===p?he=t[122]:(he=()=>p(!0),t[121]=p,t[122]=he);let ge;t[123]!==a.details||t[124]!==he?(ge=(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:he,children:a.details}),t[123]=a.details,t[124]=he,t[125]=ge):ge=t[125];let _e;t[126]!==me||t[127]!==ge?(_e=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[me,ge]}),t[126]=me,t[127]=ge,t[128]=_e):_e=t[128],t[129]!==pe||t[130]!==_e?(W=(0,$.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 rounded-xl border border-edge bg-surface-panel px-2.5 py-2 shadow-surface sm:px-3`,children:[pe,_e]}),t[129]=pe,t[130]=_e,t[131]=W):W=t[131],M=nt,V=f,H=p,j=$e,t[132]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[120] bg-scrim backdrop-blur-[1px]`}),t[132]=B):B=t[132],A=et,L=`xopc-dialog-content fixed left-1/2 top-1/2 z-[121] flex h-[min(84vh,44rem)] w-[min(100vw-2rem,54rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`;let ve;t[133]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(se,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[133]=ve):ve=t[133];let be;t[134]===a.title?be=t[135]:(be=(0,$.jsx)(tt,{className:`truncate text-sm font-semibold text-fg`,children:a.title}),t[134]=a.title,t[135]=be);let xe;t[136]===n.run.status?xe=t[137]:(xe=K(`rounded-full border px-1.5 py-0.5 text-[10px]`,y8(n.run.status)),t[136]=n.run.status,t[137]=xe);let q=a.status[n.run.status],Se;t[138]!==xe||t[139]!==q?(Se=(0,$.jsx)(`span`,{className:xe,children:q}),t[138]=xe,t[139]=q,t[140]=Se):Se=t[140];let Ce;t[141]!==be||t[142]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ve,be,Se]}),t[141]=be,t[142]=Se,t[143]=Ce):Ce=t[143];let we;t[144]===O?we=t[145]:(we=(0,$.jsx)(Ze,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:O}),t[144]=O,t[145]=we);let Te;t[146]!==Ce||t[147]!==we?(Te=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[Ce,we]}),t[146]=Ce,t[147]=we,t[148]=Te):Te=t[148];let Ee;t[149]!==k||t[150]!==n.run.id?(Ee=cN(n.run.id,{ownerAgentId:k}),t[149]=k,t[150]=n.run.id,t[151]=Ee):Ee=t[151];let De;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[152]=De):De=t[152];let Oe;t[153]!==a.openRun||t[154]!==Ee?(Oe=(0,$.jsx)(X,{asChild:!0,type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,children:(0,$.jsxs)(y,{to:Ee,children:[De,a.openRun]})}),t[153]=a.openRun,t[154]=Ee,t[155]=Oe):Oe=t[155];let J;t[156]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(ye,{className:`size-4`,"aria-hidden":!0}),t[156]=J):J=t[156];let ke;t[157]===a.close?ke=t[158]:(ke=(0,$.jsx)(Qe,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":a.close,children:J})}),t[157]=a.close,t[158]=ke);let Ae;t[159]!==Oe||t[160]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[Oe,ke]}),t[159]=Oe,t[160]=ke,t[161]=Ae):Ae=t[161],t[162]!==Te||t[163]!==Ae?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[Te,Ae]}),t[162]=Te,t[163]=Ae,t[164]=R):R=t[164];let je=a.title,Me;t[165]!==m||t[166]!==h||t[167]!==S?(Me=S.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":m===e.id,className:K(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,m===e.id?`bg-surface-hover text-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>h(e.id),children:e.label},e.id)),t[165]=m,t[166]=h,t[167]=S,t[168]=Me):Me=t[168],t[169]!==a.title||t[170]!==Me?(z=(0,$.jsx)(`div`,{className:`flex shrink-0 gap-1 border-b border-edge px-4 py-2`,role:`tablist`,"aria-label":je,children:Me}),t[169]=a.title,t[170]=Me,t[171]=z):z=t[171],G=`min-h-0 flex-1 overflow-y-auto px-4 py-3`,t[172]!==m||t[173]!==E||t[174]!==w||t[175]!==a.currentState||t[176]!==a.elapsed||t[177]!==a.runId||t[178]!==a.status||t[179]!==T||t[180]!==n.run.error||t[181]!==n.run.id||t[182]!==n.run.status?(ee=m===`overview`?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ai,{className:`size-4 text-accent`,"aria-hidden":!0}),a.currentState]}),(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`p`,{children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:a.status[n.run.status]}),(0,$.jsx)(`span`,{className:`mx-1 text-fg-subtle`,children:`·`}),E]}),(0,$.jsx)(`p`,{children:T}),w?(0,$.jsxs)(`p`,{children:[a.elapsed,`: `,(0,$.jsx)(`span`,{className:`text-fg`,children:w})]}):null,(0,$.jsxs)(`p`,{className:`break-all`,children:[a.runId,`: `,(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:n.run.id})]})]})]}),n.run.error?.message?(0,$.jsx)(`p`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:n.run.error.message}):null]}):null,t[172]=m,t[173]=E,t[174]=w,t[175]=a.currentState,t[176]=a.elapsed,t[177]=a.runId,t[178]=a.status,t[179]=T,t[180]=n.run.error,t[181]=n.run.id,t[182]=n.run.status,t[183]=ee):ee=t[183],t[184]!==m||t[185]!==i||t[186]!==l||t[187]!==g||t[188]!==_||t[189]!==s?(P=m===`agents`?(0,$.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(18rem,24rem)]`,children:[(0,$.jsx)(cM,{rollup:l,currentPhase:s.currentPhase,labels:i.phase,recentLogs:[],recentLogsHeading:i.recentLogsHeading,showAllLogsLabel:i.showAllLogs,logsExpanded:!1,onToggleLogs:T8,selectedAgentId:g?.id,onSelectAgent:_}),(0,$.jsx)(Bj,{agent:g,snapshot:s,labels:i.checkDetail,onClose:()=>_(null)})]}):null,t[184]=m,t[185]=i,t[186]=l,t[187]=g,t[188]=_,t[189]=s,t[190]=P):P=t[190],F=m===`logs`?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Wi,{className:`size-4 text-accent`,"aria-hidden":!0}),a.logs]}),e.length?(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(E8)}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.error.noExtraDetails})]}):null,t[17]=m,t[18]=E,t[19]=f,t[20]=w,t[21]=d,t[22]=i,t[23]=a.agents,t[24]=a.close,t[25]=a.currentState,t[26]=a.details,t[27]=a.elapsed,t[28]=a.logs,t[29]=a.openRun,t[30]=a.overview,t[31]=a.result,t[32]=a.runId,t[33]=a.status,t[34]=a.stop,t[35]=a.title,t[36]=r,t[37]=k,t[38]=T,t[39]=l,t[40]=g,t[41]=h,t[42]=p,t[43]=_,t[44]=s,t[45]=O,t[46]=n.logs,t[47]=n.run.error,t[48]=n.run.id,t[49]=n.run.status,t[50]=A,t[51]=j,t[52]=M,t[53]=N,t[54]=P,t[55]=F,t[56]=L,t[57]=R,t[58]=z,t[59]=B,t[60]=V,t[61]=H,t[62]=U,t[63]=W,t[64]=G,t[65]=ee}else A=t[50],j=t[51],M=t[52],N=t[53],P=t[54],F=t[55],L=t[56],R=t[57],z=t[58],B=t[59],V=t[60],H=t[61],U=t[62],W=t[63],G=t[64],ee=t[65];let te;t[191]!==m||t[192]!==i||t[193]!==a.noResult||t[194]!==n.run.result?(te=m===`result`?iN(n.run.result)?(0,$.jsx)(dM,{result:n.run.result,labels:i.result}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.noResult}):null,t[191]=m,t[192]=i,t[193]=a.noResult,t[194]=n.run.result,t[195]=te):te=t[195];let ne;t[196]!==P||t[197]!==F||t[198]!==te||t[199]!==G||t[200]!==ee?(ne=(0,$.jsxs)(`div`,{className:G,children:[ee,P,F,te]}),t[196]=P,t[197]=F,t[198]=te,t[199]=G,t[200]=ee,t[201]=ne):ne=t[201];let re;t[202]===n.run.definitionId?re=t[203]:(re=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.run.definitionId}),t[202]=n.run.definitionId,t[203]=re);let ie;t[204]!==N||t[205]!==d||t[206]!==a.stop?(ie=d?(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:N,children:[(0,$.jsx)(yr,{className:`size-3.5`,"aria-hidden":!0}),a.stop]}):null,t[204]=N,t[205]=d,t[206]=a.stop,t[207]=ie):ie=t[207];let ae;t[208]!==k||t[209]!==n.run.id?(ae=cN(n.run.id,{ownerAgentId:k}),t[208]=k,t[209]=n.run.id,t[210]=ae):ae=t[210];let oe;t[211]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),t[211]=oe):oe=t[211];let ce;t[212]!==a.openRun||t[213]!==ae?(ce=(0,$.jsx)(X,{asChild:!0,type:`button`,variant:`primary`,className:`h-8 text-xs`,children:(0,$.jsxs)(y,{to:ae,children:[oe,a.openRun]})}),t[212]=a.openRun,t[213]=ae,t[214]=ce):ce=t[214];let le;t[215]!==ie||t[216]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ie,ce]}),t[215]=ie,t[216]=ce,t[217]=le):le=t[217];let ue;t[218]!==re||t[219]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-4 py-3`,children:[re,le]}),t[218]=re,t[219]=le,t[220]=ue):ue=t[220];let de;t[221]!==A||t[222]!==L||t[223]!==R||t[224]!==z||t[225]!==ne||t[226]!==ue?(de=(0,$.jsxs)(A,{className:L,children:[R,z,ne,ue]}),t[221]=A,t[222]=L,t[223]=R,t[224]=z,t[225]=ne,t[226]=ue,t[227]=de):de=t[227];let fe;t[228]!==j||t[229]!==B||t[230]!==de?(fe=(0,$.jsxs)(j,{children:[B,de]}),t[228]=j,t[229]=B,t[230]=de,t[231]=fe):fe=t[231];let pe;t[232]!==M||t[233]!==V||t[234]!==H||t[235]!==fe?(pe=(0,$.jsx)(M,{open:V,onOpenChange:H,children:fe}),t[232]=M,t[233]=V,t[234]=H,t[235]=fe,t[236]=pe):pe=t[236];let me;return t[237]!==U||t[238]!==W||t[239]!==pe?(me=(0,$.jsxs)(`div`,{className:U,children:[W,pe]}),t[237]=U,t[238]=W,t[239]=pe,t[240]=me):me=t[240],me});function x8(e){return e.language}function S8(e){return e+1}function C8(e){return e.message}function w8(){}function T8(){}function E8(e,t){return(0,$.jsx)(`p`,{className:`break-words font-mono text-xs leading-5 text-fg-muted`,children:e},`${t}:${e}`)}function D8(e,t){return e.kind??e.projectKind??t??`general`}function O8(e){return e.effectiveWorkspaceRoot||e.workspaceRoot||void 0}async function k8(e){return(await bh({workspaceRoot:e})).inference.kind===`coding`?{kind:`codingWorkspace`,path:e}:{kind:`workingDirectory`,path:e}}function A8({attempt:e,enabled:t,conversationId:n,sourceNoteId:r,sourceNoteTitle:i,sourceContextPending:a,sourceContextFailed:o,effectiveWorkspacePath:s,workingDirectoryLocked:c,task:l,file:u,workflow:d}){return t?a?`pending:${n??``}`:l?`task:${l.task.id}:${l.task.version}`:u?`file:${u.name}:${u.type}`:d?`workflow:${d.run.id}:${d.run.status}`:r?`note:${r}:${i?.trim()??``}`:c&&s?.trim()?`workspace:${n??``}:${s.trim()}`:n?`session:${n}:attempt:${e}:failed:${o?`1`:`0`}`:`empty`:`disabled`}function j8(e){let t=A8(e);if(!e.enabled)return{key:t,context:{kind:`empty`},status:`ready`};if(e.sourceContextPending)return{key:t,context:{kind:`empty`},status:`loading`};if(e.task){let n=e.task.receipts[0];return{key:t,context:{kind:`task`,taskId:e.task.task.id,taskTitle:e.task.task.title,phase:e.task.task.phase,operationalState:e.task.operationalState,attentionSummary:e.task.attention[0]?.summary,nextAction:n?.nextAction,recentFailure:n?.failure?.recoveryAction},status:`ready`}}if(e.file)return{key:t,context:{kind:`file`,fileName:e.file.name},status:`ready`};if(e.workflow){let n=e.workflow.run;return{key:t,context:{kind:`workflow`,workflowName:n.goal.trim()||n.title||n.definitionId,status:n.status,nextAction:n.result?.followUps?.[0]?.prompt??n.result?.actions?.[0]?.label,recentFailure:n.error?.message},status:`ready`}}if(e.sourceNoteId)return{key:t,context:{kind:`note`,noteId:e.sourceNoteId,title:e.sourceNoteTitle?.trim()||`Untitled note`},status:`ready`};let n=e.effectiveWorkspacePath?.trim();return e.workingDirectoryLocked&&n?{key:t,context:{kind:`workingDirectory`,path:n},status:e.sourceContextFailed?`degraded`:`ready`}:e.conversationId?{key:t,context:{kind:`empty`},status:`loading`}:{key:t,context:{kind:`empty`},status:`ready`}}function M8({enabled:e,conversationId:t,sourceNoteId:n,sourceNoteTitle:r,sourceContextPending:i=!1,sourceContextFailed:a=!1,effectiveWorkspacePath:o,workingDirectoryLocked:s=!1,task:c,file:l,workflow:u,sessionManager:d}){let[f,p]=(0,Z.useState)(0),m={attempt:f,enabled:e,conversationId:t,sourceNoteId:n,sourceNoteTitle:r,sourceContextPending:i,sourceContextFailed:a,effectiveWorkspacePath:o,workingDirectoryLocked:s,task:c,file:l,workflow:u,sessionManager:d},h=A8(m),[g,_]=(0,Z.useState)(()=>j8(m)),v=(0,Z.useCallback)(()=>p(e=>e+1),[]);(0,Z.useEffect)(()=>{let f=!1;if(!e){_({key:h,context:{kind:`empty`},status:`ready`});return}if(i){_({key:h,context:{kind:`empty`},status:`loading`});return}if(c){_(j8(m));return}if(l||u){_(j8(m));return}if(n){_({key:h,context:{kind:`note`,noteId:n,title:r?.trim()||`Untitled note`},status:`ready`});return}let p=s?o?.trim():void 0;if(p)return _({key:h,context:{kind:`workingDirectory`,path:p},status:a?`degraded`:`ready`}),(async()=>{try{let e=await k8(p);f||_({key:h,context:e,status:a?`degraded`:`ready`})}catch{f||_({key:h,context:{kind:`workingDirectory`,path:p},status:`degraded`})}})(),()=>{f=!0};if(!t){_({key:h,context:{kind:`empty`},status:`ready`});return}return _({key:h,context:{kind:`empty`},status:`loading`}),(async()=>{let e=a,n=null;try{n=(await $h(t)).projectId?.trim()||null}catch{e=!0}if(n)try{let[t,r]=await Promise.allSettled([gh(n),_h(n)]);if(t.status===`rejected`)throw t.reason;let i=t.value,a=r.status===`fulfilled`?r.value:null;a||(e=!0);let o=i.kind??i.projectKind??null;if(!o)try{o=(await bh({name:i.name,description:i.description,workspaceRoot:i.effectiveWorkspaceRoot??i.workspaceRoot})).inference.kind}catch{e=!0,o=`general`}if(f)return;let s=D8(i,o),c=a?.blockers[0],l=a?.digest.health===`attention`?a.recentResults.find(({receipt:e})=>e.status===`failed`||e.verification.status===`failed`):void 0,u={recommendedAction:a?.digest.recommendedAction,blockedReason:c?.detail??c?.title,recentFailure:l?.receipt.failure?.recoveryAction??l?.receipt.summary};_({key:h,context:s===`coding`?{kind:`codingProject`,projectId:n,projectName:i.name,workspaceRoot:O8(i),...u}:{kind:`generalProject`,projectId:n,projectName:i.name,...u},status:e?`degraded`:`ready`});return}catch{e=!0}try{let n=await d.loadSessionAgentConfig(t),r=n.workingDirectoryLocked?n.effectiveWorkspacePath.trim():``;if(f)return;if(r){let t={kind:`workingDirectory`,path:r};try{t=await k8(r)}catch{e=!0}if(f)return;_({key:h,context:t,status:e?`degraded`:`ready`});return}}catch{e=!0}f||_({key:h,context:{kind:`empty`},status:e?`degraded`:`ready`})})(),()=>{f=!0}},[f,h,e,t,d,a,i,o,s,c,l,u,n,r]);let y=g.key===h?g:j8(m);return{context:y.context,status:y.status,retry:v}}var N8=`xopc:chat-welcome-suggestion-metrics:v2`,P8=`xopc:welcome-suggestion-metric`,F8=64;function I8(){try{let e=globalThis.localStorage?.getItem(N8);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){if(!r||typeof r!=`object`||Array.isArray(r))continue;let t=r;n[e]={impressions:Number.isFinite(t.impressions)?Number(t.impressions):0,picks:Number.isFinite(t.picks)?Number(t.picks):0,sends:Number.isFinite(t.sends)?Number(t.sends):0,acceptedSends:Number.isFinite(t.acceptedSends)?Number(t.acceptedSends):0,skips:Number.isFinite(t.skips)?Number(t.skips):0,lastUsedAt:Number.isFinite(t.lastUsedAt)?Number(t.lastUsedAt):0}}return n}catch{return{}}}function L8(e){try{let t=Object.entries(e).sort(([,e],[,t])=>t.lastUsedAt-e.lastUsedAt).slice(0,F8);globalThis.localStorage?.setItem(N8,JSON.stringify(Object.fromEntries(t)))}catch{}}function R8(e){return`${e.contextKind}\u0000${e.agentId}\u0000${e.suggestionId}`}function z8(e,t){let n=I8();return Object.fromEntries(Object.entries(n).flatMap(([n,r])=>{let[i,a,o]=n.split(`\0`);if(i!==e||a!==t||!o)return[];let s=Math.max(0,r.picks*3+r.sends*2+r.acceptedSends*6-r.skips*4);return[[o,Math.min(35,s)]]}))}function B8(e){let t=e.suggestionId.trim();if(!t)return;let n=I8(),r=R8({...e,suggestionId:t}),i=n[r]??{impressions:0,picks:0,sends:0,acceptedSends:0,skips:0,lastUsedAt:0},a=e.type===`send`&&(!e.edited||Math.abs(e.characterDelta??0)<40);n[r]={impressions:i.impressions+ +(e.type===`impression`),picks:i.picks+ +(e.type===`pick`),sends:i.sends+ +(e.type===`send`),acceptedSends:i.acceptedSends+ +!!a,skips:i.skips+ +(e.type===`skip`),lastUsedAt:Date.now()},L8(n),typeof window<`u`&&window.dispatchEvent(new CustomEvent(P8,{detail:e}))}var V8={tasks:()=>q(J(`/api/tasks?limit=200`)),list:e=>{let t=new URLSearchParams;e?.projectId&&t.set(`projectId`,e.projectId);let n=t.toString();return q(J(`/api/automations${n?`?${n}`:``}`))},metrics:()=>q(J(`/api/automations/metrics`)),draft:(e,t=crypto.randomUUID())=>q(J(`/api/automations/draft`),{method:`POST`,headers:{"Idempotency-Key":t},body:JSON.stringify(e)}),simulate:e=>q(J(`/api/automations/simulate`),{method:`POST`,body:JSON.stringify(e)}),create:e=>q(J(`/api/automations`),{method:`POST`,body:JSON.stringify(e)}),update:(e,t)=>q(J(`/api/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),remove:e=>q(J(`/api/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),runNow:e=>q(J(`/api/automations/${encodeURIComponent(e)}/run`),{method:`POST`}),pause:e=>q(J(`/api/automations/${encodeURIComponent(e)}/pause`),{method:`POST`}),resume:e=>q(J(`/api/automations/${encodeURIComponent(e)}/resume`),{method:`POST`}),runs:(e=50,t,n)=>{let r=new URLSearchParams({limit:String(e)});return t&&r.set(`automationId`,t),!t&&n?.projectId&&r.set(`projectId`,n.projectId),q(J(`/api/automation-runs?${r.toString()}`))},productEventRuns:e=>{let t=new URLSearchParams({eventType:e.eventType,limit:String(e.limit??5)});return e.source&&t.set(`source`,e.source),e.payloadKey&&t.set(`payloadKey`,e.payloadKey),e.payloadValue!==void 0&&t.set(`payloadValue`,e.payloadValue),q(J(`/api/automation-runs/product-events?${t.toString()}`))},runEvents:e=>q(J(`/api/automation-runs/${encodeURIComponent(e)}/events`)),rerun:e=>q(J(`/api/automation-runs/${encodeURIComponent(e)}/rerun`),{method:`POST`}),repairDraft:(e,t,n=crypto.randomUUID())=>q(J(`/api/automation-runs/${encodeURIComponent(e)}/repair-draft`),{method:`POST`,headers:{"Idempotency-Key":n},body:JSON.stringify(t)}),cancelRun:e=>q(J(`/api/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`}),markRunRead:e=>q(J(`/api/automation-runs/${encodeURIComponent(e)}/read`),{method:`POST`}),markAllRunsRead:e=>q(J(`/api/automation-runs/read-all${e?`?projectId=${encodeURIComponent(e)}`:``}`),{method:`POST`})};function H8(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function U8(e,t){if(!e.enabled||e.trigger.kind!==`event`||e.trigger.eventType!==t.eventType||e.trigger.source&&e.trigger.source!==t.source)return!1;let n=e.trigger.payloadMatch;if(!n)return!0;let r=t.eventPayload??{};return Object.entries(n).every(([e,t])=>Object.is(r[e],t))}function W8(e,t){let n=e.trigger,r=t.explain;return n.kind===`event`?[K8(n.eventType,n.source,t),q8(n.payloadMatch,t),Y8(e.safety,t),J8(e.action,t)]:[r.triggerMatched,J8(e.action,t)]}function G8(e,t,n){let r=e.triggerSnapshot,i=Z8(t),a=n.explain;return r.kind===`event`?[i?K8(i.type,i.source,n):K8(r.eventType,r.source,n),q8(r.payloadMatch,n),Y8(X8(t),n),J8(e.actionSnapshot,n)]:r.kind===`manual`?[a.manual,J8(e.actionSnapshot,n)]:r.kind===`webhook`?[a.webhook,J8(e.actionSnapshot,n)]:[a.schedule,J8(e.actionSnapshot,n)]}function K8(e,t,n){let r=n.explain;return t?H8(r.eventFrom,{eventType:e,source:t}):H8(r.event,{eventType:e})}function q8(e,t){if(!e||Object.keys(e).length===0)return t.explain.noPayloadFilter;let n=Object.entries(e).slice(0,3).map(([e,t])=>`${e}=${String(t)}`).join(`, `);return H8(t.explain.payloadMatched,{pairs:n})}function J8(e,t){return e.kind===`workflow`?H8(t.explain.actionWorkflow,{workflowId:e.workflowId}):e.kind===`browser_automation`?`Runs browser automation ${e.automationId}.`:e.kind===`task_command`?`Starts task ${e.taskId}.`:t.explain.actionAgent}function Y8(e,t){let n=e?.mode??`auto_apply`;return H8(t.explain.safetyMode,{mode:t.safety[n]})}function X8(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return;let t=e.data.safety;if(!t||typeof t!=`object`||Array.isArray(t))return;let n=t.mode;return n===`suggest_only`||n===`ask_before_apply`||n===`auto_apply`?{mode:n}:void 0}function Z8(e){if(!e.data||typeof e.data!=`object`||Array.isArray(e.data))return null;let t=e.data.event;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;return typeof n.type!=`string`||!n.type.trim()?null:{type:n.type,source:typeof n.source==`string`?n.source:void 0}}function Q8(e){return e===`succeeded`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:e===`cancelled`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300`}function $8(e,t){return new Date(e).toLocaleString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function e5(e){return e.some(e=>[`queued`,`running`,`cancelling`].includes(e.run.status))}function t5(e){return e===`failed`||e===`timeout`||e===`cancelled`}function n5(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId),r=!e||n.createdAtMs>e.latest.createdAtMs?n:e.latest;t.set(n.automationId,{latest:r,hadAttention:!!e?.hadAttention||t5(n.status)})}let n={total:t.size,succeeded:0,active:0,attention:0,recovered:0};for(let{latest:e,hadAttention:r}of t.values())e.status===`succeeded`&&(n.succeeded+=1),e.status===`succeeded`&&r&&(n.recovered+=1),(e.status===`queued`||e.status===`running`||e.status===`cancelling`)&&(n.active+=1),t5(e.status)&&(n.attention+=1,n.latestAttentionRun??=e);return n}function r5(e){let t=new Map;for(let{run:n}of e){let e=t.get(n.automationId);(!e||n.createdAtMs>e.createdAtMs)&&t.set(n.automationId,n)}return t}function i5(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),e)}function a5(e){let t=(0,Q.c)(47),{health:n,labels:r,primaryRepairBusy:i,onPrimaryRepair:a}=e,o=n.attention>0,s=n.active>0,c=n.recovered>0,l;t[0]!==s||t[1]!==c||t[2]!==n.active||t[3]!==n.attention||t[4]!==n.latestAttentionRun?.automationName||t[5]!==n.recovered||t[6]!==n.succeeded||t[7]!==n.total||t[8]!==r.feedback.summaryHealthy||t[9]!==r.feedback.summaryNeedsAttention||t[10]!==r.feedback.summaryRecovered||t[11]!==r.feedback.summaryRunning||t[12]!==r.feedback.thisAutomation||t[13]!==o?(l=o?i5(r.feedback.summaryNeedsAttention,{total:n.total,attention:n.attention,name:n.latestAttentionRun?.automationName??r.feedback.thisAutomation}):s?i5(r.feedback.summaryRunning,{total:n.total,active:n.active}):c?i5(r.feedback.summaryRecovered,{total:n.total,recovered:n.recovered,succeeded:n.succeeded}):i5(r.feedback.summaryHealthy,{total:n.total,succeeded:n.succeeded}),t[0]=s,t[1]=c,t[2]=n.active,t[3]=n.attention,t[4]=n.latestAttentionRun?.automationName,t[5]=n.recovered,t[6]=n.succeeded,t[7]=n.total,t[8]=r.feedback.summaryHealthy,t[9]=r.feedback.summaryNeedsAttention,t[10]=r.feedback.summaryRecovered,t[11]=r.feedback.summaryRunning,t[12]=r.feedback.thisAutomation,t[13]=o,t[14]=l):l=t[14];let u=l,d=o?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,f;t[15]===d?f=t[16]:(f=K(`break-words text-xs leading-5`,d),t[15]=d,t[16]=f);let p;t[17]!==u||t[18]!==f?(p=(0,$.jsx)(`p`,{className:f,children:u}),t[17]=u,t[18]=f,t[19]=p):p=t[19];let m;t[20]!==n.succeeded||t[21]!==r.feedback.succeededCount?(m=n.succeeded?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(j,{className:`size-3`,"aria-hidden":!0}),i5(r.feedback.succeededCount,{count:n.succeeded})]}):null,t[20]=n.succeeded,t[21]=r.feedback.succeededCount,t[22]=m):m=t[22];let h;t[23]!==n.active||t[24]!==r.feedback.activeCount?(h=n.active?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-blue-500/25 bg-blue-500/10 px-2 py-0.5 text-xs text-blue-700 dark:text-blue-300`,children:[(0,$.jsx)(M,{className:`size-3`,"aria-hidden":!0}),i5(r.feedback.activeCount,{count:n.active})]}):null,t[23]=n.active,t[24]=r.feedback.activeCount,t[25]=h):h=t[25];let g;t[26]!==n.attention||t[27]!==r.feedback.attentionCount?(g=n.attention?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(ma,{className:`size-3`,"aria-hidden":!0}),i5(r.feedback.attentionCount,{count:n.attention})]}):null,t[26]=n.attention,t[27]=r.feedback.attentionCount,t[28]=g):g=t[28];let _;t[29]!==n.recovered||t[30]!==r.feedback.recoveredCount?(_=n.recovered?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(j,{className:`size-3`,"aria-hidden":!0}),i5(r.feedback.recoveredCount,{count:n.recovered})]}):null,t[29]=n.recovered,t[30]=r.feedback.recoveredCount,t[31]=_):_=t[31];let v;t[32]!==m||t[33]!==h||t[34]!==g||t[35]!==_?(v=(0,$.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5`,children:[m,h,g,_]}),t[32]=m,t[33]=h,t[34]=g,t[35]=_,t[36]=v):v=t[36];let y;t[37]!==r.feedback.primaryRepair||t[38]!==r.feedback.primaryRepairing||t[39]!==o||t[40]!==a||t[41]!==i?(y=o&&a?(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(X,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:i,onClick:a,children:[(0,$.jsx)(ta,{className:`size-3.5`,"aria-hidden":!0}),i?r.feedback.primaryRepairing:r.feedback.primaryRepair]})}):null,t[37]=r.feedback.primaryRepair,t[38]=r.feedback.primaryRepairing,t[39]=o,t[40]=a,t[41]=i,t[42]=y):y=t[42];let b;return t[43]!==y||t[44]!==p||t[45]!==v?(b=(0,$.jsxs)(`div`,{className:`mb-3 border-l-2 border-accent/50 pl-3`,children:[p,v,y]}),t[43]=y,t[44]=p,t[45]=v,t[46]=b):b=t[46],b}function o5({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:i=3,className:a,onSaveInsight:o,isInsightSaved:s}){let c=Ee(e=>e.language),l=xe(c).automations,u=c===`zh`?`zh-CN`:`en-US`,d=[`product-automation-feedback`,e,t??``,n??``,r??``,i],[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),{data:g,mutate:_}=Zt(e&&(!n||r!==void 0)?d:null,()=>V8.productEventRuns({eventType:e,source:t,payloadKey:n,payloadValue:r,limit:i}),{revalidateOnFocus:!1,refreshInterval:e=>e?.items&&e5(e.items)?3e3:15e3}),[v,b]=(0,Z.useState)({}),[x,S]=(0,Z.useState)({}),C=g?.items??[],w=n5(C),T=r5(C);if(!C.length)return null;let E=async(e,t)=>{p(e),h(null);try{await t(),await _()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},D=async e=>{p(`${e.id}:repair`),h(null);try{let t=await V8.repairDraft(e.id,{language:c});b(n=>({...n,[e.id]:t.repair})),S(t=>({...t,[e.id]:!1}))}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},O=async(e,t,n=!1)=>{p(n?`${e.id}:applyAndRerun`:`${e.id}:applyRepair`),h(null);try{await V8.update(e.automationId,t.patch),n&&await V8.rerun(e.id),await _(),b(t=>{let n={...t};return delete n[e.id],n}),S(t=>{let n={...t};return delete n[e.id],n})}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(null)}},k=w.latestAttentionRun&&!v[w.latestAttentionRun.id]?w.latestAttentionRun:void 0,A=k?f===`${k.id}:repair`:!1;return(0,$.jsxs)(`section`,{className:K(`rounded-lg border border-edge bg-surface-panel p-3`,a),children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Ca,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:l.feedback.title})]}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:C.length})]}),(0,$.jsx)(a5,{health:w,labels:l,primaryRepairBusy:A,onPrimaryRepair:k?()=>void D(k):void 0}),m?(0,$.jsxs)(`p`,{className:`mb-2 rounded-md border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`,role:`alert`,children:[l.feedback.actionFailed,`: `,m]}):null,(0,$.jsx)(`ul`,{className:`grid gap-2`,children:C.map(({run:e,triggerEvent:t})=>{let n=T.get(e.automationId),r=n?.id===e.id,i=t5(e.status)&&!r,a=i&&n?.status===`succeeded`,c=v[e.id],d=x[e.id]??!1,p=f===`${e.id}:repair`,m=f===`${e.id}:applyRepair`,h=f===`${e.id}:applyAndRerun`,g=G8(e,t,l),_=s?.(e)??!1,C=e.status===`succeeded`&&!!e.summary&&!!o&&!_,w=f===`${e.id}:saveInsight`;return(0,$.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-inset/35 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(tr,{className:`size-3.5 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.automationName})]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-xs text-fg-muted`,children:e.error||e.summary||t.message})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,$.jsx)(`span`,{className:K(`rounded-full border px-2 py-0.5 text-xs`,Q8(e.status)),children:l.status[e.status]}),i?(0,$.jsx)(`span`,{className:`rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-xs text-emerald-700 dark:text-emerald-300`,children:a?l.feedback.recovered:l.feedback.historical}):null]})]}),(0,$.jsx)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-xs text-fg-muted`,children:(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,$.jsx)(Wn,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:$8(t.createdAtMs,u)})]})}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/60 bg-surface-base/45 px-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg`,children:l.explain.whyRan}),(0,$.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:g.map(e=>(0,$.jsx)(`span`,{className:`rounded-full border border-edge/70 bg-surface-panel px-2 py-0.5 text-xs text-fg-muted`,children:e},e))})]}),c?(0,$.jsxs)(`div`,{className:`mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-semibold text-amber-800 dark:text-amber-200`,children:[(0,$.jsx)(ta,{className:`size-3.5`,"aria-hidden":!0}),l.repair.title]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg`,children:c.explanation}),c.expectedEffect?(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:c.expectedEffect}):null,c.risks.length?(0,$.jsx)(`ul`,{className:`mt-2 list-disc space-y-1 pl-4 text-xs text-fg-muted`,children:c.risks.slice(0,3).map(e=>(0,$.jsx)(`li`,{children:e},e))}):null,c.requiresApproval?(0,$.jsxs)(`label`,{className:`mt-2 flex items-start gap-2 text-xs text-fg`,children:[(0,$.jsx)(`input`,{className:`mt-0.5`,type:`checkbox`,checked:d,onChange:t=>{S(n=>({...n,[e.id]:t.target.checked}))}}),(0,$.jsx)(`span`,{children:l.repair.approval})]}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-1.5`,children:[(0,$.jsx)(X,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,onClick:()=>{b(t=>{let n={...t};return delete n[e.id],n})},children:l.draft.discard}),(0,$.jsx)(X,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:c.requiresApproval&&!d||f!==null,onClick:()=>void O(e,c),children:m?l.feedback.working:l.repair.apply}),(0,$.jsxs)(X,{variant:`primary`,className:`h-7 rounded-md px-2 text-xs`,disabled:c.requiresApproval&&!d||f!==null,onClick:()=>void O(e,c,!0),children:[(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),h?l.feedback.working:l.feedback.applyAndRerun]})]})]}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,children:[_?(0,$.jsxs)(`span`,{className:`inline-flex h-7 items-center gap-1 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-2 text-xs text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.savedInsight]}):null,C?(0,$.jsxs)(X,{variant:`secondary`,className:`h-7 rounded-md px-2 text-xs`,disabled:f!==null,onClick:()=>void E(`${e.id}:saveInsight`,()=>Promise.resolve(o(e))),children:[(0,$.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),w?l.feedback.savingInsight:l.feedback.saveInsight]}):null,e.conversationId?(0,$.jsx)(X,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(y,{to:`/chat/${encodeURIComponent(e.conversationId)}`,children:[(0,$.jsx)(pe,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.chat]})}):null,e.workflowRunId?(0,$.jsx)(X,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(y,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,$.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.workflow]})}):null,r&&t5(e.status)&&!c?(0,$.jsxs)(X,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:f!==null,onClick:()=>void D(e),children:[(0,$.jsx)(ta,{className:`size-3.5`,"aria-hidden":!0}),p?l.repair.generating:l.repair.suggest]}):null,(0,$.jsxs)(X,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:f!==null,onClick:()=>void E(`${e.id}:rerun`,()=>V8.rerun(e.id)),children:[(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),f===`${e.id}:rerun`?l.feedback.working:l.feedback.rerun]}),(0,$.jsxs)(X,{variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,disabled:f!==null,onClick:()=>void E(`${e.id}:pause`,()=>V8.pause(e.automationId)),children:[(0,$.jsx)(gr,{className:`size-3.5`,"aria-hidden":!0}),f===`${e.id}:pause`?l.feedback.working:l.feedback.pause]}),(0,$.jsx)(X,{asChild:!0,variant:`ghost`,className:`h-7 rounded-md px-2 text-xs`,children:(0,$.jsxs)(y,{to:`/automations?run=${encodeURIComponent(e.id)}`,children:[(0,$.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),l.feedback.open]})})]})]},e.id)})})]})}function s5(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind!==`context`)return null;let n=t.data&&typeof t.data==`object`&&!Array.isArray(t.data)?t.data:null;if(!n||n.kind!==`workflow-run-link`)return null;let r=typeof n.runId==`string`?n.runId.trim():``,i=typeof n.workflowConversationId==`string`?n.workflowConversationId.trim():``,a=typeof n.ownerAgentId==`string`?n.ownerAgentId.trim():``,o=typeof n.definitionId==`string`?n.definitionId.trim():``;if(!r||!i||!o)return null;let s=typeof n.goal==`string`?n.goal:``,c=typeof n.status==`string`?n.status:`running`,l=typeof t.id==`string`&&t.id.trim()?t.id.trim():`workflow-run-link:${r}`,u=typeof t.createdAt==`string`?Date.parse(t.createdAt):void 0;return{id:l,runId:r,ownerAgentId:a||void 0,workflowConversationId:i,definitionId:o,goal:s,status:c,createdAtMs:Number.isFinite(u)?u:void 0}}function c5(e){if(!e?.length)return[];let t=new Map;for(let n of e){let e=s5(n);if(!e)continue;let r=t.get(e.runId);t.set(e.runId,{...r,...e,ownerAgentId:e.ownerAgentId??r?.ownerAgentId,workflowConversationId:e.workflowConversationId||r?.workflowConversationId||``,definitionId:e.definitionId||r?.definitionId||``,goal:e.goal||r?.goal||``})}return[...t.values()].toSorted((e,t)=>(e.createdAtMs??0)-(t.createdAtMs??0))}function l5(e){let t=(0,Q.c)(8),n=Se(u5),r;t[0]===e?r=t[1]:(r=e?.trim()||null,t[0]=e,t[1]=r);let i=r,a;t[2]!==n||t[3]!==i?(a=n&&i?[`session-workflow-run-links`,i,n]:null,t[2]=n,t[3]=i,t[4]=a):a=t[4];let o;t[5]===i?o=t[6]:(o=async()=>c5((await $h(i,{includeTranscriptRows:!0})).transcriptRows),t[5]=i,t[6]=o);let s;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[7]=s):s=t[7],Zt(a,o,s)}function u5(e){return e.conversationId}function d5(e,t){let n=(0,Q.c)(26),r=Se(p5),i=!!r,a;n[0]===e?a=n[1]:(a=e?.trim()||null,n[0]=e,n[1]=a);let o=a,s;n[2]===t?.ownerAgentId?s=n[3]:(s=t?.ownerAgentId?.trim()||void 0,n[2]=t?.ownerAgentId,n[3]=s);let c=s,l;n[4]!==i||n[5]!==c||n[6]!==r||n[7]!==o?(l=i&&o?[`workflow-run-live`,o,c??``,r]:null,n[4]=i,n[5]=c,n[6]=r,n[7]=o,n[8]=l):l=n[8];let u;n[9]!==c||n[10]!==o?(u=()=>u8(o,{ownerAgentId:c}),n[9]=c,n[10]=o,n[11]=u):u=n[11];let d;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!1,refreshInterval:f5},n[12]=d):d=n[12];let f=Zt(l,u,d),p;n[13]!==c||n[14]!==f||n[15]!==o?(p=()=>{if(!o)return;let e=e=>{let t=e.detail;if(t?.runId!==o)return;let n=t.view?.run.metadata?.agentId;if(!(c&&n&&n!==c)){if(t.view){f.mutate(t.view,{revalidate:!1});return}f.mutate()}};return window.addEventListener(`workflow-run-updated`,e),()=>window.removeEventListener(`workflow-run-updated`,e)},n[13]=c,n[14]=f,n[15]=o,n[16]=p):p=n[16];let m;n[17]!==c||n[18]!==f.mutate||n[19]!==o?(m=[c,f.mutate,o],n[17]=c,n[18]=f.mutate,n[19]=o,n[20]=m):m=n[20],(0,Z.useEffect)(p,m);let h;return n[21]!==f.data||n[22]!==f.error||n[23]!==f.isLoading||n[24]!==f.mutate?(h={view:f.data,loading:f.isLoading,error:f.error,mutate:f.mutate},n[21]=f.data,n[22]=f.error,n[23]=f.isLoading,n[24]=f.mutate,n[25]=h):h=n[25],h}function f5(e){return e&&YM.has(e.run.status)?3e3:0}function p5(e){return e.conversationId}var m5=[ta,qi,li];function h5(e){let t=(0,Q.c)(20),{agentName:n,messages:r,disabled:i,onPick:a}=e,o;t[0]!==r.setupPromptComplete||t[1]!==r.setupPromptIdentity||t[2]!==r.setupPromptProject?(o=[r.setupPromptIdentity,r.setupPromptProject,r.setupPromptComplete],t[0]=r.setupPromptComplete,t[1]=r.setupPromptIdentity,t[2]=r.setupPromptProject,t[3]=o):o=t[3];let s=o,c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-2xl bg-accent-soft text-accent`,children:(0,$.jsx)(ta,{className:`size-6`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=c):c=t[4];let l;t[5]===r.setupTitle?l=t[6]:(l=(0,$.jsx)(`h1`,{id:`agent-setup-title`,className:`mt-4 text-balance text-xl font-semibold tracking-tight text-fg`,children:r.setupTitle}),t[5]=r.setupTitle,t[6]=l);let u;t[7]!==n||t[8]!==r.setupDescription?(u=r.setupDescription.replace(`{{name}}`,n),t[7]=n,t[8]=r.setupDescription,t[9]=u):u=t[9];let d;t[10]===u?d=t[11]:(d=(0,$.jsx)(`p`,{className:`mt-2 max-w-xl text-pretty text-sm leading-relaxed text-fg-muted`,children:u}),t[10]=u,t[11]=d);let f;t[12]!==i||t[13]!==a||t[14]!==s?(f=(0,$.jsx)(`div`,{className:`mt-7 grid w-full gap-3 md:grid-cols-3`,children:s.map((e,t)=>{let n=m5[t]??ta;return(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>a(e),className:K(`flex min-h-24 items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-4 text-left text-sm font-medium leading-relaxed text-fg`,`hover:border-accent/30 hover:bg-surface-hover`,yc.transition,yc.pressCard,yc.focusRingPanel,yc.disabled),children:[(0,$.jsx)(n,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:e})]},e)})}),t[12]=i,t[13]=a,t[14]=s,t[15]=f):f=t[15];let p;return t[16]!==l||t[17]!==d||t[18]!==f?(p=(0,$.jsxs)(`section`,{className:`mx-auto flex w-full max-w-4xl flex-col items-center px-2 pb-4 pt-12 text-center sm:pt-16`,"aria-labelledby":`agent-setup-title`,children:[c,l,d,f]}),t[16]=l,t[17]=d,t[18]=f,t[19]=p):p=t[19],p}var g5={extension:zi,playwright:gi,cdp:ca,remote:Er};function _5(e){let t=(0,Q.c)(41),{payload:n}=e,r=l(),i=Ee(v5),a;t[0]===i?a=t[1]:(a=xe(i),t[0]=i,t[1]=a);let o=a.chat,s=g5[n.driver]??ce,c=o.browserSetupRequiredTitle,u=o.browserSetupRequiredReasons[n.reason]??o.browserSetupRequiredReasons.generic,d=_$(n.driver===`extension`),f=n.driver===`extension`&&d.status?.localManagementAvailable===!0,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=K(`mt-2 flex flex-col gap-2 rounded-xl border border-amber-300/60 bg-amber-50/70 p-3`,`dark:border-amber-500/30 dark:bg-amber-500/10`),t[2]=p):p=t[2];let m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=K(`flex size-8 shrink-0 items-center justify-center rounded-lg`,`bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`),t[3]=m):m=t[3];let h;t[4]===s?h=t[5]:(h=(0,$.jsx)(`span`,{className:m,"aria-hidden":!0,children:(0,$.jsx)(s,{className:`size-4`,strokeWidth:1.75})}),t[4]=s,t[5]=h);let g;t[6]===c?g=t[7]:(g=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:c}),t[6]=c,t[7]=g);let _;t[8]===u?_=t[9]:(_=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900/85 dark:text-amber-100/80`,children:u}),t[8]=u,t[9]=_);let v;t[10]!==g||t[11]!==_?(v=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g,_]}),t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==h||t[14]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[h,v]}),t[13]=h,t[14]=v,t[15]=y):y=t[15];let b;t[16]!==f||t[17]!==d||t[18]!==o.browserSetupRequiredInstallCta||t[19]!==o.browserSetupRequiredOpenCta?(b=f?(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`h-8 px-3 py-1.5 text-xs`,disabled:d.busy,onClick:()=>void d.prepareAndOpen(),children:[d.busy?(0,$.jsx)(ue,{className:`size-3.5 animate-spin`}):null,d.installed?o.browserSetupRequiredOpenCta:o.browserSetupRequiredInstallCta]}):null,t[16]=f,t[17]=d,t[18]=o.browserSetupRequiredInstallCta,t[19]=o.browserSetupRequiredOpenCta,t[20]=b):b=t[20];let x=f?`ghost`:`primary`,S;t[21]!==r||t[22]!==n.deepLink?(S=()=>r(n.deepLink),t[21]=r,t[22]=n.deepLink,t[23]=S):S=t[23];let C;t[24]!==o.browserSetupRequiredCta||t[25]!==x||t[26]!==S?(C=(0,$.jsx)(X,{type:`button`,variant:x,className:`h-8 px-3 py-1.5 text-xs`,onClick:S,children:o.browserSetupRequiredCta}),t[24]=o.browserSetupRequiredCta,t[25]=x,t[26]=S,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]===d.error?T=t[32]:(T=d.error?(0,$.jsx)(`p`,{className:`text-xs text-danger`,role:`alert`,children:d.error}):null,t[31]=d.error,t[32]=T);let E;t[33]!==o.browserSetupRequiredDetailToggle||t[34]!==n.detail?(E=n.detail?(0,$.jsxs)(`details`,{className:`group min-w-0 text-xs`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-amber-800/80 underline-offset-2 hover:text-amber-900 dark:text-amber-200/80 dark:hover:text-amber-100`,children:o.browserSetupRequiredDetailToggle}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 w-full min-w-0 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-md bg-amber-100/60 p-2 font-mono text-[11px] text-amber-900 dark:bg-amber-500/15 dark:text-amber-100 [overflow-wrap:anywhere]`,children:n.detail})]}):null,t[33]=o.browserSetupRequiredDetailToggle,t[34]=n.detail,t[35]=E):E=t[35];let D;return t[36]!==w||t[37]!==T||t[38]!==E||t[39]!==y?(D=(0,$.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:p,children:[y,w,T,E]}),t[36]=w,t[37]=T,t[38]=E,t[39]=y,t[40]=D):D=t[40],D}function v5(e){return e.language}var y5=new Set([`extension`,`playwright`,`cdp`,`remote`]),b5=new Set([`extension_not_installed`,`extension_not_connected`,`chromium_missing`,`cdp_unreachable`,`remote_api_key_missing`]);function x5(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(t.kind!==`browser_setup_required`)return null;let n=t.hint&&typeof t.hint==`object`&&!Array.isArray(t.hint)?t.hint:null;if(!n)return null;let r=n.driver,i=n.reason,a=n.deepLink;return typeof r!=`string`||!y5.has(r)||typeof i!=`string`||!b5.has(i)||typeof a!=`string`||!a.startsWith(`/settings/`)?null:{kind:`browser_setup_required`,driver:r,reason:i,deepLink:a,detail:typeof n.detail==`string`?n.detail:void 0}}function S5(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.type!==`tool_use`||n.name!==`browser_use`)continue;let r=x5(n.details);if(r)return r}return null}var C5=120*1e3,w5=new Map;function T5(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function E5(e){for(let[t,n]of w5)n.expiresAt<=e&&w5.delete(t)}function D5(e,t=Date.now()){E5(t);let n=T5();return w5.set(n,{attachments:e.map(e=>({...e})),expiresAt:t+C5}),n}function O5(e,t=Date.now()){let n=w5.get(e);if(!n)return null;if(n.expiresAt<=t)return w5.delete(e),null;if(!n.attachments)return null;let r=n.attachments;return n.attachments=null,r}var k5=(0,Z.lazy)(async()=>({default:(await s(()=>import(`./chat-terminal-dock-ClbmjCL2.js`),__vite__mapDeps([158,1,4,24,9,26,27,28,31,5,15,16,159]))).ChatTerminalDock}));function A5(e,t){let n=e.replace(/\s+/g,``).toLocaleLowerCase(),r=t.replace(/\s+/g,``).toLocaleLowerCase();if(!n||!r)return!1;if(n===r)return!0;let i=Math.min(18,Math.max(8,Math.floor(n.length*.16)));return r.includes(n.slice(0,i))}function j5(e=new Date){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function M5({embedded:e=!1,conversationId:t,taskId:n}={}){let r=Ee(e=>e.language),i=xe(r),a=Se(e=>e.conversationId),o=l(),s=b(),{pathname:c}=s,[d]=u(),f=(0,Z.useRef)(null),p=(0,Z.useRef)(0),m=(0,Z.useRef)(null),h=(0,Z.useRef)(``),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),[v,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)({}),[w,T]=(0,Z.useState)(0),[E,D]=(0,Z.useState)(null),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(!1),[I,L]=(0,Z.useState)(null),R=n?.trim()||null,{data:z}=mc(R??``),{auth:B,session:V,messages:H,timeline:U,stream:W,followUp:G,clarify:ee,agents:ne}=T6({fixedConversationId:t,taskId:R??void 0}),re=!e&&!R&&d.get(`scene`)===`find-skills`,ie=!e&&!R&&d.get(`agentSetup`)===`1`,ae=d.get(`skill`)?.trim()??``,oe=d.get(`slash`)?.trim()??``,se=d.get(`draft`)??``,ce=d.get(`autoSend`)===`1`,le=d.get(`attachmentHandoff`),ue=d.get(`attachmentsHandoff`),de=V.decodedKey??V.conversationId,[fe,pe]=(0,Z.useState)(null),me=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{if(le){let e=vE(le);e&&pe(e),me.current=de;return}me.current!==de&&(me.current=de,pe(null))},[le,de]);let he=ex(e=>e.markViewed);(0,Z.useEffect)(()=>{de&&he(de)},[de,he]);let{data:ge}=E6(de),_e=(0,Z.useCallback)(async e=>{if(de)try{let t=await V.sessionManager.forkSessionAtTurn(de,e);window.dispatchEvent(new CustomEvent(`session-created`,{detail:{key:t.conversationId,conversationId:t.conversationId}})),Yl(`success`,i.chat.messageForkCreated),o(`/chat/${encodeURIComponent(t.conversationId)}`)}catch(e){throw Yl(`error`,e instanceof Error?e.message:i.chat.messageForkFailed),e}},[de,i.chat.messageForkCreated,i.chat.messageForkFailed,o,V.sessionManager]),ve=ge?.workflowRunId??null,{view:ye}=d5(ve,{ownerAgentId:ge?.ownerAgentId??void 0}),{data:be=[],mutate:q}=l5(de),Ce=!!(ve&&ye&&YM.has(ye.run.status)),we=H.items.at(-1),Te=we?.role===`assistant`?S5(we.content):null,De=!e&&!W.streaming&&!W.sending&&Te!==null;(0,Z.useEffect)(()=>{if(!de)return;let e=e=>{let t=e.detail;(t?.key??t?.conversationId)===de&&q()};return window.addEventListener(`session-transcript-updated`,e),window.addEventListener(`workflow-run-started-from-chat`,e),()=>{window.removeEventListener(`session-transcript-updated`,e),window.removeEventListener(`workflow-run-started-from-chat`,e)}},[de,q]),(0,Z.useEffect)(()=>{f.current=null},[V.conversationId]),(0,Z.useEffect)(()=>{if(!B.hasToken||!ae&&!oe&&!se&&!(V.projectPreparation&&ue)||ce&&!V.projectPreparation||V.showSessionLoading||V.sessionRoutePending||!V.conversationId&&!V.projectPreparation)return;let e=V.projectPreparation&&ue?O5(ue)??void 0:void 0,t=()=>{let e=new URLSearchParams(d);e.delete(`skill`),e.delete(`slash`),e.delete(`draft`),V.projectPreparation&&(e.delete(`autoSend`),e.delete(`attachmentsHandoff`));let t=e.toString();o({pathname:c,search:t?`?${t}`:``},{replace:!0})},n=(n,r)=>{f.current!==r&&(f.current=r,queueMicrotask(()=>{e?.length?NT(n,e):(p.current+=1,x({id:p.current,text:n})),t()}))},r=Vg(ae,se);if(r||e?.length){let e=`${V.conversationId}:draft:${r}`;n(r??``,e);return}if(ae){t();return}if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(oe)){t();return}let i=`${V.conversationId}:slash:${oe}`;f.current!==i&&queueMicrotask(()=>{(async()=>{try{let e=await ZT(),t=oe.toLowerCase(),n=e.find(e=>e.name.toLowerCase()===t||Array.isArray(e.aliases)&&e.aliases.some(e=>e.toLowerCase()===t));if(n){if(f.current===i)return;f.current=i,p.current+=1,x({id:p.current,text:zW(n)})}}finally{t()}})()})},[B.hasToken,ae,oe,se,ce,ue,V.projectPreparation,d,V.showSessionLoading,V.sessionRoutePending,V.conversationId,o,c]);let{scrollRef:Oe,atBottom:J,registerListContentRef:ke,scrollToBottom:Ae,onScroll:je}=QI({hasToken:B.hasToken,showSessionLoading:V.showSessionLoading,conversationId:V.conversationId,chatMessages:H.items,hasMore:V.hasMore,loadingMore:V.loadingMore,loadMoreMessages:V.loadMoreMessages}),[Me,Ne]=(0,Z.useState)(0),Pe=(0,Z.useRef)(null),Fe=(0,Z.useRef)(null),Ie=(0,Z.useMemo)(()=>{let e=-1;for(let t of U.items)typeof t.displayIndex==`number`&&Number.isFinite(t.displayIndex)&&(e=Math.max(e,t.displayIndex));return e<0?0:Math.max(0,e+1-H.items.length)},[H.items.length,U.items]),Le=(0,Z.useCallback)(e=>{let t=Oe.current;if(!t)return!1;let n=t.querySelector(`[data-chat-message-index="${e}"]`);if(!n)return!1;Ne(e);let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=t.scrollTop+i.top-r.top-16;return t.scrollTo({top:Math.max(0,a),behavior:`smooth`}),!0},[Oe]),Re=(0,Z.useCallback)(()=>{let e=Oe.current;if(!e)return;let t=Array.from(e.querySelectorAll(`[data-chat-message-index]`));if(t.length===0){Ne(0);return}let n=e.getBoundingClientRect(),r=n.top+Math.min(180,n.height*.35),i=t[0];for(let e of t){if(e.getBoundingClientRect().top<=r){i=e;continue}break}let a=i.dataset.chatMessageIndex,o=a?Number.parseInt(a,10):0;Number.isFinite(o)&&Ne(e=>e===o?e:o)},[Oe]),ze=(0,Z.useCallback)(()=>{Pe.current!=null&&cancelAnimationFrame(Pe.current),Pe.current=requestAnimationFrame(()=>{Pe.current=null,Re()})},[Re]),Be=(0,Z.useCallback)(()=>{je(),ze()},[je,ze]),Ve=(0,Z.useCallback)(e=>{let t=e-Ie;if(t<0||t>=H.items.length){t<0&&V.hasMore&&!V.loadingMore&&(Fe.current=e,V.loadMoreMessages());return}Fe.current=null,Le(t)},[H.items.length,Le,V.hasMore,V.loadMoreMessages,V.loadingMore,Ie]),He=U4({conversationId:V.conversationId,taskId:R,messages:H.items,displayOffset:Ie,viewportRef:Oe,onRevealDisplayIndex:Ve});(0,Z.useEffect)(()=>{let e=Fe.current;if(e==null)return;let t=e-Ie;if(t>=0&&t<H.items.length){Fe.current=null,requestAnimationFrame(()=>Le(t));return}if(t<0&&V.hasMore&&!V.loadingMore){V.loadMoreMessages();return}(t>=H.items.length||!V.hasMore)&&(Fe.current=null)},[H.items.length,Le,V.hasMore,V.loadMoreMessages,V.loadingMore,Ie]),(0,Z.useEffect)(()=>{ze()},[H.items.length,ze,V.conversationId,Ie]),(0,Z.useEffect)(()=>()=>{Pe.current!=null&&cancelAnimationFrame(Pe.current)},[]),(0,Z.useEffect)(()=>{x(null),m.current=null,h.current=``,C({})},[V.conversationId]);let Ue=(0,Z.useCallback)(e=>{m.current=e,B8({type:`pick`,suggestionId:e.suggestionId,categoryId:e.categoryId,contextKind:e.contextKind,agentId:ne.displayAgentId}),p.current+=1,x({id:p.current,text:e.prompt})},[ne.displayAgentId]),We=(0,Z.useCallback)(()=>{let e=g.current,t=e?.categories.find(e=>e.scope===`explore`),n=t?.scenarios[0];e&&t&&n&&B8({type:`skip`,suggestionId:n.id??`${t.id}:0`,categoryId:t.id,contextKind:e.contextKind,agentId:ne.displayAgentId}),T(e=>e+1)},[ne.displayAgentId]),Ge=!!(V.conversationId&&!V.showSessionLoading&&!V.sessionRoutePending&&V.workspaceSource!==`project`&&V.workspaceSource!==`execution_environment`&&H.items.length===0),Ke=yw(e=>e.setAgentId);(0,Z.useEffect)(()=>{if(B.hasToken)return Ke(ne.displayAgentId),()=>Ke(``)},[B.hasToken,ne.displayAgentId,Ke]);let qe=V.conversationPhase===`creating-session`,Je=V.conversationPhase===`loading-history`,Xe=qe||Je,Qe=Je,rt=!Qe&&H.items.length===0&&!W.streaming,it=(0,Z.useMemo)(()=>{if(W.taskPlan){let e=f4(W.taskPlan);return e?{plan:e,changeSummary:T4(H.items,W.streaming)?.changeSummary??null}:null}return T4(H.items,W.streaming)},[H.items,W.streaming,W.taskPlan]),at=(0,Z.useMemo)(()=>(V.sessionRoutePending&&V.decodedKey?V.decodedKey:V.conversationId)?V.sessionName?.trim()||i.chat.newSession:i.nav.chat,[V.conversationId,V.sessionName,V.sessionRoutePending,V.decodedKey,i.nav.chat,i.chat.newSession]),ot=ge?.sourceNoteId??null,st=c2(de,d.get(`projectId`)),ct=V.projectPreparation?.project??st,[lt,ut]=(0,Z.useState)([]),dt=Se(e=>e.baseUrl),Y=de?i2(dt,a,de):null,ft=r2.store(e=>Y?e.drafts[Y]:void 0),pt=(0,Z.useRef)(void 0),[mt,ht]=(0,Z.useState)(!1);(0,Z.useLayoutEffect)(()=>{if(pt.current!==void 0){de&&de!==pt.current&&(pt.current=void 0);return}ut([])},[de]),(0,Z.useEffect)(()=>{let e=!1;if(D(null),ot)return wL(ot).then(t=>{e||D(t?.title?.trim()||null)}).catch(()=>{e||D(null)}),()=>{e=!0}},[ot]);let gt=E||ge?.sourceNoteTitle||i.chat.sourceNoteFallbackTitle,_t=M8({enabled:B.hasToken&&!!de&&!ie&&H.items.length===0&&!V.showSessionLoading&&!V.sessionRoutePending,conversationId:de,sourceNoteId:ot,sourceNoteTitle:gt,effectiveWorkspacePath:V.effectiveWorkspacePath,workingDirectoryLocked:V.workspaceSource===`execution_environment`||V.workspaceSource===`session_override`||V.workspaceSource===`agent_workspace`,task:z,file:fe,workflow:ye,sessionManager:V.sessionManager}),vt=(0,Z.useMemo)(()=>ne.chatAgents?.items.find(e=>e.id===ne.displayAgentId)??{id:ne.displayAgentId},[ne.chatAgents?.items,ne.displayAgentId]);(0,Z.useEffect)(()=>{C(z8(_t.context.kind,ne.displayAgentId))},[ne.displayAgentId,_t.context.kind]);let yt=(0,Z.useMemo)(()=>qo(_t.context,i.chat.welcomeSpotlight,vt,{affinity:S,contextStatus:_t.status,explorationSeed:j5(),explorationOffset:w}),[i.chat.welcomeSpotlight,S,vt,_t.context,_t.status,w]),bt=_t.status===`loading`,xt=bt?void 0:yt;g.current=xt??null,(0,Z.useEffect)(()=>{if(!bt){F(!1);return}let e=window.setTimeout(()=>F(!0),180);return()=>window.clearTimeout(e)},[bt]);let St=(0,Z.useMemo)(()=>xt?{suggestionId:xt.primaryRecommendation.id,categoryId:xt.primaryRecommendation.categoryId,contextKind:xt.contextKind,prompt:xt.primaryRecommendation.prompt}:null,[xt]);(0,Z.useEffect)(()=>{if(H.items.length>0||W.streaming||!xt)return;let e=xt.primaryRecommendation,t=`${de??`new`}:${xt.contextStatus}:${e.id}`;h.current!==t&&(h.current=t,B8({type:`impression`,suggestionId:e.id,categoryId:e.categoryId,contextKind:xt.contextKind,agentId:ne.displayAgentId}))},[xt,ne.displayAgentId,de,H.items.length,W.streaming]);let Ct=(0,Z.useCallback)((...e)=>{let[t,n,r,a,o]=e;if(ft&&(I||t.trim().startsWith(`/`)))return qb.getState().setShellError(i.chat.pageContext.pending),!1;let s=m.current;if(s&&A5(s.prompt,t)&&B8({type:`send`,suggestionId:s.suggestionId,categoryId:s.categoryId,contextKind:s.contextKind,agentId:ne.displayAgentId,edited:s.prompt.trim()!==t.trim(),characterDelta:t.length-s.prompt.length}),m.current=null,I)return L(null),W.replaceLatestUserTurn(I.turnId,t,n,r,a);let c=!1,l=W.sendMessage(t,n,r,a,void 0,ft?.envelope,(e,t)=>{c=!0,o?.onDispatched?.({clientSubmissionId:e,messageRenderKey:t})});return c?(Y&&ft&&r2.remove(Y,ft),!0):l},[ne.displayAgentId,I,W.replaceLatestUserTurn,W.sendMessage,ft,Y,i.chat.pageContext.pending]),wt=s2({preparation:V.projectPreparation,conversationId:de,ready:V.modelConfigReady&&!Xe,onSend:Ct}),Tt=(0,Z.useCallback)(e=>{e.turnId&&(L({turnId:e.turnId}),NT(e.userTurnDocument?ls(e.userTurnDocument):ov(e.content),cv(e.attachments),e.contextRefs?.map(e=>({refId:e.refId,kind:e.kind,sourceId:e.sourceId,expectedVersion:e.version,title:e.title,fileKind:e.fileKind}))))},[]),Et=(0,Z.useCallback)(()=>{L(null),NT(``)},[]);(0,Z.useEffect)(()=>{L(null)},[V.conversationId]),(0,Z.useEffect)(()=>{if(!ce||!se.trim()&&!ue||!B.hasToken||V.showSessionLoading||V.sessionRoutePending||!V.conversationId||W.sending||W.streaming)return;let e=Vg(ae,se),t=ue?O5(ue):void 0;if(!e&&!t?.length)return;let n=`${V.conversationId}:auto-send:${e??``}:${ue??``}`;if(f.current===n)return;f.current=n;let r=new URLSearchParams(d);r.delete(`skill`),r.delete(`slash`),r.delete(`draft`),r.delete(`autoSend`),r.delete(`attachmentsHandoff`);let i=r.toString();o({pathname:c,search:i?`?${i}`:``},{replace:!0}),Ct(e??``,t??void 0)},[B.hasToken,ce,ue,se,Ct,o,c,d,V.conversationId,V.sessionRoutePending,V.showSessionLoading,ae,W.sending,W.streaming]);let Dt=(0,Z.useCallback)(()=>{_.current?.reject(),_.current=null,k(null),j(!1)},[]);(0,Z.useEffect)(()=>{Dt()},[Dt,ot]);let Ot=(0,Z.useMemo)(()=>({title:i.chat.timelineTitle,turn:i.chat.timelineTurn,messageFallback:i.chat.timelineMessageFallback,toolCount_one:i.chat.timelineToolCount_one,toolCount_other:i.chat.timelineToolCount_other,searchedWeb:i.chat.stepSearchedWeb,searchedMemory:i.chat.stepSearchedMemory,searchedCode:i.chat.stepSearchedCode,searched:i.chat.stepSearched,readFile:i.chat.stepReadFile,runCommand:i.chat.stepRunCommand,listDirectory:i.chat.stepListDirectory,writeFile:i.chat.stepWriteFile,editFile:i.chat.stepEditFile,openUrl:i.chat.stepOpenUrl,fetchUrl:i.chat.stepFetchUrl,unknownTool:i.chat.stepUnknownTool}),[i.chat.timelineTitle,i.chat.timelineTurn,i.chat.timelineMessageFallback,i.chat.timelineToolCount_one,i.chat.timelineToolCount_other,i.chat.stepSearchedWeb,i.chat.stepSearchedMemory,i.chat.stepSearchedCode,i.chat.stepSearched,i.chat.stepReadFile,i.chat.stepRunCommand,i.chat.stepListDirectory,i.chat.stepWriteFile,i.chat.stepEditFile,i.chat.stepOpenUrl,i.chat.stepFetchUrl,i.chat.stepUnknownTool]),kt=(0,Z.useCallback)(async e=>{if(!ot)return;_.current?.reject(),j(!1);let t=i.chat.sourceNoteAppendSourceLine.replace(`{{time}}`,new Date().toLocaleString(r));return k({heading:i.chat.sourceNoteAppendHeading,content:`${t}\n\n${e.trim()}`}),new Promise((e,t)=>{_.current={sourceNoteId:ot,resolve:e,reject:t}})},[r,i.chat.sourceNoteAppendHeading,i.chat.sourceNoteAppendSourceLine,ot]),At=(0,Z.useCallback)(async e=>{try{let t=await SL(e.trim(),`web`);Yl(`success`,i.chat.messageSavedToNote,void 0,{href:`/notes/${encodeURIComponent(t.id)}`})}catch(e){throw Yl(`error`,e instanceof Error?e.message:i.notes.quickCaptureFailed),e}},[i.chat.messageSavedToNote,i.notes.quickCaptureFailed]),jt=(0,Z.useCallback)(async()=>{let e=_.current;if(!e||!O)return;let t=O.heading.trim()||i.chat.sourceNoteAppendHeading,n=O.content.trim();if(n){j(!0),N(null);try{await zL(e.sourceNoteId,n,t),window.dispatchEvent(new CustomEvent(`note-updated`,{detail:{noteId:e.sourceNoteId,source:`chat`,conversationId:de}})),e.resolve(),_.current=null,k(null)}catch(e){N(e instanceof Error?e.message:i.chat.sourceNoteSaveFailed)}finally{j(!1)}}},[de,i.chat.sourceNoteAppendHeading,i.chat.sourceNoteSaveFailed,i.chat.sourceNoteSaveSuccess,O]),Mt=(0,Z.useCallback)(async e=>{if(!ot)return;let t=e.trim().split(/\n+/)[0]?.replace(/^[-#*>\s]+/,``).trim()||i.chat.sourceNoteTaskFallbackTitle;try{await BL(t.slice(0,120),{sourceNoteId:ot,sourceConversationId:de})}catch(e){throw Yl(`error`,e instanceof Error?e.message:i.chat.sourceNoteTaskFailed),e}},[de,i.chat.sourceNoteTaskFailed,i.chat.sourceNoteTaskFallbackTitle,i.chat.sourceNoteTaskSuccess,ot]),Nt=(0,Z.useCallback)(()=>{if(!ot)return;let e=i.chat.sourceNoteDigestPrompt.replace(`{{title}}`,gt);if(W.streaming||W.sending){G.addPendingFollowUp(e),Jl({tone:`info`,status:`done`,title:i.chat.sourceNoteDigestQueued,source:r===`zh`?`笔记整理`:`Note digest`,dedupeKey:ot?`note-digest:${ot}`:void 0});return}W.sendMessage(e)},[G,r,i.chat.sourceNoteDigestPrompt,i.chat.sourceNoteDigestQueued,ot,gt,W]),Pt=(0,Z.useCallback)(async e=>{if(!(mt||wt.busy)){if(V.projectPreparation){pt.current=null,o(Gg(e),{state:{forceNewChat:!0,agentId:ne.displayAgentId,temporary:V.userContextMode===`temporary`}});return}if(!(pt.current!==void 0||W.sending||W.streaming||Xe)){pt.current=de,ht(!0);try{e?o(Gg(e),{state:{forceNewChat:!0,agentId:ne.displayAgentId,temporary:V.userContextMode===`temporary`}}):await V.createNewSession({forceNew:!0,projectId:e,temporary:V.userContextMode===`temporary`})}catch(e){pt.current=void 0,Yl(`error`,i.chat.composerContext.changeFailed,{error:e instanceof Error?e.message:String(e)})}finally{ht(!1)}}}},[de,Xe,i.chat.composerContext.changeFailed,mt,wt.busy,V.createNewSession,V.projectPreparation,V.userContextMode,W.sending,W.streaming,o,ne.displayAgentId]),Ft=(0,Z.useCallback)(()=>Pt(null),[Pt]),It=(0,Z.useCallback)(e=>Pt(e),[Pt]),Lt=(0,Z.useCallback)(async e=>{if(!(mt||Xe||W.sending||W.streaming||!Ge)){ht(!0);try{await V.onSessionWorkingDirectoryChange(e)}finally{ht(!1)}}},[mt,Xe,W.sending,W.streaming,Ge,V.onSessionWorkingDirectoryChange]),Rt=(0,Z.useMemo)(()=>({project:ct,draftRefs:lt,onLeaveProject:mt||wt.busy?void 0:Ft,leaveProjectLabel:i.chat.scopeRemoveProject,onDraftSourceNote:ot?Nt:void 0,draftSourceNoteLabel:i.chat.sourceNoteDigestAction}),[mt,wt.busy,ct,lt,Ft,i.chat.scopeRemoveProject,ot,Nt,i.chat.sourceNoteDigestAction]);return B.hasToken?(W.error?Qg(W.error):null)?.code===`session_not_found`?(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsx)(e4,{}),(0,$.jsx)(G2,{chatHeadline:i.chat.sessionNotFoundTitle,chatAgents:ne.chatAgents?.items??[],showChatAgentSelector:!1,chatAgentId:ne.displayAgentId,onChatAgentChange:ne.onChatAgentChange,chatAgentDisabled:!0}),(0,$.jsx)(`main`,{className:`mx-auto flex w-full max-w-xl flex-1 items-center px-4 py-12 sm:px-6`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsx)(PO,{errorText:W.error})})})]}):(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,$.jsx)(e4,{}),e?null:(0,$.jsx)(G2,{chatHeadline:re&&H.items.length===0?i.skills.findTitle:at,chatAgents:ne.chatAgents?.items??[],showChatAgentSelector:!ie&&ne.showChatAgentSelector,chatAgentId:ne.displayAgentId,onChatAgentChange:ne.onChatAgentChange,chatAgentDisabled:wt.busy||mt||Xe&&!V.projectPreparation,conversationId:V.conversationId,hasMessages:!Xe&&H.items.length>0,workspacePath:V.effectiveWorkspacePath,userContextMode:V.userContextMode,projectId:ct?.id,context:Rt,canChangeWorkspace:!1,workspaceDisabled:Xe||W.sending||W.streaming,onWorkspaceChange:V.onSessionWorkingDirectoryChange,prepareTerminalSession:V.projectPreparation?wt.prepareSession:void 0,terminalDisabled:!!(V.projectPreparation&&(wt.busy||!wt.allowed||wt.checking)),showContextControls:!ie,onFindOpen:He.show}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 w-full flex-1 flex-col`,children:[!e&&ge?.parentConversationId?(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted sm:px-5 xl:px-6`,children:[(0,$.jsx)(y,{to:`/chat/${encodeURIComponent(ge.parentConversationId)}`,className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:i.chat.forkedFromConversation.replace(`{{name}}`,ge.forkedFromSessionName||i.chat.forkedFromConversationFallback)}),(0,$.jsx)(`span`,{className:`ms-2`,children:i.chat.forkSharedWorkspaceNotice})]}):null,s.state?.fromAgentEditor&&ne.displayAgentId?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,$.jsxs)(y,{to:xW(ne.displayAgentId),className:`inline-flex items-center gap-1 text-xs font-medium text-accent transition-colors hover:text-accent-fg`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`←`}),i.agentsSettings.backToEditor]})}):null,e&&ot?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle bg-surface-panel/80 px-3 py-1.5 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:i.chat.sourceNoteBanner.replace(`{{title}}`,gt)}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex h-7 items-center gap-1.5 rounded-md border border-edge-subtle px-2 font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,onClick:Nt,children:[(0,$.jsx)(zr,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:i.chat.sourceNoteDigestAction})]}),(0,$.jsx)(y,{to:te(`/notes/${encodeURIComponent(ot)}`,`${s.pathname}${s.search}`),className:`font-medium text-accent transition-colors hover:text-accent-fg`,children:i.chat.sourceNoteOpen})]})]})}):null,(0,$.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(E4,{open:He.open,query:He.query,activeIndex:He.activeIndex,resultCount:He.resultCount,searching:He.searching,truncated:He.truncated,limitedToLoaded:He.limitedToLoaded,inputRef:He.inputRef,labels:i.chat.find,onQueryChange:He.setQuery,onPrevious:He.previous,onNext:He.next,onClose:He.close}),e?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-1/2 z-20 hidden w-full max-w-[calc(var(--max-width-chat-frame)+8rem)] -translate-x-1/2 xl:block`,children:(0,$.jsx)(`div`,{className:`pointer-events-auto absolute inset-y-0 right-0`,children:(0,$.jsx)(K6,{items:U.items,activeMessageIndex:Me+Ie,labels:Ot,onSelectMessage:Ve})})}),(0,$.jsx)(`div`,{ref:Oe,"data-chat-scroll-viewport":!0,className:K(`chat-messages chat-messages--wide-viewport min-h-0 flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] [scrollbar-gutter:stable_both-edges]`,rt?`chat-messages--compact-welcome pt-5 pb-2`:`py-4`),onScroll:Be,"data-chat-find-open":He.open?``:void 0,children:(0,$.jsx)(`div`,{className:e?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,$.jsx)(`div`,{"data-chat-message-frame":!0,className:K(`mx-auto w-full min-w-0`,!e&&`xl:max-w-[var(--max-width-chat-frame)]`),children:Je?(0,$.jsxs)(`div`,{className:`flex min-h-[min(40vh,20rem)] w-full flex-col gap-10 py-8`,"aria-busy":`true`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(xn,{className:`h-11 w-[min(70%,22rem)] rounded-2xl`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(xn,{className:`h-4 w-24`}),(0,$.jsx)(xn,{className:`h-4 w-[min(82%,36rem)]`}),(0,$.jsx)(xn,{className:`h-4 w-[min(74%,32rem)]`}),(0,$.jsx)(xn,{className:`h-4 w-[min(48%,22rem)]`})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(xn,{className:`h-11 w-[min(62%,18rem)] rounded-2xl`})})]}):(0,$.jsxs)($.Fragment,{children:[V.loadingMore?(0,$.jsx)(`div`,{className:`mb-3 text-center text-xs text-fg-muted`,children:i.chat.loadOlder}):null,W.error?(0,$.jsx)(`div`,{className:K(`sticky z-20 shrink-0 bg-transparent pe-2`,rt?`-top-5`:`-top-4`),children:(0,$.jsx)(PO,{errorText:W.error})}):null,!e&&R?(0,$.jsx)(`div`,{className:`hidden md:block`,children:(0,$.jsx)(gc,{taskId:R})}):null,be.length>0?(0,$.jsx)(`div`,{className:`mb-6 flex flex-col gap-3`,children:be.map(e=>(0,$.jsx)(J6,{link:e},e.id))}):null,Ce&&ye?(0,$.jsx)(b8,{view:ye,conversationId:de,onAbortCurrentTurn:W.abort}):null,!e&&de?(0,$.jsx)(o5,{eventType:`session.transcript.updated`,source:`sessions`,payloadKey:`conversationId`,payloadValue:de,className:`mb-6`}):null,(0,$.jsx)(UI,{messages:H.items,authToken:a??void 0,conversationId:V.decodedKey??V.conversationId,projectId:ct?.id,streaming:W.streaming,progress:W.progress,reasoningLevel:V.reasoningLevel,registerListContentRef:ke,onPickWelcomePrompt:Ue,welcomeSpotlight:xt,welcomeOverlay:ie?(0,$.jsx)(h5,{agentName:vt.name?.trim()||ne.displayAgentId,messages:i.agentsSettings,disabled:V.sessionRoutePending||V.showSessionLoading,onPick:e=>{p.current+=1,x({id:p.current,text:e})}}):re?(0,$.jsx)(s$,{sk:i.skills,disabled:V.sessionRoutePending||V.showSessionLoading,onPick:e=>{p.current+=1,x({id:p.current,text:Vg(`find-skills`,e)})}}):bt?(0,$.jsx)(QD,{showSkeleton:P,compact:e}):void 0,compactWelcome:e,onRetryWelcomeContext:_t.retry,onRefreshWelcomeExploration:xt?.categories.some(e=>e.scope===`explore`)?We:void 0,onSelectWelcomeProject:It,onDeleteRound:R?void 0:W.deleteMessageRound,onRetryUserMessageRound:R?void 0:W.retryUserMessageRound,deleteRoundDisabled:W.streaming||W.sending,onEditUserMessage:R?void 0:Tt,editLatestUserOnly:!0,editRequiresTurnId:!0,onSaveAssistantAsNote:At,onSaveAssistantToSourceNote:ot?kt:void 0,onExtractAssistantTask:ot?Mt:void 0,onForkAssistantTurn:!R&&ge?.sessionType===`chat`?_e:void 0,trailingContent:Te?.driver===`extension`?(0,$.jsx)(x$,{enabled:De}):De&&Te?(0,$.jsx)(_5,{payload:Te}):null})]})})})}),(0,$.jsx)(`div`,{className:`sticky bottom-0 z-10 shrink-0 bg-surface-panel`,children:(0,$.jsx)(`div`,{className:e?`px-3`:`px-3 sm:px-5 xl:px-6`,children:(0,$.jsxs)(`div`,{"data-chat-composer-frame":!0,className:K(`relative mx-auto w-full min-w-0`,!e&&`xl:max-w-[var(--max-width-chat-frame)]`,rt?`py-2.5`:`py-2 sm:py-4`),children:[(0,$.jsx)(KI,{visible:!V.showSessionLoading&&!J,onClick:()=>Ae(!0),running:W.streaming||W.sending}),(0,$.jsx)(`div`,{className:`absolute bottom-full right-0 z-20 mb-2 flex items-center rounded-full border border-edge-subtle bg-surface-panel/95 p-1 shadow-elevated backdrop-blur-sm empty:hidden xl:hidden`,children:e?null:(0,$.jsx)(z6,{items:U.items,activeMessageIndex:Me+Ie,labels:Ot,openLabel:i.chat.timelineOpen,closeLabel:i.chat.timelineClose,currentLabel:i.chat.timelineCurrent,onSelectMessage:Ve})}),(0,$.jsx)(Sc,{prompt:ee.clarifyPrompt,submitting:ee.clarifySubmitting,submitError:ee.clarifySubmitError,labels:i.chat,onSubmit:ee.submitClarifyAnswer,onAgentDecide:ee.letAgentDecideClarification,onCancel:ee.cancelClarification}),it?(0,$.jsx)(c4,{plan:it.plan,changeSummary:it.changeSummary,isStreaming:W.streaming,labels:{heading:i.chat.planHeading,stepProgress:i.chat.planStepProgress,completedProgress:i.chat.planCompletedProgress,finished:i.chat.planFinished,ended:i.chat.planEnded,planned:i.chat.planPlanned,filesChangedOne:i.chat.planFilesChanged_one,filesChangedOther:i.chat.planFilesChanged_other}}):null,re&&H.items.length>0?(0,$.jsx)(`div`,{className:`mb-2 text-right`,children:(0,$.jsx)(y,{to:`/capabilities/skills`,className:`text-xs text-accent-fg hover:underline`,children:i.skills.findBack})}):null,(0,$.jsx)(dJ,{}),(0,$.jsx)(Q0,{placeholder:ie?i.agentsSettings.setupComposerPlaceholder:re?i.skills.findPlaceholder:void 0,composerContext:!ie&&!e&&!R&&!I&&!Qe&&H.items.length===0?{project:ct,disabled:mt||wt.busy||Xe&&!V.projectPreparation,environmentPicker:V.projectPreparation?(0,$.jsx)(a2,{selection:wt}):void 0,workspacePath:V.effectiveWorkspacePath,canChangeWorkspace:Ge,onProjectChange:Pt,onWorkspaceChange:Lt}:void 0,contextRefs:lt,pageContextPreview:ft&&Y?(0,$.jsx)($0,{draft:ft,disabled:W.sending,waiting:W.streaming,onRemove:()=>r2.remove(Y,ft)}):void 0,setContextRefs:ut,disabled:!V.modelConfigReady||!V.projectPreparation&&Xe||!!(V.projectPreparation&&!wt.allowed)||V.modelConfigSaving||wt.busy||mt,sending:W.sending,streaming:W.streaming,conversationId:V.conversationId,prepareContextSession:V.projectPreparation?wt.prepareSession:void 0,welcomeDraftSeed:v,welcomeSuggestion:!re&&rt?St:null,onAcceptWelcomeSuggestion:Ue,thinkingLevel:V.thinkingLevel,modelSupportsThinking:V.modelSupportsThinking,onThinkingChange:V.onSessionThinkingLevelChange,onSend:wt.send,editingUserTurnId:I?.turnId,onCancelUserMessageEdit:Et,onAbort:W.abort,onAddPendingFollowUp:ft?void 0:G.addPendingFollowUp,onSteeringInterrupt:ft?void 0:(e,t,n)=>void W.interruptAndSend(e,t,void 0,n),pendingFollowUps:G.pendingFollowUps,editingFollowUpId:G.editingFollowUpId,onBeginEditFollowUp:G.beginEditFollowUp,onCancelEditFollowUp:G.cancelEditFollowUp,onCommitEditFollowUp:(e,t,n,r,i)=>void G.commitEditFollowUp(e,t,n,r,i),onPendingFollowUpRemove:G.removePendingFollowUp,onPendingFollowUpMove:G.movePendingFollowUp,onPendingFollowUpReorder:G.reorderPendingFollowUp,onPendingFollowUpSteer:e=>void G.steerPendingFollowUp(e),steeringFollowUpId:G.steeringFollowUpId,sessionModel:V.sessionModel,showModelSelector:!0,onModelChange:V.onSessionModelChange,modelDisabled:Xe&&!V.projectPreparation||wt.busy||W.streaming||W.sending||V.modelConfigSaving,onChatAgentChange:!ie&&!R&&ne.showChatAgentSelector?ne.onChatAgentChange:void 0,currentAgentId:ne.displayAgentId,voiceAgentName:vt.name,voiceTaskId:R??void 0,prepareVoiceSession:V.projectPreparation?()=>V.projectPreparation.create(wt.mode):void 0})]})})})]})]}),!e&&de&&window.electronAPI?.terminal?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(k5,{conversationId:de},de)}):null,(0,$.jsx)(nt,{open:O!==null,onOpenChange:e=>{!e&&!A&&Dt()},children:(0,$.jsxs)($e,{children:[(0,$.jsx)(Ye,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[1px]`}),(0,$.jsxs)(et,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(82vh,42rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(tt,{className:`text-base font-semibold text-fg`,children:i.chat.sourceNoteSaveDialogTitle}),(0,$.jsx)(Ze,{className:`mt-1 text-sm text-fg-muted`,children:i.chat.sourceNoteSaveDialogDescription.replace(`{{title}}`,gt)})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4`,children:[M?(0,$.jsxs)(`p`,{className:`rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:[i.chat.sourceNoteSaveFailed,`: `,M]}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:i.chat.sourceNoteSaveDialogHeadingLabel}),(0,$.jsx)(`input`,{value:O?.heading??``,onChange:e=>k(t=>t&&{...t,heading:e.target.value}),className:`h-10 rounded-lg border border-edge bg-surface-base px-3 text-sm font-normal text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:A})]}),(0,$.jsxs)(`label`,{className:`flex min-h-0 flex-1 flex-col gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:i.chat.sourceNoteSaveDialogContentLabel}),(0,$.jsx)(`textarea`,{value:O?.content??``,onChange:e=>k(t=>t&&{...t,content:e.target.value}),className:`min-h-[18rem] flex-1 resize-none rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg outline-none transition-colors focus:border-accent focus:ring-2 focus:ring-accent/20`,disabled:A})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(X,{type:`button`,variant:`secondary`,onClick:Dt,disabled:A,children:i.chat.sourceNoteSaveDialogCancel}),(0,$.jsx)(X,{type:`button`,variant:`primary`,onClick:()=>void jt(),disabled:A||!O?.content.trim(),children:A?i.chat.sourceNoteSaveDialogSaving:i.chat.sourceNoteSaveDialogConfirm})]})]})]})})]}):(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-[var(--max-width-chat-frame)] px-3 py-16 text-center text-sm leading-relaxed text-fg-muted sm:px-5`,children:i.chat.needToken})}function N5(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col overflow-hidden`,children:(0,$.jsx)(f,{})}),e[0]=t):t=e[0],t}var P5=`:conversationId?`;function F5(){let e=(0,Q.c)(5),{taskId:t}=p(),n=t===void 0?``:t,{data:r,error:i,isLoading:a,conversationLoading:o,conversationError:s}=mc(n),c=r?.conversation.activeConversationId??null;if(a||o||r&&!c&&!s){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-6`,"aria-busy":!0,children:[(0,$.jsx)(xn,{className:`h-10 w-64`}),(0,$.jsx)(xn,{className:`min-h-0 flex-1 rounded-xl`})]}),e[0]=t):t=e[0],t}if(i||s||!r){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`grid h-full place-items-center text-sm text-danger`,children:`Task conversation could not be loaded.`}),e[1]=t):t=e[1],t}if(!c)return null;let l;return e[2]!==c||e[3]!==n?(l=(0,$.jsx)(M5,{conversationId:c,taskId:n}),e[2]=c,e[3]=n,e[4]=l):l=e[4],l}function I5(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>{let r=t[n];return r===void 0||r===``?``:String(r)}).replace(/\s+/g,` `).trim()}function L5(e,t,n){return typeof t!=`number`||typeof n!=`number`?``:e.progressSuffix.replace(/\{\{completed\}\}/g,String(t)).replace(/\{\{total\}\}/g,String(n))}function R5(e){return e===`researching`||e===`browsing`?`research`:e===`reading`?`read`:e===`editing`?`create`:e===`planning`||e===`compacting`||e===`preparing`?`prepare`:e===`waiting`?`wait`:`execute`}function z5(e,t,n,r,i){let a=Kc(t,e,i);return{action:I5(e.tipTool,{action:a,detail:r?I5(e.targetSuffix,{detail:r}):``}),animation:R5(n),priority:`normal`}}function B5(e,t,n,r){return{action:I5(t===`running`?e.tipValidate:e.tipProgress,{progress:L5(e,n,r)}),animation:R5(t),priority:`normal`}}function V5(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function H5(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t.trim()}}function U5(e){if(!e||e.includes(`
121
- `)||e.includes(`\r`))return;let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1);if(!(!t||t.length>80||/(?:token|api[_-]?key|password|secret)=/i.test(t)))return t}function W5(e){if(e)try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t.host:void 0}catch{return}}function G5(e,t){let n=t??Ut(e??``,`running`);return n.category===`planning`?`planning`:n.category===`navigation`||n.category===`web`&&n.action===`read`?`browsing`:n.action===`search`?`researching`:n.category===`file`&&(n.action===`read`||n.action===`list`)?`reading`:n.category===`file`&&(n.action===`edit`||n.action===`write`)?`editing`:n.category===`command`?`running`:`preparing`}function K5(e,t,n){let r=V5(t),i=n??Ut(e??``,`running`),a={phase:G5(e,i)};return a.phase===`reading`||a.phase===`editing`?a.detail=U5(H5(r,`path`,`filePath`,`file`)):a.phase===`browsing`&&(a.detail=W5(H5(r,`url`,`href`))),(i.category===`command`||i.action===`search`)&&delete a.detail,a}function q5(e){let t=V5(e),n=H5(t,`stage`)?.toLowerCase(),r=n===`compaction`?`compacting`:n===`planning`?`planning`:n===`research`||n===`search`?`researching`:n===`verification`||n===`running`?`running`:n===`waiting`||n===`clarifying`?`waiting`:`preparing`,i=Number(t.completed),a=Number(t.total);return{phase:r,...Number.isFinite(i)&&i>=0?{completed:i}:{},...Number.isFinite(a)&&a>0?{total:a}:{}}}function J5(e){return e&&typeof e==`object`?e:{}}function Y5(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function X5(e){let t=Y5(e)?.replace(/```[\s\S]*?```/g,``).replace(/[`*_#>\[\]]/g,``).replace(/https?:\/\/\S+/g,``).replace(/(?:token|authorization|api[_-]?key|password|secret)\s*[:=].*/gi,`[redacted]`).replace(/\s+/g,` `).trim();return t?t.slice(0,96):void 0}var Z5=new Set([`working`,`waiting`,`success`,`error`]),Q5=new Set([`making_progress`,`waiting_safely`,`completed`,`work_preserved`,`details_available`]),$5=new Set([`open_session`,`confirm`,`review_error`]);function e7(e){let t=J5(e);if(t.version!==2||!Z5.has(String(t.taskState))||t.sensitivity!==`public`&&t.sensitivity!==`private`)return;let n=J5(t.nextAction),r=$5.has(String(n.type))&&$5.has(String(n.label))?{type:String(n.type),label:String(n.label)}:void 0,i=J5(t.progress),a=typeof i.completed==`number`&&typeof i.total==`number`&&i.total>0?{completed:i.completed,total:i.total}:void 0,o=Q5.has(String(t.reassurance))?t.reassurance:void 0,s=t.sensitivity===`public`?X5(t.publicSummary):void 0;return{version:2,taskState:String(t.taskState),sensitivity:t.sensitivity,...o?{reassurance:o}:{},...r?{nextAction:r}:{},...a?{progress:a}:{},...s?{publicSummary:s}:{}}}function t7(e,t,n,r){if(!e.conversationId)return null;let i=J5(e.event),a=J5(i.payload),o=Y5(i.type);if(!o)return null;let s=Y5(i.runId)??`active`,c={conversationId:e.conversationId,runId:s,sessionLabel:n,sequence:t,timestamp:Date.now()},l=e7(a.petFeedback??i.petFeedback),u=l?l.publicSummary:X5(a.publicSummary??i.publicSummary);if(o===`run_start`)return{...c,state:`running`,phase:`preparing`,action:r.tipRunStart,animation:`prepare`,priority:`low`};if(o===`thinking_delta`)return e.activityDetailLevel===`stream`?{...c,state:`running`,phase:`planning`,action:r.tipThinking,animation:`prepare`,priority:`low`}:null;if(o===`tool_start`||o===`tool_update`){let e=Y5(i.toolName)??Y5(a.toolName)??`tool`,t=J5(a.activity),n=typeof t.category==`string`&&typeof t.action==`string`?t:void 0,o=K5(e,a.args,n),s=o.phase??`running`,l=z5(r,e,s,o.detail,n);return{...c,state:`running`,phase:s,...l,detail:o.detail}}if(o===`progress`||o===`compaction`){let e=o===`compaction`?{phase:`compacting`}:q5(a),t=e.phase??`preparing`,n=B5(r,t,e.completed,e.total);return{...c,state:`running`,phase:t,...n,feedback:l,progress:l?.progress??(typeof e.completed==`number`&&typeof e.total==`number`?{completed:e.completed,total:e.total}:void 0)}}if(o===`clarify_request`)return{...c,state:`waiting`,phase:`waiting`,action:r.tipWaiting,animation:`wait`,priority:`high`,publicSummary:u,feedback:l};if(o===`assistant_message_start`||o===`assistant_delta`)return{...c,state:`running`,phase:`running`,action:r.tipAssistantDelta,animation:`create`,priority:`low`};if(o===`review_start`||o===`review_delta`)return{...c,state:`running`,phase:`reading`,action:r.tipReview,animation:`read`,priority:`normal`};if(o===`command_output_delta`)return{...c,state:`running`,phase:`running`,action:r.tipCommandDelta,animation:`execute`,priority:`low`};if(o===`assistant_message_end`){let e=Y5(a.presentation)===`narration`?`narration`:`answer`;return{...c,state:`running`,phase:e===`narration`?`preparing`:`running`,action:e===`narration`?r.tipAssistantNarrationDone:r.tipAssistantAnswerDone,animation:e===`narration`?`prepare`:`create`,priority:e===`narration`?`low`:`normal`,publicSummary:u}}if(o===`run_end`){let e=l?.taskState===`error`?`error`:`success`;return{...c,state:e,phase:e===`error`?`waiting`:`running`,action:e===`error`?r.tipError:r.tipComplete,animation:e===`error`?`concern`:`success`,priority:`high`,publicSummary:u,feedback:l}}return o===`error`?{...c,state:`error`,phase:`waiting`,action:r.tipError,animation:`concern`,priority:`high`,publicSummary:u,feedback:l}:null}function n7(e){return{searchedWeb:e.toolActionSearch,searchedMemory:e.toolActionSearchMemory,searchedCode:e.toolActionSearchCode,searched:e.toolActionSearchGeneric,readFile:e.toolActionReadFile,runCommand:e.toolActionRunCommand,updatePlan:e.toolActionUpdatePlan,listDirectory:e.toolActionListDirectory,writeFile:e.toolActionWriteFile,editFile:e.toolActionEditFile,openUrl:e.toolActionOpenUrl,fetchUrl:e.toolActionFetchUrl,unknownTool:e.toolActionUnknownNamed,tipRunStart:e.tipRunStart,tipTool:e.tipTool,tipProgress:e.tipProgress,tipValidate:e.tipValidate,tipWaiting:e.tipWaiting,tipThinking:e.tipThinking,tipAssistantDelta:e.tipAssistantDelta,tipCommandDelta:e.tipCommandDelta,tipAssistantNarrationDone:e.tipAssistantNarrationDone,tipAssistantAnswerDone:e.tipAssistantAnswerDone,tipReview:e.tipReview,tipComplete:e.tipComplete,tipError:e.tipError,targetSuffix:e.tipTargetSuffix,progressSuffix:e.tipProgressSuffix}}function r7(){let e=(0,Q.c)(10),t=Ee(s7),n;e[0]===t?n=e[1]:(n=xe(t),e[0]=t,e[1]=n);let r=n.desktopPet,i;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=new Map,e[2]=i):i=e[2];let a=(0,Z.useRef)(i),o;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=new Map,e[3]=o):o=e[3];let s=(0,Z.useRef)(o),c;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=new Set,e[4]=c):c=e[4];let l=(0,Z.useRef)(c),u;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=new Map,e[5]=u):u=e[5];let d=(0,Z.useRef)(u),f;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=new Map,e[6]=f):f=e[6];let p=(0,Z.useRef)(f),m=(0,Z.useRef)(null),h,g;return e[7]===r?(h=e[8],g=e[9]):(h=()=>{let e=window.electronAPI?.pet;if(!An()||!e)return;let t=t=>{p.current.set(t.conversationId,t),e.sendEvent(t).catch(o7)},n=()=>{m.current=null;for(let e of d.current.values())t(e);d.current.clear()},i=e=>{let t=s.current.get(e);return!t&&!l.current.has(e)&&(l.current.add(e),we(J(`/api/sessions/${encodeURIComponent(e)}?offset=0&limit=1`)).then(a7).then(t=>{t&&s.current.set(e,t)}).catch(i7).finally(()=>l.current.delete(e))),t??r.fallbackSessionLabel},o=e=>{let o=e.detail;if(!o.conversationId)return;let s=i(o.conversationId),c=(a.current.get(o.conversationId??``)??0)+1,l=t7(o,c,s,n7(r));if(!l)return;a.current.set(l.conversationId,c);let u=d.current.get(l.conversationId)??p.current.get(l.conversationId),f=l.state===`error`||l.state===`waiting`||l.state===`success`,h=!u||u.runId!==l.runId||u.state!==l.state||u.phase!==l.phase||u.animation!==l.animation||u.action!==l.action;if(f||h){d.current.delete(l.conversationId),t(l);return}d.current.set(l.conversationId,l),m.current===null&&(m.current=window.setTimeout(n,500))};return window.addEventListener(FA,o),()=>{window.removeEventListener(FA,o),m.current!==null&&window.clearTimeout(m.current),m.current=null,d.current.clear()}},g=[r],e[7]=r,e[8]=h,e[9]=g),(0,Z.useEffect)(h,g),null}function i7(){}async function a7(e){return e.ok?(await e.json()).session?.name?.trim():void 0}function o7(){}function s7(e){return e.language}async function c7(e){let t=await we(e);if(!t.ok){let e=await t.json().catch(()=>({})),n=je(t.status,t.statusText,e.error?.message);throw Error(n)}return t.json()}function l7(e){let t=(0,Q.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={fetcher:c7,revalidateOnFocus:!1,dedupingInterval:2e3,shouldRetryOnError:!0,errorRetryCount:2},t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,$.jsx)(Qt,{value:r,children:n}),t[1]=n,t[2]=i),i}var u7=(0,Z.lazy)(()=>op().then(e=>({default:e.SessionsPage}))),d7=(0,Z.lazy)(()=>sp().then(e=>({default:e.AutomationsPage}))),f7=(0,Z.lazy)(()=>lp().then(e=>({default:e.BrowserAutomationsPage}))),p7=(0,Z.lazy)(()=>cp().then(e=>({default:e.ScenesPage}))),m7=(0,Z.lazy)(()=>up().then(e=>({default:e.HomePage}))),h7=(0,Z.lazy)(()=>dp().then(e=>({default:e.TaskDetailPage}))),g7=(0,Z.lazy)(()=>fp().then(e=>({default:e.ProjectsPage}))),_7=(0,Z.lazy)(()=>pp().then(e=>({default:e.ProjectDetailPage}))),v7=(0,Z.lazy)(()=>mp().then(e=>({default:e.NotesPage}))),y7=(0,Z.lazy)(()=>hp().then(e=>({default:e.WorkflowsPage}))),b7=(0,Z.lazy)(()=>hp().then(e=>({default:e.WorkflowDetailPage}))),x7=(0,Z.lazy)(()=>hp().then(e=>({default:e.WorkflowEditorPage}))),S7=(0,Z.lazy)(()=>hp().then(e=>({default:e.WorkflowRunPage}))),C7=(0,Z.lazy)(()=>s(()=>import(`./imports-page-rssb4rjP.js`).then(e=>({default:e.ImportsPage})),__vite__mapDeps([160,1,2,3,4,5,6,7,94,9,11,19,25,26,27,28,15,31,106,16,38,39,17]))),w7=(0,Z.lazy)(()=>s(()=>import(`./capabilities-page-DH3aDk53.js`).then(e=>({default:e.CapabilitiesPage})),__vite__mapDeps([99,1,7,4,6,27,28,16,15,100,25,9,12,3,5,13,14,31]))),T7=(0,Z.lazy)(()=>_p().then(e=>({default:e.UserModelPage}))),E7=(0,Z.lazy)(()=>s(()=>import(`./connector-service-page-F-fYNIx8.js`).then(e=>e.n).then(e=>({default:e.ConnectorServicePage})),__vite__mapDeps([161,1,2,3,4,5,6,7,8,26,9,27,28,31,15,16]))),D7=(0,Z.lazy)(()=>vp().then(e=>({default:e.LogsPage}))),O7=(0,Z.lazy)(()=>yp().then(e=>({default:e.SettingsPage}))),k7=(0,Z.lazy)(()=>Lp().then(e=>({default:e.CapabilitiesSettingsPanel}))),A7=(0,Z.lazy)(()=>bp().then(e=>({default:e.AgentBrowserSettingsPage}))),j7=(0,Z.lazy)(()=>xp().then(e=>({default:e.ComputerSettingsPage}))),M7=(0,Z.lazy)(()=>Sp().then(e=>({default:e.ExtensionPage}))),N7=(0,Z.lazy)(()=>Cp().then(e=>({default:e.ExtensionSettingsPage}))),P7=(0,Z.lazy)(()=>wp().then(e=>({default:e.ExtensionDebugPage}))),F7=(0,Z.lazy)(()=>Tp().then(e=>({default:e.SharePreviewPage}))),I7=(0,Z.lazy)(()=>s(()=>import(`./desktop-pet-C1TZzKS3.js`).then(e=>({default:e.DesktopPetPage})),__vite__mapDeps([162,1,4,26,9,27,28,130,15]))),L7=(0,Z.lazy)(()=>Ep().then(e=>({default:e.LocalAppsPage}))),R7=(0,Z.lazy)(()=>Dp().then(e=>({default:e.LocalAppWorkbenchPage}))),z7=(0,Z.lazy)(()=>Op().then(e=>({default:e.ProductOpenPage}))),B7=(0,Z.lazy)(()=>kp().then(e=>({default:e.WorkDiscoveryPage})));function V7(){let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,$.jsx)(xn,{className:`h-5 w-44`}),(0,$.jsx)(xn,{className:`h-3 w-64 max-w-full`})]}),(0,$.jsx)(xn,{className:`h-9 w-24 shrink-0 rounded-lg`})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:Array.from({length:4}).map(U7)}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[t,n,(0,$.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:Array.from({length:6}).map(H7)})]})}),e[2]=r):r=e[2],r}function H7(e,t){return(0,$.jsx)(xn,{className:`h-36 rounded-lg`},t)}function U7(e,t){return(0,$.jsx)(xn,{className:`h-20 rounded-lg`},t)}function W7(){let e=(0,Q.c)(4),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(xn,{className:`h-8 w-48 max-w-full`}),n=(0,$.jsx)(xn,{className:`mt-6 h-36 rounded-xl`}),r=(0,$.jsx)(xn,{className:`mt-4 h-24 rounded-xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"aria-busy":!0,children:(0,$.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,$.jsxs)(`div`,{className:`mt-6 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(xn,{className:`h-20 rounded-xl`}),(0,$.jsx)(xn,{className:`h-20 rounded-xl`})]})]})}),e[3]=i):i=e[3],i}var G7=v([{path:`/desktop-pet`,errorElement:(0,$.jsx)(TQ,{}),element:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(I7,{})})},{path:`/share/:token`,errorElement:(0,$.jsx)(TQ,{}),element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(F7,{})})},{path:`/`,element:(0,$.jsx)(lQ,{}),errorElement:(0,$.jsx)(TQ,{}),children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(m7,{})})},{path:`open`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(z7,{})})},{path:`onboarding/workspace`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(B7,{})})},{path:`chat`,element:(0,$.jsx)(N5,{}),children:[{path:`task/:taskId`,element:(0,$.jsx)(F5,{})},{path:P5,element:(0,$.jsx)(M5,{})}]},...[`scenes`,`scenes/inbox`,`scenes/new/:templateKey`,`scenes/:activationId`].map(e=>({path:e,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(p7,{})})})),{path:`automations`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(d7,{})})},{path:`browser-automations`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(f7,{})})},{path:`user-model`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(T7,{})})},{path:`tasks/:taskId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(h7,{})})},{path:`projects`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(g7,{})})},{path:`:projectId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(_7,{})})},{path:`:projectId/:tabId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(_7,{})})},{path:`:projectId/notes/:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(_7,{})})}]},{path:`notes`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(v7,{})})},{path:`:noteId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(v7,{})})}]},{path:`workflows`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(y7,{})})},{path:`new`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(x7,{})})},{path:`runs/:runId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(S7,{})})},{path:`:definitionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(b7,{})})},{path:`:definitionId/edit`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(x7,{})})}]},{path:`capabilities/:section?/:detailId?`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(w7,{})})},{path:`settings/connector-service`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(E7,{})})},{path:`local-apps`,children:[{index:!0,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(L7,{})})},{path:`:appId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(R7,{})})}]},{path:`extensions/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(M7,{})})},{path:`extensions/:extensionId/:pageId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(M7,{})})},{path:`settings`,element:(0,$.jsx)(i$,{children:(0,$.jsx)(QQ,{})}),children:[{index:!0,element:(0,$.jsx)(_,{to:`overview`,replace:!0})},{path:`imports`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(C7,{})})},{path:`sessions`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(u7,{})})},{path:`logs`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(V7,{}),children:(0,$.jsx)(D7,{})})},{path:`computer-use`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(j7,{})})},{path:`agent-browser`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(A7,{})})},{path:`capabilities/:capability`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(k7,{})})},{path:`extensions/debug`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(P7,{})})},{path:`ext/:extensionId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(N7,{})})},{path:`ext/:extensionId/:panelId`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(N7,{})})},{path:`:section`,element:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(W7,{}),children:(0,$.jsx)(O7,{})})}]}]}]);function K7(){let e=(0,Q.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0],(0,Z.useEffect)(q7,t),null}function q7(){let e=Xd.persist.onFinishHydration(Y7),t=Rd.persist.onFinishHydration(J7),n=Ae(),r=Qd();return()=>{e?.(),t?.(),n(),r()}}function J7(){zd()}function Y7(){Zd()}function X7(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(K7,{}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(l7,{children:(0,$.jsx)(tj,{children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col *:min-h-0 *:flex-1`,children:[(0,$.jsx)(r7,{}),(0,$.jsx)(Un,{router:G7})]})]})})}),e[1]=n):n=e[1],n}function Z7(e){return e instanceof DOMException&&e.name===`AbortError`}function Q7(e){if(e.error!==void 0&&e.error!==null)return e.error;let t=e.filename?` (${e.filename}${e.lineno?`:${e.lineno}:${e.colno}`:``})`:``;return Error(`${e.message||`Unknown window error`}${t}`)}function $7(e){let t=!1,n=n=>{if(t||!n.message&&n.error==null)return;let r=Q7(n);Z7(r)||(t=!0,n.preventDefault(),e(r,`window.error`))},r=n=>{t||Z7(n.reason)||(t=!0,n.preventDefault(),e(n.reason??Error(`Unhandled promise rejection`),`unhandledrejection`))};return window.addEventListener(`error`,n),window.addEventListener(`unhandledrejection`,r),()=>{window.removeEventListener(`error`,n),window.removeEventListener(`unhandledrejection`,r)}}async function e9(){let e=(0,wa.createRoot)(document.getElementById(`root`)),t=!1,n=(n,r)=>{t||(t=!0,console.error(`Renderer fatal error (${r})`,n),e.render((0,$.jsx)(wQ,{error:n,source:r})))};$7(n);try{Ce(Te()),Yd(),Ld(),await ke(),e.render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(EQ,{children:(0,$.jsx)(X7,{})})}))}catch(e){n(e,`bootstrap`)}}e9();export{GX as $,Qh as $a,Pi as $c,KC as $i,Jn as $l,AL as $n,xd as $o,YM as $r,Qs as $s,hq as $t,e8 as A,Cx as Aa,ua as Ac,DD as Ai,Dr as Al,wW as An,Fp as Ao,UF as Ar,Ol as As,oY as At,F1 as B,h_ as Ba,Xi as Bc,QE as Bi,pr as Bl,YV as Bn,vf as Bo,kN as Br,jl as Bs,RJ as Bt,g8 as C,qS as Ca,Ca as Cc,aj as Ci,Hr as Cl,oG as Cn,xh as Co,BF as Cr,xl as Cs,kY as Ct,o8 as D,kS as Da,ma as Dc,FD as Di,jr as Dl,EW as Dn,Hp as Do,PF as Dr,fl as Ds,uY as Dt,Q6 as E,GS as Ea,ga as Ec,bA as Ei,Nr as El,TW as En,em as Eo,VF as Er,kl as Es,lY as Et,j2 as F,ux as Fa,na as Fc,SD as Fi,xr as Fl,oW as Fn,zp as Fo,uP as Fr,bl as Fs,$J as Ft,f$ as G,Cg as Ga,Ui as Gc,CT as Gi,or as Gl,NL as Gn,Xd as Go,ZM as Gr,ll as Gs,CJ as Gt,p$ as H,Hg as Ha,Ji as Hc,IT as Hi,dr as Hl,GV as Hn,hf as Ho,fN as Hr,_l as Hs,VJ as Ht,i2 as I,Fy as Ia,ta as Ic,fD as Ii,br as Il,rW as In,jp as Io,fP as Ir,il as Is,rY as It,zQ as J,pg as Ja,zi as Jc,yw as Ji,tr as Jl,OL as Jn,jd as Jo,aN as Jr,bc as Js,eJ as Jt,d$ as K,kg as Ka,Hi as Kc,Ow as Ki,ar as Kl,jL as Kn,kd as Ko,XM as Kr,Al as Ks,SJ as Kt,r2 as L,Cy as La,ea as Lc,sD as Li,yr as Ll,GU as Ln,Vp as Lo,eP as Lr,Sl as Ls,QJ as Lt,R2 as M,hx as Ma,sa as Mc,_D as Mi,Tr as Ml,xW as Mn,Rp as Mo,IF as Mr,yl as Ms,iY as Mt,F2 as N,mx as Na,oa as Nc,vD as Ni,wr as Nl,sW as Nn,Np as No,zP as Nr,al as Ns,tY as Nt,n8 as O,mS as Oa,pa as Oc,OD as Oi,kr as Ol,SW as On,Ip as Oo,zF as Or,Tl as Os,cY as Ot,z2 as P,fx as Pa,ra as Pc,xD as Pi,Cr as Pl,aW as Pn,Bp as Po,RP as Pr,ul as Ps,nY as Pt,ZX as Q,$h as Qa,Fi as Qc,QC as Qi,Yn as Ql,KL as Qn,vd as Qo,rN as Qr,oc as Qs,mq as Qt,W1 as R,xy as Ra,$i as Rc,iD as Ri,gr as Rl,PU as Rn,Pp as Ro,LN as Rr,Dl as Rs,eY as Rt,$6 as S,JS as Sa,Da as Sc,rj as Si,Ur as Sl,uG as Sn,Eh as So,KF as Sr,Cl as Ss,AY as St,h8 as T,BS as Ta,_a as Tc,$A as Ti,zr as Tl,WW as Tn,Am as To,RF as Tr,pl as Ts,_Y as Tt,c$ as U,Gg as Ua,qi as Uc,FT as Ui,lr as Ul,XV as Un,gf as Uo,nN as Ur,gl as Us,UJ as Ut,B1 as V,g_ as Va,Yi as Vc,QT as Vi,fr as Vl,qV as Vn,yf as Vo,dN as Vr,dl as Vs,LJ as Vt,u$ as W,Mg as Wa,Ki as Wc,PT as Wi,cr as Wl,KV as Wn,ef as Wo,QM as Wr,wl as Ws,wJ as Wt,xZ as X,tg as Xa,Li as Xc,pw as Xi,Zn as Xl,wL as Xn,Sd as Xo,$M as Xr,mc as Xs,Tq as Xt,zZ as Y,rg as Ya,Ri as Yc,vw as Yi,er as Yl,EL as Yn,Od as Yo,uN as Yr,yc as Ys,Sq as Yt,QX as Z,sg as Za,Ii as Zc,uw as Zi,Xn as Zl,LL as Zn,_d as Zo,sN as Zr,uc as Zs,Eq as Zt,d8 as _,lC as _a,Gs as _c,cM as _i,Qr as _l,aG as _n,hh as _o,gL as _r,$c as _s,GY as _t,o5 as a,rw as aa,ac,GM as ai,Si as al,qG as an,qh as ao,FL as ar,Wu as as,oX as at,r8 as b,uC as ba,Bs as bc,Mj as bi,Gr as bl,cG as bn,kh as bo,JF as br,hl as bs,OY as bt,U8 as c,GC as ca,ic as cc,KM as ci,_i as cl,XG as cn,Ah as co,WL as cr,$l as cs,fX as ct,m8 as d,PC as da,sc as dc,NM as di,oi as dl,jG as dn,gh as do,ML as dr,Il as ds,nX as dt,XC as ea,Zs as ec,BM as ei,Ai as el,sq as en,Yh as eo,GL as er,gd as es,UX as et,Kn as eu,t8 as f,BC as fa,nc as fc,OM as fi,ai as fl,AG as fn,vh as fo,kL as fr,Ll as fs,dX as ft,u8 as g,YS as ga,ec as gc,dM as gi,$r as gl,fG as gn,Oh as go,yL as gr,Jc as gs,QY as gt,i8 as h,XS as ha,tc as hc,kM as hi,ei as hl,dG as hn,Mh as ho,VL as hr,Yc as hs,iX as ht,d5 as i,WC as ia,rc as ic,VM as ii,wi as il,mK as in,og as io,xL as ir,qu as is,PX as it,y3 as j,px as ja,ca as jc,yD as ji,Er as jl,bW as jn,Up as jo,WF as jr,cl as js,aY as jt,p8 as k,uS as ka,da as kc,ED as ki,Or as kl,CW as kn,Mp as ko,HF as kr,El as ks,sY as kt,V8 as l,ZC as la,lc,UM as li,hi as ll,$G as ln,Ph as lo,RL as lr,Yl as ls,pX as lt,f8 as m,wC as ma,Ys as mc,jM as mi,ni as ml,DG as mn,_h as mo,TL as mr,ol as ms,sX as mt,M5 as n,UC as na,Xs as nc,RM as ni,Di as nl,kK as nn,eg as no,DL as nr,id as ns,VX as nt,W8 as o,HC as oa,qs as oc,zM as oi,bi as ol,JG as on,Ch as oo,SL as or,Lu as os,cX as ot,s8 as p,AC as pa,cc as pc,DM as pi,ri as pl,kG as pn,jh as po,qL as pr,rl as ps,lX as pt,l$ as q,hg as qa,Vi as qc,Dw as qi,rr as ql,CL as qn,Ad as qo,oN as qr,ml as qs,tJ as qt,D5 as r,JC as ra,Js as rc,WM as ri,Ti as rl,xK as rn,ig as ro,IL as rr,rd as rs,zX as rt,H8 as s,qC as sa,$s as sc,HM as si,yi as sl,KG as sn,yh as so,UL as sr,Fu as ss,uX as st,R5 as t,$C as ta,Ks as tc,JM as ti,Oi as tl,AK as tn,ag as to,bL as tr,md as ts,HX as tt,Wn as tu,v8 as u,YC as ua,dc as uc,LM as ui,si as ul,MG as un,Dh as uo,PL as ur,Jl as us,aX as ut,Z6 as v,sC as va,Hs as vc,eM as vi,Zr as vl,sG as vn,Th as vo,fL as vr,Xc as vs,NY as vt,a8 as w,US as wa,Sa as wc,ZA as wi,Br as wl,GW as wn,dh as wo,FF as wr,nl as ws,yY as wt,l8 as x,KS as xa,Ls as xc,lj as xi,Wr as xl,nG as xn,Nh as xo,qF as xr,vl as xs,jY as xt,X6 as y,cC as ya,Us as yc,Ij as yi,Yr as yl,lG as yn,wh as yo,dL as yr,Zc as ys,DY as yt,L1 as z,c_ as za,Zi as zc,$E as zi,hr as zl,JV as zn,ap as zo,RN as zr,el as zs,HJ as zt};