@xopcai/xopc 0.0.277 → 0.0.278

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 (330) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/adapters/cli-login.js +3 -3
  3. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  4. package/dist/extensions/telegram/src/inbound-processor.js +2 -2
  5. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +2 -2
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/extensions/weixin/src/api/api.js +2 -2
  9. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  10. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  11. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  12. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cavbls0E.js → agent-avatar-dicebear-lRVOwbrK.js} +1 -1
  13. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-DyCyuJpi.js → agent-defaults-settings-panel-DAqn5DdL.js} +1 -1
  14. package/dist/gateway/static/root/assets/{agents-DlDTItrB.js → agents-DNQNTDkU.js} +1 -1
  15. package/dist/gateway/static/root/assets/{app-management-settings-panel-5gS0_LWl.js → app-management-settings-panel-oHTY5PDs.js} +1 -1
  16. package/dist/gateway/static/root/assets/{appearance-settings-DHzZCJon.js → appearance-settings-B0YnZ3ig.js} +1 -1
  17. package/dist/gateway/static/root/assets/{apps-page-__yzruGu.js → apps-page-Bh0etSmL.js} +1 -1
  18. package/dist/gateway/static/root/assets/{archive-plugin-Ia98yZe3.js → archive-plugin-D4x142le.js} +1 -1
  19. package/dist/gateway/static/root/assets/{attachment-load-DiWW88c8.js → attachment-load-zibD2Hod.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-page-BuhTeGRJ.js → automations-page-Dkp7gp_S.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automations-workspace-DaisbmEh.js → automations-workspace-w4McwueN.js} +1 -1
  22. package/dist/gateway/static/root/assets/{binary-plugins-DDD48cJv.js → binary-plugins-CfUzu1Hc.js} +1 -1
  23. package/dist/gateway/static/root/assets/{block-editor-0AWVCD3F.js → block-editor-r5nCBBan.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-automations-page-BKOYX5xV.js → browser-automations-page-BnL4JnTM.js} +1 -1
  25. package/dist/gateway/static/root/assets/{browser-settings-page-C7zjxscU.js → browser-settings-page-DxX-t0EJ.js} +1 -1
  26. package/dist/gateway/static/root/assets/{capabilities-settings-panel-7kZMT1r6.js → capabilities-settings-panel-CvacBQAI.js} +1 -1
  27. package/dist/gateway/static/root/assets/{channels-settings-BKUh6hzO.js → channels-settings-CJzSNo-L.js} +1 -1
  28. package/dist/gateway/static/root/assets/{chat-terminal-dock-CW9Byi8V.js → chat-terminal-dock-CWVnJtBp.js} +1 -1
  29. package/dist/gateway/static/root/assets/{connectors-page-m8J-F3u8.js → connectors-page-DNBhBT0b.js} +1 -1
  30. package/dist/gateway/static/root/assets/{date-picker-gdYmKC8W.js → date-picker-XjPSlgq_.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-40BYmiMc.js → dependency-picker-CkyfEP88.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-By1z6tKE.js → desktop-pet-BAE_NVx5.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-ByjJqx9H.js → desktop-pet-settings-BUw6V2R9.js} +1 -1
  34. package/dist/gateway/static/root/assets/{device-pairing-wizard-CfWQfz7a.js → device-pairing-wizard-DsR5NQEC.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-DQO65KbM.js → extension-debug-page-giBeIVUT.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-Db32jip6.js → extension-page-Bqo9bNtx.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-CL8Wx8lf.js → extension-settings-page-BX-6AA3k.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-wLly-Kc1.js → gateway-settings-Dil7vuyU.js} +1 -1
  39. package/dist/gateway/static/root/assets/{heartbeat-settings-CRXWu2q6.js → heartbeat-settings-DWFAopk_.js} +1 -1
  40. package/dist/gateway/static/root/assets/{home-page-FqgSwpmy.js → home-page-Dpeuvazg.js} +1 -1
  41. package/dist/gateway/static/root/assets/{index-5UchbidQ.js → index-B03HGpzt.js} +9 -9
  42. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CjehhHPz.js → keyboard-shortcuts-settings-BKGPpBnV.js} +1 -1
  43. package/dist/gateway/static/root/assets/{local-app-workbench-page-DtYZa4GK.js → local-app-workbench-page-CBtemxFc.js} +1 -1
  44. package/dist/gateway/static/root/assets/{local-apps-page-CrIdaTrK.js → local-apps-page-B06ToOxB.js} +1 -1
  45. package/dist/gateway/static/root/assets/{logs-page-FfSwV_VH.js → logs-page-DibI1GsP.js} +1 -1
  46. package/dist/gateway/static/root/assets/{management-settings-BakV5aOw.js → management-settings-DJ6yMZCd.js} +1 -1
  47. package/dist/gateway/static/root/assets/{media-plugins-Blv9U6Jp.js → media-plugins-CdrLNAks.js} +1 -1
  48. package/dist/gateway/static/root/assets/{note-detail-panel-JbvyGdEX.js → note-detail-panel-GOxomxOK.js} +3 -3
  49. package/dist/gateway/static/root/assets/{notes-page-Dm7mE2FK.js → notes-page-CQBgk3_x.js} +1 -1
  50. package/dist/gateway/static/root/assets/{page-tabs-BQfVtLLC.js → page-tabs-B7LA4z-x.js} +1 -1
  51. package/dist/gateway/static/root/assets/{preview-open-alternatives-kjHFiO81.js → preview-open-alternatives-DTQRN7WR.js} +1 -1
  52. package/dist/gateway/static/root/assets/proactive-card-BF3741px.js +1 -0
  53. package/dist/gateway/static/root/assets/proactive-page-1EM217v0.js +1 -0
  54. package/dist/gateway/static/root/assets/{project-detail-page-h00lfcVI.js → project-detail-page-B1Pm-fQd.js} +1 -1
  55. package/dist/gateway/static/root/assets/{projects-page-C2Bo1FAL.js → projects-page-DUrxyNR9.js} +1 -1
  56. package/dist/gateway/static/root/assets/{remote-access-hub-_bZYAl49.js → remote-access-hub-C6VzHUwx.js} +1 -1
  57. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BhJlopSW.js → runtime-tools-settings-panel-D-DZf4I1.js} +1 -1
  58. package/dist/gateway/static/root/assets/{schema-form-cxoO_5I1.js → schema-form-B-Yj9DVW.js} +1 -1
  59. package/dist/gateway/static/root/assets/{sessions-page-F7CHsvPa.js → sessions-page-DtemHfkv.js} +1 -1
  60. package/dist/gateway/static/root/assets/settings-advanced-gate-ByEVQe0c.js +1 -0
  61. package/dist/gateway/static/root/assets/{settings-form-section-BiRTWiBi.js → settings-form-section-BxPUqwY6.js} +1 -1
  62. package/dist/gateway/static/root/assets/{settings-page-D-Cb71pq.js → settings-page-zLn8lIrs.js} +1 -1
  63. package/dist/gateway/static/root/assets/setup-status-panel-BwIrk3Jx.js +1 -0
  64. package/dist/gateway/static/root/assets/{share-preview-page-DciHfTay.js → share-preview-page-DAc_FkVc.js} +1 -1
  65. package/dist/gateway/static/root/assets/{shares-settings-BS2pnWO0.js → shares-settings-Dwdv6QyS.js} +1 -1
  66. package/dist/gateway/static/root/assets/{skill-reload-api-DX344nVV.js → skill-reload-api-CDzQWN60.js} +1 -1
  67. package/dist/gateway/static/root/assets/{skills-page-BhfKUsv7.js → skills-page-CO5XVkbY.js} +1 -1
  68. package/dist/gateway/static/root/assets/{skills-page.utils-CU7PALQB.js → skills-page.utils-BR5bk2vT.js} +1 -1
  69. package/dist/gateway/static/root/assets/{system-settings-panel-GpjNbqvM.js → system-settings-panel-C0ptJutB.js} +1 -1
  70. package/dist/gateway/static/root/assets/task-detail-page-DOjcKOzQ.js +1 -0
  71. package/dist/gateway/static/root/assets/{tunnel-api-Bhi_x_h4.js → tunnel-api-BABuQvGD.js} +1 -1
  72. package/dist/gateway/static/root/assets/{use-autosave-LvCiBidm.js → use-autosave-Dc5aN2px.js} +1 -1
  73. package/dist/gateway/static/root/assets/{user-model-page-BydARq2C.js → user-model-page-UhsSP_pC.js} +1 -1
  74. package/dist/gateway/static/root/assets/{voice-api-key-field-BlGysZxj.js → voice-api-key-field-CY0DpJui.js} +1 -1
  75. package/dist/gateway/static/root/assets/{work-discovery-overlay-DvIQOR5x.js → work-discovery-overlay-Brg9yJBr.js} +1 -1
  76. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-JIp60bXT.js → workflow-run-setup-panel-D3fq7boB.js} +1 -1
  77. package/dist/gateway/static/root/assets/{workflows-page-B972t6zx.js → workflows-page-S7XXNBWa.js} +1 -1
  78. package/dist/gateway/static/root/index.html +1 -1
  79. package/dist/package.js +1 -1
  80. package/dist/src/agent/agent-manager.js +17 -17
  81. package/dist/src/agent/agent-scope.js +2 -2
  82. package/dist/src/agent/background-review/run-background-review.js +4 -4
  83. package/dist/src/agent/commands/command-isolation.d.ts +1 -0
  84. package/dist/src/agent/commands/command-isolation.js +17 -1
  85. package/dist/src/agent/commands/commandMounts.d.ts +2 -0
  86. package/dist/src/agent/commands/commandMounts.js +32 -0
  87. package/dist/src/agent/context/coordinator.js +3 -3
  88. package/dist/src/agent/context/execution-context.js +4 -4
  89. package/dist/src/agent/context/execution-scope.js +2 -2
  90. package/dist/src/agent/context/project-context.js +4 -4
  91. package/dist/src/agent/embedded/index.js +2 -2
  92. package/dist/src/agent/embedded/model-runtime.js +1 -1
  93. package/dist/src/agent/embedded/run-for-session.js +5 -5
  94. package/dist/src/agent/embedded/run-turn.js +2 -2
  95. package/dist/src/agent/embedded/session-tool-result-guard.js +3 -3
  96. package/dist/src/agent/external-tools/composio-provider.js +1 -1
  97. package/dist/src/agent/external-tools/gateway-tools.js +1 -1
  98. package/dist/src/agent/external-tools/mcp-provider.js +2 -2
  99. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  100. package/dist/src/agent/image/generation/providers/dashscope.js +1 -1
  101. package/dist/src/agent/image/generation/providers/fal.js +1 -1
  102. package/dist/src/agent/image/generation/providers/google.js +1 -1
  103. package/dist/src/agent/image/generation/runtime.js +1 -1
  104. package/dist/src/agent/image/index.js +1 -1
  105. package/dist/src/agent/image/load-image-media.js +1 -1
  106. package/dist/src/agent/image/tool-model-config.js +1 -1
  107. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  108. package/dist/src/agent/inbound/inbound-loop.js +2 -2
  109. package/dist/src/agent/index.js +1 -1
  110. package/dist/src/agent/mcp/bundle-mcp-gateway.js +1 -1
  111. package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
  112. package/dist/src/agent/mcp/index.js +2 -2
  113. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  114. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
  115. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  116. package/dist/src/agent/memory/index.js +2 -2
  117. package/dist/src/agent/messaging/outbound-coordinator.js +1 -1
  118. package/dist/src/agent/orchestration/agent-orchestrator.js +5 -5
  119. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  120. package/dist/src/agent/sandbox/command-validator.js +0 -20
  121. package/dist/src/agent/sandbox/exec-policy.d.ts +1 -0
  122. package/dist/src/agent/sandbox/exec-policy.js +3 -3
  123. package/dist/src/agent/sandbox/fileAccess.d.ts +7 -0
  124. package/dist/src/agent/sandbox/fileAccess.js +100 -0
  125. package/dist/src/agent/sandbox/path-policy.d.ts +2 -0
  126. package/dist/src/agent/sandbox/path-policy.js +54 -17
  127. package/dist/src/agent/sandbox/sanitize-env-vars.js +10 -9
  128. package/dist/src/agent/service/direct-turn-helpers.js +6 -6
  129. package/dist/src/agent/service/process-direct-one-shot.js +1 -1
  130. package/dist/src/agent/service/process-direct-streaming.js +5 -5
  131. package/dist/src/agent/service/webchat-tts.js +2 -2
  132. package/dist/src/agent/service.js +19 -19
  133. package/dist/src/agent/session/session-inspector.js +1 -1
  134. package/dist/src/agent/skills/filesystem-watcher.js +1 -1
  135. package/dist/src/agent/skills/hub-lock.js +1 -1
  136. package/dist/src/agent/skills/hub-pull.js +3 -3
  137. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +1 -1
  138. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
  139. package/dist/src/agent/tasks/task-judge-service.js +5 -5
  140. package/dist/src/agent/tools/apply-patch.js +25 -38
  141. package/dist/src/agent/tools/create-share-tool.js +13 -5
  142. package/dist/src/agent/tools/delegate-tool.js +3 -3
  143. package/dist/src/agent/tools/exec-command.js +2 -1
  144. package/dist/src/agent/tools/executor.js +1 -1
  145. package/dist/src/agent/tools/factory.js +13 -13
  146. package/dist/src/agent/tools/find.js +5 -3
  147. package/dist/src/agent/tools/grep.js +21 -4
  148. package/dist/src/agent/tools/image-generate-tool.js +5 -6
  149. package/dist/src/agent/tools/index.js +5 -5
  150. package/dist/src/agent/tools/list-dir.js +2 -1
  151. package/dist/src/agent/tools/managed-job-tool.js +1 -0
  152. package/dist/src/agent/tools/publish-artifacts.js +4 -3
  153. package/dist/src/agent/tools/read.js +9 -6
  154. package/dist/src/agent/tools/repository-search.d.ts +2 -0
  155. package/dist/src/agent/tools/repository-search.js +51 -7
  156. package/dist/src/agent/tools/review-workspace.js +76 -10
  157. package/dist/src/agent/tools/send-media.js +5 -4
  158. package/dist/src/agent/tools/skills-tools.js +1 -1
  159. package/dist/src/agent/tools/tool-paths.js +3 -1
  160. package/dist/src/agent/tools/tts-tool.js +1 -1
  161. package/dist/src/agent/tools/user-context-tool.js +1 -1
  162. package/dist/src/agent/tools/write.js +6 -19
  163. package/dist/src/agent/tools/xopc-use-tool.js +6 -6
  164. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  165. package/dist/src/agent-config/schema.d.ts +24 -0
  166. package/dist/src/agent-config/schema.js +2 -1
  167. package/dist/src/ai-assist/text-assist.js +1 -1
  168. package/dist/src/auth/credentials.js +2 -2
  169. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  170. package/dist/src/auth/profiles/store.js +1 -1
  171. package/dist/src/auth/sync-provider-auth.js +2 -2
  172. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  173. package/dist/src/capabilities/store-connector.js +1 -1
  174. package/dist/src/channels/attachments/voice-stt-webchat.js +2 -2
  175. package/dist/src/channels/index.js +2 -2
  176. package/dist/src/channels/outbound-sender.js +1 -1
  177. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  178. package/dist/src/channels/pairing/pairing-store.js +6 -6
  179. package/dist/src/chat-commands/builtins/config.js +2 -2
  180. package/dist/src/chat-commands/builtins/review.js +1 -1
  181. package/dist/src/chat-commands/builtins/session.js +1 -1
  182. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  183. package/dist/src/chat-commands/builtins/tts.js +1 -1
  184. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  185. package/dist/src/chat-commands/builtins/workflow.js +2 -2
  186. package/dist/src/chat-commands/context.js +2 -2
  187. package/dist/src/chat-commands/index.js +3 -3
  188. package/dist/src/cli/commands/agent.js +6 -6
  189. package/dist/src/cli/commands/agents.js +1 -1
  190. package/dist/src/cli/commands/config.js +1 -1
  191. package/dist/src/cli/commands/doctor/checks/provider-auth.js +21 -20
  192. package/dist/src/cli/commands/extension-dev.js +1 -1
  193. package/dist/src/cli/commands/extension.js +1 -1
  194. package/dist/src/cli/commands/gateway/shared.js +1 -1
  195. package/dist/src/cli/commands/gateway/token.js +1 -1
  196. package/dist/src/cli/commands/image.js +1 -1
  197. package/dist/src/cli/commands/init.js +1 -1
  198. package/dist/src/cli/commands/models.js +1 -1
  199. package/dist/src/cli/commands/onboard.js +1 -1
  200. package/dist/src/cli/commands/project.js +2 -2
  201. package/dist/src/cli/commands/runtime.js +1 -1
  202. package/dist/src/cli/commands/skills.js +2 -2
  203. package/dist/src/cli/commands/tui.js +1 -1
  204. package/dist/src/cli/commands/tunnel.js +3 -3
  205. package/dist/src/cli/extension-cli-register.js +4 -4
  206. package/dist/src/cli/utils/gateway-client.js +1 -1
  207. package/dist/src/config/index.js +5 -5
  208. package/dist/src/config/loader.js +2 -2
  209. package/dist/src/config/models-json.js +1 -1
  210. package/dist/src/config/schema.d.ts +16 -0
  211. package/dist/src/connectors/connected-source-understanding.js +2 -2
  212. package/dist/src/connectors/connection-recovery-service.js +3 -3
  213. package/dist/src/discussions/live-worker.js +1 -1
  214. package/dist/src/discussions/sealer.js +1 -1
  215. package/dist/src/extensions/api.js +3 -3
  216. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  217. package/dist/src/extensions/index.js +1 -1
  218. package/dist/src/extensions/loader.js +1 -1
  219. package/dist/src/extensions/lockfile.js +1 -1
  220. package/dist/src/extensions/sdk/index.js +1 -1
  221. package/dist/src/gateway/agents-admin.js +4 -4
  222. package/dist/src/gateway/device-routes.js +2 -2
  223. package/dist/src/gateway/file-path-classifier.js +2 -2
  224. package/dist/src/gateway/heartbeat/service.js +1 -1
  225. package/dist/src/gateway/hono/app.js +3 -3
  226. package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -0
  227. package/dist/src/gateway/hono/lib/config-payload.js +3 -3
  228. package/dist/src/gateway/hono/routes/agents.js +1 -1
  229. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  230. package/dist/src/gateway/hono/routes/browser.js +1 -1
  231. package/dist/src/gateway/hono/routes/commands-skills.js +3 -3
  232. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  233. package/dist/src/gateway/hono/routes/mcp.js +2 -2
  234. package/dist/src/gateway/hono/routes/media.js +1 -1
  235. package/dist/src/gateway/hono/routes/models.js +5 -5
  236. package/dist/src/gateway/hono/routes/notes.js +1 -1
  237. package/dist/src/gateway/hono/routes/proactive-control.js +4 -4
  238. package/dist/src/gateway/hono/routes/projects.js +2 -2
  239. package/dist/src/gateway/hono/routes/sessions.js +1 -1
  240. package/dist/src/gateway/hono/routes/shares.js +25 -4
  241. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  242. package/dist/src/gateway/hono/routes/status.js +1 -1
  243. package/dist/src/gateway/hono/routes/tasks.js +4 -4
  244. package/dist/src/gateway/hono/routes/user-model.js +4 -4
  245. package/dist/src/gateway/hono/routes/voice.js +3 -3
  246. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  247. package/dist/src/gateway/image-generation-setup.js +1 -1
  248. package/dist/src/gateway/lock.js +10 -10
  249. package/dist/src/gateway/media-access.js +2 -2
  250. package/dist/src/gateway/ports.js +6 -6
  251. package/dist/src/gateway/server.js +1 -1
  252. package/dist/src/gateway/service/config-coordinator.js +4 -4
  253. package/dist/src/gateway/service/marketplace-service.js +3 -3
  254. package/dist/src/gateway/service/run-gateway-agent.js +3 -3
  255. package/dist/src/gateway/service.js +36 -36
  256. package/dist/src/gateway/session-context-summary.js +2 -2
  257. package/dist/src/gateway/workspace-editor-path.js +2 -2
  258. package/dist/src/heartbeat/index.js +1 -1
  259. package/dist/src/infra/gateway-processes.js +2 -2
  260. package/dist/src/infra/path-env.js +3 -3
  261. package/dist/src/infra/update-global.js +10 -10
  262. package/dist/src/local-apps/service.js +1 -1
  263. package/dist/src/media-shared/http/ssrf-guard.js +1 -1
  264. package/dist/src/notes/agent-context.js +3 -3
  265. package/dist/src/proactive/actions/service.js +1 -1
  266. package/dist/src/proactive/execution/agent-executor.js +1 -1
  267. package/dist/src/proactive/execution/context.js +1 -1
  268. package/dist/src/proactive/execution/worker.js +1 -1
  269. package/dist/src/proactive/experience.js +7 -2
  270. package/dist/src/proactive/follow-ups.js +1 -1
  271. package/dist/src/proactive/inbox/cards.js +2 -2
  272. package/dist/src/proactive/inbox/delivery.js +2 -2
  273. package/dist/src/proactive/inbox/digest.js +2 -2
  274. package/dist/src/proactive/inbox/notification-policy.js +1 -1
  275. package/dist/src/proactive/inbox/repository.js +1 -1
  276. package/dist/src/proactive/inbox/service.js +1 -1
  277. package/dist/src/proactive/index.js +1 -1
  278. package/dist/src/proactive/temporal/worker.js +1 -1
  279. package/dist/src/projects/project-skill-service.js +2 -2
  280. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  281. package/dist/src/providers/index.js +2 -2
  282. package/dist/src/providers/model-reference-auditor.js +1 -1
  283. package/dist/src/providers/model-registry.js +1 -1
  284. package/dist/src/providers/register-runtime-providers.js +1 -1
  285. package/dist/src/remote-access/exposure-manager.js +1 -1
  286. package/dist/src/session/index.js +2 -2
  287. package/dist/src/session/session-title.js +1 -1
  288. package/dist/src/session/store.js +3 -3
  289. package/dist/src/session/thinking-resolve.js +1 -1
  290. package/dist/src/share/share-store.js +6 -2
  291. package/dist/src/share/share-thumbnail.js +1 -1
  292. package/dist/src/share/site-share-store.js +1 -1
  293. package/dist/src/storage/sqlite/connection.js +9 -9
  294. package/dist/src/tasks/execution-context.js +1 -1
  295. package/dist/src/tasks/home-query-service.js +3 -3
  296. package/dist/src/tasks/index.js +3 -3
  297. package/dist/src/tasks/task-application-service.js +78 -4
  298. package/dist/src/tasks/task-context-assembler.js +2 -1
  299. package/dist/src/tasks/task-handoff-service.js +1 -1
  300. package/dist/src/tasks/task-run-coordinator.js +1 -1
  301. package/dist/src/tui/backends/embedded-backend.js +9 -9
  302. package/dist/src/tui/backends/gateway-realtime-backend.js +2 -2
  303. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  304. package/dist/src/tui/tui-command-formatters.js +1 -1
  305. package/dist/src/tui/tui-commands.js +5 -5
  306. package/dist/src/tui/tui-picker-overlay.js +1 -1
  307. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  308. package/dist/src/tui/tui-startup-resources.js +5 -5
  309. package/dist/src/tui/tui.js +3 -3
  310. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  311. package/dist/src/voice/local/runtime-worker.js +1 -1
  312. package/dist/src/voice/realtime/memory-context.js +3 -3
  313. package/dist/src/voice/stt/index.js +2 -2
  314. package/dist/src/voice/stt/preflight.js +1 -1
  315. package/dist/src/voice/stt/providers/local-transcription.js +1 -1
  316. package/dist/src/voice/stt/transcribe-core.js +1 -1
  317. package/dist/src/voice/tts/index.js +3 -3
  318. package/dist/src/voice/tts/merge-config.js +1 -1
  319. package/dist/src/voice/tts/payload.js +1 -1
  320. package/dist/src/voice/tts/speak-core.js +1 -1
  321. package/dist/src/work-discovery/service.js +3 -3
  322. package/dist/src/workflows/context/workflow-context.js +1 -1
  323. package/dist/src/workflows/service/workflow-run-service.js +6 -6
  324. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  325. package/package.json +3 -3
  326. package/dist/gateway/static/root/assets/proactive-card-Ap_wfos3.js +0 -1
  327. package/dist/gateway/static/root/assets/proactive-page-D1lEuanT.js +0 -1
  328. package/dist/gateway/static/root/assets/settings-advanced-gate-DtZSUX4H.js +0 -1
  329. package/dist/gateway/static/root/assets/setup-status-panel-VPfBsNVv.js +0 -1
  330. package/dist/gateway/static/root/assets/task-detail-page-CElcQ9Sh.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a,p as o,t as s}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as c}from"./check-DUBLcKHA.js";import{d as l,f as u,l as d,n as f,p,r as m,t as h,u as g}from"./popover-select-DGmMQt4t.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./copy-Dv6d4Dvw.js";import{t as y}from"./download-Dk-ZjtO6.js";import{t as b}from"./external-link-DjqjBmc3.js";import{d as x,p as S,t as C}from"./markdown-view-DF3aJP_5.js";import{t as w}from"./git-branch-Dh9uxTot.js";import{t as T}from"./loader-circle-CifKLtgG.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./x-B_N4OPjy.js";import{t as O}from"./cn-JdwAhgNB.js";import{a as k,c as A,f as j,n as M,r as N}from"./locale-store-BkJ7g35d.js";import{t as P}from"./messages-BGc-OJWg.js";import{a as F,c as I,i as L,n as R,o as z,r as B,s as ee,t as te}from"./dist-BGTk37IG.js";import{t as V}from"./copy-to-clipboard-HOJ79TWv.js";import{i as H}from"./vendor-swr-BIWyz7Rc.js";import{t as U}from"./button-BA45yciM.js";import{t as W}from"./skeleton-BwbyijEw.js";import{Aa as ne,Ac as re,As as G,Au as K,Bi as ie,Bn as ae,Bs as oe,Ca as q,Cn as se,Da as J,Dn as ce,Ea as le,Es as ue,Eu as de,Fa as Y,Fc as fe,Fi as pe,Gc as me,Gi as he,Hi as ge,Hl as _e,Hn as ve,Ia as ye,Ir as be,Jl as xe,Jn as Se,Ki as Ce,Lc as we,Li as Te,Ma as Ee,Ml as De,Mo as Oe,Mu as ke,Na as Ae,Nl as je,Ns as Me,Oa as Ne,Oc as Pe,Ol as Fe,Os as Ie,Pa as Le,Pc as Re,Pi as ze,Pl as Be,Qi as Ve,Ql as He,Ri as Ue,Rn as We,Rs as Ge,Sa as Ke,Sn as qe,Ta as Je,To as Ye,Ts as Xe,Ui as Ze,Vi as Qe,Vn as $e,Vt as et,Wc as tt,Wi as nt,Ws as rt,Xc as it,Xi as at,Xr as ot,Xs as st,Zi as ct,Zn as lt,Zs as ut,_c as dt,_l as ft,_s as pt,an as mt,ba as ht,bl as gt,bn as _t,bu as vt,cl as yt,cn as bt,co as xt,dc as St,du as Ct,ea as wt,ec as Tt,fc as Et,fi as Dt,fu as Ot,hc as kt,hs as At,ic as jt,ir as Mt,ja as Nt,jc as Pt,js as Ft,ka as It,kl as Lt,kn as Rt,ku as zt,lc as Bt,ll as Vt,lu as Ht,mc as Ut,mi as Wt,ms as Gt,mu as Kt,nu as qt,qi as Jt,ra as Yt,rc as Xt,rl as Zt,si as Qt,sr as $t,su as en,un as tn,us as nn,uu as rn,va as an,wa as on,wn as sn,xl as cn,xn as ln,ya as un,yc as dn,yl as fn,yn as pn,ys as mn,za as hn,zi as gn}from"./index-5UchbidQ.js";import{i as _n,n as vn,r as yn,t as bn}from"./note-detail-panel-JbvyGdEX.js";import{n as xn,t as Sn}from"./use-autosave-LvCiBidm.js";import{t as Cn}from"./page-tabs-BQfVtLLC.js";import{t as wn}from"./date-picker-gdYmKC8W.js";import{t as Tn}from"./automations-workspace-DaisbmEh.js";import{i as En,p as Dn,s as On}from"./skills-page.utils-CU7PALQB.js";import{t as X}from"./dependency-picker-40BYmiMc.js";import{c as kn,l as An,n as jn,o as Mn,r as Nn,t as Pn}from"./style-TIDOdKy0.js";var Z=e(t(),1),Q=n(),$=r();function Fn(e){let t=(0,Q.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":u}=e,d=c===void 0?`max-w-[min(12rem,40vw)]`:c,f=l===void 0?!1:l,p,m;t[0]!==a||t[1]!==n?(m=n.trim(),p=m?Ve(m):a??``,t[0]=a,t[1]=n,t[2]=p,t[3]=m):(p=t[2],m=t[3]);let h=p,g=o??(m||void 0),_=u??o??h,v=f?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,y=!f&&d,b=i&&`cursor-not-allowed opacity-60`,x;t[4]!==s||t[5]!==v||t[6]!==y||t[7]!==b?(x=O(v,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,nn.transition,nn.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,y,b,s),t[4]=s,t[5]=v,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==i||t[10]!==r?(S=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=S):S=t[11];let C=f?`size-4`:`size-3.5`,w;t[12]===C?w=t[13]:(w=O(`shrink-0 text-fg-muted`,C),t[12]=C,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(De,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==f||t[17]!==h?(E=f?null:(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:h}),t[16]=f,t[17]=h,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==S||t[21]!==T||t[22]!==E||t[23]!==g||t[24]!==_||t[25]!==x?(D=(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:g,"aria-label":_,className:x,onClick:S,children:[T,E]}),t[19]=i,t[20]=S,t[21]=T,t[22]=E,t[23]=g,t[24]=_,t[25]=x,t[26]=D):D=t[26],D}function In(e){let t=(0,Q.c)(38),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,autoFocus:c,trailing:l}=e,u;t[0]!==r||t[1]!==n?(u={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=ct(u),f;t[3]===n?f=t[4]:(f=n.trim(),t[3]=n,t[4]=f);let p=f,m=p?`${p}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,h;t[5]===s?h=t[6]:(h=O(`min-w-0 flex-1`,s),t[5]=s,t[6]=h);let g=i||d.picking,_;t[7]===r?_=t[8]:(_=e=>void r(e.target.value),t[7]=r,t[8]=_);let v=o??a.pathInputPlaceholder,y;t[9]!==c||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==n?(y=(0,$.jsx)(`input`,{type:`text`,className:h,value:n,disabled:g,onChange:_,placeholder:v,autoFocus:c,autoComplete:`off`,spellCheck:!1}),t[9]=c,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=n,t[15]=y):y=t[15];let b=i||d.picking,x;t[16]!==m||t[17]!==d.pick||t[18]!==b||t[19]!==n||t[20]!==a.selectWorkingDirectory?(x=(0,$.jsx)(Fn,{compact:!0,value:n,onPick:d.pick,disabled:b,title:m,"aria-label":a.selectWorkingDirectory}),t[16]=m,t[17]=d.pick,t[18]=b,t[19]=n,t[20]=a.selectWorkingDirectory,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==l?(S=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,l]}),t[22]=x,t[23]=l,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==y?(C=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[y,S]}),t[25]=S,t[26]=y,t[27]=C):C=t[27];let w;t[28]!==d.confirmPick||t[29]!==d.hasNativePicker||t[30]!==d.modalOpen||t[31]!==d.setModalOpen||t[32]!==p||t[33]!==a?(w=d.hasNativePicker?null:(0,$.jsx)(Jt,{open:d.modalOpen,onOpenChange:d.setModalOpen,initialAbsolutePath:p||void 0,onConfirm:d.confirmPick,wd:a}),t[28]=d.confirmPick,t[29]=d.hasNativePicker,t[30]=d.modalOpen,t[31]=d.setModalOpen,t[32]=p,t[33]=a,t[34]=w):w=t[34];let T;return t[35]!==C||t[36]!==w?(T=(0,$.jsxs)($.Fragment,{children:[C,w]}),t[35]=C,t[36]=w,t[37]=T):T=t[37],T}function Ln(e){let t=(0,Q.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]!==r||t[1]!==n?(s=$t(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s;if(a){let e;t[3]===i?e=t[4]:(e=O(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(fn,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,$.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!0),t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=O(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==c||t[13]!==u?(d=(0,$.jsx)(lt,{src:c,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:l,className:u}),t[11]=n,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Rn(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function zn(e){let t=(0,Q.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=Mt(),f=Mt(Vn),p=u===n&&d===r,m=p&&o,h=p&&s,g=p?c:0,_=p&&l>0?l:i??0,v=_>0?Math.min(g/_*100,100):0,y;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==f?(y=e=>{e.stopPropagation(),f(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=f,t[4]=y):y=t[4];let b=y,x;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==f?(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),f(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=f,t[9]=x):x=t[9];let S=x,C;t[10]===a?C=t[11]:(C=O(`flex items-center gap-2`,a),t[10]=a,t[11]=C);let w=m?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,E;t[12]===w?E=t[13]:(E=O(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,w),t[12]=w,t[13]=E);let D=m?`Pause`:`Play`,k;t[14]!==h||t[15]!==m?(k=h?(0,$.jsx)(T,{className:`size-3.5 animate-spin`}):m?(0,$.jsx)(Re,{className:`size-3.5`}):(0,$.jsx)(Pe,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=k):k=t[16];let A;t[17]!==b||t[18]!==S||t[19]!==E||t[20]!==D||t[21]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:b,onKeyDown:S,className:E,"aria-label":D,children:k}),t[17]=b,t[18]=S,t[19]=E,t[20]=D,t[21]=k,t[22]=A):A=t[22];let j=`${v}%`,M;t[23]===j?M=t[24]:(M=(0,$.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:j}})}),t[23]=j,t[24]=M);let N;t[25]!==_||t[26]!==p||t[27]!==g?(N=Rn(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=N):N=t[28];let P;t[29]===N?P=t[30]:(P=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==F||t[35]!==C||t[36]!==A?(I=(0,$.jsxs)(`div`,{className:C,onClick:Bn,children:[A,F]}),t[34]=F,t[35]=C,t[36]=A,t[37]=I):I=t[37],I}function Bn(e){return e.stopPropagation()}function Vn(e){return e.toggle}function Hn(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Un(e){let t=(0,Q.c)(88),{note:n,selected:r,onPress:i,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=r===void 0?!1:r,d;t[0]!==c||t[1]!==n?(d=Hn(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[m]=(0,Z.useState)(Xn),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=_n(n.createdAt,m,l),t[3]=n.createdAt,t[4]=m,t[5]=l,t[6]=h):h=t[6];let g=h,_,v;t[7]!==n.id||t[8]!==i?(_=()=>i(n.id),v=e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),i(n.id))},t[7]=n.id,t[8]=i,t[9]=_,t[10]=v):(_=t[9],v=t[10]);let y=u?`bg-surface-active hover:bg-surface-active`:`bg-transparent hover:bg-surface-panel/70`,b;t[11]===y?b=t[12]:(b=O(`group relative flex cursor-pointer flex-col gap-2 overflow-hidden rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-rail`,y),t[11]=y,t[12]=b);let x=u?`true`:void 0,S;t[13]===u?S=t[14]:(S=u?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-y-2 left-0 w-0.5 rounded-r-pill bg-accent`,"aria-hidden":!0}):null,t[13]=u,t[14]=S);let C;t[15]!==n.coverAttachmentId||t[16]!==n.id||t[17]!==n.kind||t[18]!==n.voiceAttachmentId||t[19]!==n.voiceDurationSec?(C=n.coverAttachmentId?(0,$.jsx)(Ln,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,$.jsx)(zn,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[15]=n.coverAttachmentId,t[16]=n.id,t[17]=n.kind,t[18]=n.voiceAttachmentId,t[19]=n.voiceDurationSec,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=n.title&&(0,$.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[21]=n.title,t[22]=w);let T=n.title?`text-fg-muted`:p?`italic text-fg-muted`:`text-fg`,E;t[23]===T?E=t[24]:(E=O(`truncate text-sm leading-5`,T),t[23]=T,t[24]=E);let D;t[25]!==f||t[26]!==E?(D=(0,$.jsx)(`p`,{className:E,children:f}),t[25]=f,t[26]=E,t[27]=D):D=t[27];let k;t[28]!==w||t[29]!==D?(k=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(_e,{className:`size-4`}),t[31]=A):A=t[31];let j;t[32]===c.actions?j=t[33]:(j=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Yn,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-100 transition-opacity hover:bg-surface-panel focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:opacity-0 lg:group-hover:opacity-100 lg:focus-visible:opacity-100`,"aria-label":c.actions,title:c.actions,children:A})}),t[32]=c.actions,t[33]=j);let M;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(M=()=>{a(n.id,!n.pinned).catch(qn)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=M):M=t[37];let N;t[38]===n.pinned?N=t[39]:(N=n.pinned?(0,$.jsx)(re,{className:`size-4`}):(0,$.jsx)(Pt,{className:`size-4`}),t[38]=n.pinned,t[39]=N);let P=n.pinned?c.unpin:c.pin,F;t[40]!==M||t[41]!==N||t[42]!==P?(F=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:M,children:[N,P]}),t[40]=M,t[41]=N,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==n.id||t[45]!==o?(I=()=>{o(n.id).catch(Kn)},t[44]=n.id,t[45]=o,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ke,{className:`size-4`}),t[47]=L):L=t[47];let R;t[48]!==c.archive||t[49]!==I?(R=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:I,children:[L,c.archive]}),t[48]=c.archive,t[49]=I,t[50]=R):R=t[50];let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(se,{className:`my-1 h-px bg-edge-subtle`}),t[51]=z):z=t[51];let B;t[52]!==n.id||t[53]!==s?(B=()=>{s(n.id).catch(Gn)},t[52]=n.id,t[53]=s,t[54]=B):B=t[54];let ee;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(rt,{className:`size-4`}),t[55]=ee):ee=t[55];let te;t[56]!==c.delete||t[57]!==B?(te=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:B,children:[ee,c.delete]}),t[56]=c.delete,t[57]=B,t[58]=te):te=t[58];let V;t[59]!==F||t[60]!==R||t[61]!==te?(V=(0,$.jsx)(ln,{children:(0,$.jsxs)(pn,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Jn,children:[F,R,z,te]})}),t[59]=F,t[60]=R,t[61]=te,t[62]=V):V=t[62];let H;t[63]!==j||t[64]!==V?(H=(0,$.jsxs)(qe,{children:[j,V]}),t[63]=j,t[64]=V,t[65]=H):H=t[65];let U;t[66]!==C||t[67]!==k||t[68]!==H?(U=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,k,H]}),t[66]=C,t[67]=k,t[68]=H,t[69]=U):U=t[69];let W;t[70]===n.pinned?W=t[71]:(W=n.pinned&&(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,$.jsx)(Pt,{className:`size-3`})}),t[70]=n.pinned,t[71]=W);let ne;t[72]===n.tags?ne=t[73]:(ne=n.tags?.slice(0,2).map(Wn),t[72]=n.tags,t[73]=ne);let G;t[74]===g?G=t[75]:(G=(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=G);let K;t[76]!==W||t[77]!==ne||t[78]!==G?(K=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[W,ne,G]}),t[76]=W,t[77]=ne,t[78]=G,t[79]=K):K=t[79];let ie;return t[80]!==U||t[81]!==K||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(ie=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,U,K]}),t[80]=U,t[81]=K,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=ie):ie=t[87],ie}function Wn(e){return(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function Gn(){}function Kn(){}function qn(){}function Jn(e){return e.stopPropagation()}function Yn(e){return e.stopPropagation()}function Xn(){return Date.now()}var Zn=3e4;function Qn(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function $n({placeholder:e,submitLabel:t,actionsLabel:n,imageLabel:r,voiceLabel:i,stopRecordingLabel:a,onCapture:o,onImagePick:s,onVoiceCapture:c,onVoiceError:l,recordingLabel:u,imageDisabled:d=!1,voiceDisabled:f=!1,onDiscussionCapture:p,discussionCaptureLabel:m}){let[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),D=(0,Z.useRef)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)([]),j=(0,Z.useRef)(0),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(0,Z.useCallback)(()=>{M.current&&=(clearInterval(M.current),null),N.current&&=(clearTimeout(N.current),null),k.current?.getTracks().forEach(e=>e.stop()),k.current=null,D.current=null,A.current=[],b(!1),S(0)},[]);(0,Z.useEffect)(()=>()=>P(),[P]);let F=(0,Z.useCallback)(async()=>{let e=D.current;if(!e||e.state!==`recording`)return;w(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-j.current)/1e3)),n=e.mimeType||Qn()||`audio/webm`,r=new Blob(A.current,{type:n});if(P(),r.size>0&&c){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await c(i,t)}finally{w(!1)}return}w(!1)},[P,c]),I=(0,Z.useCallback)(async()=>{if(!(!c||C||y)){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){l?.();return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});k.current=e;let t=Qn(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);D.current=n,A.current=[],j.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&A.current.push(e.data)},n.start(),b(!0),S(0),M.current=setInterval(()=>{S(Math.round((Date.now()-j.current)/1e3))},250),N.current=setTimeout(()=>{F()},Zn)}catch{P(),l?.()}}},[P,c,l,y,F,C]),L=(0,Z.useCallback)(async()=>{let e=h.trim();if(!(!e||_)){v(!0),g(``);try{await o(e)}catch{g(e)}finally{v(!1),T.current?.focus()}}},[h,_,o]),R=(0,Z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L())},[L]),z=_||C,B=!!(s||c||p);return(0,$.jsxs)(`div`,{className:O(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel p-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,y&&`border-danger ring-1 ring-danger/40`),"aria-busy":z,children:[y?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void F(),disabled:C,className:`shrink-0 rounded-lg bg-danger-soft p-2 text-danger transition-colors hover:bg-danger-soft disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":a,title:a,"aria-pressed":`true`,children:(0,$.jsx)(Tt,{className:`size-4 fill-current`,"aria-hidden":!0})}):B?(0,$.jsxs)(qe,{children:[(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:z,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":n,title:n,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(ln,{children:(0,$.jsxs)(pn,{side:`top`,align:`start`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:[s?(0,$.jsxs)(_t,{disabled:d,onSelect:s,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(ft,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,$.jsxs)(_t,{disabled:f,onSelect:()=>void I(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(tt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,$.jsxs)(_t,{onSelect:p,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(de,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(x))}):(0,$.jsx)(`textarea`,{ref:T,value:h,onChange:e=>g(e.target.value),onKeyDown:R,placeholder:e,"aria-label":e,rows:1,disabled:z,className:`max-h-28 min-h-8 flex-1 resize-none overflow-y-auto bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,$.jsx)(`button`,{type:`button`,disabled:!h.trim()||z||y,onClick:()=>void L(),"aria-label":t,title:t,className:O(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!z&&!y?`bg-accent text-white hover:bg-accent-hover`:`text-fg-disabled`),children:(0,$.jsx)(Ut,{className:`size-4`,"aria-hidden":!0})})]})}var er={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},tr=240,nr=320,rr=520,ir=560;function ar(e){if(globalThis.localStorage===void 0)return nr;try{let t=globalThis.localStorage.getItem(e);if(!t)return nr;let n=Number(t);return Number.isFinite(n)?n:nr}catch{return nr}}function or(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var sr={thought:ut,todo:Xt,voice:tt,media:ft,bookmark:vt,mixed:ut,task:Xt};function cr(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function lr(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function ur(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function dr({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:a=!0,projectId:o,listTitle:s,listDescription:c,emptyText:l,emptyDescription:u,listWidthStorageKey:d=`xopc.notes.listWidth`}){let p=M(e=>e.language),h=P(p).notes,g=!!A(e=>e.sessionKey),[_,v]=(0,Z.useReducer)(at,er),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(0),[T,k]=(0,Z.useState)(()=>ar(d)),[N,I]=(0,Z.useState)(!1),[V,U]=(0,Z.useState)(!1),[W,ne]=(0,Z.useState)(!1),[re,G]=(0,Z.useState)(null),[K,ie]=(0,Z.useState)(null),oe=(0,Z.useRef)(null),q=(0,Z.useRef)(null),[se]=(0,Z.useState)(()=>Date.now()),J=i(),le=(0,Z.useCallback)(e=>{let t=oe.current?.clientWidth??window.innerWidth,n=Math.max(tr,t-ir);return Math.max(tr,Math.min(Math.min(rr,n),e))},[]),ue=(0,Z.useCallback)(e=>{let t=le(e);k(t),or(d,t)},[le,d]);(0,Z.useLayoutEffect)(()=>{k(e=>le(e))},[le]);let{data:de,mutate:Y,isLoading:fe}=H((0,Z.useMemo)(()=>g?[`notes-list`,o,_.statusFilter,_.kindFilter,_.pinnedOnly]:null,[g,o,_.statusFilter,_.kindFilter,_.pinnedOnly]),()=>We({status:_.statusFilter===`all`?void 0:_.statusFilter,kind:_.kindFilter===`all`?void 0:_.kindFilter,projectId:o,pinned:_.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),pe=fe&&!de,me=de?.items??[],he=de?.total??0,ge=x.trim(),{data:_e,isLoading:ye}=H(g&&y&&ge?[`notes-search`,o,ge]:null,()=>We({search:ge,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),be=_e?.items??[],xe=e?me.some(t=>t.id===e):!0;(0,Z.useEffect)(()=>{w(0)},[ge]),(0,Z.useEffect)(()=>{C>=be.length&&w(Math.max(0,be.length-1))},[C,be.length]),(0,Z.useEffect)(()=>{let e=()=>{Y().catch(e=>{G(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[Y,h.quickCaptureFailedHint,h.refreshFailed]);let Ce=xt(e=>e.setPageHeader),Te=xt(e=>e.clearPageHeader),Ee=h.noteCount.replace(`{{count}}`,String(he)),De=!r&&he===0&&c?c:Ee,Oe=h.searchDialogTitle,ke=h.searchClose,Ae=h.searchClear,je=(0,Z.useMemo)(()=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:O(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Ye),"aria-label":Oe,children:[(0,$.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:Oe})]}),[Oe]);(0,Z.useLayoutEffect)(()=>{if(n)return g?(Ce({startExtra:null,main:(0,$.jsxs)(`div`,{className:O(`flex min-w-0 items-center gap-2`,Ye),children:[(0,$.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:s??h.title}),Ee?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Ee}):null]}),end:je}),()=>Te()):(Te(),()=>Te())},[Te,g,je,s,n,h.title,Ee,e,Ce]);let Me=(0,Z.useMemo)(()=>({justNow:h.justNow,minutesAgo:h.minutesAgo,today:h.today,yesterday:h.yesterday,daysAgo:h.daysAgo,locale:j(p)}),[p,h.justNow,h.minutesAgo,h.today,h.yesterday,h.daysAgo]),Ne=(0,Z.useMemo)(()=>[{id:`recent`,label:h.viewRecent,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:h.filterInbox,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:h.pinned,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:h.viewTasks,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:h.kindVoice,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:h.kindMedia,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:h.kindBookmark,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:h.filterProcessed,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:h.filterArchived,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[h.filterArchived,h.filterInbox,h.filterProcessed,h.kindBookmark,h.kindMedia,h.kindVoice,h.pinned,h.viewRecent,h.viewTasks]),Pe=Ne.find(e=>lr(_,e))??Ne[0],Fe=s??Pe.label,Ie=(0,Z.useCallback)(async e=>{G(null);try{let n=o?await ce({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await ae(e,`web`);await Y(),J(ur(t,n.id))}catch(e){throw G(`${h.quickCaptureFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`),e}},[t,Y,h.quickCaptureFailed,h.quickCaptureFailedHint,J,o]),Le=(0,Z.useCallback)(async()=>{if(!W){ne(!0),G(null);try{let e=await ce({markdown:``,kind:`thought`,projectId:o,channel:`web`});v({type:`patch`,patch:er}),await Y(),ie(e.id),J(ur(t,e.id))}catch(e){G(`${h.createBlankFailed}: ${e instanceof Error?e.message:h.createBlankFailedHint}`)}finally{ne(!1)}}},[t,W,Y,h.createBlankFailed,h.createBlankFailedHint,J,o]),Re=(0,Z.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{G(null),await $e(t,`web`),await Y()}catch(e){G(`${h.imageUploadFailed}: ${e instanceof Error?e.message:h.imageUploadFailedHint}`)}},e.click()},[Y,h.imageUploadFailed,h.imageUploadFailedHint]),ze=(0,Z.useCallback)(async(e,t)=>{try{G(null),await ve(e,t,`web`),await Y()}catch(e){G(`${h.voiceUploadFailed}: ${e instanceof Error?e.message:h.voiceUploadFailedHint}`)}},[Y,h.voiceUploadFailed,h.voiceUploadFailedHint]),Be=(0,Z.useCallback)(()=>{G(`${h.voiceCaptureFailed}: ${h.voiceCaptureFailedHint}`)},[h.voiceCaptureFailed,h.voiceCaptureFailedHint]),Ve=(0,Z.useCallback)(async(e,t)=>{G(null);try{await Se(e,{pinned:t}),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),He=(0,Z.useCallback)(async e=>{G(null);try{await Se(e,{status:`archived`}),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ue=(0,Z.useCallback)(async e=>{G(null);try{await Rt(e),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ge=(0,Z.useCallback)(e=>{J(ur(t,e))},[t,J]),Ke=(0,Z.useCallback)(e=>{J(ur(t,e)),b(!1)},[t,J]),qe=(0,Z.useCallback)(e=>{if(be.length){if(e.key===`ArrowDown`)e.preventDefault(),w(e=>Math.min(be.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),w(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=be[C]??be[0];t&&Ke(t.id)}}},[C,Ke,be]),Je=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=q.current;t.setPointerCapture(e.pointerId),I(!0);let r=oe.current?.clientWidth??window.innerWidth,i=Math.max(tr,r-ir),a=Math.min(rr,i),o=e=>Math.max(tr,Math.min(a,e)),s=e.clientX,c=o(T),l=e.pointerId,u=0,f=c,p=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,p=f,n&&(n.style.width=`${p}px`)},h=e=>{f=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}I(!1),oe.current?.style.setProperty(`--notes-list-width`,`${p}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),k(p),or(d,p),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[d,T]);(0,Z.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),Le())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Le]);let Xe=(0,Z.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),ue(T-16)):e.key===`ArrowRight`?(e.preventDefault(),ue(T+16)):e.key===`Home`?(e.preventDefault(),ue(tr)):e.key===`End`&&(e.preventDefault(),ue(rr))},[ue,T]);return g?(0,$.jsxs)(`div`,{ref:oe,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${T}px`},children:[(0,$.jsxs)(`section`,{ref:q,className:O(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden border-r border-edge bg-surface-rail`,!N&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":V?!0:void 0,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[re?(0,$.jsx)(`p`,{className:`mb-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:re}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,$.jsx)(f,{value:Pe.id,onChange:e=>{let t=Ne.find(t=>t.id===e.target.value);t&&v({type:`patch`,patch:t.patch})},className:`-ml-1 h-7 w-full max-w-44 rounded-lg border border-transparent bg-transparent px-2 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":h.libraryTitle,children:Ne.map(e=>(0,$.jsx)(m,{value:e.id,children:e.label},e.id))}):(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Fe}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:De})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.collapseNotesList,title:h.collapseNotesList,children:(0,$.jsx)(we,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:Le,disabled:W,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":h.createBlankNote,title:h.createBlankShortcut,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":h.searchDialogTitle,title:h.searchDialogTitle,children:(0,$.jsx)(kt,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:pe?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,$.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):me.length===0?(0,$.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-1 inline-flex size-12 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-fg-muted`,children:(0,$.jsx)(ut,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!xe?h.noteOutsideCurrentView:l??h.noNotes}),e&&!xe?null:(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:u??h.noNotesDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!xe?(0,$.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:h.noteOutsideCurrentView}):null,me.map((t,n)=>{let r=n>0?vn(me[n-1].createdAt):null;return(0,$.jsxs)(`div`,{children:[vn(t.createdAt)!==r&&(0,$.jsx)(`div`,{className:O(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:yn(t.createdAt,se,Me)}),(0,$.jsx)(Un,{note:t,selected:t.id===e,onPress:Ge,onPin:Ve,onArchive:He,onDelete:Ue,timeLabels:Me,labels:{pin:h.pin,unpin:h.unpin,archive:h.archive,delete:h.delete,actions:h.noteActions,imageNote:h.imageNote,noText:h.noText}})]},t.id)})]})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)($n,{placeholder:h.quickCapturePlaceholder,submitLabel:h.quickCaptureSubmit,actionsLabel:h.quickCaptureActions,imageLabel:h.quickCaptureImage,voiceLabel:h.quickCaptureVoice,stopRecordingLabel:h.stopRecording,onCapture:Ie,onImagePick:a?Re:void 0,onVoiceCapture:a?ze:void 0,onVoiceError:Be,recordingLabel:h.recording,discussionCaptureLabel:h.discussionCapture.title,onDiscussionCapture:()=>hn(o)})})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.resizeNotesList,"aria-valuemin":tr,"aria-valuemax":rr,"aria-valuenow":Math.round(T),tabIndex:0,onPointerDown:Je,onDoubleClick:()=>ue(nr),onKeyDown:Xe,title:h.resizeNotesList,className:O(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-surface-base lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-2 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,$.jsx)(`span`,{"aria-hidden":!0,className:O(`h-full w-px bg-edge transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,N&&`bg-accent scale-x-[2]`)})}),(0,$.jsxs)(`section`,{className:O(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[V?(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.expandNotesList,title:h.expandNotesList,children:(0,$.jsx)(we,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,$.jsx)(bn,{noteId:e,onBack:()=>J(t),onSaved:()=>{Y().catch(e=>{G(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>b(!0),autoFocus:e===K,onAutoFocusConsumed:()=>ie(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(ut,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:h.emptyEditorTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h.emptyEditorDescription}),(0,$.jsxs)(`button`,{type:`button`,onClick:Le,disabled:W,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),W?h.creatingBlankNote:h.createBlankNote]})]})})]}),(0,$.jsx)(te,{open:y,onOpenChange:b,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(ee,{className:`text-sm font-semibold text-fg`,children:Oe}),(0,$.jsx)(L,{className:`sr-only`,children:h.searchPlaceholder}),(0,$.jsx)(R,{asChild:!0,children:(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":ke,children:(0,$.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`p-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),onKeyDown:qe,placeholder:h.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),x?(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Ae,children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,$.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:ge?ye&&!_e?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,$.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):be.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(ut,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchNoResults}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchNoResultsDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:h.searchResultsCount.replace(`{{count}}`,String(_e?.total??be.length))}),be.map((e,t)=>{let n=sr[e.kind]||ut,r=cr(e,{imageNote:h.imageNote,noText:h.noText});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Ke(e.id),onMouseEnter:()=>w(t),className:O(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===C?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:_n(e.updatedAt,se,Me)})]}),e.title?(0,$.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,$.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(kt,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchEmptyTitle}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchEmptyDescription})]})})]})]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,$.jsx)(ut,{className:`size-10 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.needToken})]})}function fr(e){return k(N(`/api/projects/${encodeURIComponent(e)}/skills`))}function pr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function mr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function hr(e,t){let n=new FormData;return n.set(`file`,t),k(N(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function gr(e,t,n={}){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function _r(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function vr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function yr({projectId:e,copy:t}){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!0),[T,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,I]=(0,Z.useState)(null),[L,V]=(0,Z.useState)(null),[H,ne]=(0,Z.useState)(``),[re,G]=(0,Z.useState)(1),[K,ie]=(0,Z.useState)(null),[ae,q]=(0,Z.useState)(!1),[se,J]=(0,Z.useState)(``),[ce,le]=(0,Z.useState)(``),ue=(0,Z.useRef)(null),de=(0,Z.useCallback)(async()=>{C(!0),N(``);try{let t=await fr(e);r(t.items),a(t.inheritedItems),s(t.sources)}catch(e){N(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e]);(0,Z.useEffect)(()=>{de()},[de]),(0,Z.useEffect)(()=>{let t=!1;return Ne(e).then(e=>{t||d(e)}).catch(()=>{t||d([])}),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!f){v(null);return}let e=c.find(e=>e.key===f),t=!1;return v(null),N(``),x(!0),tn(e?.agentId??e?.routing?.agentId,f,!0).then(e=>{t||v(e)}).catch(e=>{t||N(e instanceof Error?e.message:String(e))}).finally(()=>{t||x(!1)}),()=>{t=!0}},[f,c]),(0,Z.useEffect)(()=>{if(P!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{q(!0),J(``),Dn({q:H,page:re,pageSize:8,sort:`downloads`,signal:e.signal}).then(ie).catch(t=>{e.signal.aborted||J(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||q(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[P,re,H]);async function Y(e,t){k(!0),j(t??null),N(``);try{await e(),I(null),le(``),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1),j(null)}}async function fe(t){N(``);try{V((await pr(e,t)).skill)}catch(e){N(e instanceof Error?e.message:String(e))}}async function pe(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){k(!0);try{await vr(e,n.directoryId),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}}}async function me(){k(!0),N(``);try{await mr(e,!0),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}}let he=o.find(e=>e.origin===`agents-workspace`),ge=new Map(_?.skills.map(e=>[e.name,e]));return(0,$.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,$.jsxs)(u,{children:[(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(U,{type:`button`,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.add,(0,$.jsx)(Ot,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,$.jsx)(l,{children:(0,$.jsxs)(g,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,$.jsx)(Cr,{icon:st,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>I(`marketplace`)}),(0,$.jsx)(Cr,{icon:w,title:t.source,hint:t.sourceHint,onClick:()=>I(`source`)}),(0,$.jsx)(Cr,{icon:oe,title:t.upload,hint:t.uploadHint,onClick:()=>ue.current?.click()})]})})]}),(0,$.jsx)(`input`,{ref:ue,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&Y(()=>hr(e,n)),t.target.value=``}})]})}),M?(0,$.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:M}):null,he?.state===`untrusted`?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(it,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:T,onClick:()=>void me(),children:[(0,$.jsx)(Bt,{className:`size-4`,"aria-hidden":!0}),T?t.trusting:t.trustAction]})]}):null,c.length?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b?t.sessionLoading:f?_?.agentId:t.sessionViewAll})]}),(0,$.jsx)(h,{value:f,options:c.map(e=>({value:e.key,label:e.name?.trim()||`${t.sessionFallback} · ${e.key.slice(-12)}`})),placeholder:t.sessionViewAll,emptyLabel:t.sessionViewAll,triggerClassName:`w-[min(24rem,calc(100vw-3rem))]`,onChange:m})]}):null,S?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,$.jsx)(W,{className:`h-36 rounded-lg`},e))}):n.length?(0,$.jsx)(br,{title:t.localTitle,items:n,copy:t,busy:T,availabilityByName:ge,onPreview:fe,onRemove:pe}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!S&&i.length?(0,$.jsx)(br,{title:t.inheritedTitle,hint:t.inheritedHint,items:i,copy:t,busy:T,availabilityByName:ge,onPreview:fe,onRemove:pe}):null,(0,$.jsx)(te,{open:P!==null,onOpenChange:e=>{e||I(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:O(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,P===`marketplace`?`h-[min(46rem,calc(100vh-2rem))] w-[min(58rem,calc(100vw-2rem))]`:`h-[min(22rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))]`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:P===`marketplace`?t.marketplace:t.source}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,$.jsx)(D,{className:`size-4`})})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:P===`marketplace`?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,$.jsxs)(`div`,{className:`relative mt-3`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{className:`h-10 w-full rounded-md border border-edge bg-surface-base pl-9 pr-3 text-sm outline-none focus:border-accent`,value:H,onChange:e=>{ne(e.target.value),G(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),se?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:se}):null,ae&&!K?(0,$.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,$.jsx)(W,{className:`h-32 rounded-lg`},e))}):K?.items.length?(0,$.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:K.items.map(r=>{let i=r.providerId??K.provider,a=En(r,i),o=n.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===r.id||e.directoryId===a||e.name===r.name)),s=A===a;return(0,$.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(On,{name:r.name,className:`size-10`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:r.name}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:r.description||`—`}),(0,$.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,$.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,r.downloads]}),(0,$.jsx)(U,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:o?`secondary`:`primary`,disabled:T||o,onClick:()=>void Y(()=>gr(e,a,{provider:i}),a),children:o?t.marketplaceInstalled:s?t.installing:t.install})]})]})]},`${i??`default`}:${r.id}`)})}):ae?null:(0,$.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),K&&K.meta.totalPages>1?(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(K.meta.page)).replace(`{{total}}`,String(K.meta.totalPages))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:ae||re<=1,onClick:()=>G(e=>Math.max(1,e-1)),children:[(0,$.jsx)(Ct,{className:`size-4`}),t.marketplacePrevious]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:ae||re>=K.meta.totalPages,onClick:()=>G(e=>e+1),children:[t.marketplaceNext,(0,$.jsx)(rn,{className:`size-4`})]})]})]}):null]}):(0,$.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,$.jsx)(`input`,{className:`mt-4 h-10 w-full rounded-md border border-edge bg-surface-base px-3 text-sm outline-none focus:border-accent`,value:ce,onChange:e=>le(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`secondary`,children:t.close})}),(0,$.jsx)(U,{type:`button`,disabled:T||!ce.trim(),onClick:()=>void Y(()=>_r(e,ce.trim())),children:T?t.installing:t.install})]})]})})]})]})}),(0,$.jsx)(te,{open:!!L,onOpenChange:e=>{e||V(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:L?.name}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,$.jsx)(D,{className:`size-4`})})})]}),(0,$.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:L?.bodyMarkdown})]})]})})]})}function br(e){let t=(0,Q.c)(25),{title:n,hint:r,items:i,copy:a,busy:o,availabilityByName:s,onPreview:c,onRemove:l}=e,u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=r?(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p;if(t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==i||t[11]!==c||t[12]!==l){let e;t[14]!==s||t[15]!==o||t[16]!==a||t[17]!==c||t[18]!==l?(e=e=>{let t=e.effective?s.get(e.name):void 0;return(0,$.jsxs)(`article`,{className:O(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ke,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:xr(a,e.origin)}),e.writable?null:(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,$.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-2 py-0.5 text-amber-800 dark:text-amber-200`,children:a.shadowed}),t?(0,$.jsx)(`span`,{className:O(`rounded-md px-2 py-0.5`,t.availableForCurrentAgent?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:Sr(a,t)}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,$.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0}),a.remove]}):null]})]},e.key)},t[14]=s,t[15]=o,t[16]=a,t[17]=c,t[18]=l,t[19]=e):e=t[19],p=i.map(e),t[7]=s,t[8]=o,t[9]=a,t[10]=i,t[11]=c,t[12]=l,t[13]=p}else p=t[13];let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:p}),t[20]=p,t[21]=m);let h;return t[22]!==f||t[23]!==m?(h=(0,$.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=h):h=t[24],h}function xr(e,t){switch(t){case`xopc-workspace`:return e.xopcSource;case`agents-workspace`:return e.agentsSource;case`xopc-global`:case`custom-global`:return e.globalXopcSource;case`agents-global`:return e.globalAgentsSource;case`bundled`:return e.bundledSource;case`extra`:return e.extraSource}}function Sr(e,t){if(t.availableForCurrentAgent)return e.sessionAvailable;switch(t.unavailableReason){case`agent-denied`:return e.sessionUnavailableAgent;case`disabled`:return e.sessionUnavailableDisabled;case`requirements-unmet`:return e.sessionUnavailableRequirements;case`model-invocation-disabled`:return e.sessionUnavailableModel;case`tool-gated`:return e.sessionUnavailableTools;default:return e.sessionUnavailableAgent}}function Cr(e){let t=(0,Q.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==a||t[10]!==o||t[11]!==l?(u=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 rounded-md px-3 py-2.5 text-left hover:bg-surface-hover`,onClick:a,children:[o,l]})}),t[9]=a,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}var wr={active:0,review:1,ready:2,backlog:3,closed:4},Tr={blocked:0,waiting:1,verifying:2,running:3,queued:4,idle:5},Er={critical:0,high:1,normal:2,low:3};function Dr(e,t=4){return e.filter(e=>e.phase!==`closed`&&!(e.operationalState===`waiting`&&e.attention.length===0)).sort((e,t)=>{let n=Number(t.attention.length>0)-Number(e.attention.length>0);if(n!==0)return n;let r=Tr[e.operationalState]-Tr[t.operationalState];if(r!==0)return r;let i=wr[e.phase]-wr[t.phase];if(i!==0)return i;let a=Er[e.priority]-Er[t.priority];return a===0?t.updatedAt-e.updatedAt:a}).slice(0,t)}var Or=[`backlog`,`ready`,`active`,`review`,`closed`];function kr(e){return{backlog:e.filter(e=>e.phase===`backlog`),ready:e.filter(e=>e.phase===`ready`),active:e.filter(e=>e.phase===`active`),review:e.filter(e=>e.phase===`review`),closed:e.filter(e=>e.phase===`closed`)}}function Ar(e,t){if(e.phase!==t){if(e.phase===`closed`&&t!==`closed`&&e.allowedCommands.includes(`reopen`))return`reopen_${t}`;if(t===`closed`&&e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(t!==`closed`&&e.allowedCommands.includes(`move`))return`move_${t}`}}function jr(e){if(e.allowedCommands.includes(`resolve_wait`))return`resume`;if(e.allowedCommands.includes(`mark_ready`))return`ready`;if(e.allowedCommands.includes(`start`))return`run`;if(e.allowedCommands.includes(`request_review`))return`review`;if(e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(e.allowedCommands.includes(`reopen`))return`reopen`;if(e.allowedCommands.includes(`add_wait`))return`pause`}function Mr(e){let t=new Map,n=new Map;for(let r of e)t.set(r.dependencyTaskId,[...t.get(r.dependencyTaskId)??[],r.dependentTaskId]),n.set(r.dependentTaskId,[...n.get(r.dependentTaskId)??[],r.dependencyTaskId]);return{outgoing:t,incoming:n}}function Nr(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=Mr(t.filter(e=>n.has(e.dependencyTaskId)&&n.has(e.dependentTaskId))),a=new Map(e.map(e=>[e.id,i.get(e.id)?.length??0])),o=new Map(e.map(e=>[e.id,0])),s=e.filter(e=>a.get(e.id)===0).sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id);for(let e=0;e<s.length;e+=1){let t=s[e];for(let e of r.get(t)??[]){o.set(e,Math.max(o.get(e)??0,(o.get(t)??0)+1));let n=(a.get(e)??1)-1;a.set(e,n),n===0&&s.push(e)}}let c=new Map;for(let t of e){let e=o.get(t.id)??0;c.set(e,[...c.get(e)??[],t.id])}let l=new Map;for(let[e,t]of c)t.forEach((t,n)=>l.set(t,{x:e*300,y:n*136}));return l}function Pr(e,t){let{incoming:n}=Mr(t),r=new Set(e.filter(e=>e.operationalState===`blocked`).map(e=>e.id)),i=[...r];for(let e=0;e<i.length;e+=1)for(let t of n.get(i[e])??[])r.has(t)||(r.add(t),i.push(t));return r}function Fr(e,t){let{incoming:n,outgoing:r}=Mr(t),i=new Set([e]);for(let t of[n,r]){let n=[e],r=new Set(n);for(let e=0;e<n.length;e+=1)for(let a of t.get(n[e])??[])r.has(a)||(r.add(a),i.add(a),n.push(a))}return i}var Ir={backlog:`border-edge`,ready:`border-edge`,active:`border-accent ring-2 ring-accent/15`,review:`border-amber-400/80`,closed:`border-emerald-400/60`};function Lr(e){let t=(0,Q.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=Ir[i.phase],s=r&&`ring-2 ring-accent/30`,c=n.dimmed&&`opacity-30`,l;t[0]!==o||t[1]!==s||t[2]!==c?(l=O(`group w-56 rounded-xl border bg-surface-panel p-3 shadow-surface transition-opacity`,o,s,c),t[0]=o,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Nn,{type:`target`,position:An.Left,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[4]=u):u=t[4];let d;t[5]===i.title?d=t[6]:(d=(0,$.jsx)(`strong`,{className:`line-clamp-2 min-w-0 text-sm font-medium leading-5 text-fg`,children:i.title}),t[5]=i.title,t[6]=d);let f;t[7]===a?f=t[8]:(f=a?(0,$.jsx)(gt,{className:`mt-0.5 size-3.5 shrink-0 text-violet-600 dark:text-violet-300`,"aria-hidden":!0}):null,t[7]=a,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===n.phaseLabel?m=t[13]:(m=(0,$.jsx)(`span`,{children:n.phaseLabel}),t[12]=n.phaseLabel,t[13]=m);let h;t[14]!==a||t[15]!==i.blockedBy?(h=a&&i.blockedBy.length>0?(0,$.jsx)(`span`,{children:i.blockedBy.length}):null,t[14]=a,t[15]=i.blockedBy,t[16]=h):h=t[16];let g;t[17]!==h||t[18]!==m?(g=(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-[11px] text-fg-subtle`,children:[m,h]}),t[17]=h,t[18]=m,t[19]=g):g=t[19];let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Nn,{type:`source`,position:An.Right,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[20]=_):_=t[20];let v;return t[21]!==g||t[22]!==l||t[23]!==p?(v=(0,$.jsxs)(`div`,{className:l,children:[u,p,g,_]}),t[21]=g,t[22]=l,t[23]=p,t[24]=v):v=t[24],v}var Rr={taskNode:Lr};function zr(e){let t=(0,Q.c)(90),{tasks:n,dependencyEdges:r,returnTo:i,copy:a,onDependenciesChange:o}=e,[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(),[m,h]=(0,Z.useState)(),g=(0,Z.useRef)(null),_;t[0]!==r||t[1]!==n?(_=Pr(n,r),t[0]=r,t[1]=n,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==u||t[5]!==c||t[6]!==n?(y=u?n.filter(e=>v.has(e.id)):c?n:n.filter(qr),t[3]=v,t[4]=u,t[5]=c,t[6]=n,t[7]=y):y=t[7];let x=y,S;t[8]===x?S=t[9]:(S=new Set(x.map(Kr)),t[8]=x,t[9]=S);let C=S,w;if(t[10]!==r||t[11]!==C){let e;t[13]===C?e=t[14]:(e=e=>C.has(e.dependencyTaskId)&&C.has(e.dependentTaskId),t[13]=C,t[14]=e),w=r.filter(e),t[10]=r,t[11]=C,t[12]=w}else w=t[12];let T=w,E;t[15]!==T||t[16]!==x?(E=Nr(x,T),t[15]=T,t[16]=x,t[17]=E):E=t[17];let D=E,k;t[18]!==f||t[19]!==T?(k=f?Fr(f,T):void 0,t[18]=f,t[19]=T,t[20]=k):k=t[20];let A=k,j;t[21]===f?j=t[22]:(j=e=>e.id===f,t[21]=f,t[22]=j);let M=x.find(j),N;t[23]===x?N=t[24]:(N=new Map(x.map(Gr)),t[23]=x,t[24]=N);let P=N,F;if(t[25]!==a.phases||t[26]!==D||t[27]!==A||t[28]!==x){let e;t[30]!==a.phases||t[31]!==D||t[32]!==A?(e=e=>({id:e.id,type:`taskNode`,position:D.get(e.id)??{x:0,y:0},data:{task:e,phaseLabel:a.phases[e.phase],dimmed:!!(A&&!A.has(e.id))}}),t[30]=a.phases,t[31]=D,t[32]=A,t[33]=e):e=t[33],F=x.map(e),t[25]=a.phases,t[26]=D,t[27]=A,t[28]=x,t[29]=F}else F=t[29];let I=F,L;if(t[34]!==A||t[35]!==P||t[36]!==T){let e;t[38]!==A||t[39]!==P?(e=e=>{let t=P.get(e.dependencyTaskId),n=t?.phase===`closed`&&t.resolution===`done`,r=!!(A&&(!A.has(e.dependencyTaskId)||!A.has(e.dependentTaskId)));return{id:`${e.dependencyTaskId}:${e.dependentTaskId}`,source:e.dependencyTaskId,target:e.dependentTaskId,markerEnd:{type:kn.ArrowClosed},style:{stroke:n?`var(--color-edge-strong)`:`var(--color-accent)`,strokeWidth:n?1.25:1.75,opacity:r?.18:1,strokeDasharray:n?`5 5`:void 0}}},t[38]=A,t[39]=P,t[40]=e):e=t[40],L=T.map(e),t[34]=A,t[35]=P,t[36]=T,t[37]=L}else L=t[37];let R=L,z,B;t[41]!==f||t[42]!==C?(z=()=>{f&&!C.has(f)&&p(void 0)},B=[f,C],t[41]=f,t[42]=C,t[43]=z,t[44]=B):(z=t[43],B=t[44]),(0,Z.useEffect)(z,B);let ee,te;t[45]!==R||t[46]!==m?(ee=()=>{m&&!R.some(e=>e.id===m)&&h(void 0)},te=[R,m],t[45]=R,t[46]=m,t[47]=ee,t[48]=te):(ee=t[47],te=t[48]),(0,Z.useEffect)(ee,te);let V;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=window.requestAnimationFrame(()=>{g.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=V):V=t[49];let H;t[50]!==u||t[51]!==c||t[52]!==x.length?(H=[u,c,x.length],t[50]=u,t[51]=c,t[52]=x.length,t[53]=H):H=t[53],(0,Z.useEffect)(V,H);let W;t[54]===f?W=t[55]:(W=()=>{f&&g.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=W);let ne=W,re;t[56]!==r||t[57]!==o?(re=e=>{if(!e.source||!e.target||e.source===e.target)return;let t=r.filter(t=>t.dependentTaskId===e.target).map(Wr);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=re):re=t[58];let G=re,K;t[59]!==r||t[60]!==o||t[61]!==m?(K=()=>{if(!m)return;let e=r.find(e=>`${e.dependencyTaskId}:${e.dependentTaskId}`===m);e&&(h(void 0),o(e.dependentTaskId,r.filter(t=>t.dependentTaskId===e.dependentTaskId&&t.dependencyTaskId!==e.dependencyTaskId).map(Ur)))},t[59]=r,t[60]=o,t[61]=m,t[62]=K):K=t[62];let ie=K,ae;t[63]===a.connectHint?ae=t[64]:(ae=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ae);let oe=u?`secondary`:`ghost`,q;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>d(Hr),t[65]=q):q=t[65];let se=u?a.allTasks:a.blockedChains,J;t[66]!==u||t[67]!==oe||t[68]!==se?(J=(0,$.jsx)(U,{type:`button`,variant:oe,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:q,children:se}),t[66]=u,t[67]=oe,t[68]=se,t[69]=J):J=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>l(Vr),t[70]=ce):ce=t[70];let le=c?a.hideCompleted:a.showCompleted,ue;t[71]!==u||t[72]!==c||t[73]!==le?(ue=(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":c,onClick:ce,disabled:u,children:le}),t[71]=u,t[72]=c,t[73]=le,t[74]=ue):ue=t[74];let de=M?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:ne,children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,Y;t[75]!==a.removeDependency||t[76]!==ie||t[77]!==m?(Y=m?(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:ie,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=ie,t[77]=m,t[78]=Y):Y=t[78];let fe;t[79]!==J||t[80]!==ue||t[81]!==de||t[82]!==Y?(fe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[J,ue,de,Y]}),t[79]=J,t[80]=ue,t[81]=de,t[82]=Y,t[83]=fe):fe=t[83];let pe;t[84]!==ae||t[85]!==fe?(pe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-edge bg-surface-panel px-3 py-2.5`,children:[ae,fe]}),t[84]=ae,t[85]=fe,t[86]=pe):pe=t[86];let me=x.length>0?(0,$.jsxs)(`div`,{className:O(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,M&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,$.jsxs)(Mn,{nodes:I,edges:R,nodeTypes:Rr,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>h(t.id),onConnect:G,onPaneClick:()=>{p(void 0),h(void 0)},onInit:e=>{g.current=e},fitView:!0,minZoom:.25,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:{hideAttribution:!0},children:[(0,$.jsx)(Pn,{color:`var(--color-edge)`,gap:22,size:1}),(0,$.jsx)(jn,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),M?(0,$.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[M.phase]}),(0,$.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:M.title}),M.operationalState===`blocked`&&M.blockedBy.length>0?(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(M.blockedBy.length))}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:M.blockedBy.map(Br)})]}):null,(0,$.jsxs)(s,{to:Ie(i,M.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,$.jsx)(`div`,{className:`flex min-h-72 items-center justify-center px-6 text-center text-sm text-fg-muted`,children:a.empty}),he;return t[87]!==pe||t[88]!==me?(he=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base/40`,children:[pe,me]}),t[87]=pe,t[88]=me,t[89]=he):he=t[89],he}function Br(e){return(0,$.jsx)(`li`,{children:e.title},e.id)}function Vr(e){return!e}function Hr(e){return!e}function Ur(e){return e.dependencyTaskId}function Wr(e){return e.dependencyTaskId}function Gr(e){return[e.id,e]}function Kr(e){return e.id}function qr(e){return e.phase!==`closed`}function Jr({policy:e,copy:t,onSave:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(e.mode),[s,c]=(0,Z.useState)(Math.round(e.confidenceThreshold*100)),[l,u]=(0,Z.useState)(!!e.quietHours),[d,p]=(0,Z.useState)(e.quietHours?.startHour??22),[h,g]=(0,Z.useState)(e.quietHours?.endHour??8),[_,v]=(0,Z.useState)(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),[y,b]=(0,Z.useState)(e.allowedActions.includes(`create_project_task`)),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)();(0,Z.useEffect)(()=>{o(e.mode),c(Math.round(e.confidenceThreshold*100)),u(!!e.quietHours),p(e.quietHours?.startHour??22),g(e.quietHours?.endHour??8),v(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),b(e.allowedActions.includes(`create_project_task`))},[e]);let T=async()=>{S(!0),w(void 0);try{await n({mode:a,confidenceThreshold:s/100,quietHours:l?{startHour:d,endHour:h,timezone:_}:null,allowedActions:y?[`create_project_task`]:[]}),i(!1)}catch(e){w(e instanceof Error?e.message:t.saveFailed)}finally{S(!1)}};return(0,$.jsxs)(te,{open:r,onOpenChange:e=>{x||i(e)},children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-9 gap-2 px-2.5 text-xs`,children:[(0,$.jsx)(Et,{className:`size-3.5`,"aria-hidden":!0}),t.modes[e.mode]]})}),(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100vh-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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.title}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:x,children:(0,$.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:t.mode}),(0,$.jsx)(f,{value:a,onChange:e=>o(e.target.value),children:Object.entries(t.modes).map(([e,t])=>(0,$.jsx)(m,{value:e,children:t},e))})]}),(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[t.confidence,` · `,s,`%`]}),(0,$.jsx)(`input`,{type:`range`,min:`50`,max:`100`,step:`5`,value:s,onChange:e=>c(Number(e.target.value)),className:`accent-accent`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),t.quietHours]}),l?(0,$.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,$.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:d,onChange:e=>p(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,$.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:h,onChange:e=>g(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,$.jsxs)(`label`,{className:`col-span-2 grid gap-1 text-xs text-fg-muted`,children:[t.timezone,(0,$.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]})]}):null]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:y,onChange:e=>b(e.target.checked)}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:t.allowTaskCreation}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.allowTaskCreationDescription})]})]})]}),(0,$.jsxs)(`div`,{className:`shrink-0 border-t border-edge px-5 py-3`,children:[C?(0,$.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:C}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:x,children:t.cancel})}),(0,$.jsx)(U,{type:`button`,variant:`primary`,disabled:x||!_.trim()||d<0||d>23||h<0||h>23,onClick:()=>void T(),children:x?t.saving:t.save})]})]})]})]})]})}function Yr(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Xr={backlog:en,ready:en,active:Zt,review:Ge,closed:_},Zr={backlog:`bg-surface-hover text-fg-muted`,ready:`bg-surface-panel text-fg-muted`,active:`bg-accent-soft text-accent-fg`,review:`bg-amber-500/10 text-amber-700 dark:text-amber-300`,closed:`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`};function Qr(e){return e===`running`||e===`queued`?`border-accent/20 bg-accent-soft text-accent-fg`:e===`verifying`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`waiting`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`blocked`?`border-violet-500/20 bg-violet-500/10 text-violet-700 dark:text-violet-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function $r(e){return e===`passed`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function ei(e){let t=(0,Q.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,f,p,m,h,g,v,y,b,x,S,C,w,T,E;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(m=jr(n),h=m!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,f=n.phase===`closed`,p=!!(n.dueAt&&n.dueAt<Date.now()&&!f),d=f?_:qt,v=n.priority!==`normal`,g=v||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,x=!0,t[20]!==c||t[21]!==n.id?(S=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=S):S=t[22],t[23]===c?C=t[24]:(C=()=>c(``),t[23]=c,t[24]=C),w=ni,t[25]!==l||t[26]!==n.id?(T=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=T):T=t[27],E=`group relative min-h-max min-w-0 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface transition-[border-color,box-shadow] hover:border-edge focus-within:border-accent/40`,u=s,t[28]!==r||t[29]!==n.id?(y=Ie(r,n.id),t[28]=r,t[29]=n.id,t[30]=y):y=t[30],b=O(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,h?`pr-19`:m&&`pr-11`),t[0]=c,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]=v,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E):(u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],v=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19]);let D=f?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,k;t[31]===D?k=t[32]:(k=O(`mt-0.5 size-4 shrink-0`,D),t[31]=D,t[32]=k);let A;t[33]!==d||t[34]!==k?(A=(0,$.jsx)(d,{className:k,"aria-hidden":!0}),t[33]=d,t[34]=k,t[35]=A):A=t[35];let j=f?`text-fg-subtle`:`text-fg`,M;t[36]===j?M=t[37]:(M=O(`min-w-0 break-words text-sm font-semibold leading-5`,j),t[36]=j,t[37]=M);let N;t[38]!==M||t[39]!==n.title?(N=(0,$.jsx)(`h3`,{className:M,children:n.title}),t[38]=M,t[39]=n.title,t[40]=N):N=t[40];let P;t[41]!==A||t[42]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[A,N]}),t[41]=A,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(F=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,$.jsxs)(`div`,{className:`ml-6.5 mt-2.5 rounded-lg bg-violet-500/8 px-2.5 py-2 text-xs text-violet-700 dark:text-violet-300`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,$.jsx)(gt,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(ti).join(`、`)})]}):n.attention[0]?(0,$.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Ht,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`line-clamp-2`,children:n.attention[0].summary})]}):null,t[44]=i,t[45]=n.attention,t[46]=n.blockedBy,t[47]=n.operationalState,t[48]=F):F=t[48];let I;t[49]!==i||t[50]!==p||t[51]!==g||t[52]!==v||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(I=g?(0,$.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[v?(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,n.priority===`critical`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:n.priority===`high`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:i.priorityOptions[n.priority]}):null,n.operationalState===`idle`?null:(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Qr(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,$r(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,$.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-edge-subtle bg-surface-hover px-2 text-fg-muted`,children:[(0,$.jsx)(Zt,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,$.jsxs)(`span`,{className:O(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,p?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:[(0,$.jsx)(Kt,{className:`size-3`,"aria-hidden":!0}),be(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,$.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-accent/20 bg-accent-soft px-2 text-accent-fg`,children:[(0,$.jsx)(Kt,{className:`size-3`,"aria-hidden":!0}),be(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=p,t[51]=g,t[52]=v,t[53]=n.acceptanceCriteriaCount,t[54]=n.dueAt,t[55]=n.latestVerification,t[56]=n.nextCheckAt,t[57]=n.operationalState,t[58]=n.priority,t[59]=I):I=t[59];let L;t[60]!==u||t[61]!==y||t[62]!==P||t[63]!==F||t[64]!==I||t[65]!==b?(L=(0,$.jsxs)(u,{to:y,className:b,children:[P,F,I]}),t[60]=u,t[61]=y,t[62]=P,t[63]=F,t[64]=I,t[65]=b,t[66]=L):L=t[66];let R;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==m||t[71]!==h||t[72]!==n?(R=m?(0,$.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,children:[h?(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,h),className:`inline-flex size-7 items-center justify-center rounded-md bg-surface-hover text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[h],title:i.actions[h],children:(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,m),className:`inline-flex size-7 items-center justify-center rounded-md bg-accent-soft text-accent-fg hover:bg-accent-soft/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[m],title:i.actions[m],children:(0,$.jsx)(zt,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=m,t[71]=h,t[72]=n,t[73]=R):R=t[73];let z;return t[74]!==L||t[75]!==R||t[76]!==x||t[77]!==S||t[78]!==C||t[79]!==w||t[80]!==T||t[81]!==E?(z=(0,$.jsxs)(`article`,{draggable:x,onDragStart:S,onDragEnd:C,onDragOver:w,onDrop:T,className:E,children:[L,R]}),t[74]=L,t[75]=R,t[76]=x,t[77]=S,t[78]=C,t[79]=w,t[80]=T,t[81]=E,t[82]=z):z=t[82],z}function ti(e){return e.title}function ni(e){e.preventDefault(),e.stopPropagation()}function ri({tasks:e,dependencyEdges:t,monitoring:n,returnTo:r,copy:i,onAction:a,onReorder:o,onUndoMove:s,onDependenciesChange:c,onMonitoringChange:l,onCreate:u,actionBusyId:d,ref:p}){let h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,T]=(0,Z.useState)(`board`),[E,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(()=>crypto.randomUUID()),[j,N]=(0,Z.useState)(``),[I,V]=(0,Z.useState)(`normal`),[H,W]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)([]),[G,K]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(null),oe=M(e=>e.language),q=ot({chat:P(oe).chat}),se=kr(e),J=e.filter(e=>e.phase!==`closed`),ce=(e,t)=>void a(e,t),le=async(t,n)=>{let r=e.find(e=>e.id===_);if(v(null),!r||r.id===n)return;let i=se[r.phase],s=i.findIndex(e=>e.id===r.id),c=s>=0?i[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=Ar(r,t);r.phase!==t&&!l||l&&!await a(r,l)||await o(r.id,n)&&S({taskId:r.id,phase:r.phase,beforeTaskId:c})},ue=async e=>{e.preventDefault();let t=j.trim();if(!(!t||G)){K(!0),ae(null);try{let e=H?new Date(`${H}T23:59:59.999`).getTime():void 0;await u({requestId:k,objective:t,priority:I,dependsOnTaskIds:ne,attachments:q.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),N(``),V(`normal`),W(``),re([]),q.clearAttachments(),A(crypto.randomUUID()),D(!1)}catch(e){ae(e instanceof Error?e.message:i.createFailed)}finally{K(!1)}}},de=()=>{A(crypto.randomUUID()),N(``),V(`normal`),W(``),re([]),q.clearAttachments(),ae(null),D(!0)};(0,Z.useImperativeHandle)(p,()=>({openCreate:de})),(0,Z.useEffect)(()=>{if(!x)return;let e=window.setTimeout(()=>S(null),6e3);return()=>window.clearTimeout(e)},[x]);let Y=(0,Z.useCallback)(e=>{let t=g.current;!t||t.pointerId!==e.pointerId||(g.current=null,b(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),pe=(0,Z.useCallback)(e=>{if(e.button!==0||Yr(e.target))return;let t=h.current;t&&(g.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),me=(0,Z.useCallback)(e=>{let t=g.current,n=h.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,b(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,$.jsxs)(`section`,{id:`project-panel-board`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-board`,className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Jr,{policy:n,copy:i.monitoring,onSave:l}),(0,$.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":C===`board`,onClick:()=>T(`board`),className:O(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,C===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,$.jsx)(yt,{className:`size-3.5`,"aria-hidden":!0}),i.views.board]}),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":C===`graph`,onClick:()=>T(`graph`),className:O(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,C===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),i.views.graph]})]})]})]}),C===`board`?(0,$.jsx)(`div`,{ref:h,className:O(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,y?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:pe,onPointerMove:me,onPointerUp:Y,onPointerCancel:Y,onLostPointerCapture:e=>{g.current?.pointerId===e.pointerId&&(g.current=null,b(!1))},children:(0,$.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:Or.map(t=>{let n=Xr[t],a=se[t];return(0,$.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===_);r&&(r.phase===t||Ar(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),le(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-muted/70 p-2.5`,children:[(0,$.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,$.jsxs)(`div`,{className:O(`flex items-center gap-1.5 rounded-md px-2 py-1`,Zr[t]),children:[(0,$.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:i.phases[t]})]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain pr-1 [scrollbar-gutter:stable] [scrollbar-width:thin]`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,$.jsx)(ei,{task:e,returnTo:r,copy:i,busy:d===e.id,onAction:ce,onDragStart:v,onDropBefore:e=>void le(t,e)},e.id))})})]},t)})})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,$.jsx)(zr,{tasks:e,dependencyEdges:t,returnTo:r,copy:{...i.graph,phases:i.phases},onDependenciesChange:c})}),(0,$.jsx)(te,{open:E,onOpenChange:e=>{G||D(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:i.createTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.createDescription})]}),(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void ue(e),children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:i.objective}),(0,$.jsxs)(`div`,{className:O(`overflow-hidden rounded-lg border border-edge bg-surface-base transition-colors focus-within:border-accent`,q.isDragging&&`border-accent bg-accent-soft/30`),onDragOver:e=>{e.preventDefault(),G||q.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||q.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),q.setIsDragging(!1),G||q.processFiles(Array.from(e.dataTransfer.files))},children:[(0,$.jsx)(`textarea`,{id:`project-task-objective`,autoFocus:!0,className:`min-h-28 w-full resize-y bg-transparent px-3 py-3 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle`,value:j,onChange:e=>{N(e.target.value),ae(null)},placeholder:i.objectivePlaceholder,maxLength:12e3,disabled:G}),(0,$.jsx)(Qt,{attachments:q.attachments,topPadded:!1,onRemove:e=>{G||q.removeAttachment(e)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:G,onClick:()=>q.fileInputRef.current?.click(),children:[(0,$.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),i.addFiles]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.attachmentsDescription}),(0,$.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{q.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:i.priority}),(0,$.jsx)(f,{value:I,onChange:e=>V(e.target.value),disabled:G,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,$.jsx)(m,{value:e,children:i.priorityOptions[e]},e))})]}),(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[i.dueDate,` `,(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,$.jsx)(wn,{className:`min-h-10 bg-surface-base`,value:H,onChange:W,disabled:G,ariaLabel:i.dueDate})]})]}),(0,$.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,$.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[i.dependencies,` `,(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:i.dependenciesDescription}),(0,$.jsx)(X,{candidates:J,selectedIds:ne,disabled:G,onChange:re,labels:{link:i.linkDependencies,linked:i.linkedDependencies,searchPlaceholder:i.dependencySearchPlaceholder,noMatches:i.noDependencyMatches,noCandidates:i.noDependencyCandidates,remove:i.removeDependency}})]}),ie?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:G,children:i.cancel})}),(0,$.jsx)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:G||!j.trim(),children:G?i.creating:oe===`zh`?`保存待安排任务`:`Save for later`})]})]})]})]})}),x?(0,$.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-50 flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-float`,children:[(0,$.jsx)(`span`,{children:i.moved}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=x;S(null),s(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||S(e)})},children:i.undo})]}):null]})}var ii=new Set([{id:`overview`,icon:Vt},{id:`tasks`,icon:xe},{id:`automations`,icon:Me},{id:`files`,icon:Fe},{id:`notes`,icon:Be},{id:`skills`,icon:jt},{id:`sessions`,icon:me},{id:`progress`,icon:cn},{id:`settings`,icon:St}].map(e=>e.id)),ai=`xopc.projectFiles.panelWidthPx`,oi=320,si=220,ci=560;function li(e,t){return e.name!==t.name||e.description!==(t.description??``)||e.status!==t.status||e.defaultAgentId!==(t.defaultAgentId??``)||e.executionMode!==t.executionMode||e.brief!==(t.brief??``)||e.instructions!==(t.instructions??``)}function ui(e){return Math.min(ci,Math.max(si,Math.round(e)))}function di(){try{let e=window.localStorage.getItem(ai);if(e==null)return oi;let t=Number.parseInt(e,10);return Number.isFinite(t)?ui(t):oi}catch{return oi}}function fi(e){try{window.localStorage.setItem(ai,String(ui(e)))}catch{}}function pi(e){return!!(e&&ii.has(e))}function mi(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function hi(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):be(n)}function gi(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function _i(e){let t=(0,Q.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function vi(e=!1){return O(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function yi(e){let t=(0,Q.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`font-mono text-xs`,c;t[2]===s?c=t[3]:(c=O(`mt-1 min-w-0 truncate text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,$.jsx)(`div`,{className:c,title:r,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function bi(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function xi(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function Si(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function Ci(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function wi(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function Ti(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Ei(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function Di(e){let t=e.sourceChannel?.trim();if(t)return Oi(t);let n=e.key.split(`:`).filter(Boolean),r=(n[0]?.toLowerCase()===`agent`?n.slice(2).join(`:`):e.key).split(`:`)[0]?.split(/[-_]/)[0]?.trim();return Oi(r||``)}function Oi(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function ki(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function Ai(e){return e.map(e=>({fileId:e.fileId,name:e.name,path:e.path,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function ji(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:ji(e.children,t,n)}:e)}function Mi({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,s]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)([e]),[m,h]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(`new`),[T,D]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(null),[I,V]=(0,Z.useState)(null),H=(0,Z.useCallback)(async()=>{v(!0),b(null);try{let t=await It({limit:100});f(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e]);(0,Z.useEffect)(()=>{f(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,Z.useEffect)(()=>{o&&H()},[H,o]);let W=(0,Z.useMemo)(()=>{let t=m.trim().toLowerCase().split(/\s+/).filter(Boolean);return d.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=bi(e);return t.every(e=>n.includes(e))}).sort((e,t)=>xi(t)-xi(e))},[e.id,d,m]),ne=e=>t.statuses[e.status]??e.status,re=e=>e.description||e.brief||t.common.defaultWorkspace,G=e=>{w(e),D(``),A(``),P(null),S(!0),s(!1)},K=(0,Z.useCallback)(async(e={})=>{let t=k.trim(),n=T.trim()||(C===`directory`?Si(t):``);if(n){M(!0),P(null),V(null);try{let r=await un({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});S(!1),D(``),A(``),f(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=Ci(e);t?(V(t),S(!1)):P(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[C,T,a,k]),ie=(0,Z.useCallback)(e=>{e.preventDefault(),K()},[K]),ae=(0,Z.useCallback)(()=>{K({createWorkspaceRoot:!0})},[K]),oe=(0,Z.useCallback)(()=>{V(null),S(!0)},[]),q=e=>{A(e),C===`directory`&&!T.trim()&&D(Si(e))},se=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:O(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,$.jsx)(c,{className:O(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:re(e)})]}),(0,$.jsx)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,gi(e.status)),children:ne(e)})]},e.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(u,{open:o,onOpenChange:s,children:[(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`group flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,gi(e.status)),children:ne(e)})]}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:re(e)})]}),(0,$.jsx)(Ot,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,$.jsx)(l,{children:(0,$.jsxs)(g,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`label`,{className:`relative block`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:m,onChange:e=>h(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,$.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),se(e,!0),(0,$.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),y?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:y}):null,_&&W.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!_&&W.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,W.map(e=>se(e,!1))]}),(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>G(`new`),children:[(0,$.jsx)(E,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>G(`directory`),children:[(0,$.jsx)(Fe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,$.jsx)(St,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,$.jsx)(te,{open:x,onOpenChange:e=>!j&&S(e),children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:C===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm text-fg-muted`,children:C===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:ie,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:[N?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:N}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,$.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:T,onChange:e=>D(e.target.value),placeholder:`xopc`})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,$.jsx)(In,{value:k,onChange:q,disabled:j,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:j,children:n.cancel})}),(0,$.jsxs)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:j||!(T.trim()||C===`directory`&&Si(k)),children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,$.jsx)(te,{open:!!I,onOpenChange:e=>{e||V(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[110] flex 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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:I?mi(n.workspaceMissingDescription,{workspace:I}):null})]}),I?(0,$.jsx)(`div`,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(Fe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:I})]})}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:oe,disabled:j,children:n.workspaceMissingBack}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:ae,disabled:j,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function Ni(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),[c]=a(),l=M(e=>e.language),u=P(l),d=u.chat.workingDirectory,p=u.projectDetailPage,h=u.projectsPage,g=xt(e=>e.setPageHeader),_=xt(e=>e.clearPageHeader),[y,b]=(0,Z.useState)(null),[T,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)([]),[N,I]=(0,Z.useState)(``),[H,ae]=(0,Z.useState)([]),[oe,se]=(0,Z.useState)(0),[ce,de]=(0,Z.useState)(!1),[fe,_e]=(0,Z.useState)(!1),[ve,be]=(0,Z.useState)(!1),[Se,we]=(0,Z.useState)([]),[De,je]=(0,Z.useState)(null),Pe=(0,Z.useRef)(new Set),[Re,Ve]=(0,Z.useState)(null),[We,Ge]=(0,Z.useState)(null),[qe,Ye]=(0,Z.useState)(null),[$e,tt]=(0,Z.useState)(di),[it,at]=(0,Z.useState)(!1),[ot,st]=(0,Z.useState)(!1),[ct,lt]=(0,Z.useState)(``),[ut,ft]=(0,Z.useState)([]),[gt,_t]=(0,Z.useState)(!1),[vt,yt]=(0,Z.useState)(null),[Ct,Tt]=(0,Z.useState)(!1),[Et,Ot]=(0,Z.useState)(null),[Mt,It]=(0,Z.useState)([]),[Rt,zt]=(0,Z.useState)(``),[Bt,Ut]=(0,Z.useState)(!0),[Kt,qt]=(0,Z.useState)(!1),[Jt,Xt]=(0,Z.useState)(!1),[Zt,Qt]=(0,Z.useState)(null),[$t,en]=(0,Z.useState)(!1),[tn,nn]=(0,Z.useState)(`fixed`),[rn,sn]=(0,Z.useState)(``),[ln,un]=(0,Z.useState)(null),[fn,pn]=(0,Z.useState)(!1),[hn,_n]=(0,Z.useState)(!1),[vn,yn]=(0,Z.useState)(!1),[bn,wn]=(0,Z.useState)(null),En=(0,Z.useRef)(null),Dn=(0,Z.useRef)(!1),[On,X]=(0,Z.useState)(null),[kn,An]=(0,Z.useState)({title:``,reason:``}),[jn,Mn]=(0,Z.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),Nn=(0,Z.useRef)(jn),Pn=`overview`,Q=n?`notes`:pi(t)?t:Pn,Fn=(0,Z.useMemo)(()=>x(c.get(`returnTo`),`/projects`,[`/chat`]),[c]),Ln=(0,Z.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Fn===`/projects`?n:S(n,Fn)},[Fn,e]),Rn=(0,Z.useCallback)(t=>{e&&r(Ln(t))},[r,e,Ln]),zn=(0,Z.useCallback)(()=>{if(Q===`tasks`&&En.current){En.current.openCreate();return}Dn.current=!0,Rn(`tasks`)},[Rn,Q]);(0,Z.useEffect)(()=>{Q!==`tasks`||!Dn.current||(Dn.current=!1,En.current?.openCreate())},[Q]);let Bn=(0,Z.useCallback)(t=>{e&&r(Ln(t),{replace:!0})},[r,e,Ln]),Vn=(0,Z.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||Bn(e)},[Bn]),Hn=(0,Z.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:Q,[Q]);(0,Z.useEffect)(()=>{!e||!t||pi(t)||r(Ln(Pn),{replace:!0})},[Pn,r,e,Ln,t]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return Ut(!0),X(null),Promise.all([q(e),le(e),Ne(e),bt().catch(()=>null),J(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;b(e),k(n),j(r),je(a),It(i?.agents??[]),zt(e.defaultAgentId??``);let o={name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``};Nn.current=o,Mn(o)}).catch(e=>{t||(je(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Ut(!1)}),()=>{t=!0}},[e]);let Un=(0,Z.useCallback)(async()=>{e&&k(await le(e))},[e]);(0,Z.useEffect)(()=>{let t,n=n=>{let r=G.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Un(),120))},r=n=>{let r=Ft.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Un(),120))};return window.addEventListener(`task-changed-v2`,n),window.addEventListener(`task-deleted-v1`,r),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,n),window.removeEventListener(`task-deleted-v1`,r)}},[e,Un]);let Wn=(0,Z.useCallback)(async(e,t)=>{wn(e.id),X(null);try{let n=await mn(e.id),r=t.startsWith(`move_`)?{type:`move`,phase:t.slice(5)}:t.startsWith(`reopen_`)?{type:`reopen`,phase:t.slice(7)}:t===`ready`?{type:`mark_ready`}:t===`run`?{type:`start`,executor:{kind:`agent`,agentId:n.task.delegateAgentId??(await pt(e.id)).agentId}}:t===`pause`?{type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}:t===`review`?{type:`request_review`}:t===`complete`?{type:`close`,resolution:`done`}:t===`reopen`?{type:`reopen`,phase:`ready`}:{type:`resolve_wait`,waitId:n.waits[0]?.id??``};if(r.type===`resolve_wait`&&!r.waitId)throw Error(`No active wait to resolve`);return await Gt(e.id,r,n.task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[T,p.board.actionFailed,Un]),Gn=(0,Z.useCallback)(async t=>{e&&(X(null),await At({idempotencyKey:t.requestId,title:t.objective,projectId:e,priority:t.priority,dueAt:t.dueAt,locale:l,contract:{objective:t.objective,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:t.dependsOnTaskIds,context:t.attachments.map((e,t)=>({targetKind:`file`,targetId:e.uri??e.name??`attachment-${t+1}`,role:`input`,title:e.name,pinned:!0,retrievalPolicy:{},metadata:{mimeType:e.mimeType,size:e.size,data:e.data}})),authorityGrants:[],activation:{mode:`capture`,phase:`backlog`}}),await Un())},[l,e,Un]),Kn=(0,Z.useCallback)(async(e,t)=>{wn(e),X(null);try{return await Xe(e,t,(await mn(e)).task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[p.board.actionFailed,Un]),qn=(0,Z.useCallback)(async(e,t,n)=>{wn(e),X(null);try{let r=await mn(e);return r.task.phase!==t&&(r=await Gt(e,r.task.phase===`closed`?{type:`reopen`,phase:t===`closed`?`ready`:t}:t===`closed`?{type:`close`,resolution:`done`}:{type:`move`,phase:t},r.task.version)),await Xe(e,n,r.task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[p.board.actionFailed,Un]),Jn=(0,Z.useCallback)(async(e,t)=>{wn(e),X(null);try{await ue(e,t,(await mn(e)).task.version),await Un()}catch(e){await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed)}finally{wn(null)}},[p.board.actionFailed,Un]),Yn=(0,Z.useCallback)(async t=>{if(e){X(null);try{await ye(e,t),await Un()}catch(e){throw X(e instanceof Error?e.message:p.board.actionFailed),e}}},[p.board.actionFailed,e,Un]),Xn=(0,Z.useCallback)(async()=>{if(y){de(!0),X(null);try{let e=await on(y.id,{includeRelated:fe,limit:100});ae(e.items),se(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{de(!1)}}},[y,fe]);(0,Z.useEffect)(()=>{Q===`progress`&&Xn()},[Xn,Q]);let Zn=(0,Z.useCallback)(async()=>{if(!y?.effectiveWorkspaceRoot?.trim()){we([]),Pe.current.clear(),Ot(null);return}Tt(!0),Ot(null),Pe.current.clear();try{we(Ai((await Je(y.id,``)).entries)),Pe.current.add(``)}catch(e){we([]),Pe.current.clear(),Ot(e instanceof Error?e.message:String(e))}finally{Tt(!1)}},[y]),Qn=(0,Z.useCallback)(async e=>{if(!(!y?.effectiveWorkspaceRoot?.trim()||Pe.current.has(e))){Pe.current.add(e),Ot(null);try{let t=await Je(y.id,e);we(n=>ji(n,e,Ai(t.entries)))}catch(t){Pe.current.delete(e),Ot(t instanceof Error?t.message:String(t))}}},[y]),$n=(0,Z.useCallback)(async e=>{if(!y?.effectiveWorkspaceRoot?.trim())return;let t=Ai((await Je(y.id,e)).entries);we(e?n=>ji(n,e,t):t),Pe.current.add(e)},[y]);(0,Z.useEffect)(()=>{Q===`files`&&Zn()},[Zn,Q]);let er=ct.trim();(0,Z.useEffect)(()=>{if(Q!==`files`||!y||!ot||!er){ft([]),_t(!1),yt(null);return}let e=!1;_t(!0),yt(null),ft([]);let t=window.setTimeout(()=>{Ae(y.id,er,50).then(t=>{e||ft(t)}).catch(t=>{e||yt(t instanceof Error?t.message:String(t))}).finally(()=>{e||_t(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[er,y,ot,Q]);let tr=(0,Z.useCallback)(async()=>{if(!y)return;let[e,t]=await Promise.all([q(y.id),le(y.id)]);k(t),b(e)},[y]),nr=(0,Z.useCallback)(async e=>{if(e.preventDefault(),!(!y||!kn.title.trim())){_n(!0),X(null);try{await ht(y.id,{title:kn.title.trim(),reason:kn.reason.trim()||void 0}),An({title:``,reason:``}),yn(!1),await tr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{_n(!1)}}},[kn.reason,kn.title,y,tr]),rr=(0,Z.useMemo)(()=>(0,$.jsx)(s,{to:Fn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Fn===`/projects`?p.backToProjects:u.sidebar.back,children:(0,$.jsx)(K,{className:`size-4`,"aria-hidden":!0})}),[Fn,u.sidebar.back,p.backToProjects]),ir=(0,Z.useMemo)(()=>y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(y.id)}`,children:[(0,$.jsx)(w,{className:`size-4`,"aria-hidden":!0}),p.common.runWorkflow]})}),(0,$.jsxs)(U,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:zn,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),p.board.create]}),(0,$.jsx)(U,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:Yt(y.id),state:{forceNewChat:!0,agentId:y.defaultAgentId},onClick:Vn(`sessions`),children:[(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0}),p.common.newChat]})})]}):null,[zn,Vn,p.board.create,p.common.newChat,p.common.runWorkflow,y]);(0,Z.useLayoutEffect)(()=>(g({startExtra:rr,main:y?(0,$.jsx)(Mi,{currentProject:y,pm:p,projectsText:h,wd:d}):(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:p.fallbackTitle}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:p.fallbackContext})]}),end:ir}),()=>_()),[_,ir,rr,p,y,h,g,d]);function ar(e){b(t=>t?{...t,...e}:null),zt(e.defaultAgentId??``),J(e.id).then(je).catch(()=>je(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function or(e=Nn.current){if(!(!y||!li(e,y))){X(null),Qt(null);try{let t=await Y(y.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions});ar(t);let n=Nn.current,r={...n,name:n.name===e.name?t.name:n.name,description:n.description===e.description?t.description??``:n.description,status:n.status===e.status?t.status:n.status,defaultAgentId:n.defaultAgentId===e.defaultAgentId?t.defaultAgentId??``:n.defaultAgentId,executionMode:n.executionMode===e.executionMode?t.executionMode:n.executionMode,brief:n.brief===e.brief?t.brief??``:n.brief,instructions:n.instructions===e.instructions?t.instructions??``:n.instructions};Nn.current=r,Mn(r)}catch(e){let t=Ci(e);throw t?Qt(t):X(e instanceof Error?e.message:String(e)),e}}}function sr(e){e.preventDefault(),Tr.flush()}function cr(e,t=!1){let n={...Nn.current,...e};Nn.current=n,Mn(n),t&&Tr.saveNow(n)}let lr=(0,Z.useCallback)(()=>{if(!y)return;let e=y.workspaceRoot?.trim()??``;nn(e?`fixed`:`follow`),sn(e||y.effectiveWorkspaceRoot||``),en(!0)},[y]);async function ur(e={}){if(!y)return;let t=tn===`fixed`?rn.trim():``;if(!(tn===`fixed`&&!t)){qt(!0),X(null),Qt(null);try{let n=await Y(y.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});ar(n),cr({workspaceRoot:n.workspaceRoot??``}),en(!1),Qt(null)}catch(e){let t=Ci(e);t?(Qt(t),en(!1)):X(e instanceof Error?e.message:String(e))}finally{qt(!1)}}}async function fr(){if(!(!y||ln)){un(`pin`),X(null);try{ar(y.pinnedAt?await Le(y.id):await ne(y.id))}catch(e){X(e instanceof Error?e.message:String(e))}finally{un(null)}}}async function pr(){if(!(!y||ln)){un(`archive`),X(null);try{let e=y.status===`archived`?await Nt(y.id):await an(y.id);ar(e),cr({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{un(null)}}}async function mr(){if(y){pn(!0),X(null);try{await Ke(y.id),Xt(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{pn(!1)}}}async function hr(){if(!(!y||ve)){be(!0),X(null);try{await Ee(y.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{be(!1)}}}let gr=(0,Z.useCallback)(e=>{Ve(e)},[]),_r=(0,Z.useCallback)((e,t)=>{t||Ve(e)},[]),vr=(0,Z.useCallback)(async(e,t,n)=>{let r=y?.id;if(r)switch(e){case`preview`:t.isDirectory||Ve(t.path);break;case`download`:if(t.isDirectory)return;try{let e=pe(t.path);if(Te(ze(e))!==`text`){let n=await Qe(t.path,{projectId:r}),i=wt(e)??`application/octet-stream`;gn(e,await n.arrayBuffer(),i)}else{let{content:n}=await ge(t.path,{projectId:r});ie(e,n)}}catch(e){Oe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await V(t.path)&&Oe(`success`,u.workspace.pathCopied,void 0,{duration:2500})}catch{Oe(`warning`,u.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await Wt(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),u.workspace.openFileFailed);break;case`openWith`:await Wt(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),u.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Wt(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),u.workspace.openFileFailed);break;case`revealInFolder`:await Wt(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),u.workspace.revealFileFailed);break;case`trash`:Ge(t);break;case`delete`:t.isDirectory||Ye(t);break;default:break}},[u.clipboard.copyFailed,u.workspace.openFileFailed,u.workspace.pathCopied,u.workspace.revealFileFailed,y?.id]),br=(0,Z.useCallback)(async()=>{let e=We;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){Oe(`warning`,t?.error??u.workspace.trashFailed,void 0,{duration:4e3});return}Re===e.path&&Ve(null),Ge(null),await Zn(),Oe(`success`,u.workspace.trashSuccess,void 0,{duration:2500})},[u.workspace.trashFailed,u.workspace.trashSuccess,We,Re,Zn]),xr=(0,Z.useCallback)(async(e,t)=>{let n=y?.id;if(n)try{await Promise.all(e.map(e=>Ze(e,t,{projectId:n}))),await $n(t).catch(()=>void 0),Oe(`success`,u.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await $n(t).catch(()=>void 0),Oe(`warning`,`${u.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[u.workspace.uploadFailed,u.workspace.uploadSuccess,y?.id,$n]),Sr=(0,Z.useCallback)(async()=>{let e=qe;if(e)try{await Ue(e.fileId),Re===e.path&&Ve(null),Ye(null);let t=e.path.lastIndexOf(`/`);await $n(t<0?``:e.path.slice(0,t)).catch(()=>void 0),Oe(`success`,u.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Oe(`warning`,`${u.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[u.workspace.deleteFailed,u.workspace.deleteSuccess,qe,Re,$n]),Cr=(0,Z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),at(!0);let r=e.clientX,i=$e,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=ui(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}at(!1),tt(c),fi(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[$e]);(0,Z.useEffect)(()=>{Q!==`files`&&Ve(null)},[e,Q]);let wr=!!(y&&li(jn,y)),Tr=Sn({value:y?jn:null,dirty:wr,onSave:or,validate:e=>e.name.trim()?null:p.settings.nameRequired});if(Bt)return(0,$.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:p.loading});if(!y)return(0,$.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,$.jsxs)(s,{to:Fn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,$.jsx)(K,{className:`size-4`,"aria-hidden":!0}),Fn===`/projects`?p.backToProjects:u.sidebar.back]}),(0,$.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:On||p.notFound})]});let Er=A.slice(0,3),Or=T?.blockers??[],kr=Dr(T?.tasks??[]),Ar=T?.tasks.filter(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)).length??0,jr=e=>p.statuses[e]??e,Mr=e=>mi(p.common.messages,{count:e}),Nr=N.trim().toLowerCase(),Pr=Nr?A.filter(e=>{let t=hi(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=e.name?.trim()||p.sessions.fallbackTitle,i=Mr(e.messageCount??0),a=Di(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Nr)}):A,Fr=A.length>0&&Pr.length===0,Ir=Mt.find(e=>e.id===y.defaultAgentId)?.name||y.defaultAgentId||p.settings.globalDefaultAgent,Lr=Mt.find(e=>e.id===jn.defaultAgentId),Rr=y.workspaceRoot?.trim()||``,zr=y.status===`archived`,Br=!!y.pinnedAt,Vr=!Rr,Hr=Rr||Lr?.workspace||y.effectiveWorkspaceRoot||p.common.defaultWorkspace,Ur=tn===`fixed`?rn.trim()||p.settings.workspacePlaceholder:Lr?.workspace||y.effectiveWorkspaceRoot||p.common.defaultWorkspace,Wr=(tn===`fixed`?rn.trim():``)!==Rr&&(tn===`follow`||!!rn.trim()),Gr=[{id:`overview`,icon:Vt,label:p.tabs.overview},{id:`tasks`,icon:xe,label:p.tabs.tasks},{id:`automations`,icon:Me,label:p.tabs.automations},{id:`files`,icon:Fe,label:p.tabs.files},{id:`notes`,icon:Be,label:p.tabs.notes},{id:`skills`,icon:jt,label:p.tabs.skills},{id:`sessions`,icon:me,label:p.tabs.sessions},{id:`progress`,icon:cn,label:p.tabs.progress}];async function Kr(){if(!Hr)return;let e=await V(Hr);Oe(e?`success`:`warning`,e?u.workspace.pathCopied:u.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function qr(){Qt(null),en(!0)}return(0,$.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,$.jsx)(Cn,{items:Gr,activeTab:Q,onChange:Rn,ariaLabel:p.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,$.jsxs)(U,{id:`project-primary-tab-settings`,type:`button`,variant:Q===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":Q===`settings`?`page`:void 0,onClick:()=>Rn(`settings`),children:[(0,$.jsx)(St,{className:`size-4`,"aria-hidden":!0}),p.tabs.settings,wr?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":p.settings.unsavedChanges}):null]})]}),(0,$.jsx)(`div`,{className:`mt-2 shrink-0`,children:(0,$.jsx)(U,{variant:`ghost`,onClick:()=>r(`/assistant-work?view=new&project=${encodeURIComponent(e)}`),children:l===`zh`?`让助理帮我跟进`:`Ask the assistant to follow this project`})}),On?(0,$.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:On}):null,(0,$.jsxs)(`div`,{className:O(`mt-3 min-h-0 flex-1`,Q===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:Q===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[Q===`overview`?(0,$.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.directionTitle}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:mi(p.overview.activitySummary,{moving:Ar,attention:Or.length})})]}),(0,$.jsx)(`p`,{className:`mt-2 max-w-3xl text-base font-medium leading-7 text-fg`,children:y.outcome||y.description||y.brief||p.overview.directionFallback}),T?.digest.recommendedAction?(0,$.jsx)(`p`,{className:`mt-3 max-w-3xl rounded-lg bg-surface-hover px-3 py-2.5 text-sm font-medium leading-6 text-fg`,children:mi(p.overview.recommendedNext,{action:T.digest.recommendedAction})}):null]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,onClick:()=>void hr(),disabled:ve,children:[(0,$.jsx)(dt,{className:`size-3.5`,"aria-hidden":!0}),ve?p.overview.savingDigest:p.overview.saveDigest]})]})}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3.5`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.nextActions}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted transition-colors hover:text-fg`,onClick:()=>Rn(`tasks`),children:p.common.viewAll})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle`,children:kr.length?kr.map(e=>(0,$.jsxs)(s,{to:Ie(Ln(`overview`),e.id),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsxs)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.attention.length?`bg-warning/10 text-warning`:`bg-surface-hover text-fg-muted`),children:[p.board.phases[e.phase],e.operationalState===`idle`?``:` · ${p.board.operationalStates[e.operationalState]}`]})]}),e.attention[0]?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noNextActions})})]})]}),T?.recentResults.length?(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.recentResults})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:T.recentResults.slice(0,3).map(({taskId:e,taskTitle:t,receipt:n})=>(0,$.jsxs)(s,{to:Ie(Ln(`overview`),e),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,$.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[p.overview.resultStatuses[n.status],` · `,p.board.verification[n.verification.status]]})]}),(0,$.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-5 text-fg-muted`,children:(0,$.jsx)(C,{content:n.summary,compact:!0})})]},n.runId))})]}):null,y.milestones.length||y.recentUpdates.length?(0,$.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[y.milestones.length?(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.milestones})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:y.milestones.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:p.statuses[e.status]})]},e.id))})]}):null,y.recentUpdates.length?(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.projectUpdates})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:y.recentUpdates.slice(0,3).map(e=>(0,$.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:p.overview.healthLabels[e.health]})]},e.id))})]}):null]}):null]}),(0,$.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.attention}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,"aria-expanded":vn,onClick:()=>yn(e=>!e),children:[(0,$.jsx)(E,{className:O(`size-3.5 transition-transform`,vn&&`rotate-45`),"aria-hidden":!0}),p.overview.addBlocker]})]}),Or.length?(0,$.jsx)(`div`,{className:`mt-3 grid gap-3`,children:Or.map(e=>{let t=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Ht,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,$.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[p.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${jr(e.status)}`:``]})]});return e.href?(0,$.jsx)(s,{to:e.href,onClick:Vn(Hn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,$.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:p.overview.noBlockedTasks}),vn?(0,$.jsxs)(`form`,{onSubmit:nr,className:`mt-4 flex gap-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:kn.title,onChange:e=>An(t=>({...t,title:e.target.value})),placeholder:p.overview.blockerTitlePlaceholder}),(0,$.jsx)(U,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:hn||!kn.title.trim(),"aria-label":hn?p.overview.addingBlocker:p.overview.addBlocker,title:hn?p.overview.addingBlocker:p.overview.addBlocker,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]}):null]}),(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(He,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:p.overview.recentSessions})]}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Rn(`sessions`),children:p.common.viewAll})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Er.length?Er.map(e=>(0,$.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Vn(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:hi(e.updatedAt)})]}),(e.routing?.agentId||e.agentId)&&(e.routing?.agentId||e.agentId)!==y.defaultAgentId?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.routing?.agentId||e.agentId}):null]},e.key)):(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noSessions})})]})]})]}):null,Q===`tasks`?(0,$.jsx)(ri,{ref:En,tasks:T?.tasks??[],dependencyEdges:T?.dependencyEdges??[],monitoring:T?.monitoring??{projectId:e??``,mode:`observe`,allowedActions:[],confidenceThreshold:.75,scenarios:[],configured:!1},returnTo:Ln(`tasks`),copy:p.board,onAction:Wn,onReorder:Kn,onUndoMove:qn,onDependenciesChange:Jn,onMonitoringChange:Yn,onCreate:Gn,actionBusyId:bn}):null,Q===`automations`?(0,$.jsx)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-automations`,className:`grid min-h-full content-start gap-4`,children:(0,$.jsx)(Tn,{projectId:y.id,embedded:!0,title:p.automations.title,subtitle:p.automations.hint})}):null,Q===`notes`?(0,$.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,$.jsx)(dr,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(y.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:y.id,listTitle:p.notes.title,listDescription:p.notes.hint,emptyText:p.notes.emptyTitle,emptyDescription:p.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${y.id}`})}):null,Q===`skills`?(0,$.jsx)(yr,{projectId:y.id,copy:p.skills}):null,Q===`files`?(0,$.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-files`,className:`flex h-full min-h-[28rem] flex-col`,children:(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:y.effectiveWorkspaceRoot?(0,$.jsxs)(`div`,{"data-project-files-grid":!0,className:O(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,it&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${$e}px`},children:[(0,$.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[De?(0,$.jsx)(Dt,{resourceId:De.fileId,displayName:De.name}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:O(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,ot&&`bg-surface-hover text-fg`),onClick:()=>st(!0),"aria-label":p.files.search,title:p.files.search,"aria-pressed":ot,children:(0,$.jsx)(kt,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(he,{className:`size-7 shrink-0 rounded-md p-0`,loading:Ct,label:u.cron.refresh,onClick:()=>void Zn()})]})]}),ot?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex h-8 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)(kt,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:ct,onChange:e=>lt(e.target.value),placeholder:p.files.searchPlaceholder,"aria-label":p.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":p.files.clearSearch,title:p.files.clearSearch,onClick:()=>{lt(``),st(!1)},children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Et?(0,$.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Et}):null,er?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:gt?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(W,{className:`h-11 w-full`}),(0,$.jsx)(W,{className:`h-11 w-full`}),(0,$.jsx)(W,{className:`h-11 w-full`})]}):vt?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[u.workspace.loadError,`: `,vt]}):ut.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:p.files.noSearchResults}):ut.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:O(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Re===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Ve(e.path),title:e.path,children:[(0,$.jsx)(Be,{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))}):Ct&&Se.length===0?(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.files.loading}):(0,$.jsx)(nt,{tree:Se,selectedPath:Re,onSelectFile:gr,onSelectEntry:_r,onExpandDir:e=>void Qn(e),onAction:vr,onUploadFiles:(e,t)=>void xr(e,t),uploadDropHint:u.workspace.dropToUpload,actionLabels:{preview:u.workspace.preview,download:u.workspace.download,copyPath:u.workspace.copyPath,openDefault:u.workspace.openSystemApp,openDirectory:u.workspace.openInFileManager,openWith:u.workspace.openWith,revealInFolder:u.workspace.revealInFolder,trash:u.workspace.moveToTrash,delete:u.workspace.deleteFile,recommendedApps:u.workspace.recommendedApps,desktopUpdateRequired:u.workspace.desktopUpdateRequired},emptyHint:p.files.emptyDirectory})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":p.files.resizeHandle,className:O(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,it&&`bg-surface-hover`),onPointerDown:Cr,children:(0,$.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Re?(0,$.jsx)(et,{filePath:Re,projectId:y.id,agentId:y.defaultAgentId||Rt||void 0,onClose:()=>Ve(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(Fe,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p.files.previewEmptyTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.files.previewEmptyDescription})]})})})]}):(0,$.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:p.files.needWorkspace}),(0,$.jsx)(`div`,{children:(0,$.jsx)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Rn(`settings`),children:p.files.openSettings})})]})})}):null,Q===`sessions`?(0,$.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[A.length?(0,$.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:N,onChange:e=>I(e.currentTarget.value),placeholder:p.sessions.searchPlaceholder,"aria-label":p.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),N?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md 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":p.sessions.clearSearch,onClick:()=>I(``),children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Pr.length?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Pr.map(e=>{let t=hi(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=Di(e),i=e.name?.trim()||p.sessions.fallbackTitle,a=Mr(e.messageCount??0);return(0,$.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Vn(`sessions`),className:`group flex min-h-[8.75rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-2 py-0.5 text-[11px] font-medium leading-5 text-fg-muted`,children:r}):null]})})]}),(0,$.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.agent,`: `,n]}),(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,$.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.updated,`: `,t]}):null]})]},e.key)})}):Fr?(0,$.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.noMatches})}):(0,$.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.emptyTitle}),(0,$.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:p.sessions.emptyDescription})]})})]}):null,Q===`progress`?(0,$.jsxs)(`section`,{id:`project-panel-progress`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-progress`,className:`grid min-h-full content-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.progress.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:mi(p.progress.count,{count:oe})})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:fe,onChange:e=>_e(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),p.progress.includeRelated]}),(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Xn(),disabled:ce,children:[(0,$.jsx)(dn,{className:O(`size-4`,ce&&`animate-spin`),"aria-hidden":!0}),p.common.refresh]})]})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:ce&&H.length===0?(0,$.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.progress.loading}):H.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge`,children:H.map(e=>{let t=p.progress.types[e.type]??e.type,n=p.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=ki(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===y.id);return(0,$.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:p.progress.related}):null]}),(0,$.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,Ti(e)]})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:hi(e.createdAt)})]}),r?(0,$.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[p.progress.actor,`: `,wi(e)]}),(0,$.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.progress.source,`: `,Ei(e)]})]})]},e.id)})}):(0,$.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.progress.empty})})]}):null,Q===`settings`?(0,$.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:sr,onBlurCapture:Tr.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,$.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.summaryTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.settings.summaryHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,$.jsx)(`span`,{className:O(`rounded-full px-2 py-0.5 text-xs font-medium`,gi(jn.status)),children:p.settings.statuses[jn.status]}),(0,$.jsx)(xn,{status:Tr.status,error:Tr.error})]})]}),(0,$.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4`,children:[(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.detailsTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.detailsHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsx)(_i,{label:p.settings.name,children:(0,$.jsx)(`input`,{className:vi(),value:jn.name,onChange:e=>cr({name:e.target.value})})}),(0,$.jsx)(_i,{label:p.settings.defaultAgent,children:(0,$.jsxs)(f,{className:vi(),value:jn.defaultAgentId,onChange:e=>cr({defaultAgentId:e.target.value},!0),children:[(0,$.jsx)(m,{value:``,children:p.settings.globalDefaultAgent}),Mt.map(e=>(0,$.jsx)(m,{value:e.id,children:mt(e,u.agentsSettings)},e.id))]})}),(0,$.jsx)(_i,{label:p.settings.status,children:zr?(0,$.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:p.settings.statuses.archived}):(0,$.jsxs)(f,{className:vi(),value:jn.status===`archived`?`active`:jn.status,onChange:e=>cr({status:e.target.value},!0),children:[(0,$.jsx)(m,{value:`active`,children:p.settings.statuses.active}),(0,$.jsx)(m,{value:`paused`,children:p.settings.statuses.paused})]})}),(0,$.jsx)(_i,{label:p.settings.executionMode,hint:p.settings.executionModeHint,children:(0,$.jsxs)(f,{className:vi(),value:jn.executionMode,onChange:e=>cr({executionMode:e.target.value},!0),children:[(0,$.jsx)(m,{value:`managed_worktree`,children:p.settings.executionModeWorktree}),(0,$.jsx)(m,{value:`local_checkout`,children:p.settings.executionModeLocal})]})}),(0,$.jsx)(_i,{label:p.settings.description,hint:p.settings.descriptionHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.description,onChange:e=>cr({description:e.target.value})})})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.projectGuidanceTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.projectGuidanceHint})]}),(0,$.jsx)(_i,{label:p.settings.brief,hint:p.settings.briefHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.brief,onChange:e=>cr({brief:e.target.value})})}),(0,$.jsx)(_i,{label:p.settings.instructions,hint:p.settings.instructionsHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.instructions,onChange:e=>cr({instructions:e.target.value})})})]})]}),(0,$.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.workspaceRoot}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceIndependentHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`span`,{className:`w-fit rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Vr?p.settings.workspaceModeFollow:p.settings.workspaceModeFixed}),(0,$.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Hr,children:Hr}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void Kr(),children:[(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),p.settings.copyWorkspacePath]}),De?(0,$.jsx)(Dt,{resourceId:De.fileId,displayName:De.name}):null,(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:lr,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.migrateWorkspace]})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.currentProjectTitle}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(yi,{label:p.settings.defaultAgent,value:Ir}),(0,$.jsx)(yi,{label:p.settings.pinState,value:Br?p.settings.pinned:p.settings.notPinned}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(yi,{label:p.settings.createdAt,value:hi(y.createdAt)||p.common.never}),(0,$.jsx)(yi,{label:p.settings.updatedAt,value:hi(y.updatedAt)||p.common.never})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.managementTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.managementHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Br?p.settings.pinnedTitle:p.settings.pinTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.pinHint})]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:ln===`pin`,onClick:()=>void fr(),children:[Br?(0,$.jsx)(re,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(Pt,{className:`size-4`,"aria-hidden":!0}),Br?p.settings.unpinProject:p.settings.pinProject]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:zr?p.settings.restoreTitle:p.settings.archiveTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:zr?p.settings.restoreHint:p.settings.archiveHint})]}),(0,$.jsxs)(U,{type:`button`,variant:zr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:ln===`archive`,onClick:()=>void pr(),children:[zr?(0,$.jsx)(dn,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ke,{className:`size-4`,"aria-hidden":!0}),zr?p.settings.restoreProject:p.settings.archiveProject]})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:p.settings.dangerTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:p.settings.dangerHint})]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>Xt(!0),children:[(0,$.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,$.jsx)(te,{open:Jt,onOpenChange:e=>{fn||Xt(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,$.jsx)(Ht,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.deleteConfirmTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:y?mi(p.settings.deleteConfirm,{name:y.name}):p.settings.deleteConfirmFallback})]})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:fn,children:p.common.cancel})}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:fn||!y,onClick:()=>void mr(),children:[(0,$.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]})]})]})}),(0,$.jsx)(Ce,{open:!!We,title:u.workspace.trashConfirmTitle,description:u.workspace.trashConfirmDescription.replace(`{{name}}`,We?.name??``),confirmLabel:u.workspace.moveToTrash,cancelLabel:u.workspace.cancel,destructive:!0,onConfirm:()=>void br(),onCancel:()=>Ge(null)}),(0,$.jsx)(Ce,{open:!!qe,title:u.workspace.deleteConfirmTitle,description:u.workspace.deleteConfirmDescription.replace(`{{name}}`,qe?.name??``),confirmLabel:u.workspace.deleteFile,cancelLabel:u.workspace.cancel,destructive:!0,onConfirm:()=>void Sr(),onCancel:()=>Ye(null)}),(0,$.jsx)(te,{open:$t,onOpenChange:e=>{Kt||en(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMigrationTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.workspaceMigrationDescription})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:p.settings.workspaceMode}),(0,$.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:O(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,tn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,$.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:tn===`fixed`,onChange:()=>nn(`fixed`),disabled:Kt}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFixed}),(0,$.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceMigrationFixedHint})]})]}),(0,$.jsxs)(`label`,{className:O(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,tn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,$.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:tn===`follow`,onChange:()=>nn(`follow`),disabled:Kt}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFollow}),(0,$.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceHint})]})]})]})]}),tn===`fixed`?(0,$.jsx)(In,{value:rn,onChange:sn,disabled:Kt,wd:d,placeholder:p.settings.workspacePlaceholder,inputClassName:vi(),autoFocus:!0}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:p.settings.workspaceMigrationImpact}),(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:mi(p.settings.workspaceCurrent,{workspace:Ur})})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Kt,children:p.common.cancel})}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Kt||!Wr,onClick:()=>void ur(),children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMigrationConfirm]})]})]})]})}),(0,$.jsx)(te,{open:!!Zt,onOpenChange:e=>{e||Qt(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex 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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMissingTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Zt?mi(p.settings.workspaceMissingDescription,{workspace:Zt}):null})]}),Zt?(0,$.jsx)(`div`,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(Fe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:Zt})]})}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:qr,disabled:Kt,children:p.settings.workspaceMissingBack}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void ur({createWorkspaceRoot:!0}),disabled:Kt,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMissingCreate]})]})]})]})})]})}export{Ni as ProjectDetailPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a,p as o,t as s}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as c}from"./check-DUBLcKHA.js";import{d as l,f as u,l as d,n as f,p,r as m,t as h,u as g}from"./popover-select-DGmMQt4t.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./copy-Dv6d4Dvw.js";import{t as y}from"./download-Dk-ZjtO6.js";import{t as b}from"./external-link-DjqjBmc3.js";import{d as x,p as S,t as C}from"./markdown-view-DF3aJP_5.js";import{t as w}from"./git-branch-Dh9uxTot.js";import{t as T}from"./loader-circle-CifKLtgG.js";import{t as E}from"./plus-Q2yW6OE7.js";import{t as D}from"./x-B_N4OPjy.js";import{t as O}from"./cn-JdwAhgNB.js";import{a as k,c as A,f as j,n as M,r as N}from"./locale-store-BkJ7g35d.js";import{t as P}from"./messages-BGc-OJWg.js";import{a as F,c as I,i as L,n as R,o as z,r as B,s as ee,t as te}from"./dist-BGTk37IG.js";import{t as V}from"./copy-to-clipboard-HOJ79TWv.js";import{i as H}from"./vendor-swr-BIWyz7Rc.js";import{t as U}from"./button-BA45yciM.js";import{t as W}from"./skeleton-BwbyijEw.js";import{Aa as ne,Ac as re,As as G,Au as K,Bi as ie,Bn as ae,Bs as oe,Ca as q,Cn as se,Da as J,Dn as ce,Ea as le,Es as ue,Eu as de,Fa as Y,Fc as fe,Fi as pe,Gc as me,Gi as he,Hi as ge,Hl as _e,Hn as ve,Ia as ye,Ir as be,Jl as xe,Jn as Se,Ki as Ce,Lc as we,Li as Te,Ma as Ee,Ml as De,Mo as Oe,Mu as ke,Na as Ae,Nl as je,Ns as Me,Oa as Ne,Oc as Pe,Ol as Fe,Os as Ie,Pa as Le,Pc as Re,Pi as ze,Pl as Be,Qi as Ve,Ql as He,Ri as Ue,Rn as We,Rs as Ge,Sa as Ke,Sn as qe,Ta as Je,To as Ye,Ts as Xe,Ui as Ze,Vi as Qe,Vn as $e,Vt as et,Wc as tt,Wi as nt,Ws as rt,Xc as it,Xi as at,Xr as ot,Xs as st,Zi as ct,Zn as lt,Zs as ut,_c as dt,_l as ft,_s as pt,an as mt,ba as ht,bl as gt,bn as _t,bu as vt,cl as yt,cn as bt,co as xt,dc as St,du as Ct,ea as wt,ec as Tt,fc as Et,fi as Dt,fu as Ot,hc as kt,hs as At,ic as jt,ir as Mt,ja as Nt,jc as Pt,js as Ft,ka as It,kl as Lt,kn as Rt,ku as zt,lc as Bt,ll as Vt,lu as Ht,mc as Ut,mi as Wt,ms as Gt,mu as Kt,nu as qt,qi as Jt,ra as Yt,rc as Xt,rl as Zt,si as Qt,sr as $t,su as en,un as tn,us as nn,uu as rn,va as an,wa as on,wn as sn,xl as cn,xn as ln,ya as un,yc as dn,yl as fn,yn as pn,ys as mn,za as hn,zi as gn}from"./index-B03HGpzt.js";import{i as _n,n as vn,r as yn,t as bn}from"./note-detail-panel-GOxomxOK.js";import{n as xn,t as Sn}from"./use-autosave-Dc5aN2px.js";import{t as Cn}from"./page-tabs-B7LA4z-x.js";import{t as wn}from"./date-picker-XjPSlgq_.js";import{t as Tn}from"./automations-workspace-w4McwueN.js";import{i as En,p as Dn,s as On}from"./skills-page.utils-BR5bk2vT.js";import{t as X}from"./dependency-picker-CkyfEP88.js";import{c as kn,l as An,n as jn,o as Mn,r as Nn,t as Pn}from"./style-TIDOdKy0.js";var Z=e(t(),1),Q=n(),$=r();function Fn(e){let t=(0,Q.c)(27),{value:n,onPick:r,disabled:i,placeholder:a,title:o,className:s,maxWidthClass:c,compact:l,"aria-label":u}=e,d=c===void 0?`max-w-[min(12rem,40vw)]`:c,f=l===void 0?!1:l,p,m;t[0]!==a||t[1]!==n?(m=n.trim(),p=m?Ve(m):a??``,t[0]=a,t[1]=n,t[2]=p,t[3]=m):(p=t[2],m=t[3]);let h=p,g=o??(m||void 0),_=u??o??h,v=f?`inline-flex size-9 shrink-0 items-center justify-center rounded-lg p-0`:`inline-flex min-h-8 min-w-0 shrink-0 items-center gap-1 rounded-lg px-2 py-1 text-xs`,y=!f&&d,b=i&&`cursor-not-allowed opacity-60`,x;t[4]!==s||t[5]!==v||t[6]!==y||t[7]!==b?(x=O(v,`border border-edge-subtle/80 bg-surface-hover/40 dark:border-edge-subtle`,nn.transition,nn.focusRingPanel,`cursor-pointer hover:bg-surface-hover/70 dark:hover:bg-surface-hover/50`,y,b,s),t[4]=s,t[5]=v,t[6]=y,t[7]=b,t[8]=x):x=t[8];let S;t[9]!==i||t[10]!==r?(S=e=>{e.stopPropagation(),i||r()},t[9]=i,t[10]=r,t[11]=S):S=t[11];let C=f?`size-4`:`size-3.5`,w;t[12]===C?w=t[13]:(w=O(`shrink-0 text-fg-muted`,C),t[12]=C,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(De,{className:w,"aria-hidden":!0}),t[14]=w,t[15]=T);let E;t[16]!==f||t[17]!==h?(E=f?null:(0,$.jsx)(`span`,{className:`min-w-0 truncate text-left font-medium text-fg`,children:h}),t[16]=f,t[17]=h,t[18]=E):E=t[18];let D;return t[19]!==i||t[20]!==S||t[21]!==T||t[22]!==E||t[23]!==g||t[24]!==_||t[25]!==x?(D=(0,$.jsxs)(`button`,{type:`button`,disabled:i,title:g,"aria-label":_,className:x,onClick:S,children:[T,E]}),t[19]=i,t[20]=S,t[21]=T,t[22]=E,t[23]=g,t[24]=_,t[25]=x,t[26]=D):D=t[26],D}function In(e){let t=(0,Q.c)(38),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,inputClassName:s,autoFocus:c,trailing:l}=e,u;t[0]!==r||t[1]!==n?(u={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=u):u=t[2];let d=ct(u),f;t[3]===n?f=t[4]:(f=n.trim(),t[3]=n,t[4]=f);let p=f,m=p?`${p}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`,h;t[5]===s?h=t[6]:(h=O(`min-w-0 flex-1`,s),t[5]=s,t[6]=h);let g=i||d.picking,_;t[7]===r?_=t[8]:(_=e=>void r(e.target.value),t[7]=r,t[8]=_);let v=o??a.pathInputPlaceholder,y;t[9]!==c||t[10]!==h||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==n?(y=(0,$.jsx)(`input`,{type:`text`,className:h,value:n,disabled:g,onChange:_,placeholder:v,autoFocus:c,autoComplete:`off`,spellCheck:!1}),t[9]=c,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=n,t[15]=y):y=t[15];let b=i||d.picking,x;t[16]!==m||t[17]!==d.pick||t[18]!==b||t[19]!==n||t[20]!==a.selectWorkingDirectory?(x=(0,$.jsx)(Fn,{compact:!0,value:n,onPick:d.pick,disabled:b,title:m,"aria-label":a.selectWorkingDirectory}),t[16]=m,t[17]=d.pick,t[18]=b,t[19]=n,t[20]=a.selectWorkingDirectory,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==l?(S=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[x,l]}),t[22]=x,t[23]=l,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==y?(C=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[y,S]}),t[25]=S,t[26]=y,t[27]=C):C=t[27];let w;t[28]!==d.confirmPick||t[29]!==d.hasNativePicker||t[30]!==d.modalOpen||t[31]!==d.setModalOpen||t[32]!==p||t[33]!==a?(w=d.hasNativePicker?null:(0,$.jsx)(Jt,{open:d.modalOpen,onOpenChange:d.setModalOpen,initialAbsolutePath:p||void 0,onConfirm:d.confirmPick,wd:a}),t[28]=d.confirmPick,t[29]=d.hasNativePicker,t[30]=d.modalOpen,t[31]=d.setModalOpen,t[32]=p,t[33]=a,t[34]=w):w=t[34];let T;return t[35]!==C||t[36]!==w?(T=(0,$.jsxs)($.Fragment,{children:[C,w]}),t[35]=C,t[36]=w,t[37]=T):T=t[37],T}function Ln(e){let t=(0,Q.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]!==r||t[1]!==n?(s=$t(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=s;if(a){let e;t[3]===i?e=t[4]:(e=O(`flex size-12 shrink-0 items-center justify-center rounded-lg border border-edge-subtle bg-surface-hover text-fg-muted`,i),t[3]=i,t[4]=e);let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(fn,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,$.jsx)(`div`,{className:e,"aria-hidden":!0,children:n}),t[6]=e,t[7]=r),r}let l;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>o(!0),t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=O(`size-12 shrink-0 rounded-lg border border-edge-subtle bg-surface-hover object-cover`,i),t[9]=i,t[10]=u);let d;return t[11]!==n||t[12]!==c||t[13]!==u?(d=(0,$.jsx)(lt,{src:c,expectedNoteId:n,alt:``,loading:`lazy`,draggable:!1,onLoadFailed:l,className:u}),t[11]=n,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Rn(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e/60),n=Math.floor(e%60);return`${t}:${String(n).padStart(2,`0`)}`}function zn(e){let t=(0,Q.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=Mt(),f=Mt(Vn),p=u===n&&d===r,m=p&&o,h=p&&s,g=p?c:0,_=p&&l>0?l:i??0,v=_>0?Math.min(g/_*100,100):0,y;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==f?(y=e=>{e.stopPropagation(),f(n,r,i)},t[0]=r,t[1]=i,t[2]=n,t[3]=f,t[4]=y):y=t[4];let b=y,x;t[5]!==r||t[6]!==i||t[7]!==n||t[8]!==f?(x=e=>{(e.key===`Enter`||e.key===` `)&&(e.stopPropagation(),e.preventDefault(),f(n,r,i))},t[5]=r,t[6]=i,t[7]=n,t[8]=f,t[9]=x):x=t[9];let S=x,C;t[10]===a?C=t[11]:(C=O(`flex items-center gap-2`,a),t[10]=a,t[11]=C);let w=m?`bg-accent text-white`:`bg-accent/10 text-accent hover:bg-accent/20`,E;t[12]===w?E=t[13]:(E=O(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,w),t[12]=w,t[13]=E);let D=m?`Pause`:`Play`,k;t[14]!==h||t[15]!==m?(k=h?(0,$.jsx)(T,{className:`size-3.5 animate-spin`}):m?(0,$.jsx)(Re,{className:`size-3.5`}):(0,$.jsx)(Pe,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=k):k=t[16];let A;t[17]!==b||t[18]!==S||t[19]!==E||t[20]!==D||t[21]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:b,onKeyDown:S,className:E,"aria-label":D,children:k}),t[17]=b,t[18]=S,t[19]=E,t[20]=D,t[21]=k,t[22]=A):A=t[22];let j=`${v}%`,M;t[23]===j?M=t[24]:(M=(0,$.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:j}})}),t[23]=j,t[24]=M);let N;t[25]!==_||t[26]!==p||t[27]!==g?(N=Rn(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=N):N=t[28];let P;t[29]===N?P=t[30]:(P=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:N}),t[29]=N,t[30]=P);let F;t[31]!==M||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[M,P]}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==F||t[35]!==C||t[36]!==A?(I=(0,$.jsxs)(`div`,{className:C,onClick:Bn,children:[A,F]}),t[34]=F,t[35]=C,t[36]=A,t[37]=I):I=t[37],I}function Bn(e){return e.stopPropagation()}function Vn(e){return e.toggle}function Hn(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Un(e){let t=(0,Q.c)(88),{note:n,selected:r,onPress:i,onPin:a,onArchive:o,onDelete:s,labels:c,timeLabels:l}=e,u=r===void 0?!1:r,d;t[0]!==c||t[1]!==n?(d=Hn(n,c),t[0]=c,t[1]=n,t[2]=d):d=t[2];let f=d,p=!n.snippet?.trim(),[m]=(0,Z.useState)(Xn),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=_n(n.createdAt,m,l),t[3]=n.createdAt,t[4]=m,t[5]=l,t[6]=h):h=t[6];let g=h,_,v;t[7]!==n.id||t[8]!==i?(_=()=>i(n.id),v=e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),i(n.id))},t[7]=n.id,t[8]=i,t[9]=_,t[10]=v):(_=t[9],v=t[10]);let y=u?`bg-surface-active hover:bg-surface-active`:`bg-transparent hover:bg-surface-panel/70`,b;t[11]===y?b=t[12]:(b=O(`group relative flex cursor-pointer flex-col gap-2 overflow-hidden rounded-lg px-3 py-2.5`,`transition-colors duration-150 ease-out`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-rail`,y),t[11]=y,t[12]=b);let x=u?`true`:void 0,S;t[13]===u?S=t[14]:(S=u?(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-y-2 left-0 w-0.5 rounded-r-pill bg-accent`,"aria-hidden":!0}):null,t[13]=u,t[14]=S);let C;t[15]!==n.coverAttachmentId||t[16]!==n.id||t[17]!==n.kind||t[18]!==n.voiceAttachmentId||t[19]!==n.voiceDurationSec?(C=n.coverAttachmentId?(0,$.jsx)(Ln,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,$.jsx)(zn,{noteId:n.id,attachmentId:n.voiceAttachmentId,durationSec:n.voiceDurationSec,className:`mt-0.5 w-28 shrink-0`}):null,t[15]=n.coverAttachmentId,t[16]=n.id,t[17]=n.kind,t[18]=n.voiceAttachmentId,t[19]=n.voiceDurationSec,t[20]=C):C=t[20];let w;t[21]===n.title?w=t[22]:(w=n.title&&(0,$.jsx)(`h3`,{className:`mb-0.5 truncate text-sm font-semibold text-fg`,children:n.title}),t[21]=n.title,t[22]=w);let T=n.title?`text-fg-muted`:p?`italic text-fg-muted`:`text-fg`,E;t[23]===T?E=t[24]:(E=O(`truncate text-sm leading-5`,T),t[23]=T,t[24]=E);let D;t[25]!==f||t[26]!==E?(D=(0,$.jsx)(`p`,{className:E,children:f}),t[25]=f,t[26]=E,t[27]=D):D=t[27];let k;t[28]!==w||t[29]!==D?(k=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=k):k=t[30];let A;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(_e,{className:`size-4`}),t[31]=A):A=t[31];let j;t[32]===c.actions?j=t[33]:(j=(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Yn,className:`shrink-0 rounded-md p-1 text-fg-muted opacity-100 transition-opacity hover:bg-surface-panel focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:opacity-0 lg:group-hover:opacity-100 lg:focus-visible:opacity-100`,"aria-label":c.actions,title:c.actions,children:A})}),t[32]=c.actions,t[33]=j);let M;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(M=()=>{a(n.id,!n.pinned).catch(qn)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=M):M=t[37];let N;t[38]===n.pinned?N=t[39]:(N=n.pinned?(0,$.jsx)(re,{className:`size-4`}):(0,$.jsx)(Pt,{className:`size-4`}),t[38]=n.pinned,t[39]=N);let P=n.pinned?c.unpin:c.pin,F;t[40]!==M||t[41]!==N||t[42]!==P?(F=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:M,children:[N,P]}),t[40]=M,t[41]=N,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==n.id||t[45]!==o?(I=()=>{o(n.id).catch(Kn)},t[44]=n.id,t[45]=o,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ke,{className:`size-4`}),t[47]=L):L=t[47];let R;t[48]!==c.archive||t[49]!==I?(R=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:I,children:[L,c.archive]}),t[48]=c.archive,t[49]=I,t[50]=R):R=t[50];let z;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(se,{className:`my-1 h-px bg-edge-subtle`}),t[51]=z):z=t[51];let B;t[52]!==n.id||t[53]!==s?(B=()=>{s(n.id).catch(Gn)},t[52]=n.id,t[53]=s,t[54]=B):B=t[54];let ee;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(rt,{className:`size-4`}),t[55]=ee):ee=t[55];let te;t[56]!==c.delete||t[57]!==B?(te=(0,$.jsxs)(_t,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-500 outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:B,children:[ee,c.delete]}),t[56]=c.delete,t[57]=B,t[58]=te):te=t[58];let V;t[59]!==F||t[60]!==R||t[61]!==te?(V=(0,$.jsx)(ln,{children:(0,$.jsxs)(pn,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Jn,children:[F,R,z,te]})}),t[59]=F,t[60]=R,t[61]=te,t[62]=V):V=t[62];let H;t[63]!==j||t[64]!==V?(H=(0,$.jsxs)(qe,{children:[j,V]}),t[63]=j,t[64]=V,t[65]=H):H=t[65];let U;t[66]!==C||t[67]!==k||t[68]!==H?(U=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,k,H]}),t[66]=C,t[67]=k,t[68]=H,t[69]=U):U=t[69];let W;t[70]===n.pinned?W=t[71]:(W=n.pinned&&(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs font-medium text-accent`,children:(0,$.jsx)(Pt,{className:`size-3`})}),t[70]=n.pinned,t[71]=W);let ne;t[72]===n.tags?ne=t[73]:(ne=n.tags?.slice(0,2).map(Wn),t[72]=n.tags,t[73]=ne);let G;t[74]===g?G=t[75]:(G=(0,$.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=G);let K;t[76]!==W||t[77]!==ne||t[78]!==G?(K=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[W,ne,G]}),t[76]=W,t[77]=ne,t[78]=G,t[79]=K):K=t[79];let ie;return t[80]!==U||t[81]!==K||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(ie=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,U,K]}),t[80]=U,t[81]=K,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=ie):ie=t[87],ie}function Wn(e){return(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e)}function Gn(){}function Kn(){}function qn(){}function Jn(e){return e.stopPropagation()}function Yn(e){return e.stopPropagation()}function Xn(){return Date.now()}var Zn=3e4;function Qn(){if(!(typeof MediaRecorder>`u`))return[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`].find(e=>MediaRecorder.isTypeSupported(e))}function $n({placeholder:e,submitLabel:t,actionsLabel:n,imageLabel:r,voiceLabel:i,stopRecordingLabel:a,onCapture:o,onImagePick:s,onVoiceCapture:c,onVoiceError:l,recordingLabel:u,imageDisabled:d=!1,voiceDisabled:f=!1,onDiscussionCapture:p,discussionCaptureLabel:m}){let[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(0),[C,w]=(0,Z.useState)(!1),T=(0,Z.useRef)(null),D=(0,Z.useRef)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)([]),j=(0,Z.useRef)(0),M=(0,Z.useRef)(null),N=(0,Z.useRef)(null),P=(0,Z.useCallback)(()=>{M.current&&=(clearInterval(M.current),null),N.current&&=(clearTimeout(N.current),null),k.current?.getTracks().forEach(e=>e.stop()),k.current=null,D.current=null,A.current=[],b(!1),S(0)},[]);(0,Z.useEffect)(()=>()=>P(),[P]);let F=(0,Z.useCallback)(async()=>{let e=D.current;if(!e||e.state!==`recording`)return;w(!0),await new Promise(t=>{e.addEventListener(`stop`,()=>t(),{once:!0}),e.stop()});let t=Math.max(1,Math.round((Date.now()-j.current)/1e3)),n=e.mimeType||Qn()||`audio/webm`,r=new Blob(A.current,{type:n});if(P(),r.size>0&&c){let e=n.includes(`mp4`)?`m4a`:n.includes(`ogg`)?`ogg`:`webm`,i=new File([r],`voice-${Date.now()}.${e}`,{type:n});try{await c(i,t)}finally{w(!1)}return}w(!1)},[P,c]),I=(0,Z.useCallback)(async()=>{if(!(!c||C||y)){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){l?.();return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});k.current=e;let t=Qn(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);D.current=n,A.current=[],j.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&A.current.push(e.data)},n.start(),b(!0),S(0),M.current=setInterval(()=>{S(Math.round((Date.now()-j.current)/1e3))},250),N.current=setTimeout(()=>{F()},Zn)}catch{P(),l?.()}}},[P,c,l,y,F,C]),L=(0,Z.useCallback)(async()=>{let e=h.trim();if(!(!e||_)){v(!0),g(``);try{await o(e)}catch{g(e)}finally{v(!1),T.current?.focus()}}},[h,_,o]),R=(0,Z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),L())},[L]),z=_||C,B=!!(s||c||p);return(0,$.jsxs)(`div`,{className:O(`flex items-center gap-1.5 rounded-2xl border border-edge bg-surface-panel p-2 shadow-float dark:shadow-elevated`,`focus-within:border-accent focus-within:ring-1 focus-within:ring-accent`,y&&`border-danger ring-1 ring-danger/40`),"aria-busy":z,children:[y?(0,$.jsx)(`button`,{type:`button`,onClick:()=>void F(),disabled:C,className:`shrink-0 rounded-lg bg-danger-soft p-2 text-danger transition-colors hover:bg-danger-soft disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":a,title:a,"aria-pressed":`true`,children:(0,$.jsx)(Tt,{className:`size-4 fill-current`,"aria-hidden":!0})}):B?(0,$.jsxs)(qe,{children:[(0,$.jsx)(sn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:z,className:`shrink-0 rounded-lg p-2 text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":n,title:n,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(ln,{children:(0,$.jsxs)(pn,{side:`top`,align:`start`,sideOffset:8,className:`z-50 min-w-44 rounded-xl border border-edge bg-surface-panel p-1 shadow-popover`,children:[s?(0,$.jsxs)(_t,{disabled:d,onSelect:s,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(ft,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,$.jsxs)(_t,{disabled:f,onSelect:()=>void I(),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,$.jsx)(tt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,$.jsxs)(_t,{onSelect:p,className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover focus:bg-surface-hover`,children:[(0,$.jsx)(de,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(x))}):(0,$.jsx)(`textarea`,{ref:T,value:h,onChange:e=>g(e.target.value),onKeyDown:R,placeholder:e,"aria-label":e,rows:1,disabled:z,className:`max-h-28 min-h-8 flex-1 resize-none overflow-y-auto bg-transparent py-1.5 text-sm leading-5 text-fg placeholder:text-fg-muted focus:outline-none disabled:opacity-60`,style:{fieldSizing:`content`}}),(0,$.jsx)(`button`,{type:`button`,disabled:!h.trim()||z||y,onClick:()=>void L(),"aria-label":t,title:t,className:O(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!z&&!y?`bg-accent text-white hover:bg-accent-hover`:`text-fg-disabled`),children:(0,$.jsx)(Ut,{className:`size-4`,"aria-hidden":!0})})]})}var er={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},tr=240,nr=320,rr=520,ir=560;function ar(e){if(globalThis.localStorage===void 0)return nr;try{let t=globalThis.localStorage.getItem(e);if(!t)return nr;let n=Number(t);return Number.isFinite(n)?n:nr}catch{return nr}}function or(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var sr={thought:ut,todo:Xt,voice:tt,media:ft,bookmark:vt,mixed:ut,task:Xt};function cr(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function lr(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function ur(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function dr({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:a=!0,projectId:o,listTitle:s,listDescription:c,emptyText:l,emptyDescription:u,listWidthStorageKey:d=`xopc.notes.listWidth`}){let p=M(e=>e.language),h=P(p).notes,g=!!A(e=>e.sessionKey),[_,v]=(0,Z.useReducer)(at,er),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(0),[T,k]=(0,Z.useState)(()=>ar(d)),[N,I]=(0,Z.useState)(!1),[V,U]=(0,Z.useState)(!1),[W,ne]=(0,Z.useState)(!1),[re,G]=(0,Z.useState)(null),[K,ie]=(0,Z.useState)(null),oe=(0,Z.useRef)(null),q=(0,Z.useRef)(null),[se]=(0,Z.useState)(()=>Date.now()),J=i(),le=(0,Z.useCallback)(e=>{let t=oe.current?.clientWidth??window.innerWidth,n=Math.max(tr,t-ir);return Math.max(tr,Math.min(Math.min(rr,n),e))},[]),ue=(0,Z.useCallback)(e=>{let t=le(e);k(t),or(d,t)},[le,d]);(0,Z.useLayoutEffect)(()=>{k(e=>le(e))},[le]);let{data:de,mutate:Y,isLoading:fe}=H((0,Z.useMemo)(()=>g?[`notes-list`,o,_.statusFilter,_.kindFilter,_.pinnedOnly]:null,[g,o,_.statusFilter,_.kindFilter,_.pinnedOnly]),()=>We({status:_.statusFilter===`all`?void 0:_.statusFilter,kind:_.kindFilter===`all`?void 0:_.kindFilter,projectId:o,pinned:_.pinnedOnly?!0:void 0,limit:100,sortBy:`createdAt`,sortOrder:`desc`}),{keepPreviousData:!0}),pe=fe&&!de,me=de?.items??[],he=de?.total??0,ge=x.trim(),{data:_e,isLoading:ye}=H(g&&y&&ge?[`notes-search`,o,ge]:null,()=>We({search:ge,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),be=_e?.items??[],xe=e?me.some(t=>t.id===e):!0;(0,Z.useEffect)(()=>{w(0)},[ge]),(0,Z.useEffect)(()=>{C>=be.length&&w(Math.max(0,be.length-1))},[C,be.length]),(0,Z.useEffect)(()=>{let e=()=>{Y().catch(e=>{G(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[Y,h.quickCaptureFailedHint,h.refreshFailed]);let Ce=xt(e=>e.setPageHeader),Te=xt(e=>e.clearPageHeader),Ee=h.noteCount.replace(`{{count}}`,String(he)),De=!r&&he===0&&c?c:Ee,Oe=h.searchDialogTitle,ke=h.searchClose,Ae=h.searchClear,je=(0,Z.useMemo)(()=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:O(`inline-flex h-9 items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Ye),"aria-label":Oe,children:[(0,$.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:Oe})]}),[Oe]);(0,Z.useLayoutEffect)(()=>{if(n)return g?(Ce({startExtra:null,main:(0,$.jsxs)(`div`,{className:O(`flex min-w-0 items-center gap-2`,Ye),children:[(0,$.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:s??h.title}),Ee?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Ee}):null]}),end:je}),()=>Te()):(Te(),()=>Te())},[Te,g,je,s,n,h.title,Ee,e,Ce]);let Me=(0,Z.useMemo)(()=>({justNow:h.justNow,minutesAgo:h.minutesAgo,today:h.today,yesterday:h.yesterday,daysAgo:h.daysAgo,locale:j(p)}),[p,h.justNow,h.minutesAgo,h.today,h.yesterday,h.daysAgo]),Ne=(0,Z.useMemo)(()=>[{id:`recent`,label:h.viewRecent,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1}},{id:`inbox`,label:h.filterInbox,patch:{statusFilter:`inbox`,kindFilter:`all`,pinnedOnly:!1}},{id:`pinned`,label:h.pinned,patch:{statusFilter:`all`,kindFilter:`all`,pinnedOnly:!0}},{id:`tasks`,label:h.viewTasks,patch:{statusFilter:`all`,kindFilter:`todo`,pinnedOnly:!1}},{id:`voice`,label:h.kindVoice,patch:{statusFilter:`all`,kindFilter:`voice`,pinnedOnly:!1}},{id:`media`,label:h.kindMedia,patch:{statusFilter:`all`,kindFilter:`media`,pinnedOnly:!1}},{id:`bookmarks`,label:h.kindBookmark,patch:{statusFilter:`all`,kindFilter:`bookmark`,pinnedOnly:!1}},{id:`processed`,label:h.filterProcessed,patch:{statusFilter:`processed`,kindFilter:`all`,pinnedOnly:!1}},{id:`archive`,label:h.filterArchived,patch:{statusFilter:`archived`,kindFilter:`all`,pinnedOnly:!1}}],[h.filterArchived,h.filterInbox,h.filterProcessed,h.kindBookmark,h.kindMedia,h.kindVoice,h.pinned,h.viewRecent,h.viewTasks]),Pe=Ne.find(e=>lr(_,e))??Ne[0],Fe=s??Pe.label,Ie=(0,Z.useCallback)(async e=>{G(null);try{let n=o?await ce({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await ae(e,`web`);await Y(),J(ur(t,n.id))}catch(e){throw G(`${h.quickCaptureFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`),e}},[t,Y,h.quickCaptureFailed,h.quickCaptureFailedHint,J,o]),Le=(0,Z.useCallback)(async()=>{if(!W){ne(!0),G(null);try{let e=await ce({markdown:``,kind:`thought`,projectId:o,channel:`web`});v({type:`patch`,patch:er}),await Y(),ie(e.id),J(ur(t,e.id))}catch(e){G(`${h.createBlankFailed}: ${e instanceof Error?e.message:h.createBlankFailedHint}`)}finally{ne(!1)}}},[t,W,Y,h.createBlankFailed,h.createBlankFailedHint,J,o]),Re=(0,Z.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`image/*`,e.onchange=async()=>{let t=e.files?.[0];if(t)try{G(null),await $e(t,`web`),await Y()}catch(e){G(`${h.imageUploadFailed}: ${e instanceof Error?e.message:h.imageUploadFailedHint}`)}},e.click()},[Y,h.imageUploadFailed,h.imageUploadFailedHint]),ze=(0,Z.useCallback)(async(e,t)=>{try{G(null),await ve(e,t,`web`),await Y()}catch(e){G(`${h.voiceUploadFailed}: ${e instanceof Error?e.message:h.voiceUploadFailedHint}`)}},[Y,h.voiceUploadFailed,h.voiceUploadFailedHint]),Be=(0,Z.useCallback)(()=>{G(`${h.voiceCaptureFailed}: ${h.voiceCaptureFailedHint}`)},[h.voiceCaptureFailed,h.voiceCaptureFailedHint]),Ve=(0,Z.useCallback)(async(e,t)=>{G(null);try{await Se(e,{pinned:t}),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),He=(0,Z.useCallback)(async e=>{G(null);try{await Se(e,{status:`archived`}),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ue=(0,Z.useCallback)(async e=>{G(null);try{await Rt(e),await Y()}catch(e){G(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[Y,h.actionFailed,h.quickCaptureFailedHint]),Ge=(0,Z.useCallback)(e=>{J(ur(t,e))},[t,J]),Ke=(0,Z.useCallback)(e=>{J(ur(t,e)),b(!1)},[t,J]),qe=(0,Z.useCallback)(e=>{if(be.length){if(e.key===`ArrowDown`)e.preventDefault(),w(e=>Math.min(be.length-1,e+1));else if(e.key===`ArrowUp`)e.preventDefault(),w(e=>Math.max(0,e-1));else if(e.key===`Enter`){e.preventDefault();let t=be[C]??be[0];t&&Ke(t.id)}}},[C,Ke,be]),Je=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=q.current;t.setPointerCapture(e.pointerId),I(!0);let r=oe.current?.clientWidth??window.innerWidth,i=Math.max(tr,r-ir),a=Math.min(rr,i),o=e=>Math.max(tr,Math.min(a,e)),s=e.clientX,c=o(T),l=e.pointerId,u=0,f=c,p=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,p=f,n&&(n.style.width=`${p}px`)},h=e=>{f=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}I(!1),oe.current?.style.setProperty(`--notes-list-width`,`${p}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),k(p),or(d,p),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[d,T]);(0,Z.useEffect)(()=>{let e=e=>{e.defaultPrevented||e.repeat||e.key.toLowerCase()!==`n`||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||(e.preventDefault(),Le())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Le]);let Xe=(0,Z.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),ue(T-16)):e.key===`ArrowRight`?(e.preventDefault(),ue(T+16)):e.key===`Home`?(e.preventDefault(),ue(tr)):e.key===`End`&&(e.preventDefault(),ue(rr))},[ue,T]);return g?(0,$.jsxs)(`div`,{ref:oe,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${T}px`},children:[(0,$.jsxs)(`section`,{ref:q,className:O(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden border-r border-edge bg-surface-rail`,!N&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:min-w-0 lg:max-w-0 lg:pointer-events-none`:`lg:w-[var(--notes-list-width)]`,e&&`hidden lg:flex`),"aria-hidden":V?!0:void 0,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[re?(0,$.jsx)(`p`,{className:`mb-3 rounded-lg border border-danger/25 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:re}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,$.jsx)(f,{value:Pe.id,onChange:e=>{let t=Ne.find(t=>t.id===e.target.value);t&&v({type:`patch`,patch:t.patch})},className:`-ml-1 h-7 w-full max-w-44 rounded-lg border border-transparent bg-transparent px-2 text-sm font-semibold text-fg transition-colors hover:border-edge hover:bg-surface-base focus:border-accent focus:bg-surface-base focus:outline-none focus:ring-1 focus:ring-accent`,"aria-label":h.libraryTitle,children:Ne.map(e=>(0,$.jsx)(m,{value:e.id,children:e.label},e.id))}):(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Fe}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:De})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!0),className:`hidden size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.collapseNotesList,title:h.collapseNotesList,children:(0,$.jsx)(we,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:Le,disabled:W,className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":h.createBlankNote,title:h.createBlankShortcut,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b(!0),className:`inline-flex size-8 items-center justify-center rounded-lg text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":h.searchDialogTitle,title:h.searchDialogTitle,children:(0,$.jsx)(kt,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:pe?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,$.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):me.length===0?(0,$.jsxs)(`div`,{className:`flex h-full min-h-48 flex-col items-center justify-center gap-2 px-6 py-10 text-center`,children:[(0,$.jsx)(`span`,{className:`mb-1 inline-flex size-12 items-center justify-center rounded-xl border border-edge-subtle bg-surface-base text-fg-muted`,children:(0,$.jsx)(ut,{className:`size-6`,"aria-hidden":!0})}),(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!xe?h.noteOutsideCurrentView:l??h.noNotes}),e&&!xe?null:(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:u??h.noNotesDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!xe?(0,$.jsx)(`div`,{className:`mb-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-xs leading-5 text-fg-muted`,children:h.noteOutsideCurrentView}):null,me.map((t,n)=>{let r=n>0?vn(me[n-1].createdAt):null;return(0,$.jsxs)(`div`,{children:[vn(t.createdAt)!==r&&(0,$.jsx)(`div`,{className:O(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:yn(t.createdAt,se,Me)}),(0,$.jsx)(Un,{note:t,selected:t.id===e,onPress:Ge,onPin:Ve,onArchive:He,onDelete:Ue,timeLabels:Me,labels:{pin:h.pin,unpin:h.unpin,archive:h.archive,delete:h.delete,actions:h.noteActions,imageNote:h.imageNote,noText:h.noText}})]},t.id)})]})}),(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,$.jsx)($n,{placeholder:h.quickCapturePlaceholder,submitLabel:h.quickCaptureSubmit,actionsLabel:h.quickCaptureActions,imageLabel:h.quickCaptureImage,voiceLabel:h.quickCaptureVoice,stopRecordingLabel:h.stopRecording,onCapture:Ie,onImagePick:a?Re:void 0,onVoiceCapture:a?ze:void 0,onVoiceError:Be,recordingLabel:h.recording,discussionCaptureLabel:h.discussionCapture.title,onDiscussionCapture:()=>hn(o)})})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.resizeNotesList,"aria-valuemin":tr,"aria-valuemax":rr,"aria-valuenow":Math.round(T),tabIndex:0,onPointerDown:Je,onDoubleClick:()=>ue(nr),onKeyDown:Xe,title:h.resizeNotesList,className:O(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-surface-base lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,V?`lg:w-0 lg:opacity-0 lg:pointer-events-none`:`lg:w-2 lg:opacity-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-0`),children:(0,$.jsx)(`span`,{"aria-hidden":!0,className:O(`h-full w-px bg-edge transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,N&&`bg-accent scale-x-[2]`)})}),(0,$.jsxs)(`section`,{className:O(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[V?(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`absolute left-3 top-3 z-10 hidden size-8 items-center justify-center rounded-lg border border-edge bg-surface-base text-fg-muted shadow-surface transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent lg:inline-flex`,"aria-label":h.expandNotesList,title:h.expandNotesList,children:(0,$.jsx)(we,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,$.jsx)(bn,{noteId:e,onBack:()=>J(t),onSaved:()=>{Y().catch(e=>{G(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>b(!0),autoFocus:e===K,onAutoFocusConsumed:()=>ie(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(ut,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:h.emptyEditorTitle}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h.emptyEditorDescription}),(0,$.jsxs)(`button`,{type:`button`,onClick:Le,disabled:W,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),W?h.creatingBlankNote:h.createBlankNote]})]})})]}),(0,$.jsx)(te,{open:y,onOpenChange:b,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-24 z-[90] w-[min(36rem,calc(100vw-2rem))] -translate-x-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsx)(ee,{className:`text-sm font-semibold text-fg`,children:Oe}),(0,$.jsx)(L,{className:`sr-only`,children:h.searchPlaceholder}),(0,$.jsx)(R,{asChild:!0,children:(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":ke,children:(0,$.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`p-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),onKeyDown:qe,placeholder:h.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-10 text-sm text-fg placeholder:text-fg-muted focus:border-accent focus:outline-none focus:ring-1 focus:ring-accent`}),x?(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(``),className:`absolute right-2 top-1/2 inline-flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Ae,children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,$.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:ge?ye&&!_e?(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,$.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):be.length===0?(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(ut,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchNoResults}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchNoResultsDescription})]}):(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:h.searchResultsCount.replace(`{{count}}`,String(_e?.total??be.length))}),be.map((e,t)=>{let n=sr[e.kind]||ut,r=cr(e,{imageNote:h.imageNote,noText:h.noText});return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Ke(e.id),onMouseEnter:()=>w(t),className:O(`flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors`,t===C?`bg-surface-active`:`hover:bg-surface-hover`),children:[(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:_n(e.updatedAt,se,Me)})]}),e.title?(0,$.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,$.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`max-w-24 truncate rounded-md bg-surface-hover px-1.5 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]})]},e.id)})]}):(0,$.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,$.jsx)(kt,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchEmptyTitle}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchEmptyDescription})]})})]})]})]})})]}):(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,$.jsx)(ut,{className:`size-10 text-fg-muted`}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.needToken})]})}function fr(e){return k(N(`/api/projects/${encodeURIComponent(e)}/skills`))}function pr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function mr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function hr(e,t){let n=new FormData;return n.set(`file`,t),k(N(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function gr(e,t,n={}){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function _r(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function vr(e,t){return k(N(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function yr({projectId:e,copy:t}){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!0),[T,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(``),[P,I]=(0,Z.useState)(null),[L,V]=(0,Z.useState)(null),[H,ne]=(0,Z.useState)(``),[re,G]=(0,Z.useState)(1),[K,ie]=(0,Z.useState)(null),[ae,q]=(0,Z.useState)(!1),[se,J]=(0,Z.useState)(``),[ce,le]=(0,Z.useState)(``),ue=(0,Z.useRef)(null),de=(0,Z.useCallback)(async()=>{C(!0),N(``);try{let t=await fr(e);r(t.items),a(t.inheritedItems),s(t.sources)}catch(e){N(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e]);(0,Z.useEffect)(()=>{de()},[de]),(0,Z.useEffect)(()=>{let t=!1;return Ne(e).then(e=>{t||d(e)}).catch(()=>{t||d([])}),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!f){v(null);return}let e=c.find(e=>e.key===f),t=!1;return v(null),N(``),x(!0),tn(e?.agentId??e?.routing?.agentId,f,!0).then(e=>{t||v(e)}).catch(e=>{t||N(e instanceof Error?e.message:String(e))}).finally(()=>{t||x(!1)}),()=>{t=!0}},[f,c]),(0,Z.useEffect)(()=>{if(P!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{q(!0),J(``),Dn({q:H,page:re,pageSize:8,sort:`downloads`,signal:e.signal}).then(ie).catch(t=>{e.signal.aborted||J(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||q(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[P,re,H]);async function Y(e,t){k(!0),j(t??null),N(``);try{await e(),I(null),le(``),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1),j(null)}}async function fe(t){N(``);try{V((await pr(e,t)).skill)}catch(e){N(e instanceof Error?e.message:String(e))}}async function pe(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){k(!0);try{await vr(e,n.directoryId),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}}}async function me(){k(!0),N(``);try{await mr(e,!0),await de()}catch(e){N(e instanceof Error?e.message:String(e))}finally{k(!1)}}let he=o.find(e=>e.origin===`agents-workspace`),ge=new Map(_?.skills.map(e=>[e.name,e]));return(0,$.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,$.jsxs)(u,{children:[(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(U,{type:`button`,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),t.add,(0,$.jsx)(Ot,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,$.jsx)(l,{children:(0,$.jsxs)(g,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,$.jsx)(Cr,{icon:st,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>I(`marketplace`)}),(0,$.jsx)(Cr,{icon:w,title:t.source,hint:t.sourceHint,onClick:()=>I(`source`)}),(0,$.jsx)(Cr,{icon:oe,title:t.upload,hint:t.uploadHint,onClick:()=>ue.current?.click()})]})})]}),(0,$.jsx)(`input`,{ref:ue,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&Y(()=>hr(e,n)),t.target.value=``}})]})}),M?(0,$.jsx)(`p`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:M}):null,he?.state===`untrusted`?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(it,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,$.jsxs)(U,{type:`button`,variant:`secondary`,disabled:T,onClick:()=>void me(),children:[(0,$.jsx)(Bt,{className:`size-4`,"aria-hidden":!0}),T?t.trusting:t.trustAction]})]}):null,c.length?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:b?t.sessionLoading:f?_?.agentId:t.sessionViewAll})]}),(0,$.jsx)(h,{value:f,options:c.map(e=>({value:e.key,label:e.name?.trim()||`${t.sessionFallback} · ${e.key.slice(-12)}`})),placeholder:t.sessionViewAll,emptyLabel:t.sessionViewAll,triggerClassName:`w-[min(24rem,calc(100vw-3rem))]`,onChange:m})]}):null,S?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,$.jsx)(W,{className:`h-36 rounded-lg`},e))}):n.length?(0,$.jsx)(br,{title:t.localTitle,items:n,copy:t,busy:T,availabilityByName:ge,onPreview:fe,onRemove:pe}):(0,$.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!S&&i.length?(0,$.jsx)(br,{title:t.inheritedTitle,hint:t.inheritedHint,items:i,copy:t,busy:T,availabilityByName:ge,onPreview:fe,onRemove:pe}):null,(0,$.jsx)(te,{open:P!==null,onOpenChange:e=>{e||I(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:O(`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,P===`marketplace`?`h-[min(46rem,calc(100vh-2rem))] w-[min(58rem,calc(100vw-2rem))]`:`h-[min(22rem,calc(100vh-2rem))] w-[min(36rem,calc(100vw-2rem))]`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:P===`marketplace`?t.marketplace:t.source}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,$.jsx)(D,{className:`size-4`})})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:P===`marketplace`?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,$.jsxs)(`div`,{className:`relative mt-3`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{className:`h-10 w-full rounded-md border border-edge bg-surface-base pl-9 pr-3 text-sm outline-none focus:border-accent`,value:H,onChange:e=>{ne(e.target.value),G(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),se?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:se}):null,ae&&!K?(0,$.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,$.jsx)(W,{className:`h-32 rounded-lg`},e))}):K?.items.length?(0,$.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:K.items.map(r=>{let i=r.providerId??K.provider,a=En(r,i),o=n.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===r.id||e.directoryId===a||e.name===r.name)),s=A===a;return(0,$.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(On,{name:r.name,className:`size-10`}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:r.name}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:r.description||`—`}),(0,$.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,$.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,r.downloads]}),(0,$.jsx)(U,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:o?`secondary`:`primary`,disabled:T||o,onClick:()=>void Y(()=>gr(e,a,{provider:i}),a),children:o?t.marketplaceInstalled:s?t.installing:t.install})]})]})]},`${i??`default`}:${r.id}`)})}):ae?null:(0,$.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),K&&K.meta.totalPages>1?(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(K.meta.page)).replace(`{{total}}`,String(K.meta.totalPages))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:ae||re<=1,onClick:()=>G(e=>Math.max(1,e-1)),children:[(0,$.jsx)(Ct,{className:`size-4`}),t.marketplacePrevious]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:ae||re>=K.meta.totalPages,onClick:()=>G(e=>e+1),children:[t.marketplaceNext,(0,$.jsx)(rn,{className:`size-4`})]})]})]}):null]}):(0,$.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,$.jsx)(`input`,{className:`mt-4 h-10 w-full rounded-md border border-edge bg-surface-base px-3 text-sm outline-none focus:border-accent`,value:ce,onChange:e=>le(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`secondary`,children:t.close})}),(0,$.jsx)(U,{type:`button`,disabled:T||!ce.trim(),onClick:()=>void Y(()=>_r(e,ce.trim())),children:T?t.installing:t.install})]})]})})]})]})}),(0,$.jsx)(te,{open:!!L,onOpenChange:e=>{e||V(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-50 flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-xl`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:L?.name}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,$.jsx)(D,{className:`size-4`})})})]}),(0,$.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:L?.bodyMarkdown})]})]})})]})}function br(e){let t=(0,Q.c)(25),{title:n,hint:r,items:i,copy:a,busy:o,availabilityByName:s,onPreview:c,onRemove:l}=e,u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]===r?d=t[3]:(d=r?(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[2]=r,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p;if(t[7]!==s||t[8]!==o||t[9]!==a||t[10]!==i||t[11]!==c||t[12]!==l){let e;t[14]!==s||t[15]!==o||t[16]!==a||t[17]!==c||t[18]!==l?(e=e=>{let t=e.effective?s.get(e.name):void 0;return(0,$.jsxs)(`article`,{className:O(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ke,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,$.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,$.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:xr(a,e.origin)}),e.writable?null:(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,$.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-2 py-0.5 text-amber-800 dark:text-amber-200`,children:a.shadowed}),t?(0,$.jsx)(`span`,{className:O(`rounded-md px-2 py-0.5`,t.availableForCurrentAgent?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:Sr(a,t)}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,$.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0}),a.remove]}):null]})]},e.key)},t[14]=s,t[15]=o,t[16]=a,t[17]=c,t[18]=l,t[19]=e):e=t[19],p=i.map(e),t[7]=s,t[8]=o,t[9]=a,t[10]=i,t[11]=c,t[12]=l,t[13]=p}else p=t[13];let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:p}),t[20]=p,t[21]=m);let h;return t[22]!==f||t[23]!==m?(h=(0,$.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=h):h=t[24],h}function xr(e,t){switch(t){case`xopc-workspace`:return e.xopcSource;case`agents-workspace`:return e.agentsSource;case`xopc-global`:case`custom-global`:return e.globalXopcSource;case`agents-global`:return e.globalAgentsSource;case`bundled`:return e.bundledSource;case`extra`:return e.extraSource}}function Sr(e,t){if(t.availableForCurrentAgent)return e.sessionAvailable;switch(t.unavailableReason){case`agent-denied`:return e.sessionUnavailableAgent;case`disabled`:return e.sessionUnavailableDisabled;case`requirements-unmet`:return e.sessionUnavailableRequirements;case`model-invocation-disabled`:return e.sessionUnavailableModel;case`tool-gated`:return e.sessionUnavailableTools;default:return e.sessionUnavailableAgent}}function Cr(e){let t=(0,Q.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==a||t[10]!==o||t[11]!==l?(u=(0,$.jsx)(d,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start gap-3 rounded-md px-3 py-2.5 text-left hover:bg-surface-hover`,onClick:a,children:[o,l]})}),t[9]=a,t[10]=o,t[11]=l,t[12]=u):u=t[12],u}var wr={active:0,review:1,ready:2,backlog:3,closed:4},Tr={blocked:0,waiting:1,verifying:2,running:3,queued:4,idle:5},Er={critical:0,high:1,normal:2,low:3};function Dr(e,t=4){return e.filter(e=>e.phase!==`closed`&&!(e.operationalState===`waiting`&&e.attention.length===0)).sort((e,t)=>{let n=Number(t.attention.length>0)-Number(e.attention.length>0);if(n!==0)return n;let r=Tr[e.operationalState]-Tr[t.operationalState];if(r!==0)return r;let i=wr[e.phase]-wr[t.phase];if(i!==0)return i;let a=Er[e.priority]-Er[t.priority];return a===0?t.updatedAt-e.updatedAt:a}).slice(0,t)}var Or=[`backlog`,`ready`,`active`,`review`,`closed`];function kr(e){return{backlog:e.filter(e=>e.phase===`backlog`),ready:e.filter(e=>e.phase===`ready`),active:e.filter(e=>e.phase===`active`),review:e.filter(e=>e.phase===`review`),closed:e.filter(e=>e.phase===`closed`)}}function Ar(e,t){if(e.phase!==t){if(e.phase===`closed`&&t!==`closed`&&e.allowedCommands.includes(`reopen`))return`reopen_${t}`;if(t===`closed`&&e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(t!==`closed`&&e.allowedCommands.includes(`move`))return`move_${t}`}}function jr(e){if(e.allowedCommands.includes(`resolve_wait`))return`resume`;if(e.allowedCommands.includes(`mark_ready`))return`ready`;if(e.allowedCommands.includes(`start`))return`run`;if(e.allowedCommands.includes(`request_review`))return`review`;if(e.phase===`review`&&e.allowedCommands.includes(`close`))return`complete`;if(e.allowedCommands.includes(`reopen`))return`reopen`;if(e.allowedCommands.includes(`add_wait`))return`pause`}function Mr(e){let t=new Map,n=new Map;for(let r of e)t.set(r.dependencyTaskId,[...t.get(r.dependencyTaskId)??[],r.dependentTaskId]),n.set(r.dependentTaskId,[...n.get(r.dependentTaskId)??[],r.dependencyTaskId]);return{outgoing:t,incoming:n}}function Nr(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=Mr(t.filter(e=>n.has(e.dependencyTaskId)&&n.has(e.dependentTaskId))),a=new Map(e.map(e=>[e.id,i.get(e.id)?.length??0])),o=new Map(e.map(e=>[e.id,0])),s=e.filter(e=>a.get(e.id)===0).sort((e,t)=>t.updatedAt-e.updatedAt).map(e=>e.id);for(let e=0;e<s.length;e+=1){let t=s[e];for(let e of r.get(t)??[]){o.set(e,Math.max(o.get(e)??0,(o.get(t)??0)+1));let n=(a.get(e)??1)-1;a.set(e,n),n===0&&s.push(e)}}let c=new Map;for(let t of e){let e=o.get(t.id)??0;c.set(e,[...c.get(e)??[],t.id])}let l=new Map;for(let[e,t]of c)t.forEach((t,n)=>l.set(t,{x:e*300,y:n*136}));return l}function Pr(e,t){let{incoming:n}=Mr(t),r=new Set(e.filter(e=>e.operationalState===`blocked`).map(e=>e.id)),i=[...r];for(let e=0;e<i.length;e+=1)for(let t of n.get(i[e])??[])r.has(t)||(r.add(t),i.push(t));return r}function Fr(e,t){let{incoming:n,outgoing:r}=Mr(t),i=new Set([e]);for(let t of[n,r]){let n=[e],r=new Set(n);for(let e=0;e<n.length;e+=1)for(let a of t.get(n[e])??[])r.has(a)||(r.add(a),i.add(a),n.push(a))}return i}var Ir={backlog:`border-edge`,ready:`border-edge`,active:`border-accent ring-2 ring-accent/15`,review:`border-amber-400/80`,closed:`border-emerald-400/60`};function Lr(e){let t=(0,Q.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=Ir[i.phase],s=r&&`ring-2 ring-accent/30`,c=n.dimmed&&`opacity-30`,l;t[0]!==o||t[1]!==s||t[2]!==c?(l=O(`group w-56 rounded-xl border bg-surface-panel p-3 shadow-surface transition-opacity`,o,s,c),t[0]=o,t[1]=s,t[2]=c,t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(Nn,{type:`target`,position:An.Left,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[4]=u):u=t[4];let d;t[5]===i.title?d=t[6]:(d=(0,$.jsx)(`strong`,{className:`line-clamp-2 min-w-0 text-sm font-medium leading-5 text-fg`,children:i.title}),t[5]=i.title,t[6]=d);let f;t[7]===a?f=t[8]:(f=a?(0,$.jsx)(gt,{className:`mt-0.5 size-3.5 shrink-0 text-violet-600 dark:text-violet-300`,"aria-hidden":!0}):null,t[7]=a,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===n.phaseLabel?m=t[13]:(m=(0,$.jsx)(`span`,{children:n.phaseLabel}),t[12]=n.phaseLabel,t[13]=m);let h;t[14]!==a||t[15]!==i.blockedBy?(h=a&&i.blockedBy.length>0?(0,$.jsx)(`span`,{children:i.blockedBy.length}):null,t[14]=a,t[15]=i.blockedBy,t[16]=h):h=t[16];let g;t[17]!==h||t[18]!==m?(g=(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 text-[11px] text-fg-subtle`,children:[m,h]}),t[17]=h,t[18]=m,t[19]=g):g=t[19];let _;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Nn,{type:`source`,position:An.Right,className:`!size-3 !border-2 !border-surface-panel !bg-accent opacity-60 transition-opacity group-hover:opacity-100`}),t[20]=_):_=t[20];let v;return t[21]!==g||t[22]!==l||t[23]!==p?(v=(0,$.jsxs)(`div`,{className:l,children:[u,p,g,_]}),t[21]=g,t[22]=l,t[23]=p,t[24]=v):v=t[24],v}var Rr={taskNode:Lr};function zr(e){let t=(0,Q.c)(90),{tasks:n,dependencyEdges:r,returnTo:i,copy:a,onDependenciesChange:o}=e,[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(),[m,h]=(0,Z.useState)(),g=(0,Z.useRef)(null),_;t[0]!==r||t[1]!==n?(_=Pr(n,r),t[0]=r,t[1]=n,t[2]=_):_=t[2];let v=_,y;t[3]!==v||t[4]!==u||t[5]!==c||t[6]!==n?(y=u?n.filter(e=>v.has(e.id)):c?n:n.filter(qr),t[3]=v,t[4]=u,t[5]=c,t[6]=n,t[7]=y):y=t[7];let x=y,S;t[8]===x?S=t[9]:(S=new Set(x.map(Kr)),t[8]=x,t[9]=S);let C=S,w;if(t[10]!==r||t[11]!==C){let e;t[13]===C?e=t[14]:(e=e=>C.has(e.dependencyTaskId)&&C.has(e.dependentTaskId),t[13]=C,t[14]=e),w=r.filter(e),t[10]=r,t[11]=C,t[12]=w}else w=t[12];let T=w,E;t[15]!==T||t[16]!==x?(E=Nr(x,T),t[15]=T,t[16]=x,t[17]=E):E=t[17];let D=E,k;t[18]!==f||t[19]!==T?(k=f?Fr(f,T):void 0,t[18]=f,t[19]=T,t[20]=k):k=t[20];let A=k,j;t[21]===f?j=t[22]:(j=e=>e.id===f,t[21]=f,t[22]=j);let M=x.find(j),N;t[23]===x?N=t[24]:(N=new Map(x.map(Gr)),t[23]=x,t[24]=N);let P=N,F;if(t[25]!==a.phases||t[26]!==D||t[27]!==A||t[28]!==x){let e;t[30]!==a.phases||t[31]!==D||t[32]!==A?(e=e=>({id:e.id,type:`taskNode`,position:D.get(e.id)??{x:0,y:0},data:{task:e,phaseLabel:a.phases[e.phase],dimmed:!!(A&&!A.has(e.id))}}),t[30]=a.phases,t[31]=D,t[32]=A,t[33]=e):e=t[33],F=x.map(e),t[25]=a.phases,t[26]=D,t[27]=A,t[28]=x,t[29]=F}else F=t[29];let I=F,L;if(t[34]!==A||t[35]!==P||t[36]!==T){let e;t[38]!==A||t[39]!==P?(e=e=>{let t=P.get(e.dependencyTaskId),n=t?.phase===`closed`&&t.resolution===`done`,r=!!(A&&(!A.has(e.dependencyTaskId)||!A.has(e.dependentTaskId)));return{id:`${e.dependencyTaskId}:${e.dependentTaskId}`,source:e.dependencyTaskId,target:e.dependentTaskId,markerEnd:{type:kn.ArrowClosed},style:{stroke:n?`var(--color-edge-strong)`:`var(--color-accent)`,strokeWidth:n?1.25:1.75,opacity:r?.18:1,strokeDasharray:n?`5 5`:void 0}}},t[38]=A,t[39]=P,t[40]=e):e=t[40],L=T.map(e),t[34]=A,t[35]=P,t[36]=T,t[37]=L}else L=t[37];let R=L,z,B;t[41]!==f||t[42]!==C?(z=()=>{f&&!C.has(f)&&p(void 0)},B=[f,C],t[41]=f,t[42]=C,t[43]=z,t[44]=B):(z=t[43],B=t[44]),(0,Z.useEffect)(z,B);let ee,te;t[45]!==R||t[46]!==m?(ee=()=>{m&&!R.some(e=>e.id===m)&&h(void 0)},te=[R,m],t[45]=R,t[46]=m,t[47]=ee,t[48]=te):(ee=t[47],te=t[48]),(0,Z.useEffect)(ee,te);let V;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=window.requestAnimationFrame(()=>{g.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=V):V=t[49];let H;t[50]!==u||t[51]!==c||t[52]!==x.length?(H=[u,c,x.length],t[50]=u,t[51]=c,t[52]=x.length,t[53]=H):H=t[53],(0,Z.useEffect)(V,H);let W;t[54]===f?W=t[55]:(W=()=>{f&&g.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=W);let ne=W,re;t[56]!==r||t[57]!==o?(re=e=>{if(!e.source||!e.target||e.source===e.target)return;let t=r.filter(t=>t.dependentTaskId===e.target).map(Wr);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=re):re=t[58];let G=re,K;t[59]!==r||t[60]!==o||t[61]!==m?(K=()=>{if(!m)return;let e=r.find(e=>`${e.dependencyTaskId}:${e.dependentTaskId}`===m);e&&(h(void 0),o(e.dependentTaskId,r.filter(t=>t.dependentTaskId===e.dependentTaskId&&t.dependencyTaskId!==e.dependencyTaskId).map(Ur)))},t[59]=r,t[60]=o,t[61]=m,t[62]=K):K=t[62];let ie=K,ae;t[63]===a.connectHint?ae=t[64]:(ae=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ae);let oe=u?`secondary`:`ghost`,q;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>d(Hr),t[65]=q):q=t[65];let se=u?a.allTasks:a.blockedChains,J;t[66]!==u||t[67]!==oe||t[68]!==se?(J=(0,$.jsx)(U,{type:`button`,variant:oe,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:q,children:se}),t[66]=u,t[67]=oe,t[68]=se,t[69]=J):J=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>l(Vr),t[70]=ce):ce=t[70];let le=c?a.hideCompleted:a.showCompleted,ue;t[71]!==u||t[72]!==c||t[73]!==le?(ue=(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":c,onClick:ce,disabled:u,children:le}),t[71]=u,t[72]=c,t[73]=le,t[74]=ue):ue=t[74];let de=M?(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:ne,children:[(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,Y;t[75]!==a.removeDependency||t[76]!==ie||t[77]!==m?(Y=m?(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:ie,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=ie,t[77]=m,t[78]=Y):Y=t[78];let fe;t[79]!==J||t[80]!==ue||t[81]!==de||t[82]!==Y?(fe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[J,ue,de,Y]}),t[79]=J,t[80]=ue,t[81]=de,t[82]=Y,t[83]=fe):fe=t[83];let pe;t[84]!==ae||t[85]!==fe?(pe=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-edge bg-surface-panel px-3 py-2.5`,children:[ae,fe]}),t[84]=ae,t[85]=fe,t[86]=pe):pe=t[86];let me=x.length>0?(0,$.jsxs)(`div`,{className:O(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,M&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,$.jsxs)(Mn,{nodes:I,edges:R,nodeTypes:Rr,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>h(t.id),onConnect:G,onPaneClick:()=>{p(void 0),h(void 0)},onInit:e=>{g.current=e},fitView:!0,minZoom:.25,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:{hideAttribution:!0},children:[(0,$.jsx)(Pn,{color:`var(--color-edge)`,gap:22,size:1}),(0,$.jsx)(jn,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),M?(0,$.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[M.phase]}),(0,$.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:M.title}),M.operationalState===`blocked`&&M.blockedBy.length>0?(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(M.blockedBy.length))}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:M.blockedBy.map(Br)})]}):null,(0,$.jsxs)(s,{to:Ie(i,M.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,$.jsx)(`div`,{className:`flex min-h-72 items-center justify-center px-6 text-center text-sm text-fg-muted`,children:a.empty}),he;return t[87]!==pe||t[88]!==me?(he=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base/40`,children:[pe,me]}),t[87]=pe,t[88]=me,t[89]=he):he=t[89],he}function Br(e){return(0,$.jsx)(`li`,{children:e.title},e.id)}function Vr(e){return!e}function Hr(e){return!e}function Ur(e){return e.dependencyTaskId}function Wr(e){return e.dependencyTaskId}function Gr(e){return[e.id,e]}function Kr(e){return e.id}function qr(e){return e.phase!==`closed`}function Jr({policy:e,copy:t,onSave:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(e.mode),[s,c]=(0,Z.useState)(Math.round(e.confidenceThreshold*100)),[l,u]=(0,Z.useState)(!!e.quietHours),[d,p]=(0,Z.useState)(e.quietHours?.startHour??22),[h,g]=(0,Z.useState)(e.quietHours?.endHour??8),[_,v]=(0,Z.useState)(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),[y,b]=(0,Z.useState)(e.allowedActions.includes(`create_project_task`)),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)();(0,Z.useEffect)(()=>{o(e.mode),c(Math.round(e.confidenceThreshold*100)),u(!!e.quietHours),p(e.quietHours?.startHour??22),g(e.quietHours?.endHour??8),v(e.quietHours?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone),b(e.allowedActions.includes(`create_project_task`))},[e]);let T=async()=>{S(!0),w(void 0);try{await n({mode:a,confidenceThreshold:s/100,quietHours:l?{startHour:d,endHour:h,timezone:_}:null,allowedActions:y?[`create_project_task`]:[]}),i(!1)}catch(e){w(e instanceof Error?e.message:t.saveFailed)}finally{S(!1)}};return(0,$.jsxs)(te,{open:r,onOpenChange:e=>{x||i(e)},children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-9 gap-2 px-2.5 text-xs`,children:[(0,$.jsx)(Et,{className:`size-3.5`,"aria-hidden":!0}),t.modes[e.mode]]})}),(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(36rem,calc(100vh-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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:t.title}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:x,children:(0,$.jsx)(D,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:t.mode}),(0,$.jsx)(f,{value:a,onChange:e=>o(e.target.value),children:Object.entries(t.modes).map(([e,t])=>(0,$.jsx)(m,{value:e,children:t},e))})]}),(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[t.confidence,` · `,s,`%`]}),(0,$.jsx)(`input`,{type:`range`,min:`50`,max:`100`,step:`5`,value:s,onChange:e=>c(Number(e.target.value)),className:`accent-accent`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),t.quietHours]}),l?(0,$.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3`,children:[(0,$.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietStart,(0,$.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:d,onChange:e=>p(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,$.jsxs)(`label`,{className:`grid gap-1 text-xs text-fg-muted`,children:[t.quietEnd,(0,$.jsx)(`input`,{type:`number`,min:`0`,max:`23`,value:h,onChange:e=>g(Number(e.target.value)),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]}),(0,$.jsxs)(`label`,{className:`col-span-2 grid gap-1 text-xs text-fg-muted`,children:[t.timezone,(0,$.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-fg`})]})]}):null]}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:y,onChange:e=>b(e.target.checked)}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:t.allowTaskCreation}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:t.allowTaskCreationDescription})]})]})]}),(0,$.jsxs)(`div`,{className:`shrink-0 border-t border-edge px-5 py-3`,children:[C?(0,$.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:C}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,disabled:x,children:t.cancel})}),(0,$.jsx)(U,{type:`button`,variant:`primary`,disabled:x||!_.trim()||d<0||d>23||h<0||h>23,onClick:()=>void T(),children:x?t.saving:t.save})]})]})]})]})]})}function Yr(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Xr={backlog:en,ready:en,active:Zt,review:Ge,closed:_},Zr={backlog:`bg-surface-hover text-fg-muted`,ready:`bg-surface-panel text-fg-muted`,active:`bg-accent-soft text-accent-fg`,review:`bg-amber-500/10 text-amber-700 dark:text-amber-300`,closed:`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`};function Qr(e){return e===`running`||e===`queued`?`border-accent/20 bg-accent-soft text-accent-fg`:e===`verifying`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`waiting`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`blocked`?`border-violet-500/20 bg-violet-500/10 text-violet-700 dark:text-violet-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function $r(e){return e===`passed`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`}function ei(e){let t=(0,Q.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,f,p,m,h,g,v,y,b,x,S,C,w,T,E;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(m=jr(n),h=m!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,f=n.phase===`closed`,p=!!(n.dueAt&&n.dueAt<Date.now()&&!f),d=f?_:qt,v=n.priority!==`normal`,g=v||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,x=!0,t[20]!==c||t[21]!==n.id?(S=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=S):S=t[22],t[23]===c?C=t[24]:(C=()=>c(``),t[23]=c,t[24]=C),w=ni,t[25]!==l||t[26]!==n.id?(T=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=T):T=t[27],E=`group relative min-h-max min-w-0 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface transition-[border-color,box-shadow] hover:border-edge focus-within:border-accent/40`,u=s,t[28]!==r||t[29]!==n.id?(y=Ie(r,n.id),t[28]=r,t[29]=n.id,t[30]=y):y=t[30],b=O(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,h?`pr-19`:m&&`pr-11`),t[0]=c,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]=v,t[12]=y,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E):(u=t[4],d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],v=t[11],y=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19]);let D=f?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,k;t[31]===D?k=t[32]:(k=O(`mt-0.5 size-4 shrink-0`,D),t[31]=D,t[32]=k);let A;t[33]!==d||t[34]!==k?(A=(0,$.jsx)(d,{className:k,"aria-hidden":!0}),t[33]=d,t[34]=k,t[35]=A):A=t[35];let j=f?`text-fg-subtle`:`text-fg`,M;t[36]===j?M=t[37]:(M=O(`min-w-0 break-words text-sm font-semibold leading-5`,j),t[36]=j,t[37]=M);let N;t[38]!==M||t[39]!==n.title?(N=(0,$.jsx)(`h3`,{className:M,children:n.title}),t[38]=M,t[39]=n.title,t[40]=N):N=t[40];let P;t[41]!==A||t[42]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[A,N]}),t[41]=A,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(F=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,$.jsxs)(`div`,{className:`ml-6.5 mt-2.5 rounded-lg bg-violet-500/8 px-2.5 py-2 text-xs text-violet-700 dark:text-violet-300`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,$.jsx)(gt,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(ti).join(`、`)})]}):n.attention[0]?(0,$.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,$.jsx)(Ht,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`line-clamp-2`,children:n.attention[0].summary})]}):null,t[44]=i,t[45]=n.attention,t[46]=n.blockedBy,t[47]=n.operationalState,t[48]=F):F=t[48];let I;t[49]!==i||t[50]!==p||t[51]!==g||t[52]!==v||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(I=g?(0,$.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[v?(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,n.priority===`critical`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:n.priority===`high`?`border-amber-500/20 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:i.priorityOptions[n.priority]}):null,n.operationalState===`idle`?null:(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Qr(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,$.jsx)(`span`,{className:O(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,$r(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,$.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-edge-subtle bg-surface-hover px-2 text-fg-muted`,children:[(0,$.jsx)(Zt,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,$.jsxs)(`span`,{className:O(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,p?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge-subtle bg-surface-hover text-fg-muted`),children:[(0,$.jsx)(Kt,{className:`size-3`,"aria-hidden":!0}),be(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,$.jsxs)(`span`,{className:`inline-flex min-h-6 items-center gap-1 rounded-md border border-accent/20 bg-accent-soft px-2 text-accent-fg`,children:[(0,$.jsx)(Kt,{className:`size-3`,"aria-hidden":!0}),be(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=p,t[51]=g,t[52]=v,t[53]=n.acceptanceCriteriaCount,t[54]=n.dueAt,t[55]=n.latestVerification,t[56]=n.nextCheckAt,t[57]=n.operationalState,t[58]=n.priority,t[59]=I):I=t[59];let L;t[60]!==u||t[61]!==y||t[62]!==P||t[63]!==F||t[64]!==I||t[65]!==b?(L=(0,$.jsxs)(u,{to:y,className:b,children:[P,F,I]}),t[60]=u,t[61]=y,t[62]=P,t[63]=F,t[64]=I,t[65]=b,t[66]=L):L=t[66];let R;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==m||t[71]!==h||t[72]!==n?(R=m?(0,$.jsxs)(`div`,{className:`absolute right-2.5 top-2.5 z-10 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 [@media(hover:none)]:opacity-100`,children:[h?(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,h),className:`inline-flex size-7 items-center justify-center rounded-md bg-surface-hover text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[h],title:i.actions[h],children:(0,$.jsx)(Ge,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,m),className:`inline-flex size-7 items-center justify-center rounded-md bg-accent-soft text-accent-fg hover:bg-accent-soft/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-wait disabled:opacity-50`,"aria-label":i.actions[m],title:i.actions[m],children:(0,$.jsx)(zt,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=m,t[71]=h,t[72]=n,t[73]=R):R=t[73];let z;return t[74]!==L||t[75]!==R||t[76]!==x||t[77]!==S||t[78]!==C||t[79]!==w||t[80]!==T||t[81]!==E?(z=(0,$.jsxs)(`article`,{draggable:x,onDragStart:S,onDragEnd:C,onDragOver:w,onDrop:T,className:E,children:[L,R]}),t[74]=L,t[75]=R,t[76]=x,t[77]=S,t[78]=C,t[79]=w,t[80]=T,t[81]=E,t[82]=z):z=t[82],z}function ti(e){return e.title}function ni(e){e.preventDefault(),e.stopPropagation()}function ri({tasks:e,dependencyEdges:t,monitoring:n,returnTo:r,copy:i,onAction:a,onReorder:o,onUndoMove:s,onDependenciesChange:c,onMonitoringChange:l,onCreate:u,actionBusyId:d,ref:p}){let h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),[_,v]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(null),[C,T]=(0,Z.useState)(`board`),[E,D]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(()=>crypto.randomUUID()),[j,N]=(0,Z.useState)(``),[I,V]=(0,Z.useState)(`normal`),[H,W]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)([]),[G,K]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(null),oe=M(e=>e.language),q=ot({chat:P(oe).chat}),se=kr(e),J=e.filter(e=>e.phase!==`closed`),ce=(e,t)=>void a(e,t),le=async(t,n)=>{let r=e.find(e=>e.id===_);if(v(null),!r||r.id===n)return;let i=se[r.phase],s=i.findIndex(e=>e.id===r.id),c=s>=0?i[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=Ar(r,t);r.phase!==t&&!l||l&&!await a(r,l)||await o(r.id,n)&&S({taskId:r.id,phase:r.phase,beforeTaskId:c})},ue=async e=>{e.preventDefault();let t=j.trim();if(!(!t||G)){K(!0),ae(null);try{let e=H?new Date(`${H}T23:59:59.999`).getTime():void 0;await u({requestId:k,objective:t,priority:I,dependsOnTaskIds:ne,attachments:q.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),N(``),V(`normal`),W(``),re([]),q.clearAttachments(),A(crypto.randomUUID()),D(!1)}catch(e){ae(e instanceof Error?e.message:i.createFailed)}finally{K(!1)}}},de=()=>{A(crypto.randomUUID()),N(``),V(`normal`),W(``),re([]),q.clearAttachments(),ae(null),D(!0)};(0,Z.useImperativeHandle)(p,()=>({openCreate:de})),(0,Z.useEffect)(()=>{if(!x)return;let e=window.setTimeout(()=>S(null),6e3);return()=>window.clearTimeout(e)},[x]);let Y=(0,Z.useCallback)(e=>{let t=g.current;!t||t.pointerId!==e.pointerId||(g.current=null,b(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),pe=(0,Z.useCallback)(e=>{if(e.button!==0||Yr(e.target))return;let t=h.current;t&&(g.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),me=(0,Z.useCallback)(e=>{let t=g.current,n=h.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,b(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,$.jsxs)(`section`,{id:`project-panel-board`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-board`,className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Jr,{policy:n,copy:i.monitoring,onSave:l}),(0,$.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":C===`board`,onClick:()=>T(`board`),className:O(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,C===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,$.jsx)(yt,{className:`size-3.5`,"aria-hidden":!0}),i.views.board]}),(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":C===`graph`,onClick:()=>T(`graph`),className:O(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,C===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),i.views.graph]})]})]})]}),C===`board`?(0,$.jsx)(`div`,{ref:h,className:O(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,y?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:pe,onPointerMove:me,onPointerUp:Y,onPointerCancel:Y,onLostPointerCapture:e=>{g.current?.pointerId===e.pointerId&&(g.current=null,b(!1))},children:(0,$.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:Or.map(t=>{let n=Xr[t],a=se[t];return(0,$.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===_);r&&(r.phase===t||Ar(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),le(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-muted/70 p-2.5`,children:[(0,$.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,$.jsxs)(`div`,{className:O(`flex items-center gap-1.5 rounded-md px-2 py-1`,Zr[t]),children:[(0,$.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:i.phases[t]})]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-y-contain pr-1 [scrollbar-gutter:stable] [scrollbar-width:thin]`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,$.jsx)(ei,{task:e,returnTo:r,copy:i,busy:d===e.id,onAction:ce,onDragStart:v,onDropBefore:e=>void le(t,e)},e.id))})})]},t)})})}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,$.jsx)(zr,{tasks:e,dependencyEdges:t,returnTo:r,copy:{...i.graph,phases:i.phases},onDependenciesChange:c})}),(0,$.jsx)(te,{open:E,onOpenChange:e=>{G||D(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(40rem,calc(100vh-2rem))] w-[min(38rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:i.createTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.createDescription})]}),(0,$.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void ue(e),children:[(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:i.objective}),(0,$.jsxs)(`div`,{className:O(`overflow-hidden rounded-lg border border-edge bg-surface-base transition-colors focus-within:border-accent`,q.isDragging&&`border-accent bg-accent-soft/30`),onDragOver:e=>{e.preventDefault(),G||q.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||q.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),q.setIsDragging(!1),G||q.processFiles(Array.from(e.dataTransfer.files))},children:[(0,$.jsx)(`textarea`,{id:`project-task-objective`,autoFocus:!0,className:`min-h-28 w-full resize-y bg-transparent px-3 py-3 text-sm leading-6 text-fg outline-none placeholder:text-fg-subtle`,value:j,onChange:e=>{N(e.target.value),ae(null)},placeholder:i.objectivePlaceholder,maxLength:12e3,disabled:G}),(0,$.jsx)(Qt,{attachments:q.attachments,topPadded:!1,onRemove:e=>{G||q.removeAttachment(e)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:G,onClick:()=>q.fileInputRef.current?.click(),children:[(0,$.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),i.addFiles]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.attachmentsDescription}),(0,$.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{q.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:i.priority}),(0,$.jsx)(f,{value:I,onChange:e=>V(e.target.value),disabled:G,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,$.jsx)(m,{value:e,children:i.priorityOptions[e]},e))})]}),(0,$.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[i.dueDate,` `,(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,$.jsx)(wn,{className:`min-h-10 bg-surface-base`,value:H,onChange:W,disabled:G,ariaLabel:i.dueDate})]})]}),(0,$.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,$.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[i.dependencies,` `,(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:i.optional})]}),(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:i.dependenciesDescription}),(0,$.jsx)(X,{candidates:J,selectedIds:ne,disabled:G,onChange:re,labels:{link:i.linkDependencies,linked:i.linkedDependencies,searchPlaceholder:i.dependencySearchPlaceholder,noMatches:i.noDependencyMatches,noCandidates:i.noDependencyCandidates,remove:i.removeDependency}})]}),ie?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:G,children:i.cancel})}),(0,$.jsx)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:G||!j.trim(),children:G?i.creating:oe===`zh`?`保存待安排任务`:`Save for later`})]})]})]})]})}),x?(0,$.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-50 flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-float`,children:[(0,$.jsx)(`span`,{children:i.moved}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=x;S(null),s(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||S(e)})},children:i.undo})]}):null]})}var ii=new Set([{id:`overview`,icon:Vt},{id:`tasks`,icon:xe},{id:`automations`,icon:Me},{id:`files`,icon:Fe},{id:`notes`,icon:Be},{id:`skills`,icon:jt},{id:`sessions`,icon:me},{id:`progress`,icon:cn},{id:`settings`,icon:St}].map(e=>e.id)),ai=`xopc.projectFiles.panelWidthPx`,oi=320,si=220,ci=560;function li(e,t){return e.name!==t.name||e.description!==(t.description??``)||e.status!==t.status||e.defaultAgentId!==(t.defaultAgentId??``)||e.executionMode!==t.executionMode||e.brief!==(t.brief??``)||e.instructions!==(t.instructions??``)}function ui(e){return Math.min(ci,Math.max(si,Math.round(e)))}function di(){try{let e=window.localStorage.getItem(ai);if(e==null)return oi;let t=Number.parseInt(e,10);return Number.isFinite(t)?ui(t):oi}catch{return oi}}function fi(e){try{window.localStorage.setItem(ai,String(ui(e)))}catch{}}function pi(e){return!!(e&&ii.has(e))}function mi(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function hi(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):be(n)}function gi(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`paused`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-surface-hover text-fg-muted`}function _i(e){let t=(0,Q.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,$.jsx)(`span`,{className:`text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function vi(e=!1){return O(`w-full rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,e?`min-h-24 py-2 leading-5`:`min-h-10`)}function yi(e){let t=(0,Q.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-subtle`,children:n}),t[0]=n,t[1]=o);let s=a&&`font-mono text-xs`,c;t[2]===s?c=t[3]:(c=O(`mt-1 min-w-0 truncate text-sm text-fg`,s),t[2]=s,t[3]=c);let l;t[4]!==c||t[5]!==r?(l=(0,$.jsx)(`div`,{className:c,title:r,children:r}),t[4]=c,t[5]=r,t[6]=l):l=t[6];let u;return t[7]!==o||t[8]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md bg-surface-base px-3 py-2`,children:[o,l]}),t[7]=o,t[8]=l,t[9]=u):u=t[9],u}function bi(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function xi(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function Si(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function Ci(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function wi(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.sessionKey?t.sessionKey:t.kind}function Ti(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Ei(e){let t=e.source;return t.toolCallId?`${t.kind} · ${t.toolCallId}`:t.runId?`${t.kind} · ${t.runId}`:t.requestId?`${t.kind} · ${t.requestId}`:t.kind}function Di(e){let t=e.sourceChannel?.trim();if(t)return Oi(t);let n=e.key.split(`:`).filter(Boolean),r=(n[0]?.toLowerCase()===`agent`?n.slice(2).join(`:`):e.key).split(`:`)[0]?.split(/[-_]/)[0]?.trim();return Oi(r||``)}function Oi(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function ki(e){let t=e.payload.changes;if(Array.isArray(t)&&t.length)return t.filter(e=>typeof e==`string`).join(`, `);let n=e.payload.contentPreview;if(typeof n==`string`&&n.trim())return n.trim();let r=e.payload.title??e.payload.name;return typeof r==`string`&&r.trim()?r.trim():``}function Ai(e){return e.map(e=>({fileId:e.fileId,name:e.name,path:e.path,isDirectory:e.type===`directory`,children:e.type===`directory`?[]:void 0}))}function ji(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:ji(e.children,t,n)}:e)}function Mi({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,s]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)([e]),[m,h]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(`new`),[T,D]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(null),[I,V]=(0,Z.useState)(null),H=(0,Z.useCallback)(async()=>{v(!0),b(null);try{let t=await It({limit:100});f(n=>{let r=new Map;r.set(e.id,e);for(let e of n)r.set(e.id,e);for(let e of t.items)r.set(e.id,e);return Array.from(r.values())})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e]);(0,Z.useEffect)(()=>{f(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,Z.useEffect)(()=>{o&&H()},[H,o]);let W=(0,Z.useMemo)(()=>{let t=m.trim().toLowerCase().split(/\s+/).filter(Boolean);return d.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=bi(e);return t.every(e=>n.includes(e))}).sort((e,t)=>xi(t)-xi(e))},[e.id,d,m]),ne=e=>t.statuses[e.status]??e.status,re=e=>e.description||e.brief||t.common.defaultWorkspace,G=e=>{w(e),D(``),A(``),P(null),S(!0),s(!1)},K=(0,Z.useCallback)(async(e={})=>{let t=k.trim(),n=T.trim()||(C===`directory`?Si(t):``);if(n){M(!0),P(null),V(null);try{let r=await un({name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});S(!1),D(``),A(``),f(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=Ci(e);t?(V(t),S(!1)):P(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[C,T,a,k]),ie=(0,Z.useCallback)(e=>{e.preventDefault(),K()},[K]),ae=(0,Z.useCallback)(()=>{K({createWorkspaceRoot:!0})},[K]),oe=(0,Z.useCallback)(()=>{V(null),S(!0)},[]),q=e=>{A(e),C===`directory`&&!T.trim()&&D(Si(e))},se=(e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:O(`grid w-full grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,t&&`bg-accent-soft/55 hover:bg-accent-soft/70`),onClick:()=>{s(!1),t||a(`/projects/${encodeURIComponent(e.id)}`)},children:[(0,$.jsx)(c,{className:O(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:re(e)})]}),(0,$.jsx)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,gi(e.status)),children:ne(e)})]},e.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(u,{open:o,onOpenChange:s,children:[(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`group flex max-w-full min-w-0 items-center gap-2 rounded-lg px-2 py-1 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":t.projectSwitcher.switchProject,title:t.projectSwitcher.switchProject,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,$.jsx)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,gi(e.status)),children:ne(e)})]}),(0,$.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:re(e)})]}),(0,$.jsx)(Ot,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,$.jsx)(l,{children:(0,$.jsxs)(g,{side:`bottom`,align:`start`,sideOffset:6,className:`z-[70] w-[min(26rem,calc(100vw-2rem))] overflow-hidden rounded-xl border border-edge bg-surface-panel p-1.5 shadow-popover outline-none`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`label`,{className:`relative block`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,className:`h-9 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:m,onChange:e=>h(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,$.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),se(e,!0),(0,$.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),y?(0,$.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:y}):null,_&&W.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!_&&W.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,W.map(e=>se(e,!1))]}),(0,$.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>G(`new`),children:[(0,$.jsx)(E,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>G(`directory`),children:[(0,$.jsx)(Fe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-fg hover:bg-surface-hover`,onClick:()=>{s(!1),a(`/projects`)},children:[(0,$.jsx)(St,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,$.jsx)(te,{open:x,onOpenChange:e=>!j&&S(e),children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(32rem,calc(100vh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:C===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm text-fg-muted`,children:C===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,$.jsxs)(`form`,{onSubmit:ie,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:[N?(0,$.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:N}):null,(0,$.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,$.jsx)(`input`,{className:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`,value:T,onChange:e=>D(e.target.value),placeholder:`xopc`})]}),(0,$.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,$.jsx)(In,{value:k,onChange:q,disabled:j,wd:r,placeholder:n.workspacePlaceholder,inputClassName:`min-h-10 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none placeholder:text-fg-muted focus:border-accent`}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:j,children:n.cancel})}),(0,$.jsxs)(U,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:j||!(T.trim()||C===`directory`&&Si(k)),children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,$.jsx)(te,{open:!!I,onOpenChange:e=>{e||V(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[110] flex 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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:I?mi(n.workspaceMissingDescription,{workspace:I}):null})]}),I?(0,$.jsx)(`div`,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(Fe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:I})]})}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:oe,disabled:j,children:n.workspaceMissingBack}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:ae,disabled:j,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function Ni(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),[c]=a(),l=M(e=>e.language),u=P(l),d=u.chat.workingDirectory,p=u.projectDetailPage,h=u.projectsPage,g=xt(e=>e.setPageHeader),_=xt(e=>e.clearPageHeader),[y,b]=(0,Z.useState)(null),[T,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)([]),[N,I]=(0,Z.useState)(``),[H,ae]=(0,Z.useState)([]),[oe,se]=(0,Z.useState)(0),[ce,de]=(0,Z.useState)(!1),[fe,_e]=(0,Z.useState)(!1),[ve,be]=(0,Z.useState)(!1),[Se,we]=(0,Z.useState)([]),[De,je]=(0,Z.useState)(null),Pe=(0,Z.useRef)(new Set),[Re,Ve]=(0,Z.useState)(null),[We,Ge]=(0,Z.useState)(null),[qe,Ye]=(0,Z.useState)(null),[$e,tt]=(0,Z.useState)(di),[it,at]=(0,Z.useState)(!1),[ot,st]=(0,Z.useState)(!1),[ct,lt]=(0,Z.useState)(``),[ut,ft]=(0,Z.useState)([]),[gt,_t]=(0,Z.useState)(!1),[vt,yt]=(0,Z.useState)(null),[Ct,Tt]=(0,Z.useState)(!1),[Et,Ot]=(0,Z.useState)(null),[Mt,It]=(0,Z.useState)([]),[Rt,zt]=(0,Z.useState)(``),[Bt,Ut]=(0,Z.useState)(!0),[Kt,qt]=(0,Z.useState)(!1),[Jt,Xt]=(0,Z.useState)(!1),[Zt,Qt]=(0,Z.useState)(null),[$t,en]=(0,Z.useState)(!1),[tn,nn]=(0,Z.useState)(`fixed`),[rn,sn]=(0,Z.useState)(``),[ln,un]=(0,Z.useState)(null),[fn,pn]=(0,Z.useState)(!1),[hn,_n]=(0,Z.useState)(!1),[vn,yn]=(0,Z.useState)(!1),[bn,wn]=(0,Z.useState)(null),En=(0,Z.useRef)(null),Dn=(0,Z.useRef)(!1),[On,X]=(0,Z.useState)(null),[kn,An]=(0,Z.useState)({title:``,reason:``}),[jn,Mn]=(0,Z.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),Nn=(0,Z.useRef)(jn),Pn=`overview`,Q=n?`notes`:pi(t)?t:Pn,Fn=(0,Z.useMemo)(()=>x(c.get(`returnTo`),`/projects`,[`/chat`]),[c]),Ln=(0,Z.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Fn===`/projects`?n:S(n,Fn)},[Fn,e]),Rn=(0,Z.useCallback)(t=>{e&&r(Ln(t))},[r,e,Ln]),zn=(0,Z.useCallback)(()=>{if(Q===`tasks`&&En.current){En.current.openCreate();return}Dn.current=!0,Rn(`tasks`)},[Rn,Q]);(0,Z.useEffect)(()=>{Q!==`tasks`||!Dn.current||(Dn.current=!1,En.current?.openCreate())},[Q]);let Bn=(0,Z.useCallback)(t=>{e&&r(Ln(t),{replace:!0})},[r,e,Ln]),Vn=(0,Z.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||Bn(e)},[Bn]),Hn=(0,Z.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:Q,[Q]);(0,Z.useEffect)(()=>{!e||!t||pi(t)||r(Ln(Pn),{replace:!0})},[Pn,r,e,Ln,t]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return Ut(!0),X(null),Promise.all([q(e),le(e),Ne(e),bt().catch(()=>null),J(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;b(e),k(n),j(r),je(a),It(i?.agents??[]),zt(e.defaultAgentId??``);let o={name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``};Nn.current=o,Mn(o)}).catch(e=>{t||(je(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Ut(!1)}),()=>{t=!0}},[e]);let Un=(0,Z.useCallback)(async()=>{e&&k(await le(e))},[e]);(0,Z.useEffect)(()=>{let t,n=n=>{let r=G.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Un(),120))},r=n=>{let r=Ft.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Un(),120))};return window.addEventListener(`task-changed-v2`,n),window.addEventListener(`task-deleted-v1`,r),()=>{window.clearTimeout(t),window.removeEventListener(`task-changed-v2`,n),window.removeEventListener(`task-deleted-v1`,r)}},[e,Un]);let Wn=(0,Z.useCallback)(async(e,t)=>{wn(e.id),X(null);try{let n=await mn(e.id),r=t.startsWith(`move_`)?{type:`move`,phase:t.slice(5)}:t.startsWith(`reopen_`)?{type:`reopen`,phase:t.slice(7)}:t===`ready`?{type:`mark_ready`}:t===`run`?{type:`start`,executor:{kind:`agent`,agentId:n.task.delegateAgentId??(await pt(e.id)).agentId}}:t===`pause`?{type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}:t===`review`?{type:`request_review`}:t===`complete`?{type:`close`,resolution:`done`}:t===`reopen`?{type:`reopen`,phase:`ready`}:{type:`resolve_wait`,waitId:n.waits[0]?.id??``};if(r.type===`resolve_wait`&&!r.waitId)throw Error(`No active wait to resolve`);return await Gt(e.id,r,n.task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[T,p.board.actionFailed,Un]),Gn=(0,Z.useCallback)(async t=>{e&&(X(null),await At({idempotencyKey:t.requestId,title:t.objective,projectId:e,priority:t.priority,dueAt:t.dueAt,locale:l,contract:{objective:t.objective,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:t.dependsOnTaskIds,context:t.attachments.map((e,t)=>({targetKind:`file`,targetId:e.uri??e.name??`attachment-${t+1}`,role:`input`,title:e.name,pinned:!0,retrievalPolicy:{},metadata:{mimeType:e.mimeType,size:e.size,data:e.data}})),authorityGrants:[],activation:{mode:`capture`,phase:`backlog`}}),await Un())},[l,e,Un]),Kn=(0,Z.useCallback)(async(e,t)=>{wn(e),X(null);try{return await Xe(e,t,(await mn(e)).task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[p.board.actionFailed,Un]),qn=(0,Z.useCallback)(async(e,t,n)=>{wn(e),X(null);try{let r=await mn(e);return r.task.phase!==t&&(r=await Gt(e,r.task.phase===`closed`?{type:`reopen`,phase:t===`closed`?`ready`:t}:t===`closed`?{type:`close`,resolution:`done`}:{type:`move`,phase:t},r.task.version)),await Xe(e,n,r.task.version),await Un(),!0}catch(e){return await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed),!1}finally{wn(null)}},[p.board.actionFailed,Un]),Jn=(0,Z.useCallback)(async(e,t)=>{wn(e),X(null);try{await ue(e,t,(await mn(e)).task.version),await Un()}catch(e){await Un().catch(()=>void 0),X(e instanceof Error?e.message:p.board.actionFailed)}finally{wn(null)}},[p.board.actionFailed,Un]),Yn=(0,Z.useCallback)(async t=>{if(e){X(null);try{await ye(e,t),await Un()}catch(e){throw X(e instanceof Error?e.message:p.board.actionFailed),e}}},[p.board.actionFailed,e,Un]),Xn=(0,Z.useCallback)(async()=>{if(y){de(!0),X(null);try{let e=await on(y.id,{includeRelated:fe,limit:100});ae(e.items),se(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{de(!1)}}},[y,fe]);(0,Z.useEffect)(()=>{Q===`progress`&&Xn()},[Xn,Q]);let Zn=(0,Z.useCallback)(async()=>{if(!y?.effectiveWorkspaceRoot?.trim()){we([]),Pe.current.clear(),Ot(null);return}Tt(!0),Ot(null),Pe.current.clear();try{we(Ai((await Je(y.id,``)).entries)),Pe.current.add(``)}catch(e){we([]),Pe.current.clear(),Ot(e instanceof Error?e.message:String(e))}finally{Tt(!1)}},[y]),Qn=(0,Z.useCallback)(async e=>{if(!(!y?.effectiveWorkspaceRoot?.trim()||Pe.current.has(e))){Pe.current.add(e),Ot(null);try{let t=await Je(y.id,e);we(n=>ji(n,e,Ai(t.entries)))}catch(t){Pe.current.delete(e),Ot(t instanceof Error?t.message:String(t))}}},[y]),$n=(0,Z.useCallback)(async e=>{if(!y?.effectiveWorkspaceRoot?.trim())return;let t=Ai((await Je(y.id,e)).entries);we(e?n=>ji(n,e,t):t),Pe.current.add(e)},[y]);(0,Z.useEffect)(()=>{Q===`files`&&Zn()},[Zn,Q]);let er=ct.trim();(0,Z.useEffect)(()=>{if(Q!==`files`||!y||!ot||!er){ft([]),_t(!1),yt(null);return}let e=!1;_t(!0),yt(null),ft([]);let t=window.setTimeout(()=>{Ae(y.id,er,50).then(t=>{e||ft(t)}).catch(t=>{e||yt(t instanceof Error?t.message:String(t))}).finally(()=>{e||_t(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[er,y,ot,Q]);let tr=(0,Z.useCallback)(async()=>{if(!y)return;let[e,t]=await Promise.all([q(y.id),le(y.id)]);k(t),b(e)},[y]),nr=(0,Z.useCallback)(async e=>{if(e.preventDefault(),!(!y||!kn.title.trim())){_n(!0),X(null);try{await ht(y.id,{title:kn.title.trim(),reason:kn.reason.trim()||void 0}),An({title:``,reason:``}),yn(!1),await tr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{_n(!1)}}},[kn.reason,kn.title,y,tr]),rr=(0,Z.useMemo)(()=>(0,$.jsx)(s,{to:Fn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Fn===`/projects`?p.backToProjects:u.sidebar.back,children:(0,$.jsx)(K,{className:`size-4`,"aria-hidden":!0})}),[Fn,u.sidebar.back,p.backToProjects]),ir=(0,Z.useMemo)(()=>y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(y.id)}`,children:[(0,$.jsx)(w,{className:`size-4`,"aria-hidden":!0}),p.common.runWorkflow]})}),(0,$.jsxs)(U,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:zn,children:[(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0}),p.board.create]}),(0,$.jsx)(U,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,$.jsxs)(s,{to:Yt(y.id),state:{forceNewChat:!0,agentId:y.defaultAgentId},onClick:Vn(`sessions`),children:[(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0}),p.common.newChat]})})]}):null,[zn,Vn,p.board.create,p.common.newChat,p.common.runWorkflow,y]);(0,Z.useLayoutEffect)(()=>(g({startExtra:rr,main:y?(0,$.jsx)(Mi,{currentProject:y,pm:p,projectsText:h,wd:d}):(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:p.fallbackTitle}),(0,$.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:p.fallbackContext})]}),end:ir}),()=>_()),[_,ir,rr,p,y,h,g,d]);function ar(e){b(t=>t?{...t,...e}:null),zt(e.defaultAgentId??``),J(e.id).then(je).catch(()=>je(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function or(e=Nn.current){if(!(!y||!li(e,y))){X(null),Qt(null);try{let t=await Y(y.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions});ar(t);let n=Nn.current,r={...n,name:n.name===e.name?t.name:n.name,description:n.description===e.description?t.description??``:n.description,status:n.status===e.status?t.status:n.status,defaultAgentId:n.defaultAgentId===e.defaultAgentId?t.defaultAgentId??``:n.defaultAgentId,executionMode:n.executionMode===e.executionMode?t.executionMode:n.executionMode,brief:n.brief===e.brief?t.brief??``:n.brief,instructions:n.instructions===e.instructions?t.instructions??``:n.instructions};Nn.current=r,Mn(r)}catch(e){let t=Ci(e);throw t?Qt(t):X(e instanceof Error?e.message:String(e)),e}}}function sr(e){e.preventDefault(),Tr.flush()}function cr(e,t=!1){let n={...Nn.current,...e};Nn.current=n,Mn(n),t&&Tr.saveNow(n)}let lr=(0,Z.useCallback)(()=>{if(!y)return;let e=y.workspaceRoot?.trim()??``;nn(e?`fixed`:`follow`),sn(e||y.effectiveWorkspaceRoot||``),en(!0)},[y]);async function ur(e={}){if(!y)return;let t=tn===`fixed`?rn.trim():``;if(!(tn===`fixed`&&!t)){qt(!0),X(null),Qt(null);try{let n=await Y(y.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});ar(n),cr({workspaceRoot:n.workspaceRoot??``}),en(!1),Qt(null)}catch(e){let t=Ci(e);t?(Qt(t),en(!1)):X(e instanceof Error?e.message:String(e))}finally{qt(!1)}}}async function fr(){if(!(!y||ln)){un(`pin`),X(null);try{ar(y.pinnedAt?await Le(y.id):await ne(y.id))}catch(e){X(e instanceof Error?e.message:String(e))}finally{un(null)}}}async function pr(){if(!(!y||ln)){un(`archive`),X(null);try{let e=y.status===`archived`?await Nt(y.id):await an(y.id);ar(e),cr({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{un(null)}}}async function mr(){if(y){pn(!0),X(null);try{await Ke(y.id),Xt(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{pn(!1)}}}async function hr(){if(!(!y||ve)){be(!0),X(null);try{await Ee(y.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{be(!1)}}}let gr=(0,Z.useCallback)(e=>{Ve(e)},[]),_r=(0,Z.useCallback)((e,t)=>{t||Ve(e)},[]),vr=(0,Z.useCallback)(async(e,t,n)=>{let r=y?.id;if(r)switch(e){case`preview`:t.isDirectory||Ve(t.path);break;case`download`:if(t.isDirectory)return;try{let e=pe(t.path);if(Te(ze(e))!==`text`){let n=await Qe(t.path,{projectId:r}),i=wt(e)??`application/octet-stream`;gn(e,await n.arrayBuffer(),i)}else{let{content:n}=await ge(t.path,{projectId:r});ie(e,n)}}catch(e){Oe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await V(t.path)&&Oe(`success`,u.workspace.pathCopied,void 0,{duration:2500})}catch{Oe(`warning`,u.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await Wt(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),u.workspace.openFileFailed);break;case`openWith`:await Wt(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),u.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Wt(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),u.workspace.openFileFailed);break;case`revealInFolder`:await Wt(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),u.workspace.revealFileFailed);break;case`trash`:Ge(t);break;case`delete`:t.isDirectory||Ye(t);break;default:break}},[u.clipboard.copyFailed,u.workspace.openFileFailed,u.workspace.pathCopied,u.workspace.revealFileFailed,y?.id]),br=(0,Z.useCallback)(async()=>{let e=We;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){Oe(`warning`,t?.error??u.workspace.trashFailed,void 0,{duration:4e3});return}Re===e.path&&Ve(null),Ge(null),await Zn(),Oe(`success`,u.workspace.trashSuccess,void 0,{duration:2500})},[u.workspace.trashFailed,u.workspace.trashSuccess,We,Re,Zn]),xr=(0,Z.useCallback)(async(e,t)=>{let n=y?.id;if(n)try{await Promise.all(e.map(e=>Ze(e,t,{projectId:n}))),await $n(t).catch(()=>void 0),Oe(`success`,u.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await $n(t).catch(()=>void 0),Oe(`warning`,`${u.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[u.workspace.uploadFailed,u.workspace.uploadSuccess,y?.id,$n]),Sr=(0,Z.useCallback)(async()=>{let e=qe;if(e)try{await Ue(e.fileId),Re===e.path&&Ve(null),Ye(null);let t=e.path.lastIndexOf(`/`);await $n(t<0?``:e.path.slice(0,t)).catch(()=>void 0),Oe(`success`,u.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){Oe(`warning`,`${u.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[u.workspace.deleteFailed,u.workspace.deleteSuccess,qe,Re,$n]),Cr=(0,Z.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;e.preventDefault();let t=e.currentTarget,n=t.closest(`[data-project-files-grid]`);if(!n)return;t.setPointerCapture(e.pointerId),at(!0);let r=e.clientX,i=$e,a=e.pointerId,o=0,s=i,c=i,l=()=>{o=0,c=s,n.style.setProperty(`--project-files-panel-width`,`${c}px`)},u=e=>{s=ui(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}at(!1),tt(c),fi(c),window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),window.removeEventListener(`pointercancel`,d)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d),window.addEventListener(`pointercancel`,d)},[$e]);(0,Z.useEffect)(()=>{Q!==`files`&&Ve(null)},[e,Q]);let wr=!!(y&&li(jn,y)),Tr=Sn({value:y?jn:null,dirty:wr,onSave:or,validate:e=>e.name.trim()?null:p.settings.nameRequired});if(Bt)return(0,$.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:p.loading});if(!y)return(0,$.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,$.jsxs)(s,{to:Fn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,$.jsx)(K,{className:`size-4`,"aria-hidden":!0}),Fn===`/projects`?p.backToProjects:u.sidebar.back]}),(0,$.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:On||p.notFound})]});let Er=A.slice(0,3),Or=T?.blockers??[],kr=Dr(T?.tasks??[]),Ar=T?.tasks.filter(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)).length??0,jr=e=>p.statuses[e]??e,Mr=e=>mi(p.common.messages,{count:e}),Nr=N.trim().toLowerCase(),Pr=Nr?A.filter(e=>{let t=hi(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=e.name?.trim()||p.sessions.fallbackTitle,i=Mr(e.messageCount??0),a=Di(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Nr)}):A,Fr=A.length>0&&Pr.length===0,Ir=Mt.find(e=>e.id===y.defaultAgentId)?.name||y.defaultAgentId||p.settings.globalDefaultAgent,Lr=Mt.find(e=>e.id===jn.defaultAgentId),Rr=y.workspaceRoot?.trim()||``,zr=y.status===`archived`,Br=!!y.pinnedAt,Vr=!Rr,Hr=Rr||Lr?.workspace||y.effectiveWorkspaceRoot||p.common.defaultWorkspace,Ur=tn===`fixed`?rn.trim()||p.settings.workspacePlaceholder:Lr?.workspace||y.effectiveWorkspaceRoot||p.common.defaultWorkspace,Wr=(tn===`fixed`?rn.trim():``)!==Rr&&(tn===`follow`||!!rn.trim()),Gr=[{id:`overview`,icon:Vt,label:p.tabs.overview},{id:`tasks`,icon:xe,label:p.tabs.tasks},{id:`automations`,icon:Me,label:p.tabs.automations},{id:`files`,icon:Fe,label:p.tabs.files},{id:`notes`,icon:Be,label:p.tabs.notes},{id:`skills`,icon:jt,label:p.tabs.skills},{id:`sessions`,icon:me,label:p.tabs.sessions},{id:`progress`,icon:cn,label:p.tabs.progress}];async function Kr(){if(!Hr)return;let e=await V(Hr);Oe(e?`success`:`warning`,e?u.workspace.pathCopied:u.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function qr(){Qt(null),en(!0)}return(0,$.jsxs)(`main`,{className:`flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,$.jsx)(Cn,{items:Gr,activeTab:Q,onChange:Rn,ariaLabel:p.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,$.jsxs)(U,{id:`project-primary-tab-settings`,type:`button`,variant:Q===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":Q===`settings`?`page`:void 0,onClick:()=>Rn(`settings`),children:[(0,$.jsx)(St,{className:`size-4`,"aria-hidden":!0}),p.tabs.settings,wr?(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":p.settings.unsavedChanges}):null]})]}),(0,$.jsx)(`div`,{className:`mt-2 shrink-0`,children:(0,$.jsx)(U,{variant:`ghost`,onClick:()=>r(`/assistant-work?view=new&project=${encodeURIComponent(e)}`),children:l===`zh`?`让助理帮我跟进`:`Ask the assistant to follow this project`})}),On?(0,$.jsx)(`p`,{className:`mt-3 shrink-0 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:On}):null,(0,$.jsxs)(`div`,{className:O(`mt-3 min-h-0 flex-1`,Q===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:Q===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[Q===`overview`?(0,$.jsxs)(`section`,{id:`project-panel-overview`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-overview`,className:`grid min-h-full gap-4 xl:h-full xl:min-h-0 xl:grid-cols-[minmax(0,1fr)_20rem] xl:overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.directionTitle}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:mi(p.overview.activitySummary,{moving:Ar,attention:Or.length})})]}),(0,$.jsx)(`p`,{className:`mt-2 max-w-3xl text-base font-medium leading-7 text-fg`,children:y.outcome||y.description||y.brief||p.overview.directionFallback}),T?.digest.recommendedAction?(0,$.jsx)(`p`,{className:`mt-3 max-w-3xl rounded-lg bg-surface-hover px-3 py-2.5 text-sm font-medium leading-6 text-fg`,children:mi(p.overview.recommendedNext,{action:T.digest.recommendedAction})}):null]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,onClick:()=>void hr(),disabled:ve,children:[(0,$.jsx)(dt,{className:`size-3.5`,"aria-hidden":!0}),ve?p.overview.savingDigest:p.overview.saveDigest]})]})}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3.5`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.nextActions}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted transition-colors hover:text-fg`,onClick:()=>Rn(`tasks`),children:p.common.viewAll})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle`,children:kr.length?kr.map(e=>(0,$.jsxs)(s,{to:Ie(Ln(`overview`),e.id),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsxs)(`span`,{className:O(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.attention.length?`bg-warning/10 text-warning`:`bg-surface-hover text-fg-muted`),children:[p.board.phases[e.phase],e.operationalState===`idle`?``:` · ${p.board.operationalStates[e.operationalState]}`]})]}),e.attention[0]?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noNextActions})})]})]}),T?.recentResults.length?(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.recentResults})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:T.recentResults.slice(0,3).map(({taskId:e,taskTitle:t,receipt:n})=>(0,$.jsxs)(s,{to:Ie(Ln(`overview`),e),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,$.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[p.overview.resultStatuses[n.status],` · `,p.board.verification[n.verification.status]]})]}),(0,$.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-5 text-fg-muted`,children:(0,$.jsx)(C,{content:n.summary,compact:!0})})]},n.runId))})]}):null,y.milestones.length||y.recentUpdates.length?(0,$.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[y.milestones.length?(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.milestones})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:y.milestones.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:p.statuses[e.status]})]},e.id))})]}):null,y.recentUpdates.length?(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.projectUpdates})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:y.recentUpdates.slice(0,3).map(e=>(0,$.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:p.overview.healthLabels[e.health]})]},e.id))})]}):null]}):null]}),(0,$.jsxs)(`aside`,{className:`grid min-w-0 content-start gap-4 xl:min-h-0 xl:overflow-y-auto xl:pr-1 xl:[scrollbar-gutter:stable]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.overview.attention}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,"aria-expanded":vn,onClick:()=>yn(e=>!e),children:[(0,$.jsx)(E,{className:O(`size-3.5 transition-transform`,vn&&`rotate-45`),"aria-hidden":!0}),p.overview.addBlocker]})]}),Or.length?(0,$.jsx)(`div`,{className:`mt-3 grid gap-3`,children:Or.map(e=>{let t=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(Ht,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,$.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[p.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${jr(e.status)}`:``]})]});return e.href?(0,$.jsx)(s,{to:e.href,onClick:Vn(Hn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,$.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:p.overview.noBlockedTasks}),vn?(0,$.jsxs)(`form`,{onSubmit:nr,className:`mt-4 flex gap-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsx)(`input`,{className:`min-h-9 min-w-0 flex-1 rounded-md border border-edge bg-surface-base px-3 text-sm text-fg outline-none focus:border-accent`,value:kn.title,onChange:e=>An(t=>({...t,title:e.target.value})),placeholder:p.overview.blockerTitlePlaceholder}),(0,$.jsx)(U,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:hn||!kn.title.trim(),"aria-label":hn?p.overview.addingBlocker:p.overview.addBlocker,title:hn?p.overview.addingBlocker:p.overview.addBlocker,children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]}):null]}),(0,$.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(He,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:p.overview.recentSessions})]}),(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Rn(`sessions`),children:p.common.viewAll})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Er.length?Er.map(e=>(0,$.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Vn(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:hi(e.updatedAt)})]}),(e.routing?.agentId||e.agentId)&&(e.routing?.agentId||e.agentId)!==y.defaultAgentId?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.routing?.agentId||e.agentId}):null]},e.key)):(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.overview.noSessions})})]})]})]}):null,Q===`tasks`?(0,$.jsx)(ri,{ref:En,tasks:T?.tasks??[],dependencyEdges:T?.dependencyEdges??[],monitoring:T?.monitoring??{projectId:e??``,mode:`observe`,allowedActions:[],confidenceThreshold:.75,scenarios:[],configured:!1},returnTo:Ln(`tasks`),copy:p.board,onAction:Wn,onReorder:Kn,onUndoMove:qn,onDependenciesChange:Jn,onMonitoringChange:Yn,onCreate:Gn,actionBusyId:bn}):null,Q===`automations`?(0,$.jsx)(`section`,{id:`project-panel-automations`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-automations`,className:`grid min-h-full content-start gap-4`,children:(0,$.jsx)(Tn,{projectId:y.id,embedded:!0,title:p.automations.title,subtitle:p.automations.hint})}):null,Q===`notes`?(0,$.jsx)(`section`,{id:`project-panel-notes`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-notes`,className:`flex h-full min-h-[28rem] overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:(0,$.jsx)(dr,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(y.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:y.id,listTitle:p.notes.title,listDescription:p.notes.hint,emptyText:p.notes.emptyTitle,emptyDescription:p.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${y.id}`})}):null,Q===`skills`?(0,$.jsx)(yr,{projectId:y.id,copy:p.skills}):null,Q===`files`?(0,$.jsx)(`section`,{id:`project-panel-files`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-files`,className:`flex h-full min-h-[28rem] flex-col`,children:(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:y.effectiveWorkspaceRoot?(0,$.jsxs)(`div`,{"data-project-files-grid":!0,className:O(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_6px_minmax(0,1fr)]`,it&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${$e}px`},children:[(0,$.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge lg:border-b-0 lg:border-r`,children:[(0,$.jsxs)(`div`,{className:`flex h-11 items-center gap-1 border-b border-edge bg-surface-muted/50 px-3 text-sm`,children:[De?(0,$.jsx)(Dt,{resourceId:De.fileId,displayName:De.name}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:O(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,ot&&`bg-surface-hover text-fg`),onClick:()=>st(!0),"aria-label":p.files.search,title:p.files.search,"aria-pressed":ot,children:(0,$.jsx)(kt,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(he,{className:`size-7 shrink-0 rounded-md p-0`,loading:Ct,label:u.cron.refresh,onClick:()=>void Zn()})]})]}),ot?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge bg-surface-muted/40 px-3 py-2`,children:(0,$.jsxs)(`div`,{className:`flex h-8 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)(kt,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`text`,role:`searchbox`,value:ct,onChange:e=>lt(e.target.value),placeholder:p.files.searchPlaceholder,"aria-label":p.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,$.jsx)(`button`,{type:`button`,className:`flex size-6 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":p.files.clearSearch,title:p.files.clearSearch,onClick:()=>{lt(``),st(!1)},children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Et?(0,$.jsx)(`div`,{className:`border-b border-edge bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Et}):null,er?(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:gt?(0,$.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,$.jsx)(W,{className:`h-11 w-full`}),(0,$.jsx)(W,{className:`h-11 w-full`}),(0,$.jsx)(W,{className:`h-11 w-full`})]}):vt?(0,$.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[u.workspace.loadError,`: `,vt]}):ut.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:p.files.noSearchResults}):ut.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:O(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Re===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Ve(e.path),title:e.path,children:[(0,$.jsx)(Be,{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))}):Ct&&Se.length===0?(0,$.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:p.files.loading}):(0,$.jsx)(nt,{tree:Se,selectedPath:Re,onSelectFile:gr,onSelectEntry:_r,onExpandDir:e=>void Qn(e),onAction:vr,onUploadFiles:(e,t)=>void xr(e,t),uploadDropHint:u.workspace.dropToUpload,actionLabels:{preview:u.workspace.preview,download:u.workspace.download,copyPath:u.workspace.copyPath,openDefault:u.workspace.openSystemApp,openDirectory:u.workspace.openInFileManager,openWith:u.workspace.openWith,revealInFolder:u.workspace.revealInFolder,trash:u.workspace.moveToTrash,delete:u.workspace.deleteFile,recommendedApps:u.workspace.recommendedApps,desktopUpdateRequired:u.workspace.desktopUpdateRequired},emptyHint:p.files.emptyDirectory})]}),(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":p.files.resizeHandle,className:O(`hidden cursor-col-resize touch-none items-stretch justify-center bg-surface-panel transition-colors hover:bg-surface-hover lg:flex`,it&&`bg-surface-hover`),onPointerDown:Cr,children:(0,$.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70`})}),(0,$.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Re?(0,$.jsx)(et,{filePath:Re,projectId:y.id,agentId:y.defaultAgentId||Rt||void 0,onClose:()=>Ve(null)}):(0,$.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,$.jsxs)(`div`,{className:`max-w-sm`,children:[(0,$.jsx)(Fe,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:p.files.previewEmptyTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.files.previewEmptyDescription})]})})})]}):(0,$.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:p.files.needWorkspace}),(0,$.jsx)(`div`,{children:(0,$.jsx)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Rn(`settings`),children:p.files.openSettings})})]})})}):null,Q===`sessions`?(0,$.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[A.length?(0,$.jsxs)(`label`,{className:`relative flex min-h-9 w-full max-w-lg cursor-text items-center rounded-lg bg-surface-panel py-1.5 pl-9 pr-9 shadow-surface`,children:[(0,$.jsx)(kt,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,$.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:N,onChange:e=>I(e.currentTarget.value),placeholder:p.sessions.searchPlaceholder,"aria-label":p.sessions.searchPlaceholder,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),N?(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md 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":p.sessions.clearSearch,onClick:()=>I(``),children:(0,$.jsx)(D,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Pr.length?(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Pr.map(e=>{let t=hi(e.updatedAt),n=e.routing?.agentId||e.agentId||p.common.agent,r=Di(e),i=e.name?.trim()||p.sessions.fallbackTitle,a=Mr(e.messageCount??0);return(0,$.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Vn(`sessions`),className:`group flex min-h-[8.75rem] min-w-0 flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-base text-fg-muted`,children:(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-base px-2 py-0.5 text-[11px] font-medium leading-5 text-fg-muted`,children:r}):null]})})]}),(0,$.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.agent,`: `,n]}),(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,$.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[p.sessions.updated,`: `,t]}):null]})]},e.key)})}):Fr?(0,$.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.noMatches})}):(0,$.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.sessions.emptyTitle}),(0,$.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:p.sessions.emptyDescription})]})})]}):null,Q===`progress`?(0,$.jsxs)(`section`,{id:`project-panel-progress`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-progress`,className:`grid min-h-full content-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.progress.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:mi(p.progress.count,{count:oe})})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(`label`,{className:`inline-flex min-h-9 items-center gap-2 rounded-lg bg-surface-panel px-3 text-sm text-fg-muted shadow-surface`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:fe,onChange:e=>_e(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),p.progress.includeRelated]}),(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Xn(),disabled:ce,children:[(0,$.jsx)(dn,{className:O(`size-4`,ce&&`animate-spin`),"aria-hidden":!0}),p.common.refresh]})]})]}),(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:ce&&H.length===0?(0,$.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.progress.loading}):H.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge`,children:H.map(e=>{let t=p.progress.types[e.type]??e.type,n=p.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=ki(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===y.id);return(0,$.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:p.progress.related}):null]}),(0,$.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,Ti(e)]})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:hi(e.createdAt)})]}),r?(0,$.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[p.progress.actor,`: `,wi(e)]}),(0,$.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[p.progress.source,`: `,Ei(e)]})]})]},e.id)})}):(0,$.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:p.progress.empty})})]}):null,Q===`settings`?(0,$.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:sr,onBlurCapture:Tr.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,$.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.summaryTitle}),(0,$.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.settings.summaryHint})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,$.jsx)(`span`,{className:O(`rounded-full px-2 py-0.5 text-xs font-medium`,gi(jn.status)),children:p.settings.statuses[jn.status]}),(0,$.jsx)(xn,{status:Tr.status,error:Tr.error})]})]}),(0,$.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4`,children:[(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.detailsTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.detailsHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsx)(_i,{label:p.settings.name,children:(0,$.jsx)(`input`,{className:vi(),value:jn.name,onChange:e=>cr({name:e.target.value})})}),(0,$.jsx)(_i,{label:p.settings.defaultAgent,children:(0,$.jsxs)(f,{className:vi(),value:jn.defaultAgentId,onChange:e=>cr({defaultAgentId:e.target.value},!0),children:[(0,$.jsx)(m,{value:``,children:p.settings.globalDefaultAgent}),Mt.map(e=>(0,$.jsx)(m,{value:e.id,children:mt(e,u.agentsSettings)},e.id))]})}),(0,$.jsx)(_i,{label:p.settings.status,children:zr?(0,$.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-muted px-3 text-sm text-fg-muted`,children:p.settings.statuses.archived}):(0,$.jsxs)(f,{className:vi(),value:jn.status===`archived`?`active`:jn.status,onChange:e=>cr({status:e.target.value},!0),children:[(0,$.jsx)(m,{value:`active`,children:p.settings.statuses.active}),(0,$.jsx)(m,{value:`paused`,children:p.settings.statuses.paused})]})}),(0,$.jsx)(_i,{label:p.settings.executionMode,hint:p.settings.executionModeHint,children:(0,$.jsxs)(f,{className:vi(),value:jn.executionMode,onChange:e=>cr({executionMode:e.target.value},!0),children:[(0,$.jsx)(m,{value:`managed_worktree`,children:p.settings.executionModeWorktree}),(0,$.jsx)(m,{value:`local_checkout`,children:p.settings.executionModeLocal})]})}),(0,$.jsx)(_i,{label:p.settings.description,hint:p.settings.descriptionHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.description,onChange:e=>cr({description:e.target.value})})})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.projectGuidanceTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.projectGuidanceHint})]}),(0,$.jsx)(_i,{label:p.settings.brief,hint:p.settings.briefHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.brief,onChange:e=>cr({brief:e.target.value})})}),(0,$.jsx)(_i,{label:p.settings.instructions,hint:p.settings.instructionsHint,children:(0,$.jsx)(`textarea`,{className:vi(!0),value:jn.instructions,onChange:e=>cr({instructions:e.target.value})})})]})]}),(0,$.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.workspaceRoot}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceIndependentHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`span`,{className:`w-fit rounded-md bg-surface-muted px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Vr?p.settings.workspaceModeFollow:p.settings.workspaceModeFixed}),(0,$.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Hr,children:Hr}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void Kr(),children:[(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),p.settings.copyWorkspacePath]}),De?(0,$.jsx)(Dt,{resourceId:De.fileId,displayName:De.name}):null,(0,$.jsxs)(U,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:lr,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.migrateWorkspace]})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.currentProjectTitle}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(yi,{label:p.settings.defaultAgent,value:Ir}),(0,$.jsx)(yi,{label:p.settings.pinState,value:Br?p.settings.pinned:p.settings.notPinned}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(yi,{label:p.settings.createdAt,value:hi(y.createdAt)||p.common.never}),(0,$.jsx)(yi,{label:p.settings.updatedAt,value:hi(y.updatedAt)||p.common.never})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.settings.managementTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.managementHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Br?p.settings.pinnedTitle:p.settings.pinTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:p.settings.pinHint})]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:ln===`pin`,onClick:()=>void fr(),children:[Br?(0,$.jsx)(re,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(Pt,{className:`size-4`,"aria-hidden":!0}),Br?p.settings.unpinProject:p.settings.pinProject]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:zr?p.settings.restoreTitle:p.settings.archiveTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:zr?p.settings.restoreHint:p.settings.archiveHint})]}),(0,$.jsxs)(U,{type:`button`,variant:zr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:ln===`archive`,onClick:()=>void pr(),children:[zr?(0,$.jsx)(dn,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(ke,{className:`size-4`,"aria-hidden":!0}),zr?p.settings.restoreProject:p.settings.archiveProject]})]})]})]}),(0,$.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:p.settings.dangerTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:p.settings.dangerHint})]}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-fit text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>Xt(!0),children:[(0,$.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,$.jsx)(te,{open:Jt,onOpenChange:e=>{fn||Xt(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-5 shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg bg-red-500/10 text-red-600 dark:text-red-400`,children:(0,$.jsx)(Ht,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.deleteConfirmTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:y?mi(p.settings.deleteConfirm,{name:y.name}):p.settings.deleteConfirmFallback})]})]}),(0,$.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:fn,children:p.common.cancel})}),(0,$.jsxs)(U,{type:`button`,variant:`ghost`,className:`rounded-lg text-red-600 hover:bg-red-500/10 hover:text-red-700 focus-visible:ring-red-500 dark:text-red-400 dark:hover:text-red-300`,disabled:fn||!y,onClick:()=>void mr(),children:[(0,$.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),p.settings.deleteConfirmAction]})]})]})]})}),(0,$.jsx)(Ce,{open:!!We,title:u.workspace.trashConfirmTitle,description:u.workspace.trashConfirmDescription.replace(`{{name}}`,We?.name??``),confirmLabel:u.workspace.moveToTrash,cancelLabel:u.workspace.cancel,destructive:!0,onConfirm:()=>void br(),onCancel:()=>Ge(null)}),(0,$.jsx)(Ce,{open:!!qe,title:u.workspace.deleteConfirmTitle,description:u.workspace.deleteConfirmDescription.replace(`{{name}}`,qe?.name??``),confirmLabel:u.workspace.deleteFile,cancelLabel:u.workspace.cancel,destructive:!0,onConfirm:()=>void Sr(),onCancel:()=>Ye(null)}),(0,$.jsx)(te,{open:$t,onOpenChange:e=>{Kt||en(e)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(34rem,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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMigrationTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:p.settings.workspaceMigrationDescription})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg-muted`,children:p.settings.workspaceMode}),(0,$.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:O(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,tn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,$.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:tn===`fixed`,onChange:()=>nn(`fixed`),disabled:Kt}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFixed}),(0,$.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceMigrationFixedHint})]})]}),(0,$.jsxs)(`label`,{className:O(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,tn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,$.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:tn===`follow`,onChange:()=>nn(`follow`),disabled:Kt}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:p.settings.workspaceModeFollow}),(0,$.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:p.settings.workspaceHint})]})]})]})]}),tn===`fixed`?(0,$.jsx)(In,{value:rn,onChange:sn,disabled:Kt,wd:d,placeholder:p.settings.workspacePlaceholder,inputClassName:vi(),autoFocus:!0}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm leading-6 text-amber-800 dark:text-amber-200`,children:p.settings.workspaceMigrationImpact}),(0,$.jsx)(`div`,{className:`rounded-lg bg-surface-muted px-3 py-2 text-xs leading-5 text-fg-subtle`,children:mi(p.settings.workspaceCurrent,{workspace:Ur})})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Kt,children:p.common.cancel})}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Kt||!Wr,onClick:()=>void ur(),children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMigrationConfirm]})]})]})]})}),(0,$.jsx)(te,{open:!!Zt,onOpenChange:e=>{e||Qt(null)},children:(0,$.jsxs)(z,{children:[(0,$.jsx)(F,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(B,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex 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-panel shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:p.settings.workspaceMissingTitle}),(0,$.jsx)(L,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Zt?mi(p.settings.workspaceMissingDescription,{workspace:Zt}):null})]}),Zt?(0,$.jsx)(`div`,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-muted px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(Fe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:Zt})]})}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,$.jsx)(U,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:qr,disabled:Kt,children:p.settings.workspaceMissingBack}),(0,$.jsxs)(U,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void ur({createWorkspaceRoot:!0}),disabled:Kt,children:[(0,$.jsx)(Lt,{className:`size-4`,"aria-hidden":!0}),p.settings.workspaceMissingCreate]})]})]})]})})]})}export{Ni as ProjectDetailPage};