@xopcai/xopc 0.0.359 → 0.0.360

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 (222) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-D-yhlYSG.js → agent-avatar-dicebear-CQTERenW.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPF0lunJ.js +1 -0
  5. package/dist/gateway/static/root/assets/agent-plugin-dialog-BjDaZlKy.js +1 -0
  6. package/dist/gateway/static/root/assets/agents-XopBILLB.js +66 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CiSdkzuX.js → app-management-settings-panel-V5QVeMvW.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-SdlCHKg8.js → appearance-settings-BDkRcoI6.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-ntyBe6mP.js → apps-page-DzCyL89L.js} +1 -1
  10. package/dist/gateway/static/root/assets/{automations-page-DU0R5C65.js → automations-page-DOu1wMOV.js} +1 -1
  11. package/dist/gateway/static/root/assets/automations-workspace-CiY_2otj.js +7 -0
  12. package/dist/gateway/static/root/assets/{block-editor-CLejMPkV.js → block-editor-K6is5GrS.js} +3 -3
  13. package/dist/gateway/static/root/assets/{browser-automations-page-BjGswNM0.js → browser-automations-page-B8IiXEBs.js} +2 -2
  14. package/dist/gateway/static/root/assets/{browser-settings-page-DBcYssNQ.js → browser-settings-page-Cms2Bu3Q.js} +2 -2
  15. package/dist/gateway/static/root/assets/{capabilities-page-CsTpcrPP.js → capabilities-page-BAFRNHQv.js} +2 -2
  16. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cws6od1d.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-header-actions-B0Xiav_-.js → capability-header-actions-wh3Nr0qS.js} +1 -1
  18. package/dist/gateway/static/root/assets/channels-DxwismTc.js +1 -0
  19. package/dist/gateway/static/root/assets/{chat-terminal-dock-C9pMFB6k.js → chat-terminal-dock-BU-X9nu1.js} +2 -2
  20. package/dist/gateway/static/root/assets/computer-settings-page-MyXsSqFJ.js +1 -0
  21. package/dist/gateway/static/root/assets/{connector-service-page-OyQKwHNr.js → connector-service-page-DyxPM_MZ.js} +1 -1
  22. package/dist/gateway/static/root/assets/connectors-page-C7-OC3MW.js +2 -0
  23. package/dist/gateway/static/root/assets/{constants-Co2_smKQ.js → constants-Dy8Gw0sF.js} +1 -1
  24. package/dist/gateway/static/root/assets/{date-picker-DxGsweV_.js → date-picker-WRFvi7Pu.js} +1 -1
  25. package/dist/gateway/static/root/assets/{dependency-picker-D9ZfAJwn.js → dependency-picker-CLun5Tst.js} +1 -1
  26. package/dist/gateway/static/root/assets/{desktop-pet-DFgK1z5i.js → desktop-pet-iaVa9vVM.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-settings-CyFW0raW.js → desktop-pet-settings-0RS3sP3Z.js} +1 -1
  28. package/dist/gateway/static/root/assets/device-pairing-wizard-DVAGb04L.js +1 -0
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-2nrl6Exh.js → directory-picker-path-field-Btlldlt3.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-debug-page-BodxNAys.js → extension-debug-page-BImQT4PU.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-page-DMb2YFlb.js → extension-page-BmuLv-ET.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-provider-aigS3RJu.js → extension-provider-Dg7cRxDX.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-D3hvXtxi.js → extension-settings-page-7Kr8UJK4.js} +1 -1
  34. package/dist/gateway/static/root/assets/{fallback-models-DsXySQVF.js → fallback-models-B0w1lumZ.js} +1 -1
  35. package/dist/gateway/static/root/assets/gateway-settings-DmPvmwYp.js +1 -0
  36. package/dist/gateway/static/root/assets/home-page-N0Mp-eTJ.js +1 -0
  37. package/dist/gateway/static/root/assets/{imports-page-Czzsa_Eu.js → imports-page-BLOJY67-.js} +1 -1
  38. package/dist/gateway/static/root/assets/{index-DUgsBdV3.css → index-B7AHDHSO.css} +1 -1
  39. package/dist/gateway/static/root/assets/{index-DUU_2HF0.js → index-BXrBL_Hb.js} +41 -41
  40. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DqsFlXlp.js → keyboard-shortcuts-settings-Dlbsip2R.js} +1 -1
  41. package/dist/gateway/static/root/assets/{local-app-workbench-page-BcDFXc1k.js → local-app-workbench-page-nyWeTK0r.js} +1 -1
  42. package/dist/gateway/static/root/assets/{local-apps-page-BaxqXA1-.js → local-apps-page-CfEpFLs0.js} +1 -1
  43. package/dist/gateway/static/root/assets/{logs-page-DmJjZ0Uk.js → logs-page-A38cawkA.js} +2 -2
  44. package/dist/gateway/static/root/assets/{management-settings-1O7zsu4t.js → management-settings-Cse9K61x.js} +1 -1
  45. package/dist/gateway/static/root/assets/{note-detail-panel-BLvVlQG8.js → note-detail-panel-CUGVyo2V.js} +3 -3
  46. package/dist/gateway/static/root/assets/notes-page-Dk89l5dC.js +8 -0
  47. package/dist/gateway/static/root/assets/{page-context-capture-button-gL3453SU.js → page-context-capture-button-C72qIgBg.js} +1 -1
  48. package/dist/gateway/static/root/assets/personal-page-DCtduzh8.js +1 -0
  49. package/dist/gateway/static/root/assets/{product-open-page-Dw8JPizo.js → product-open-page-CT98FsVl.js} +1 -1
  50. package/dist/gateway/static/root/assets/{project-detail-page-Zg4KZ0vK.js → project-detail-page-BlqOVwKP.js} +1 -1
  51. package/dist/gateway/static/root/assets/{projects-page-B33uj1lz.js → projects-page-DVN2q_yR.js} +1 -1
  52. package/dist/gateway/static/root/assets/remote-access-hub-BP5kUgIN.js +1 -0
  53. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BLNXzyeh.js → runtime-tools-settings-panel-ry0jprz7.js} +1 -1
  54. package/dist/gateway/static/root/assets/{scenes-page-D868Zuj9.js → scenes-page-CV1GkOj6.js} +2 -2
  55. package/dist/gateway/static/root/assets/{schema-form-5z33VTce.js → schema-form-C5zMrxgR.js} +1 -1
  56. package/dist/gateway/static/root/assets/{send-session-input-OaBPDJ9E.js → send-session-input-Dt0t5SoR.js} +1 -1
  57. package/dist/gateway/static/root/assets/session-manager-DDR-gv_e.js +16 -0
  58. package/dist/gateway/static/root/assets/sessions-page-BXtGeOsR.js +1 -0
  59. package/dist/gateway/static/root/assets/settings-advanced-gate-CvFVkELy.js +1 -0
  60. package/dist/gateway/static/root/assets/{settings-page-BG_dOYMq.js → settings-page-C88fsfZF.js} +1 -1
  61. package/dist/gateway/static/root/assets/{setup-status-panel-DNj1hD_H.js → setup-status-panel-DESlRgZS.js} +1 -1
  62. package/dist/gateway/static/root/assets/{share-preview-page-M_rAQR60.js → share-preview-page-D5Gey-6E.js} +1 -1
  63. package/dist/gateway/static/root/assets/shares-settings-btoP07Fx.js +1 -0
  64. package/dist/gateway/static/root/assets/{skill-api-BBaKs-Xx.js → skill-api-1hbX3qDC.js} +1 -1
  65. package/dist/gateway/static/root/assets/skills-page-DYJbwwBT.js +2 -0
  66. package/dist/gateway/static/root/assets/{system-settings-panel-DKjsZo49.js → system-settings-panel-DbNk-Jwq.js} +1 -1
  67. package/dist/gateway/static/root/assets/{task-detail-page-DSvaiKGb.js → task-detail-page-DoLKOJrE.js} +1 -1
  68. package/dist/gateway/static/root/assets/{tunnel-api-DR8Qu6R_.js → tunnel-api-H3FheXYH.js} +1 -1
  69. package/dist/gateway/static/root/assets/{usage-page-CAIqAduR.js → usage-page-DGbqcsV6.js} +1 -1
  70. package/dist/gateway/static/root/assets/{use-composer-attachments-CUaywGe0.js → use-composer-attachments-pzPAUV_o.js} +1 -1
  71. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D809I8ur.js → use-file-preview-expanded-DNhXjL0W.js} +1 -1
  72. package/dist/gateway/static/root/assets/user-model-page-7pW4Pazn.js +2 -0
  73. package/dist/gateway/static/root/assets/{work-discovery-overlay-wGFcle2p.js → work-discovery-overlay-DfyI9kVf.js} +1 -1
  74. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CewS2IbN.js → workflow-run-setup-panel-De80GODZ.js} +2 -2
  75. package/dist/gateway/static/root/assets/workflows-page-BuH3pC1C.js +6 -0
  76. package/dist/gateway/static/root/assets/{workspace-api-BtXzxf_w.js → workspace-api-Dwa8kHdY.js} +2 -2
  77. package/dist/gateway/static/root/index.html +9 -9
  78. package/dist/package.js +1 -1
  79. package/dist/packages/gateway-contract/src/index.js +2 -0
  80. package/dist/packages/gateway-contract/src/task-result-delivery.js +30 -0
  81. package/dist/src/agent/agent-manager.js +3 -3
  82. package/dist/src/agent/background-review/run-background-review.js +1 -1
  83. package/dist/src/agent/context/workspace-templates/SOUL.md +2 -0
  84. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  85. package/dist/src/agent/external-tools/gateway-tools.js +41 -1
  86. package/dist/src/agent/image/tool-model-config.js +1 -1
  87. package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
  88. package/dist/src/agent/prompt/sections/behavior.js +4 -1
  89. package/dist/src/agent/prompt/sections/memory-skills.js +2 -0
  90. package/dist/src/agent/service.js +2 -2
  91. package/dist/src/agent/session/session-config-service.js +11 -3
  92. package/dist/src/agent/skills/hub-lock.js +1 -1
  93. package/dist/src/agent/skills/index.js +1 -1
  94. package/dist/src/agent/skills/managed-store.js +1 -1
  95. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  96. package/dist/src/agent/tools/factory.js +32 -6
  97. package/dist/src/agent/tools/personal-preference-tool.js +11 -0
  98. package/dist/src/agent/tools/personal-request-result-tool.d.ts +22 -0
  99. package/dist/src/agent/tools/personal-request-result-tool.js +84 -0
  100. package/dist/src/agent/tools/personal-request-tool.d.ts +3 -0
  101. package/dist/src/agent/tools/personal-request-tool.js +100 -0
  102. package/dist/src/agent/tools/personal-task-tool.d.ts +6 -0
  103. package/dist/src/agent/tools/personal-task-tool.js +12 -10
  104. package/dist/src/agent/tools/tool-media.js +2 -3
  105. package/dist/src/agent/tools/xopc-use-tool.js +2 -2
  106. package/dist/src/agent-catalog/capabilities.js +2 -2
  107. package/dist/src/auth/credentials.js +1 -1
  108. package/dist/src/auth/oauth-provider-lock.js +1 -1
  109. package/dist/src/auth/profiles/store.js +1 -1
  110. package/dist/src/automations/capabilities/drafts.js +1 -1
  111. package/dist/src/bootstrap/application-state.js +1 -1
  112. package/dist/src/browser/providers/browser-ext-install.js +1 -1
  113. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  114. package/dist/src/capabilities/runtime/product.js +1 -1
  115. package/dist/src/cli/commands/agent.js +1 -1
  116. package/dist/src/cli/commands/agents.js +1 -1
  117. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  118. package/dist/src/cli/commands/models.js +1 -1
  119. package/dist/src/cli/commands/onboard/model.js +1 -1
  120. package/dist/src/cli/templates.js +4 -0
  121. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  122. package/dist/src/config/index.js +3 -3
  123. package/dist/src/config/loader.js +1 -1
  124. package/dist/src/config/models-json.js +1 -1
  125. package/dist/src/config/schema.js +1 -1
  126. package/dist/src/connectors/connection-recovery-service.d.ts +2 -0
  127. package/dist/src/connectors/connection-recovery-service.js +23 -5
  128. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  129. package/dist/src/extensions/lockfile.js +1 -1
  130. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  131. package/dist/src/gateway/agents-admin.js +2 -2
  132. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  133. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  134. package/dist/src/gateway/hono/routes/media.js +4 -3
  135. package/dist/src/gateway/hono/routes/notes.js +2 -2
  136. package/dist/src/gateway/hono/routes/personal-agent.js +68 -0
  137. package/dist/src/gateway/hono/routes/projects.js +2 -2
  138. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  139. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  140. package/dist/src/gateway/image-generation-setup.js +2 -2
  141. package/dist/src/gateway/lock.js +1 -1
  142. package/dist/src/gateway/media-access.js +2 -2
  143. package/dist/src/gateway/service.d.ts +3 -0
  144. package/dist/src/gateway/service.js +46 -5
  145. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  146. package/dist/src/local-apps/service.js +1 -1
  147. package/dist/src/media/index.js +2 -2
  148. package/dist/src/media/session-references.d.ts +2 -0
  149. package/dist/src/media/session-references.js +22 -2
  150. package/dist/src/media/store.d.ts +1 -0
  151. package/dist/src/media/store.js +2 -1
  152. package/dist/src/personal-agent/capability-service.d.ts +14 -0
  153. package/dist/src/personal-agent/capability-service.js +63 -0
  154. package/dist/src/personal-agent/communication.d.ts +4 -0
  155. package/dist/src/personal-agent/communication.js +24 -0
  156. package/dist/src/personal-agent/model-config.d.ts +5 -0
  157. package/dist/src/personal-agent/model-config.js +59 -0
  158. package/dist/src/personal-agent/policy.d.ts +1 -1
  159. package/dist/src/personal-agent/policy.js +2 -0
  160. package/dist/src/personal-agent/repository.d.ts +1 -0
  161. package/dist/src/personal-agent/repository.js +3 -1
  162. package/dist/src/personal-agent/request-delivery.d.ts +4 -0
  163. package/dist/src/personal-agent/request-delivery.js +159 -0
  164. package/dist/src/personal-agent/request-repository.d.ts +33 -0
  165. package/dist/src/personal-agent/request-repository.js +71 -0
  166. package/dist/src/personal-agent/request-result.d.ts +21 -0
  167. package/dist/src/personal-agent/request-result.js +45 -0
  168. package/dist/src/personal-agent/request-service.d.ts +18 -0
  169. package/dist/src/personal-agent/request-service.js +308 -0
  170. package/dist/src/personal-agent/service.js +30 -7
  171. package/dist/src/providers/model-catalog-persistence.js +1 -1
  172. package/dist/src/session/client-history.d.ts +2 -1
  173. package/dist/src/session/client-history.js +40 -0
  174. package/dist/src/session/compact-history.js +9 -5
  175. package/dist/src/session/config-store.js +2 -1
  176. package/dist/src/session/session-context-for-llm.js +55 -0
  177. package/dist/src/session/store.js +2 -0
  178. package/dist/src/session/types.d.ts +2 -0
  179. package/dist/src/storage/sqlite/connection-wait-repository.d.ts +5 -1
  180. package/dist/src/storage/sqlite/connection-wait-repository.js +38 -8
  181. package/dist/src/storage/sqlite/migrations/231_task_result_deliveries.sql +32 -0
  182. package/dist/src/storage/sqlite/migrations/232_personal_requests.sql +28 -0
  183. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  184. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  185. package/dist/src/storage/sqlite/schema.js +1 -1
  186. package/dist/src/storage/sqlite/session-repository.js +33 -0
  187. package/dist/src/tasks/capabilities/read.js +2 -2
  188. package/dist/src/tasks/task-application-service.d.ts +1 -0
  189. package/dist/src/tasks/task-application-service.js +7 -0
  190. package/dist/src/tasks/task-context-assembler.js +1 -0
  191. package/dist/src/tasks/task-main-update-delivery.js +32 -1
  192. package/dist/src/tasks/task-result-delivery-repository.d.ts +18 -0
  193. package/dist/src/tasks/task-result-delivery-repository.js +144 -0
  194. package/dist/src/tasks/task-result-delivery-service.d.ts +4 -0
  195. package/dist/src/tasks/task-result-delivery-service.js +128 -0
  196. package/dist/src/tasks/task-run-coordinator.js +6 -1
  197. package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
  198. package/dist/src/tasks/task-run-dispatcher.js +22 -3
  199. package/dist/src/tui/backends/embedded-backend.js +2 -2
  200. package/dist/src/voice/realtime/persona-context.js +1 -1
  201. package/package.json +3 -3
  202. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CYq-3pbE.js +0 -1
  203. package/dist/gateway/static/root/assets/agent-plugin-dialog-Cx3UbhqT.js +0 -1
  204. package/dist/gateway/static/root/assets/agents-Ce9uvui7.js +0 -66
  205. package/dist/gateway/static/root/assets/automations-workspace-BaHJml4R.js +0 -7
  206. package/dist/gateway/static/root/assets/capabilities-settings-panel-BXlVwnMr.js +0 -8
  207. package/dist/gateway/static/root/assets/channels-TPqwcbZ4.js +0 -1
  208. package/dist/gateway/static/root/assets/computer-settings-page-BJOn14Ow.js +0 -1
  209. package/dist/gateway/static/root/assets/connectors-page-DBWH5bVr.js +0 -2
  210. package/dist/gateway/static/root/assets/device-pairing-wizard-C6Co5dT3.js +0 -1
  211. package/dist/gateway/static/root/assets/gateway-settings-CubM1m6Z.js +0 -1
  212. package/dist/gateway/static/root/assets/home-page-CQ9y_LMT.js +0 -1
  213. package/dist/gateway/static/root/assets/notes-page-AWU_G61i.js +0 -8
  214. package/dist/gateway/static/root/assets/personal-page-BPy5m3QR.js +0 -1
  215. package/dist/gateway/static/root/assets/remote-access-hub-BZoUVzgS.js +0 -1
  216. package/dist/gateway/static/root/assets/session-manager-BK5IvdGz.js +0 -16
  217. package/dist/gateway/static/root/assets/sessions-page-Du7ueBFc.js +0 -1
  218. package/dist/gateway/static/root/assets/settings-advanced-gate-CaxCsIIZ.js +0 -1
  219. package/dist/gateway/static/root/assets/shares-settings-Cr_Ut6FE.js +0 -1
  220. package/dist/gateway/static/root/assets/skills-page-DU7fV5pc.js +0 -2
  221. package/dist/gateway/static/root/assets/user-model-page-C--t6SLp.js +0 -2
  222. package/dist/gateway/static/root/assets/workflows-page-CxfsWFL5.js +0 -6
@@ -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{f as i,g as a,m as o,t as s}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./chevron-right-BweFrslA.js";import{n as u,r as d,t as f}from"./popover-select-BgSdSbCL.js";import{t as p}from"./circle-alert-BEjgurr2.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./circle-dot-BAseJTrF.js";import{t as g}from"./copy-Dv6d4Dvw.js";import{t as _}from"./download-Dk-ZjtO6.js";import{t as v}from"./external-link-DjqjBmc3.js";import{M as y,N as b,P as x,S,_ as C,g as w,n as T,t as E,u as D,y as O}from"./use-composer-attachments-CUaywGe0.js";import{b as k,f as A,m as j,t as M}from"./markdown-view-DKlJx4eo.js";import{t as N}from"./git-branch-Dh9uxTot.js";import{E as P,F,N as I,b as L,g as R,i as z,k as B,s as V,v as H,y as U}from"./notes-api-D8nvWMMC.js";import{t as W}from"./loader-circle-CifKLtgG.js";import{t as G}from"./message-square-plus-XP0tGdlV.js";import{t as ee}from"./mic-CuUb7zc-.js";import{t as K}from"./pause-DuPxgSxk.js";import{t as te}from"./play-kxZvpBg8.js";import{t as ne}from"./plus-Q2yW6OE7.js";import{t as re}from"./rotate-ccw-JM1TBLpp.js";import{t as ie}from"./search-DA7gz22f.js";import{t as ae}from"./sparkles-DHlfQFAF.js";import{d as q,m as oe,p as se,u as ce}from"./use-file-preview-expanded-D809I8ur.js";import{t as le}from"./x-B_N4OPjy.js";import{t as ue}from"./messages-CnM6Qfr7.js";import{t as J}from"./cn-JdwAhgNB.js";import{a as de,c as fe,f as pe,n as me,r as he}from"./locale-store-ChN_vjs2.js";import{a as ge,i as _e,n as ve,o as ye,r as be,s as xe,t as Se}from"./dist-BGTk37IG.js";import{i as Ce,t as we}from"./tasks-CH6KoBeY.js";import{t as Te}from"./copy-to-clipboard-HOJ79TWv.js";import{i as Ee}from"./vendor-swr-BIWyz7Rc.js";import{t as Y}from"./button-CS04eWY9.js";import{a as De}from"./attachment-utils-core-BIOUBrpT.js";import{o as Oe}from"./agents-admin-api-BtnYiq7O.js";import{r as ke}from"./app-chrome-BeB4KgOf.js";import{a as Ae,i as je,o as Me,r as Ne,s as Pe}from"./dist-C3DSFZCi.js";import{t as Fe}from"./skeleton-BwbyijEw.js";import{r as Ie}from"./settings-form-draft-Dy10ldo8.js";import{a as Le,c as Re,n as ze,p as Be,r as Ve,t as He}from"./workspace-api-BtXzxf_w.js";import{$r as Ue,An as We,As as Ge,Bs as Ke,Ci as qe,Dn as Je,Do as Ye,Ei as Xe,En as Ze,Fc as Qe,Go as $e,Gr as et,Jo as tt,Ki as nt,Mc as rt,Ms as it,Nc as at,No as ot,Ns as st,On as ct,Qr as lt,Si as ut,So as dt,Ss as ft,Ti as pt,Tn as mt,Ur as ht,Vs as gt,Vt as _t,Wo as vt,Ws as yt,Xn as bt,Xo as xt,Xr as St,Za as Ct,Zs as wt,_c as Tt,_i as Et,_s as Dt,bi as Ot,co as kt,dc as At,di as jt,dn as Mt,ei as Nt,fi as Pt,gc as Ft,gi as It,go as Lt,hi as Rt,ho as zt,io as Bt,jn as Vt,jo as Ht,kc as Ut,kn as Wt,ko as Gt,mi as Kt,no as qt,oi as Jt,pi as Yt,rc as Xt,sc as Zt,si as Qt,ti as $t,ui as en,us as tn,vi as nn,wc as rn,wi as an,wr as on,xi as sn,xs as cn,yc as ln,yi as un,yo as dn}from"./index-DUU_2HF0.js";import{t as fn}from"./page-tabs-D2xpUV26.js";import{n as pn,t as mn}from"./use-autosave-R3hEHQQq.js";import{t as hn}from"./page-context-capture-button-gL3453SU.js";import{t as gn}from"./directory-picker-path-field-2nrl6Exh.js";import{d as _n,h as vn,o as yn}from"./skill-api-BBaKs-Xx.js";import{t as bn}from"./date-picker-DxGsweV_.js";import{t as xn}from"./automations-workspace-BaHJml4R.js";import{i as Sn,n as Cn,r as wn,t as Tn}from"./note-detail-panel-BLvVlQG8.js";import{t as En}from"./dependency-picker-D9ZfAJwn.js";import{c as Dn,l as On,n as kn,o as An,r as jn,t as X}from"./style-TIDOdKy0.js";var Mn=n(),Z=e(t(),1),Q=r();function Nn(e){let t=(0,Mn.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]!==r||t[1]!==n?(s=I(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=J(`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,Q.jsx)(F,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,Q.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=J(`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,Q.jsx)(B,{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 Pn(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 Fn(e){let t=(0,Mn.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=bt(),f=bt(Ln),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=J(`flex items-center gap-2`,a),t[10]=a,t[11]=C);let w=m?`bg-accent text-on-accent`:`bg-accent/10 text-accent hover:bg-accent/20`,T;t[12]===w?T=t[13]:(T=J(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,w),t[12]=w,t[13]=T);let E=m?`Pause`:`Play`,D;t[14]!==h||t[15]!==m?(D=h?(0,Q.jsx)(W,{className:`size-3.5 animate-spin`}):m?(0,Q.jsx)(K,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=D):D=t[16];let O;t[17]!==b||t[18]!==S||t[19]!==T||t[20]!==E||t[21]!==D?(O=(0,Q.jsx)(`button`,{type:`button`,onClick:b,onKeyDown:S,className:T,"aria-label":E,children:D}),t[17]=b,t[18]=S,t[19]=T,t[20]=E,t[21]=D,t[22]=O):O=t[22];let k=`${v}%`,A;t[23]===k?A=t[24]:(A=(0,Q.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:k}})}),t[23]=k,t[24]=A);let j;t[25]!==_||t[26]!==p||t[27]!==g?(j=Pn(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=j):j=t[28];let M;t[29]===j?M=t[30]:(M=(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:j}),t[29]=j,t[30]=M);let N;t[31]!==A||t[32]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[A,M]}),t[31]=A,t[32]=M,t[33]=N):N=t[33];let P;return t[34]!==N||t[35]!==C||t[36]!==O?(P=(0,Q.jsxs)(`div`,{className:C,onClick:In,children:[O,N]}),t[34]=N,t[35]=C,t[36]=O,t[37]=P):P=t[37],P}function In(e){return e.stopPropagation()}function Ln(e){return e.toggle}function $(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Rn(e){let t=(0,Mn.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=$(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)(Gn),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=Sn(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=J(`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,Q.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,Q.jsx)(Nn,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,Q.jsx)(Fn,{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,Q.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=J(`truncate text-sm leading-5`,T),t[23]=T,t[24]=E);let D;t[25]!==f||t[26]!==E?(D=(0,Q.jsx)(`p`,{className:E,children:f}),t[25]=f,t[26]=E,t[27]=D):D=t[27];let O;t[28]!==w||t[29]!==D?(O=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=O):O=t[30];let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(wt,{className:`size-4`}),t[31]=k):k=t[31];let A;t[32]===c.actions?A=t[33]:(A=(0,Q.jsx)(Vt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:Wn,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:k})}),t[32]=c.actions,t[33]=A);let j;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(j=()=>{a(n.id,!n.pinned).catch(Hn)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=j):j=t[37];let M;t[38]===n.pinned?M=t[39]:(M=n.pinned?(0,Q.jsx)(vt,{className:`size-4`}):(0,Q.jsx)($e,{className:`size-4`}),t[38]=n.pinned,t[39]=M);let N=n.pinned?c.unpin:c.pin,P;t[40]!==j||t[41]!==M||t[42]!==N?(P=(0,Q.jsxs)(Je,{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:j,children:[M,N]}),t[40]=j,t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==n.id||t[45]!==o?(F=()=>{o(n.id).catch(Vn)},t[44]=n.id,t[45]=o,t[46]=F):F=t[46];let I;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(Qe,{className:`size-4`}),t[47]=I):I=t[47];let L;t[48]!==c.archive||t[49]!==F?(L=(0,Q.jsxs)(Je,{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:F,children:[I,c.archive]}),t[48]=c.archive,t[49]=F,t[50]=L):L=t[50];let R;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(We,{className:`my-1 h-px bg-edge-subtle`}),t[51]=R):R=t[51];let z;t[52]!==n.id||t[53]!==s?(z=()=>{s(n.id).catch(Bn)},t[52]=n.id,t[53]=s,t[54]=z):z=t[54];let B;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(kt,{className:`size-4`}),t[55]=B):B=t[55];let V;t[56]!==c.delete||t[57]!==z?(V=(0,Q.jsxs)(Je,{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:z,children:[B,c.delete]}),t[56]=c.delete,t[57]=z,t[58]=V):V=t[58];let H;t[59]!==P||t[60]!==L||t[61]!==V?(H=(0,Q.jsx)(ct,{children:(0,Q.jsxs)(Ze,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Un,children:[P,L,R,V]})}),t[59]=P,t[60]=L,t[61]=V,t[62]=H):H=t[62];let U;t[63]!==A||t[64]!==H?(U=(0,Q.jsxs)(Wt,{children:[A,H]}),t[63]=A,t[64]=H,t[65]=U):U=t[65];let W;t[66]!==C||t[67]!==O||t[68]!==U?(W=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,O,U]}),t[66]=C,t[67]=O,t[68]=U,t[69]=W):W=t[69];let G;t[70]===n.pinned?G=t[71]:(G=n.pinned&&(0,Q.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,Q.jsx)($e,{className:`size-3`})}),t[70]=n.pinned,t[71]=G);let ee;t[72]===n.tags?ee=t[73]:(ee=n.tags?.slice(0,2).map(zn),t[72]=n.tags,t[73]=ee);let K;t[74]===g?K=t[75]:(K=(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=K);let te;t[76]!==G||t[77]!==ee||t[78]!==K?(te=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[G,ee,K]}),t[76]=G,t[77]=ee,t[78]=K,t[79]=te):te=t[79];let ne;return t[80]!==W||t[81]!==te||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(ne=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,W,te]}),t[80]=W,t[81]=te,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=ne):ne=t[87],ne}function zn(e){return(0,Q.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 Bn(){}function Vn(){}function Hn(){}function Un(e){return e.stopPropagation()}function Wn(e){return e.stopPropagation()}function Gn(){return Date.now()}var Kn=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 Jn({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),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)([]),k=(0,Z.useRef)(0),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=(0,Z.useCallback)(()=>{A.current&&=(clearInterval(A.current),null),j.current&&=(clearTimeout(j.current),null),D.current?.getTracks().forEach(e=>e.stop()),D.current=null,E.current=null,O.current=[],b(!1),S(0)},[]);(0,Z.useEffect)(()=>()=>M(),[M]);let N=(0,Z.useCallback)(async()=>{let e=E.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()-k.current)/1e3)),n=e.mimeType||qn()||`audio/webm`,r=new Blob(O.current,{type:n});if(M(),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)},[M,c]),P=(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});D.current=e;let t=qn(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);E.current=n,O.current=[],k.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&O.current.push(e.data)},n.start(),b(!0),S(0),A.current=setInterval(()=>{S(Math.round((Date.now()-k.current)/1e3))},250),j.current=setTimeout(()=>{N()},Kn)}catch{M(),l?.()}}},[M,c,l,y,N,C]),F=(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]),I=(0,Z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),F())},[F]),L=_||C,R=!!(s||c||p);return(0,Q.jsxs)(`div`,{className:J(`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":L,children:[y?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void N(),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,Q.jsx)(dn,{className:`size-4 fill-current`,"aria-hidden":!0})}):R?(0,Q.jsxs)(Wt,{children:[(0,Q.jsx)(Vt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,disabled:L,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,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})}),(0,Q.jsx)(ct,{children:(0,Q.jsxs)(Ze,{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,Q.jsxs)(Je,{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,Q.jsx)(Ge,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,Q.jsxs)(Je,{disabled:f,onSelect:()=>void 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 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,Q.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,Q.jsxs)(Je,{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,Q.jsx)(Ut,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(x))}):(0,Q.jsx)(`textarea`,{ref:T,value:h,onChange:e=>g(e.target.value),onKeyDown:I,placeholder:e,"aria-label":e,rows:1,disabled:L,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,Q.jsx)(`button`,{type:`button`,disabled:!h.trim()||L||y,onClick:()=>void F(),"aria-label":t,title:t,className:J(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!L&&!y?`bg-accent text-on-accent hover:bg-accent-hover`:`text-fg-disabled`),children:(0,Q.jsx)(Ht,{className:`size-4`,"aria-hidden":!0})})]})}var Yn={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Xn=240,Zn=320,Qn=520,$n=560;function er(e){if(globalThis.localStorage===void 0)return Zn;try{let t=globalThis.localStorage.getItem(e);if(!t)return Zn;let n=Number(t);return Number.isFinite(n)?n:Zn}catch{return Zn}}function tr(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var nr={thought:Lt,todo:dt,voice:ee,media:Ge,bookmark:rn,mixed:Lt,task:dt};function rr(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function ir(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function ar(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function or({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:a=!0,projectId:o,listTitle:s,listDescription:c,emptyText:l,emptyDescription:f,listWidthStorageKey:p=`xopc.notes.listWidth`}){let m=me(e=>e.language),h=ue(m).notes,g=!!fe(e=>e.conversationId),[_,v]=(0,Z.useReducer)(Ie,Yn),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(0),[T,E]=(0,Z.useState)(()=>er(p)),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(null),[I,B]=(0,Z.useState)(null),W=(0,Z.useRef)(null),G=(0,Z.useRef)(null),[ee]=(0,Z.useState)(()=>Date.now()),K=i(),te=(0,Z.useCallback)(e=>{let t=W.current?.clientWidth??window.innerWidth,n=Math.max(Xn,t-$n);return Math.max(Xn,Math.min(Math.min(Qn,n),e))},[]),re=(0,Z.useCallback)(e=>{let t=te(e);E(t),tr(p,t)},[te,p]);(0,Z.useLayoutEffect)(()=>{E(e=>te(e))},[te]);let{data:ae,mutate:q,isLoading:oe}=Ee((0,Z.useMemo)(()=>g?[`notes-list`,o,_.statusFilter,_.kindFilter,_.pinnedOnly]:null,[g,o,_.statusFilter,_.kindFilter,_.pinnedOnly]),()=>R({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}),se=oe&&!ae,ce=ae?.items??[],de=ae?.total??0,he=x.trim(),{data:Ce,isLoading:we}=Ee(g&&y&&he?[`notes-search`,o,he]:null,()=>R({search:he,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),Te=Ce?.items??[],Y=e?ce.some(t=>t.id===e):!0;(0,Z.useEffect)(()=>{w(0)},[he]),(0,Z.useEffect)(()=>{C>=Te.length&&w(Math.max(0,Te.length-1))},[C,Te.length]),(0,Z.useEffect)(()=>{let e=()=>{q().catch(e=>{F(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[q,h.quickCaptureFailedHint,h.refreshFailed]);let De=nt(e=>e.setPageHeader),Oe=nt(e=>e.clearPageHeader),Ae=h.noteCount.replace(`{{count}}`,String(de)),je=!r&&de===0&&c?c:Ae,Me=h.searchDialogTitle,Ne=h.searchClose,Pe=h.searchClear,Fe=(0,Z.useMemo)(()=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:J(`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`,ke),"aria-label":Me,children:[(0,Q.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:Me})]}),[Me]);(0,Z.useLayoutEffect)(()=>{if(n)return g?(De({startExtra:null,main:(0,Q.jsxs)(`div`,{className:J(`flex min-w-0 items-center gap-2`,ke),children:[(0,Q.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:s??h.title}),Ae?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Ae}):null]}),end:Fe}),()=>Oe()):(Oe(),()=>Oe())},[Oe,g,Fe,s,n,h.title,Ae,e,De]);let Le=(0,Z.useMemo)(()=>({justNow:h.justNow,minutesAgo:h.minutesAgo,today:h.today,yesterday:h.yesterday,daysAgo:h.daysAgo,locale:pe(m)}),[m,h.justNow,h.minutesAgo,h.today,h.yesterday,h.daysAgo]),Re=(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]),ze=Re.find(e=>ir(_,e))??Re[0],Be=s??ze.label,Ve=(0,Z.useCallback)(async e=>{F(null);try{let n=o?await z({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await H(e,`web`);await q(),K(ar(t,n.id))}catch(e){throw F(`${h.quickCaptureFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`),e}},[t,q,h.quickCaptureFailed,h.quickCaptureFailedHint,K,o]),He=(0,Z.useCallback)(async()=>{if(!j){M(!0),F(null);try{let e=await z({markdown:``,kind:`thought`,projectId:o,channel:`web`});v({type:`patch`,patch:Yn}),await q(),B(e.id),K(ar(t,e.id))}catch(e){F(`${h.createBlankFailed}: ${e instanceof Error?e.message:h.createBlankFailedHint}`)}finally{M(!1)}}},[t,j,q,h.createBlankFailed,h.createBlankFailedHint,K,o]),Ue=(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{F(null),await U(t,`web`),await q()}catch(e){F(`${h.imageUploadFailed}: ${e instanceof Error?e.message:h.imageUploadFailedHint}`)}},e.click()},[q,h.imageUploadFailed,h.imageUploadFailedHint]),We=(0,Z.useCallback)(async(e,t)=>{try{F(null),await L(e,t,`web`),await q()}catch(e){F(`${h.voiceUploadFailed}: ${e instanceof Error?e.message:h.voiceUploadFailedHint}`)}},[q,h.voiceUploadFailed,h.voiceUploadFailedHint]),Ge=(0,Z.useCallback)(()=>{F(`${h.voiceCaptureFailed}: ${h.voiceCaptureFailedHint}`)},[h.voiceCaptureFailed,h.voiceCaptureFailedHint]),Ke=(0,Z.useCallback)(async(e,t)=>{F(null);try{await P(e,{pinned:t}),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),qe=(0,Z.useCallback)(async e=>{F(null);try{await P(e,{status:`archived`}),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),Je=(0,Z.useCallback)(async e=>{F(null);try{await V(e),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),Ye=(0,Z.useCallback)(e=>{K(ar(t,e))},[t,K]),Xe=(0,Z.useCallback)(e=>{K(ar(t,e)),b(!1)},[t,K]),Ze=(0,Z.useCallback)(e=>{if(Te.length){if(e.key===`ArrowDown`)e.preventDefault(),w(e=>Math.min(Te.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=Te[C]??Te[0];t&&Xe(t.id)}}},[C,Xe,Te]),Qe=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=G.current;t.setPointerCapture(e.pointerId),O(!0);let r=W.current?.clientWidth??window.innerWidth,i=Math.max(Xn,r-$n),a=Math.min(Qn,i),o=e=>Math.max(Xn,Math.min(a,e)),s=e.clientX,c=o(T),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},h=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}O(!1),W.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),E(f),tr(p,f),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,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(),He())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[He]);let $e=(0,Z.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),re(T-16)):e.key===`ArrowRight`?(e.preventDefault(),re(T+16)):e.key===`Home`?(e.preventDefault(),re(Xn)):e.key===`End`&&(e.preventDefault(),re(Qn))},[re,T]);return g?(0,Q.jsxs)(`div`,{ref:W,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${T}px`},children:[(0,Q.jsxs)(`section`,{ref:G,className:J(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-rail`,!D&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,k?`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":k?!0:void 0,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[N?(0,Q.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:N}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,Q.jsx)(u,{value:ze.id,onChange:e=>{let t=Re.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:Re.map(e=>(0,Q.jsx)(d,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Be}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:je})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!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,Q.jsx)(xt,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:He,disabled:j,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,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),(0,Q.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,Q.jsx)(ie,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:se?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,Q.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):ce.length===0?(0,Q.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,Q.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,Q.jsx)(Lt,{className:`size-6`,"aria-hidden":!0})}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!Y?h.noteOutsideCurrentView:l??h.noNotes}),e&&!Y?null:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:f??h.noNotesDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Y?(0,Q.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,ce.map((t,n)=>{let r=n>0?Cn(ce[n-1].createdAt):null;return(0,Q.jsxs)(`div`,{children:[Cn(t.createdAt)!==r&&(0,Q.jsx)(`div`,{className:J(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:wn(t.createdAt,ee,Le)}),(0,Q.jsx)(Rn,{note:t,selected:t.id===e,onPress:Ye,onPin:Ke,onArchive:qe,onDelete:Je,timeLabels:Le,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,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,Q.jsx)(Jn,{placeholder:h.quickCapturePlaceholder,submitLabel:h.quickCaptureSubmit,actionsLabel:h.quickCaptureActions,imageLabel:h.quickCaptureImage,voiceLabel:h.quickCaptureVoice,stopRecordingLabel:h.stopRecording,onCapture:Ve,onImagePick:a?Ue:void 0,onVoiceCapture:a?We:void 0,onVoiceError:Ge,recordingLabel:h.recording,discussionCaptureLabel:h.discussionCapture.title,onDiscussionCapture:()=>mt(o)})})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.resizeNotesList,"aria-valuemin":Xn,"aria-valuemax":Qn,"aria-valuenow":Math.round(T),tabIndex:0,onPointerDown:Qe,onDoubleClick:()=>re(Zn),onKeyDown:$e,title:h.resizeNotesList,className:J(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-transparent hover:bg-surface-hover/60 lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,k?`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,Q.jsx)(`span`,{"aria-hidden":!0,className:J(`h-full w-px bg-transparent transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,D&&`bg-accent scale-x-[2]`)})}),(0,Q.jsxs)(`section`,{className:J(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[k?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!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,Q.jsx)(xt,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,Q.jsx)(Tn,{noteId:e,onBack:()=>K(t),onSaved:()=>{q().catch(e=>{F(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>b(!0),autoFocus:e===I,onAutoFocusConsumed:()=>B(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(Lt,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:h.emptyEditorTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h.emptyEditorDescription}),(0,Q.jsxs)(`button`,{type:`button`,onClick:He,disabled:j,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),j?h.creatingBlankNote:h.createBlankNote]})]})})]}),(0,Q.jsx)(Se,{open:y,onOpenChange:b,children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(xe,{className:`text-sm font-semibold text-fg`,children:Me}),(0,Q.jsx)(_e,{className:`sr-only`,children:h.searchPlaceholder}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.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":Ne,children:(0,Q.jsx)(le,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),onKeyDown:Ze,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,Q.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":Pe,children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:he?we&&!Ce?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):Te.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(Lt,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchNoResults}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchNoResultsDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:h.searchResultsCount.replace(`{{count}}`,String(Ce?.total??Te.length))}),Te.map((e,t)=>{let n=nr[e.kind]||Lt,r=rr(e,{imageNote:h.imageNote,noText:h.noText});return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Xe(e.id),onMouseEnter:()=>w(t),className:J(`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,Q.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Sn(e.updatedAt,ee,Le)})]}),e.title?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,Q.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(ie,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchEmptyTitle}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchEmptyDescription})]})})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,Q.jsx)(Lt,{className:`size-10 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.needToken})]})}function sr(e){return de(he(`/api/projects/${encodeURIComponent(e)}/skills`))}function cr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function lr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function ur(e,t){let n=new FormData;return n.set(`file`,t),de(he(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function dr(e,t,n={}){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function fr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function pr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function mr({projectId:e,copy:t}){let n=me(e=>e.language),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!0),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(1),[L,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(``),G=(0,Z.useRef)(null),ee=(0,Z.useCallback)(async()=>{x(!0),D(``);try{let t=await sr(e);i(t.items),o(t.inheritedItems),c(t.sources)}catch(e){D(e instanceof Error?e.message:String(e))}finally{x(!1)}},[e]);(0,Z.useEffect)(()=>{ee()},[ee]),(0,Z.useEffect)(()=>{let t=!1;return un(e).then(e=>{t||d(e)}).catch(()=>{t||d([])}),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!p){g(null);return}let e=u.find(e=>e.key===p),t=!1;return g(null),D(``),y(!0),ht(e?.agentId??e?.routing?.agentId,p,!0).then(e=>{t||g(e)}).catch(e=>{t||D(e instanceof Error?e.message:String(e))}).finally(()=>{t||y(!1)}),()=>{t=!0}},[p,u]),(0,Z.useEffect)(()=>{if(O!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{B(!0),H(``),yn({q:M,page:F,pageSize:8,sort:`downloads`,signal:e.signal}).then(R).catch(t=>{e.signal.aborted||H(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||B(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[O,F,M]);async function K(e,t){C(!0),T(t??null),D(``);try{await e(),k(null),W(``),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1),T(null)}}async function te(t){D(``);try{j((await cr(e,t)).skill)}catch(e){D(e instanceof Error?e.message:String(e))}}async function re(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){C(!0);try{await pr(e,n.directoryId),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1)}}}async function ae(){C(!0),D(``);try{await lr(e,!0),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1)}}let q=s.find(e=>e.origin===`agents-workspace`),oe=new Map(h?.skills.map(e=>[e.name,e]));return(0,Q.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsxs)(Y,{type:`button`,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t.add,(0,Q.jsx)(Tt,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,Q.jsx)(Ae,{children:(0,Q.jsxs)(je,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,Q.jsx)(vr,{icon:zt,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>k(`marketplace`)}),(0,Q.jsx)(vr,{icon:N,title:t.source,hint:t.sourceHint,onClick:()=>k(`source`)}),(0,Q.jsx)(vr,{icon:Bt,title:t.upload,hint:t.uploadHint,onClick:()=>G.current?.click()})]})})]}),(0,Q.jsx)(`input`,{ref:G,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&K(()=>ur(e,n)),t.target.value=``}})]})}),E?(0,Q.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:E}):null,q?.state===`untrusted`?(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(tn,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:S,onClick:()=>void ae(),children:[(0,Q.jsx)(Ye,{className:`size-4`,"aria-hidden":!0}),S?t.trusting:t.trustAction]})]}):null,u.length?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v?t.sessionLoading:p?h?.agentId:t.sessionViewAll})]}),(0,Q.jsx)(f,{value:p,options:u.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,b?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,Q.jsx)(Fe,{className:`h-36 rounded-lg`},e))}):r.length?(0,Q.jsx)(hr,{title:t.localTitle,items:r,copy:t,busy:S,availabilityByName:oe,onPreview:te,onRemove:re}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!b&&a.length?(0,Q.jsx)(hr,{title:t.inheritedTitle,hint:t.inheritedHint,items:a,copy:t,busy:S,availabilityByName:oe,onPreview:te,onRemove:re}):null,(0,Q.jsx)(Se,{open:O!==null,onOpenChange:e=>{e||k(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{className:J(`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-overlay shadow-xl`,O===`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,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:O===`marketplace`?t.marketplace:t.source}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(le,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:O===`marketplace`?(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,Q.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.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:M,onChange:e=>{P(e.target.value),I(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),V?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:V}):null,z&&!L?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(Fe,{className:`h-32 rounded-lg`},e))}):L?.items.length?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:L.items.map(i=>{let a=et(i,n),o=i.providerId??L.provider,s=vn(i,o),c=r.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===i.id||e.directoryId===s||e.name===i.name)),l=w===s;return(0,Q.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(_n,{name:i.name,className:`size-10`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:a.displayName}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:a.description||`—`}),(0,Q.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,i.downloads]}),(0,Q.jsx)(Y,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:c?`secondary`:`primary`,disabled:S||c,onClick:()=>void K(()=>dr(e,s,{provider:o}),s),children:c?t.marketplaceInstalled:l?t.installing:t.install})]})]})]},`${o??`default`}:${i.id}`)})}):z?null:(0,Q.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),L&&L.meta.totalPages>1?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(L.meta.page)).replace(`{{total}}`,String(L.meta.totalPages))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:z||F<=1,onClick:()=>I(e=>Math.max(1,e-1)),children:[(0,Q.jsx)(Ft,{className:`size-4`}),t.marketplacePrevious]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:z||F>=L.meta.totalPages,onClick:()=>I(e=>e+1),children:[t.marketplaceNext,(0,Q.jsx)(l,{className:`size-4`})]})]})]}):null]}):(0,Q.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,Q.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:U,onChange:e=>W(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,children:t.close})}),(0,Q.jsx)(Y,{type:`button`,disabled:S||!U.trim(),onClick:()=>void K(()=>fr(e,U.trim())),children:S?t.installing:t.install})]})]})})]})]})}),(0,Q.jsx)(Se,{open:!!A,onOpenChange:e=>{e||j(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:A?.name}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(le,{className:`size-4`})})})]}),(0,Q.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:A?.bodyMarkdown})]})]})})]})}function hr(e){let t=(0,Mn.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,Q.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,Q.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,Q.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,Q.jsxs)(`article`,{className:J(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Qe,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Q.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,Q.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:gr(a,e.origin)}),e.writable?null:(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,Q.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,Q.jsx)(`span`,{className:J(`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:_r(a,t)}):null]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,Q.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,Q.jsx)(kt,{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,Q.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,Q.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=h):h=t[24],h}function gr(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 _r(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 vr(e){let t=(0,Mn.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.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,Q.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,Q.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,Q.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,Q.jsx)(Ne,{asChild:!0,children:(0,Q.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}function yr(e){return{name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``}}function br(e,t,n){let r=yr(t),i=yr(n),a=Object.keys(r).filter(t=>e[t]===r[t]);return{...e,...Object.fromEntries(a.map(e=>[e,i[e]]))}}var xr={active:0,review:1,ready:2,backlog:3,closed:4},Sr={failed:0,blocked:1,waiting:2,verifying:3,running:4,queued:5,cancelled:6,idle:7},Cr={critical:0,high:1,normal:2,low:3};function wr(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=Sr[e.operationalState]-Sr[t.operationalState];if(r!==0)return r;let i=xr[e.phase]-xr[t.phase];if(i!==0)return i;let a=Cr[e.priority]-Cr[t.priority];return a===0?t.updatedAt-e.updatedAt:a}).slice(0,t)}var Tr=[`backlog`,`ready`,`active`,`review`,`closed`];function Er(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 Dr(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 Or(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 kr(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 Ar(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=kr(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 jr(e,t){let{incoming:n}=kr(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 Mr(e,t){let{incoming:n,outgoing:r}=kr(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 Nr={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 Pr(e){let t=(0,Mn.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=Nr[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=J(`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,Q.jsx)(jn,{type:`target`,position:On.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,Q.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,Q.jsx)(it,{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,Q.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,Q.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,Q.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,Q.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,Q.jsx)(jn,{type:`source`,position:On.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,Q.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 Fr={taskNode:Pr};function Ir(e){let t=(0,Mn.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?(_=jr(n,r),t[0]=r,t[1]=n,t[2]=_):_=t[2];let y=_,b;t[3]!==y||t[4]!==u||t[5]!==c||t[6]!==n?(b=u?n.filter(e=>y.has(e.id)):c?n:n.filter(Wr),t[3]=y,t[4]=u,t[5]=c,t[6]=n,t[7]=b):b=t[7];let x=b,S;t[8]===x?S=t[9]:(S=new Set(x.map(Ur)),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=Ar(x,T),t[15]=T,t[16]=x,t[17]=E):E=t[17];let D=E,O;t[18]!==f||t[19]!==T?(O=f?Mr(f,T):void 0,t[18]=f,t[19]=T,t[20]=O):O=t[20];let A=O,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(Hr)),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:Dn.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 V,H;t[45]!==R||t[46]!==m?(V=()=>{m&&!R.some(e=>e.id===m)&&h(void 0)},H=[R,m],t[45]=R,t[46]=m,t[47]=V,t[48]=H):(V=t[47],H=t[48]),(0,Z.useEffect)(V,H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=window.requestAnimationFrame(()=>{g.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=U):U=t[49];let W;t[50]!==u||t[51]!==c||t[52]!==x.length?(W=[u,c,x.length],t[50]=u,t[51]=c,t[52]=x.length,t[53]=W):W=t[53],(0,Z.useEffect)(U,W);let G;t[54]===f?G=t[55]:(G=()=>{f&&g.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=G);let ee=G,K;t[56]!==r||t[57]!==o?(K=e=>{if(!e.source||!e.target||e.source===e.target)return;let t=r.filter(t=>t.dependentTaskId===e.target).map(Vr);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=K):K=t[58];let te=K,ne;t[59]!==r||t[60]!==o||t[61]!==m?(ne=()=>{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(Br)))},t[59]=r,t[60]=o,t[61]=m,t[62]=ne):ne=t[62];let re=ne,ie;t[63]===a.connectHint?ie=t[64]:(ie=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ie);let ae=u?`secondary`:`ghost`,q;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>d(zr),t[65]=q):q=t[65];let oe=u?a.allTasks:a.blockedChains,se;t[66]!==u||t[67]!==ae||t[68]!==oe?(se=(0,Q.jsx)(Y,{type:`button`,variant:ae,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:q,children:oe}),t[66]=u,t[67]=ae,t[68]=oe,t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>l(Rr),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,Q.jsx)(Y,{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,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:ee,children:[(0,Q.jsx)(yt,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,fe;t[75]!==a.removeDependency||t[76]!==re||t[77]!==m?(fe=m?(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:re,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=re,t[77]=m,t[78]=fe):fe=t[78];let pe;t[79]!==se||t[80]!==ue||t[81]!==de||t[82]!==fe?(pe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[se,ue,de,fe]}),t[79]=se,t[80]=ue,t[81]=de,t[82]=fe,t[83]=pe):pe=t[83];let me;t[84]!==ie||t[85]!==pe?(me=(0,Q.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:[ie,pe]}),t[84]=ie,t[85]=pe,t[86]=me):me=t[86];let he=x.length>0?(0,Q.jsxs)(`div`,{className:J(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,M&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,Q.jsxs)(An,{nodes:I,edges:R,nodeTypes:Fr,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>h(t.id),onConnect:te,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,Q.jsx)(X,{color:`var(--color-edge)`,gap:22,size:1}),(0,Q.jsx)(kn,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),M?(0,Q.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[M.phase]}),(0,Q.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:M.title}),M.operationalState===`blocked`&&M.blockedBy.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(M.blockedBy.length))}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:M.blockedBy.map(Lr)})]}):null,(0,Q.jsxs)(s,{to:k(i,M.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,Q.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,Q.jsx)(`div`,{className:`flex min-h-72 items-center justify-center px-6 text-center text-sm text-fg-muted`,children:a.empty}),ge;return t[87]!==me||t[88]!==he?(ge=(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base/40`,children:[me,he]}),t[87]=me,t[88]=he,t[89]=ge):ge=t[89],ge}function Lr(e){return(0,Q.jsx)(`li`,{children:e.title},e.id)}function Rr(e){return!e}function zr(e){return!e}function Br(e){return e.dependencyTaskId}function Vr(e){return e.dependencyTaskId}function Hr(e){return[e.id,e]}function Ur(e){return e.id}function Wr(e){return e.phase!==`closed`}function Gr(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Kr={backlog:h,ready:h,active:Dt,review:qt,closed:m},qr={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 Jr(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===`failed`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-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 Yr(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 Xr(e){let t=(0,Mn.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,f,h,g,_,v,y,b,x,S,C,w,T,E,D;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(g=Or(n),_=g!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,f=n.phase===`closed`,h=!!(n.dueAt&&n.dueAt<Date.now()&&!f),d=f?m:At,y=n.priority!==`normal`,v=y||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,S=!0,t[20]!==c||t[21]!==n.id?(C=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=C):C=t[22],t[23]===c?w=t[24]:(w=()=>c(``),t[23]=c,t[24]=w),T=Qr,t[25]!==l||t[26]!==n.id?(E=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=E):E=t[27],D=`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?(b=k(r,n.id),t[28]=r,t[29]=n.id,t[30]=b):b=t[30],x=J(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_?`pr-19`:g&&`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]=h,t[8]=g,t[9]=_,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]=D):(u=t[4],d=t[5],f=t[6],h=t[7],g=t[8],_=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],E=t[18],D=t[19]);let O=f?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,A;t[31]===O?A=t[32]:(A=J(`mt-0.5 size-4 shrink-0`,O),t[31]=O,t[32]=A);let j;t[33]!==d||t[34]!==A?(j=(0,Q.jsx)(d,{className:A,"aria-hidden":!0}),t[33]=d,t[34]=A,t[35]=j):j=t[35];let M=f?`text-fg-subtle`:`text-fg`,N;t[36]===M?N=t[37]:(N=J(`min-w-0 break-words text-sm font-semibold leading-5`,M),t[36]=M,t[37]=N);let P;t[38]!==N||t[39]!==n.title?(P=(0,Q.jsx)(`h3`,{className:N,children:n.title}),t[38]=N,t[39]=n.title,t[40]=P):P=t[40];let F;t[41]!==j||t[42]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[j,P]}),t[41]=j,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(I=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,Q.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,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Q.jsx)(it,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(Zr).join(`、`)})]}):n.attention[0]?(0,Q.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(p,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Q.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]=I):I=t[48];let L;t[49]!==i||t[50]!==h||t[51]!==v||t[52]!==y||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(L=v?(0,Q.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[y?(0,Q.jsx)(`span`,{className:J(`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,Q.jsx)(`span`,{className:J(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Jr(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,Q.jsx)(`span`,{className:J(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Yr(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,Q.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,Q.jsx)(Dt,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,Q.jsxs)(`span`,{className:J(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,h?`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,Q.jsx)(ln,{className:`size-3`,"aria-hidden":!0}),on(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,Q.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,Q.jsx)(ln,{className:`size-3`,"aria-hidden":!0}),on(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=h,t[51]=v,t[52]=y,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]=L):L=t[59];let R;t[60]!==u||t[61]!==b||t[62]!==F||t[63]!==I||t[64]!==L||t[65]!==x?(R=(0,Q.jsxs)(u,{to:b,className:x,children:[F,I,L]}),t[60]=u,t[61]=b,t[62]=F,t[63]=I,t[64]=L,t[65]=x,t[66]=R):R=t[66];let z;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==g||t[71]!==_||t[72]!==n?(z=g?(0,Q.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:[_?(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,_),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[_],title:i.actions[_],children:(0,Q.jsx)(qt,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,g),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[g],title:i.actions[g],children:(0,Q.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=g,t[71]=_,t[72]=n,t[73]=z):z=t[73];let B;return t[74]!==R||t[75]!==z||t[76]!==S||t[77]!==C||t[78]!==w||t[79]!==T||t[80]!==E||t[81]!==D?(B=(0,Q.jsxs)(`article`,{draggable:S,onDragStart:C,onDragEnd:w,onDragOver:T,onDrop:E,className:D,children:[R,z]}),t[74]=R,t[75]=z,t[76]=S,t[77]=C,t[78]=w,t[79]=T,t[80]=E,t[81]=D,t[82]=B):B=t[82],B}function Zr(e){return e.title}function Qr(e){e.preventDefault(),e.stopPropagation()}function $r({tasks:e,dependencyEdges:t,returnTo:n,copy:r,onAction:i,onReorder:a,onUndoMove:o,onDependenciesChange:s,onCreate:c,actionBusyId:l,ref:f}){let p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(`board`),[C,w]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(()=>crypto.randomUUID()),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(`normal`),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)([]),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(null),H=me(e=>e.language),U=E({chat:ue(H).chat}),W=Er(e),G=e.filter(e=>e.phase!==`closed`),ee=(e,t)=>void i(e,t),K=async(t,n)=>{let r=e.find(e=>e.id===h);if(g(null),!r||r.id===n)return;let o=W[r.phase],s=o.findIndex(e=>e.id===r.id),c=s>=0?o[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=Dr(r,t);r.phase!==t&&!l||l&&!await i(r,l)||await a(r.id,n)&&b({taskId:r.id,phase:r.phase,beforeTaskId:c})},te=async e=>{e.preventDefault();let t=k.trim();if(!(!t||R)){z(!0),V(null);try{let e=P?new Date(`${P}T23:59:59.999`).getTime():void 0;await c({requestId:D,objective:t,priority:j,dependsOnTaskIds:I,attachments:U.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),A(``),M(`normal`),F(``),L([]),U.clearAttachments(),O(crypto.randomUUID()),w(!1)}catch(e){V(e instanceof Error?e.message:r.createFailed)}finally{z(!1)}}},ne=()=>{O(crypto.randomUUID()),A(``),M(`normal`),F(``),L([]),U.clearAttachments(),V(null),w(!0)};(0,Z.useImperativeHandle)(f,()=>({openCreate:ne})),(0,Z.useEffect)(()=>{if(!y)return;let e=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout(e)},[y]);let re=(0,Z.useCallback)(e=>{let t=m.current;!t||t.pointerId!==e.pointerId||(m.current=null,v(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),ie=(0,Z.useCallback)(e=>{if(e.button!==0||Gr(e.target))return;let t=p.current;t&&(m.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),ae=(0,Z.useCallback)(e=>{let t=m.current,n=p.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,v(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,Q.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,Q.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.description})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,Q.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`board`,onClick:()=>S(`board`),className:J(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(cn,{className:`size-3.5`,"aria-hidden":!0}),r.views.board]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`graph`,onClick:()=>S(`graph`),className:J(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),r.views.graph]})]})})]}),x===`board`?(0,Q.jsx)(`div`,{ref:p,className:J(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,_?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:ie,onPointerMove:ae,onPointerUp:re,onPointerCancel:re,onLostPointerCapture:e=>{m.current?.pointerId===e.pointerId&&(m.current=null,v(!1))},children:(0,Q.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:Tr.map(t=>{let i=Kr[t],a=W[t];return(0,Q.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===h);r&&(r.phase===t||Dr(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),K(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-inset/70 p-2.5`,children:[(0,Q.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-1.5 rounded-md px-2 py-1`,qr[t]),children:[(0,Q.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.phases[t]})]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,Q.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,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,Q.jsx)(Xr,{task:e,returnTo:n,copy:r,busy:l===e.id,onAction:ee,onDragStart:g,onDropBefore:e=>void K(t,e)},e.id))})})]},t)})})}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ir,{tasks:e,dependencyEdges:t,returnTo:n,copy:{...r.graph,phases:r.phases},onDependenciesChange:s})}),(0,Q.jsx)(Se,{open:C,onOpenChange:e=>{R||w(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:r.createTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.createDescription})]}),(0,Q.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void te(e),children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:r.objective}),(0,Q.jsxs)(`div`,{className:J(`overflow-hidden rounded-lg border border-edge bg-surface-base transition-colors focus-within:border-accent`,U.isDragging&&`border-accent bg-accent-soft/30`),onDragOver:e=>{e.preventDefault(),R||U.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||U.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),U.setIsDragging(!1),R||U.processFiles(Array.from(e.dataTransfer.files))},children:[(0,Q.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:k,onChange:e=>{A(e.target.value),V(null)},placeholder:r.objectivePlaceholder,maxLength:12e3,disabled:R}),(0,Q.jsx)(T,{attachments:U.attachments,topPadded:!1,onRemove:e=>{R||U.removeAttachment(e)}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:R,onClick:()=>U.fileInputRef.current?.click(),children:[(0,Q.jsx)(tt,{className:`size-3.5`,"aria-hidden":!0}),r.addFiles]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.attachmentsDescription}),(0,Q.jsx)(`input`,{ref:U.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{U.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.priority}),(0,Q.jsx)(u,{value:j,onChange:e=>M(e.target.value),disabled:R,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,Q.jsx)(d,{value:e,children:r.priorityOptions[e]},e))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[r.dueDate,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(bn,{className:`min-h-10 bg-surface-base`,value:P,onChange:F,disabled:R,ariaLabel:r.dueDate})]})]}),(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[r.dependencies,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:r.dependenciesDescription}),(0,Q.jsx)(En,{candidates:G,selectedIds:I,disabled:R,onChange:L,labels:{link:r.linkDependencies,linked:r.linkedDependencies,searchPlaceholder:r.dependencySearchPlaceholder,noMatches:r.noDependencyMatches,noCandidates:r.noDependencyCandidates,remove:r.removeDependency}})]}),B?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:B}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:R,children:r.cancel})}),(0,Q.jsx)(Y,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:R||!k.trim(),children:R?r.creating:H===`zh`?`保存待安排任务`:`Save for later`})]})]})]})]})}),y?(0,Q.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,Q.jsx)(`span`,{children:r.moved}),(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=y;b(null),o(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||b(e)})},children:r.undo})]}):null]})}var ei=new Set([{id:`overview`,icon:ft},{id:`tasks`,icon:Xt},{id:`automations`,icon:Ct},{id:`files`,icon:Ke},{id:`notes`,icon:x},{id:`skills`,icon:ae},{id:`sessions`,icon:G},{id:`progress`,icon:st},{id:`settings`,icon:Gt}].map(e=>e.id)),ti=`xopc.projectFiles.panelWidthPx`,ni=320,ri=220,ii=560;function ai(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 oi(e){return Math.min(ii,Math.max(ri,Math.round(e)))}function si(){try{let e=window.localStorage.getItem(ti);if(e==null)return ni;let t=Number.parseInt(e,10);return Number.isFinite(t)?oi(t):ni}catch{return ni}}function ci(e){try{window.localStorage.setItem(ti,String(oi(e)))}catch{}}function li(e){return!!(e&&ei.has(e))}function ui(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function di(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):on(n)}function fi(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-inset text-fg-subtle`:`bg-surface-hover text-fg-muted`}function pi(e){let t=(0,Mn.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.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,Q.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,Q.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 mi(e=!1){return J(`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 hi(e){let t=(0,Mn.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Q.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=J(`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,Q.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,Q.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 gi(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function _i(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function vi(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function yi(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function bi(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.conversationId?t.conversationId:t.kind}function xi(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Si(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 Ci(e){let t=e.sourceChannel?.trim();return t?wi(t):``}function wi(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function Ti(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 Ei(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 Di(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Di(e.children,t,n)}:e)}function Oi({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([e]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`new`),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!0),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),N=(0,Z.useCallback)(async()=>{m(!0),g(null);try{let t=await Ot({limit:100});u(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){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,Z.useEffect)(()=>{u(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,Z.useEffect)(()=>{o&&N()},[N,o]);let P=(0,Z.useMemo)(()=>{let t=d.trim().toLowerCase().split(/\s+/).filter(Boolean);return l.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=gi(e);return t.every(e=>n.includes(e))}).sort((e,t)=>_i(t)-_i(e))},[e.id,l,d]),F=e=>t.statuses[e.status]??e.status,I=e=>e.description||e.brief||t.common.defaultWorkspace,L=e=>{b(e),S(``),w(``),A(null),v(!0),s(!1)},R=(0,Z.useCallback)(async(e={})=>{let t=C.trim(),n=x.trim()||(y===`directory`?vi(t):``);if(n){E(!0),A(null),M(null);try{let r=await jt({autoUnderstand:D,name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});v(!1),S(``),w(``),O(!0),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:r.id}})),u(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=yi(e);t?(M(t),v(!1)):A(e instanceof Error?e.message:String(e))}finally{E(!1)}}},[y,x,a,C,D]),z=(0,Z.useCallback)(e=>{e.preventDefault(),R()},[R]),B=(0,Z.useCallback)(()=>{R({createWorkspaceRoot:!0})},[R]),V=(0,Z.useCallback)(()=>{M(null),v(!0)},[]),H=e=>{w(e),y===`directory`&&!x.trim()&&S(vi(e))},U=(e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`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,Q.jsx)(c,{className:J(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:I(e)})]}),(0,Q.jsx)(`span`,{className:J(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:F(e)})]},e.id);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Me,{open:o,onOpenChange:s,children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.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,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:J(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:F(e)})]}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:I(e)})]}),(0,Q.jsx)(Tt,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,Q.jsx)(Ae,{children:(0,Q.jsxs)(je,{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,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.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:d,onChange:e=>f(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,Q.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),U(e,!0),(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),h?(0,Q.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:h}):null,p&&P.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!p&&P.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,P.map(e=>U(e,!1))]}),(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,Q.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:()=>L(`new`),children:[(0,Q.jsx)(ne,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,Q.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:()=>L(`directory`),children:[(0,Q.jsx)(Ke,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,Q.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,Q.jsx)(Gt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,Q.jsx)(Se,{open:_,onOpenChange:e=>!T&&v(e),children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:y===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm text-fg-muted`,children:y===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,Q.jsxs)(`form`,{onSubmit:z,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[k?(0,Q.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:k}):null,(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,Q.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:x,onChange:e=>S(e.target.value),placeholder:`xopc`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,Q.jsx)(gn,{value:C,onChange:H,disabled:T,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,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]}),(0,Q.jsx)(Jt,{checked:D,onChange:O,disabled:T})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:T,children:n.cancel})}),(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:T||!(x.trim()||y===`directory`&&vi(C)),children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,Q.jsx)(Se,{open:!!j,onOpenChange:e=>{e||M(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:j?ui(n.workspaceMissingDescription,{workspace:j}):null})]}),j?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(Ke,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:j})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:V,disabled:T,children:n.workspaceMissingBack}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:B,disabled:T,children:[(0,Q.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function ki(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),[c]=a(),l=me(e=>e.language),f=ue(l),m=f.chat.workingDirectory,h=f.projectDetailPage,_=f.projectsPage,v=nt(e=>e.setPageHeader),T=nt(e=>e.clearPageHeader),[E,P]=(0,Z.useState)(null),F=(0,Z.useRef)(E);(0,Z.useLayoutEffect)(()=>{F.current=E},[E]);let[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)([]),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)([]),[W,ee]=(0,Z.useState)(0),[K,te]=(0,Z.useState)(!1),[de,fe]=(0,Z.useState)(!1),[pe,he]=(0,Z.useState)(!1),[Ee,ke]=(0,Z.useState)([]),[Ae,je]=(0,Z.useState)(null),Me=(0,Z.useRef)(new Set),[Ne,Pe]=(0,Z.useState)(null),[Ie,We]=(0,Z.useState)(null),[Ge,Je]=(0,Z.useState)(null),[Ye,Ze]=(0,Z.useState)(si),[et,tt]=(0,Z.useState)(!1),[rt,it]=(0,Z.useState)(!1),[ct,dt]=(0,Z.useState)(``),[mt,ht]=(0,Z.useState)([]),[yt,bt]=(0,Z.useState)(!1),[xt,wt]=(0,Z.useState)(null),[Tt,Dt]=(0,Z.useState)(!1),[Ot,At]=(0,Z.useState)(null),[jt,Ft]=(0,Z.useState)([]),[Lt,zt]=(0,Z.useState)(``),[Bt,Vt]=(0,Z.useState)(!0),[Ht,Ut]=(0,Z.useState)(!1),[Wt,qt]=(0,Z.useState)(!1),[Jt,tn]=(0,Z.useState)(null),[rn,on]=(0,Z.useState)(!1),[cn,ln]=(0,Z.useState)(`fixed`),[dn,_n]=(0,Z.useState)(``),[vn,yn]=(0,Z.useState)(null),[bn,Sn]=(0,Z.useState)(!1),[Cn,wn]=(0,Z.useState)(!1),[Tn,En]=(0,Z.useState)(!1),[Dn,On]=(0,Z.useState)(null),kn=(0,Z.useRef)(null),An=(0,Z.useRef)(!1),[jn,X]=(0,Z.useState)(null),[Mn,Nn]=(0,Z.useState)({title:``,reason:``}),[Pn,Fn]=(0,Z.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),In=(0,Z.useRef)(Pn),Ln=`overview`,$=n?`notes`:li(t)?t:Ln,Rn=(0,Z.useMemo)(()=>A(c.get(`returnTo`),`/projects`,[`/chat`]),[c]),zn=(0,Z.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Rn===`/projects`?n:j(n,Rn)},[Rn,e]),Bn=(0,Z.useCallback)(t=>{e&&r(zn(t))},[r,e,zn]),Vn=(0,Z.useCallback)(()=>{if($===`tasks`&&kn.current){kn.current.openCreate();return}An.current=!0,Bn(`tasks`)},[Bn,$]);(0,Z.useEffect)(()=>{$!==`tasks`||!An.current||(An.current=!1,kn.current?.openCreate())},[$]);let Hn=(0,Z.useCallback)(t=>{e&&r(zn(t),{replace:!0})},[r,e,zn]),Un=(0,Z.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||Hn(e)},[Hn]),Wn=(0,Z.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,Z.useEffect)(()=>{!e||!t||li(t)||r(zn(Ln),{replace:!0})},[Ln,r,e,zn,t]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return Vt(!0),X(null),Promise.all([Kt(e),Et(e),un(e),Oe().catch(()=>null),nn(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;P(e),L(n),z(r),je(a),Ft(i?.agents??[]),zt(e.defaultAgentId??``);let o=yr(e);In.current=o,Fn(o)}).catch(e=>{t||(je(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Vt(!1)}),()=>{t=!0}},[e]);let Gn=(0,Z.useCallback)(async()=>{e&&L(await Et(e))},[e]);(0,Z.useEffect)(()=>{if(Bt)return;let t=!0,n=0,r=r=>{let i=r.detail?.id;if(!e||i&&i!==e)return;let a=++n;Promise.all([Kt(e),Et(e)]).then(([e,r])=>{if(!t||n!==a)return;let i=F.current;if(!(i?.id===e.id&&i.version>e.version)){if(i?.id===e.id){let t=br(In.current,i,e);In.current=t,Fn(t)}F.current=e,P(e),L(r)}}).catch(e=>{!t||n!==a||e instanceof Error&&`status`in e&&e.status===404&&(P(null),L(null),X(e.message))})};return window.addEventListener(`project-resource-changed`,r),r(new Event(`project-resource-changed`)),()=>{t=!1,window.removeEventListener(`project-resource-changed`,r)}},[e,Bt]),(0,Z.useEffect)(()=>{let t,n=n=>{let r=we.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),120))},r=n=>{let r=Ce.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),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,Gn]);let Kn=(0,Z.useCallback)(async(e,t)=>{On(e.id),X(null);try{let n=await S(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 O(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 w(e.id,r,n.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[I,h.board.actionFailed,Gn]),qn=(0,Z.useCallback)(async t=>{e&&(X(null),await C({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 Gn())},[l,e,Gn]),Jn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{return await y(e,t,(await S(e)).task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Yn=(0,Z.useCallback)(async(e,t,n)=>{On(e),X(null);try{let r=await S(e);return r.task.phase!==t&&(r=await w(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 y(e,n,r.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Xn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{await b(e,t,(await S(e)).task.version),await Gn()}catch(e){await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed)}finally{On(null)}},[h.board.actionFailed,Gn]),Zn=(0,Z.useCallback)(async()=>{if(E){te(!0),X(null);try{let e=await Rt(E.id,{includeRelated:de,limit:100});U(e.items),ee(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{te(!1)}}},[E,de]);(0,Z.useEffect)(()=>{$===`progress`&&Zn()},[Zn,$]);let Qn=(0,Z.useCallback)(async()=>{if(!E?.effectiveWorkspaceRoot?.trim()){ke([]),Me.current.clear(),At(null);return}Dt(!0),At(null),Me.current.clear();try{ke(Ei((await It(E.id,``)).entries)),Me.current.add(``)}catch(e){ke([]),Me.current.clear(),At(e instanceof Error?e.message:String(e))}finally{Dt(!1)}},[E]),$n=(0,Z.useCallback)(async e=>{if(!(!E?.effectiveWorkspaceRoot?.trim()||Me.current.has(e))){Me.current.add(e),At(null);try{let t=await It(E.id,e);ke(n=>Di(n,e,Ei(t.entries)))}catch(t){Me.current.delete(e),At(t instanceof Error?t.message:String(t))}}},[E]),er=(0,Z.useCallback)(async e=>{if(!E?.effectiveWorkspaceRoot?.trim())return;let t=Ei((await It(E.id,e)).entries);ke(e?n=>Di(n,e,t):t),Me.current.add(e)},[E]);(0,Z.useEffect)(()=>{$===`files`&&Qn()},[Qn,$]);let tr=ct.trim();(0,Z.useEffect)(()=>{if($!==`files`||!E||!rt||!tr){ht([]),bt(!1),wt(null);return}let e=!1;bt(!0),wt(null),ht([]);let t=window.setTimeout(()=>{an(E.id,tr,50).then(t=>{e||ht(t)}).catch(t=>{e||wt(t instanceof Error?t.message:String(t))}).finally(()=>{e||bt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[tr,E,rt,$]);let nr=(0,Z.useCallback)(async()=>{if(!E)return;let[e,t]=await Promise.all([Kt(E.id),Et(E.id)]);L(t),P(e)},[E]),rr=(0,Z.useCallback)(async e=>{if(e.preventDefault(),!(!E||!Mn.title.trim())){wn(!0),X(null);try{await Pt(E.id,{title:Mn.title.trim(),reason:Mn.reason.trim()||void 0}),Nn({title:``,reason:``}),En(!1),await nr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{wn(!1)}}},[Mn.reason,Mn.title,E,nr]),ir=(0,Z.useMemo)(()=>(0,Q.jsx)(s,{to:Rn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Rn===`/projects`?h.backToProjects:f.sidebar.back,children:(0,Q.jsx)(at,{className:`size-4`,"aria-hidden":!0})}),[Rn,f.sidebar.back,h.backToProjects]),ar=(0,Z.useMemo)(()=>E?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hn,{resource:{kind:`project`,id:E.id,revision:String(E.version)},disabled:Ht||ai(Pn,E)}),(0,Q.jsx)(Y,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(E.id)}`,children:[(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":!0}),h.common.runWorkflow]})}),(0,Q.jsxs)(Y,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Vn,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),h.board.create]}),(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:D(E.id),state:{forceNewChat:!0,agentId:E.defaultAgentId},onClick:Un(`sessions`),children:[(0,Q.jsx)(G,{className:`size-4`,"aria-hidden":!0}),h.common.newChat]})})]}):null,[Vn,Un,h.board.create,h.common.newChat,h.common.runWorkflow,E,Ht,Pn]);(0,Z.useLayoutEffect)(()=>(v({startExtra:ir,main:E?(0,Q.jsx)(Oi,{currentProject:E,pm:h,projectsText:_,wd:m}):(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:h.fallbackTitle}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.fallbackContext})]}),end:ar}),()=>T()),[T,ar,ir,h,E,_,v,m]);function sr(e){P(t=>t?{...t,...e}:null),zt(e.defaultAgentId??``),nn(e.id).then(je).catch(()=>je(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function cr(e=In.current){if(!(!E||!ai(e,E))){X(null),tn(null);try{let t=await Xe(E.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions},E.version);sr(t);let n=In.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};In.current=r,Fn(r)}catch(e){let t=yi(e);throw t?tn(t):X(e instanceof Error?e.message:String(e)),e}}}function lr(e){e.preventDefault(),kr.flush()}function ur(e,t=!1){let n={...In.current,...e};In.current=n,Fn(n),t&&kr.saveNow(n)}let dr=(0,Z.useCallback)(()=>{if(!E)return;let e=E.workspaceRoot?.trim()??``;ln(e?`fixed`:`follow`),_n(e||E.effectiveWorkspaceRoot||``),on(!0)},[E]);async function fr(e={}){if(!E)return;let t=cn===`fixed`?dn.trim():``;if(!(cn===`fixed`&&!t)){Ut(!0),X(null),tn(null);try{let n=await Xe(E.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}},E.version);sr(n),ur({workspaceRoot:n.workspaceRoot??``}),on(!1),tn(null)}catch(e){let t=yi(e);t?(tn(t),on(!1)):X(e instanceof Error?e.message:String(e))}finally{Ut(!1)}}}async function pr(){if(!(!E||vn)){yn(`pin`),X(null);try{sr(E.pinnedAt?await pt(E.id,E.version):await sn(E.id,E.version))}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function hr(){if(!(!E||vn)){yn(`archive`),X(null);try{let e=E.status===`archived`?await ut(E.id,E.version):await en(E.id,E.version);sr(e),ur({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function gr(){if(E){Sn(!0),X(null);try{await Yt(E.id,E.version),qt(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Sn(!1)}}}async function _r(){if(!(!E||pe)){he(!0),X(null);try{await qe(E.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{he(!1)}}}let vr=(0,Z.useCallback)(e=>{Pe(e)},[]),xr=(0,Z.useCallback)((e,t)=>{t||Pe(e)},[]),Sr=(0,Z.useCallback)(async(e,t,n)=>{let r=E?.id;if(r)switch(e){case`preview`:t.isDirectory||Pe(t.path);break;case`download`:if(t.isDirectory)return;try{let e=q(t.path);if(se(ce(e))!==`text`){let n=await Le(t.path,{projectId:r}),i=De(e)??`application/octet-stream`;ze(e,await n.arrayBuffer(),i)}else{let{content:n}=await Re(t.path,{projectId:r});Ve(e,n)}}catch(e){oe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await Te(t.path)&&oe(`success`,f.workspace.pathCopied,void 0,{duration:2500})}catch{oe(`warning`,f.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await lt(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWith`:await lt(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await lt(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),f.workspace.openFileFailed);break;case`revealInFolder`:await lt(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),f.workspace.revealFileFailed);break;case`trash`:We(t);break;case`delete`:t.isDirectory||Je(t);break;default:break}},[f.clipboard.copyFailed,f.workspace.openFileFailed,f.workspace.pathCopied,f.workspace.revealFileFailed,E?.id]),Cr=(0,Z.useCallback)(async()=>{let e=Ie;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){oe(`warning`,t?.error??f.workspace.trashFailed,void 0,{duration:4e3});return}Ne===e.path&&Pe(null),We(null),await Qn(),oe(`success`,f.workspace.trashSuccess,void 0,{duration:2500})},[f.workspace.trashFailed,f.workspace.trashSuccess,Ie,Ne,Qn]),Tr=(0,Z.useCallback)(async(e,t)=>{let n=E?.id;if(n)try{await Promise.all(e.map(e=>Be(e,t,{projectId:n}))),await er(t).catch(()=>void 0),oe(`success`,f.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await er(t).catch(()=>void 0),oe(`warning`,`${f.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.uploadFailed,f.workspace.uploadSuccess,E?.id,er]),Er=(0,Z.useCallback)(async()=>{let e=Ge;if(e)try{await He(e.fileId),Ne===e.path&&Pe(null),Je(null);let t=e.path.lastIndexOf(`/`);await er(t<0?``:e.path.slice(0,t)).catch(()=>void 0),oe(`success`,f.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){oe(`warning`,`${f.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.deleteFailed,f.workspace.deleteSuccess,Ge,Ne,er]),Dr=(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),tt(!0);let r=e.clientX,i=Ye,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=oi(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}tt(!1),Ze(c),ci(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)},[Ye]);(0,Z.useEffect)(()=>{$!==`files`&&Pe(null)},[e,$]);let Or=!!(E&&ai(Pn,E)),kr=mn({value:E?Pn:null,dirty:Or,onSave:cr,validate:e=>e.name.trim()?null:h.settings.nameRequired});if(Bt)return(0,Q.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:h.loading});if(!E)return(0,Q.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,Q.jsxs)(s,{to:Rn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,Q.jsx)(at,{className:`size-4`,"aria-hidden":!0}),Rn===`/projects`?h.backToProjects:f.sidebar.back]}),(0,Q.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:jn||h.notFound})]});let Ar=R.slice(0,3),jr=I?.blockers??[],Mr=wr(I?.tasks??[]),Nr=I?.tasks.filter(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)).length??0,Pr=e=>h.statuses[e]??e,Fr=e=>ui(h.common.messages,{count:e}),Ir=B.trim().toLowerCase(),Lr=Ir?R.filter(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=e.name?.trim()||h.sessions.fallbackTitle,i=Fr(e.messageCount??0),a=Ci(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Ir)}):R,Rr=R.length>0&&Lr.length===0,zr=jt.find(e=>e.id===E.defaultAgentId)?.name||E.defaultAgentId||h.settings.globalDefaultAgent,Br=jt.find(e=>e.id===Pn.defaultAgentId),Vr=E.workspaceRoot?.trim()||``,Hr=E.status===`archived`,Ur=!!E.pinnedAt,Wr=!Vr,Gr=Vr||Br?.workspace||E.effectiveWorkspaceRoot||h.common.defaultWorkspace,Kr=cn===`fixed`?dn.trim()||h.settings.workspacePlaceholder:Br?.workspace||E.effectiveWorkspaceRoot||h.common.defaultWorkspace,qr=(cn===`fixed`?dn.trim():``)!==Vr&&(cn===`follow`||!!dn.trim()),Jr=[{id:`overview`,icon:ft,label:h.tabs.overview},{id:`tasks`,icon:Xt,label:h.tabs.tasks},{id:`automations`,icon:Ct,label:h.tabs.automations},{id:`files`,icon:Ke,label:h.tabs.files},{id:`notes`,icon:x,label:h.tabs.notes},{id:`skills`,icon:ae,label:h.tabs.skills},{id:`sessions`,icon:G,label:h.tabs.sessions},{id:`progress`,icon:st,label:h.tabs.progress}];async function Yr(){if(!Gr)return;let e=await Te(Gr);oe(e?`success`:`warning`,e?f.workspace.pathCopied:f.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function Xr(){tn(null),on(!0)}return(0,Q.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,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,Q.jsx)(fn,{items:Jr,activeTab:$,onChange:Bn,ariaLabel:h.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,Q.jsxs)(Y,{id:`project-primary-tab-settings`,type:`button`,variant:$===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":$===`settings`?`page`:void 0,onClick:()=>Bn(`settings`),children:[(0,Q.jsx)(Gt,{className:`size-4`,"aria-hidden":!0}),h.tabs.settings,Or?(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":h.settings.unsavedChanges}):null]})]}),jn?(0,Q.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:jn}):null,(0,Q.jsxs)(`div`,{className:J(`mt-3 min-h-0 flex-1`,$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:$===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,Q.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,Q.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,Q.jsx)(Qt,{projectId:E.id},E.id),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[(0,Q.jsx)(`div`,{className:`p-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.directionTitle}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:ui(h.overview.activitySummary,{moving:Nr,attention:jr.length})})]}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-3xl text-base font-medium leading-7 text-fg`,children:E.outcome||E.description||E.brief||h.overview.directionFallback}),I?.digest.recommendedAction?(0,Q.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:ui(h.overview.recommendedNext,{action:I.digest.recommendedAction})}):null]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,onClick:()=>void _r(),disabled:pe,children:[(0,Q.jsx)(ot,{className:`size-3.5`,"aria-hidden":!0}),pe?h.overview.savingDigest:h.overview.saveDigest]})]})}),(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3.5`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.nextActions}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted transition-colors hover:text-fg`,onClick:()=>Bn(`tasks`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle`,children:Mr.length?Mr.map(e=>(0,Q.jsxs)(s,{to:k(zn(`overview`),e.id),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsxs)(`span`,{className:J(`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:[h.board.phases[e.phase],e.operationalState===`idle`?``:` · ${h.board.operationalStates[e.operationalState]}`]})]}),e.attention[0]?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noNextActions})})]})]}),I?.recentResults.length?(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.recentResults})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:I.recentResults.slice(0,3).map(({taskId:e,taskTitle:t,receipt:n})=>(0,Q.jsxs)(s,{to:k(zn(`overview`),e),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[h.overview.resultStatuses[n.status],` · `,h.board.verification[n.verification.status]]})]}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-5 text-fg-muted`,children:(0,Q.jsx)(M,{content:n.summary,compact:!0})})]},n.runId))})]}):null,E.milestones.length||E.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[E.milestones.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.milestones})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:E.milestones.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:h.statuses[e.status]})]},e.id))})]}):null,E.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.projectUpdates})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:E.recentUpdates.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.overview.healthLabels[e.health]})]},e.id))})]}):null]}):null]}),(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.attention}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,"aria-expanded":Tn,onClick:()=>En(e=>!e),children:[(0,Q.jsx)(ne,{className:J(`size-3.5 transition-transform`,Tn&&`rotate-45`),"aria-hidden":!0}),h.overview.addBlocker]})]}),jr.length?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3`,children:jr.map(e=>{let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(p,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,Q.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[h.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${Pr(e.status)}`:``]})]});return e.href?(0,Q.jsx)(s,{to:e.href,onClick:Un(Wn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,Q.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.overview.noBlockedTasks}),Tn?(0,Q.jsxs)(`form`,{onSubmit:rr,className:`mt-4 flex gap-2 border-t border-edge-subtle pt-4`,children:[(0,Q.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:Mn.title,onChange:e=>Nn(t=>({...t,title:e.target.value})),placeholder:h.overview.blockerTitlePlaceholder}),(0,Q.jsx)(Y,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:Cn||!Mn.title.trim(),"aria-label":Cn?h.overview.addingBlocker:h.overview.addBlocker,title:Cn?h.overview.addingBlocker:h.overview.addBlocker,children:(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})]}):null]}),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Zt,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:h.overview.recentSessions})]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Bn(`sessions`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ar.length?Ar.map(e=>(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:di(e.updatedAt)})]}),(e.routing?.agentId||e.agentId)&&(e.routing?.agentId||e.agentId)!==E.defaultAgentId?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.routing?.agentId||e.agentId}):null]},e.key)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noSessions})})]})]})]}):null,$===`tasks`?(0,Q.jsx)($r,{ref:kn,tasks:I?.tasks??[],dependencyEdges:I?.dependencyEdges??[],returnTo:zn(`tasks`),copy:h.board,onAction:Kn,onReorder:Jn,onUndoMove:Yn,onDependenciesChange:Xn,onCreate:qn,actionBusyId:Dn}):null,$===`automations`?(0,Q.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,Q.jsx)(xn,{projectId:E.id,embedded:!0,title:h.automations.title,subtitle:h.automations.hint})}):null,$===`notes`?(0,Q.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,Q.jsx)(or,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(E.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:E.id,listTitle:h.notes.title,listDescription:h.notes.hint,emptyText:h.notes.emptyTitle,emptyDescription:h.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${E.id}`})}):null,$===`skills`?(0,Q.jsx)(mr,{projectId:E.id,copy:h.skills}):null,$===`files`?(0,Q.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,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl bg-surface-panel`,children:E.effectiveWorkspaceRoot?(0,Q.jsxs)(`div`,{"data-project-files-grid":!0,className:J(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_8px_minmax(0,1fr)]`,et&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${Ye}px`},children:[(0,Q.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge bg-surface-panel lg:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-1 bg-surface-hover/30 px-3 text-sm`,children:[Ae?(0,Q.jsx)(St,{resourceId:Ae.fileId,displayName:Ae.name}):null,(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:J(`inline-flex size-7 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,rt&&`bg-surface-hover text-fg`),onClick:()=>it(!0),"aria-label":h.files.search,title:h.files.search,"aria-pressed":rt,children:(0,Q.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(Nt,{className:`size-7 shrink-0 rounded-md p-0`,loading:Tt,label:f.cron.refresh,onClick:()=>void Qn()})]})]}),rt?(0,Q.jsx)(`div`,{className:`shrink-0 bg-surface-hover/20 px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md bg-surface-base px-2 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,Q.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`text`,role:`searchbox`,value:ct,onChange:e=>dt(e.target.value),placeholder:h.files.searchPlaceholder,"aria-label":h.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,Q.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":h.files.clearSearch,title:h.files.clearSearch,onClick:()=>{dt(``),it(!1)},children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Ot?(0,Q.jsx)(`div`,{className:`bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Ot}):null,tr?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:yt?(0,Q.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,Q.jsx)(Fe,{className:`h-11 w-full`}),(0,Q.jsx)(Fe,{className:`h-11 w-full`}),(0,Q.jsx)(Fe,{className:`h-11 w-full`})]}):xt?(0,Q.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[f.workspace.loadError,`: `,xt]}):mt.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:h.files.noSearchResults}):mt.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Ne===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Pe(e.path),title:e.path,children:[(0,Q.jsx)(x,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):Tt&&Ee.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.files.loading}):(0,Q.jsx)(Ue,{tree:Ee,selectedPath:Ne,onSelectFile:vr,onSelectEntry:xr,onExpandDir:e=>void $n(e),onAction:Sr,onUploadFiles:(e,t)=>void Tr(e,t),uploadDropHint:f.workspace.dropToUpload,actionLabels:{preview:f.workspace.preview,download:f.workspace.download,copyPath:f.workspace.copyPath,openDefault:f.workspace.openSystemApp,openDirectory:f.workspace.openInFileManager,openWith:f.workspace.openWith,revealInFolder:f.workspace.revealInFolder,trash:f.workspace.moveToTrash,delete:f.workspace.deleteFile,recommendedApps:f.workspace.recommendedApps,desktopUpdateRequired:f.workspace.desktopUpdateRequired},emptyHint:h.files.emptyDirectory})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.files.resizeHandle,className:J(`group hidden cursor-col-resize touch-none items-stretch justify-center bg-transparent transition-colors hover:bg-surface-hover/60 lg:flex`,et&&`bg-surface-hover/70`),onPointerDown:Dr,children:(0,Q.jsx)(`div`,{className:J(`my-3 w-px rounded-full bg-transparent transition-colors`,`group-hover:bg-edge-strong/55`,et&&`bg-accent/60`)})}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Ne?(0,Q.jsx)(_t,{filePath:Ne,projectId:E.id,agentId:E.defaultAgentId||Lt||void 0,onClose:()=>Pe(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(Ke,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:h.files.previewEmptyTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.files.previewEmptyDescription})]})})})]}):(0,Q.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:h.files.needWorkspace}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Bn(`settings`),children:h.files.openSettings})})]})})}):null,$===`sessions`?(0,Q.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[R.length?(0,Q.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,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:B,onChange:e=>V(e.currentTarget.value),placeholder:h.sessions.searchPlaceholder,"aria-label":h.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`}),B?(0,Q.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":h.sessions.clearSearch,onClick:()=>V(``),children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Lr.length?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Lr.map(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=Ci(e),i=e.name?.trim()||h.sessions.fallbackTitle,a=Fr(e.messageCount??0);return(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`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,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.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,Q.jsx)(G,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,Q.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,Q.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.agent,`: `,n]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,Q.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.updated,`: `,t]}):null]})]},e.key)})}):Rr?(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.noMatches})}):(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.emptyTitle}),(0,Q.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:h.sessions.emptyDescription})]})})]}):null,$===`progress`?(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.progress.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ui(h.progress.count,{count:W})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.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,Q.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),h.progress.includeRelated]}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Zn(),disabled:K,children:[(0,Q.jsx)(re,{className:J(`size-4`,K&&`animate-spin`),"aria-hidden":!0}),h.common.refresh]})]})]}),(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:K&&H.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.loading}):H.length?(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:H.map(e=>{let t=h.progress.types[e.type]??e.type,n=h.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Ti(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===E.id);return(0,Q.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:h.progress.related}):null]}),(0,Q.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,xi(e)]})]}),(0,Q.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:di(e.createdAt)})]}),r?(0,Q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[h.progress.actor,`: `,bi(e)]}),(0,Q.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.progress.source,`: `,Si(e)]})]})]},e.id)})}):(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.empty})})]}):null,$===`settings`?(0,Q.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:lr,onBlurCapture:kr.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,Q.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.summaryTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:h.settings.summaryHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,Q.jsx)(`span`,{className:J(`rounded-full px-2 py-0.5 text-xs font-medium`,fi(Pn.status)),children:h.settings.statuses[Pn.status]}),(0,Q.jsx)(pn,{status:kr.status,error:kr.error})]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.detailsTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.detailsHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(pi,{label:h.settings.name,children:(0,Q.jsx)(`input`,{className:mi(),value:Pn.name,onChange:e=>ur({name:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.defaultAgent,children:(0,Q.jsxs)(u,{className:mi(),value:Pn.defaultAgentId,onChange:e=>ur({defaultAgentId:e.target.value},!0),children:[(0,Q.jsx)(d,{value:``,children:h.settings.globalDefaultAgent}),jt.map(e=>(0,Q.jsx)(d,{value:e.id,children:Mt(e,f.agentsSettings)},e.id))]})}),(0,Q.jsx)(pi,{label:h.settings.status,children:Hr?(0,Q.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-inset px-3 text-sm text-fg-muted`,children:h.settings.statuses.archived}):(0,Q.jsxs)(u,{className:mi(),value:Pn.status===`archived`?`active`:Pn.status,onChange:e=>ur({status:e.target.value},!0),children:[(0,Q.jsx)(d,{value:`active`,children:h.settings.statuses.active}),(0,Q.jsx)(d,{value:`paused`,children:h.settings.statuses.paused})]})}),(0,Q.jsx)(pi,{label:h.settings.executionMode,hint:h.settings.executionModeHint,children:(0,Q.jsxs)(u,{className:mi(),value:Pn.executionMode,onChange:e=>ur({executionMode:e.target.value},!0),children:[(0,Q.jsx)(d,{value:`managed_worktree`,children:h.settings.executionModeWorktree}),(0,Q.jsx)(d,{value:`local_checkout`,children:h.settings.executionModeLocal})]})}),(0,Q.jsx)(pi,{label:h.settings.description,hint:h.settings.descriptionHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.description,onChange:e=>ur({description:e.target.value})})})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.projectGuidanceTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.projectGuidanceHint})]}),(0,Q.jsx)(pi,{label:h.settings.brief,hint:h.settings.briefHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.brief,onChange:e=>ur({brief:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.instructions,hint:h.settings.instructionsHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.instructions,onChange:e=>ur({instructions:e.target.value})})})]})]}),(0,Q.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.workspaceRoot}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceIndependentHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`span`,{className:`w-fit rounded-md bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Wr?h.settings.workspaceModeFollow:h.settings.workspaceModeFixed}),(0,Q.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Gr,children:Gr}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void Yr(),children:[(0,Q.jsx)(g,{className:`size-4`,"aria-hidden":!0}),h.settings.copyWorkspacePath]}),Ae?(0,Q.jsx)(St,{resourceId:Ae.fileId,displayName:Ae.name}):null,(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:dr,children:[(0,Q.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),h.settings.migrateWorkspace]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.currentProjectTitle}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.defaultAgent,value:zr}),(0,Q.jsx)(hi,{label:h.settings.pinState,value:Ur?h.settings.pinned:h.settings.notPinned}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.createdAt,value:di(E.createdAt)||h.common.never}),(0,Q.jsx)(hi,{label:h.settings.updatedAt,value:di(E.updatedAt)||h.common.never})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.managementTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.managementHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Ur?h.settings.pinnedTitle:h.settings.pinTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.pinHint})]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`pin`,onClick:()=>void pr(),children:[Ur?(0,Q.jsx)(vt,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)($e,{className:`size-4`,"aria-hidden":!0}),Ur?h.settings.unpinProject:h.settings.pinProject]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Hr?h.settings.restoreTitle:h.settings.archiveTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:Hr?h.settings.restoreHint:h.settings.archiveHint})]}),(0,Q.jsxs)(Y,{type:`button`,variant:Hr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`archive`,onClick:()=>void hr(),children:[Hr?(0,Q.jsx)(re,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(Qe,{className:`size-4`,"aria-hidden":!0}),Hr?h.settings.restoreProject:h.settings.archiveProject]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:h.settings.dangerTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:h.settings.dangerHint})]}),(0,Q.jsxs)(Y,{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:()=>qt(!0),children:[(0,Q.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,Q.jsx)(Se,{open:Wt,onOpenChange:e=>{bn||qt(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay p-5 shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.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,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.deleteConfirmTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:E?ui(h.settings.deleteConfirm,{name:E.name}):h.settings.deleteConfirmFallback})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:bn,children:h.common.cancel})}),(0,Q.jsxs)(Y,{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:bn||!E,onClick:()=>void gr(),children:[(0,Q.jsx)(kt,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})}),(0,Q.jsx)($t,{open:!!Ie,title:f.workspace.trashConfirmTitle,description:f.workspace.trashConfirmDescription.replace(`{{name}}`,Ie?.name??``),confirmLabel:f.workspace.moveToTrash,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Cr(),onCancel:()=>We(null)}),(0,Q.jsx)($t,{open:!!Ge,title:f.workspace.deleteConfirmTitle,description:f.workspace.deleteConfirmDescription.replace(`{{name}}`,Ge?.name??``),confirmLabel:f.workspace.deleteFile,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Er(),onCancel:()=>Je(null)}),(0,Q.jsx)(Se,{open:rn,onOpenChange:e=>{Ht||on(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMigrationTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.workspaceMigrationDescription})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:h.settings.workspaceMode}),(0,Q.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:J(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,cn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:cn===`fixed`,onChange:()=>ln(`fixed`),disabled:Ht}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFixed}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceMigrationFixedHint})]})]}),(0,Q.jsxs)(`label`,{className:J(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,cn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:cn===`follow`,onChange:()=>ln(`follow`),disabled:Ht}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFollow}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceHint})]})]})]})]}),cn===`fixed`?(0,Q.jsx)(gn,{value:dn,onChange:_n,disabled:Ht,wd:m,placeholder:h.settings.workspacePlaceholder,inputClassName:mi(),autoFocus:!0}):null,(0,Q.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:h.settings.workspaceMigrationImpact}),(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-subtle`,children:ui(h.settings.workspaceCurrent,{workspace:Kr})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Ht,children:h.common.cancel})}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Ht||!qr,onClick:()=>void fr(),children:[(0,Q.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMigrationConfirm]})]})]})]})}),(0,Q.jsx)(Se,{open:!!Jt,onOpenChange:e=>{e||tn(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMissingTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Jt?ui(h.settings.workspaceMissingDescription,{workspace:Jt}):null})]}),Jt?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(Ke,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:Jt})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Xr,disabled:Ht,children:h.settings.workspaceMissingBack}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void fr({createWorkspaceRoot:!0}),disabled:Ht,children:[(0,Q.jsx)(gt,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMissingCreate]})]})]})]})})]})}export{ki 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{f as i,g as a,m as o,t as s}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./chevron-right-BweFrslA.js";import{n as u,r as d,t as f}from"./popover-select-BgSdSbCL.js";import{t as p}from"./circle-alert-BEjgurr2.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./circle-dot-BAseJTrF.js";import{t as g}from"./copy-Dv6d4Dvw.js";import{t as _}from"./download-Dk-ZjtO6.js";import{t as v}from"./external-link-DjqjBmc3.js";import{M as y,N as b,P as x,S,_ as C,g as w,n as T,t as E,u as D,y as O}from"./use-composer-attachments-pzPAUV_o.js";import{b as k,f as A,m as j,t as M}from"./markdown-view-DKlJx4eo.js";import{t as N}from"./git-branch-Dh9uxTot.js";import{E as P,F,N as I,b as L,g as R,i as z,k as B,s as V,v as H,y as U}from"./notes-api-D8nvWMMC.js";import{t as W}from"./loader-circle-CifKLtgG.js";import{t as G}from"./message-square-plus-XP0tGdlV.js";import{t as ee}from"./mic-CuUb7zc-.js";import{t as K}from"./pause-DuPxgSxk.js";import{t as te}from"./play-kxZvpBg8.js";import{t as ne}from"./plus-Q2yW6OE7.js";import{t as re}from"./rotate-ccw-JM1TBLpp.js";import{t as ie}from"./search-DA7gz22f.js";import{t as ae}from"./sparkles-DHlfQFAF.js";import{d as q,m as oe,p as se,u as ce}from"./use-file-preview-expanded-DNhXjL0W.js";import{t as le}from"./x-B_N4OPjy.js";import{t as ue}from"./messages-CnM6Qfr7.js";import{t as J}from"./cn-JdwAhgNB.js";import{a as de,c as fe,f as pe,n as me,r as he}from"./locale-store-ChN_vjs2.js";import{a as ge,i as _e,n as ve,o as ye,r as be,s as xe,t as Se}from"./dist-BGTk37IG.js";import{i as Ce,t as we}from"./tasks-CH6KoBeY.js";import{t as Te}from"./copy-to-clipboard-HOJ79TWv.js";import{i as Ee}from"./vendor-swr-BIWyz7Rc.js";import{t as Y}from"./button-CS04eWY9.js";import{a as De}from"./attachment-utils-core-BIOUBrpT.js";import{o as Oe}from"./agents-admin-api-BtnYiq7O.js";import{r as ke}from"./app-chrome-BeB4KgOf.js";import{a as Ae,i as je,o as Me,r as Ne,s as Pe}from"./dist-C3DSFZCi.js";import{t as Fe}from"./skeleton-BwbyijEw.js";import{r as Ie}from"./settings-form-draft-Dy10ldo8.js";import{a as Le,c as Re,n as ze,p as Be,r as Ve,t as He}from"./workspace-api-Dwa8kHdY.js";import{$r as Ue,Ac as We,An as Ge,Ao as Ke,Ci as qe,Co as Je,Cs as Ye,Di as Xe,Dn as Ze,Ei as Qe,En as $e,Go as et,Gs as tt,Hs as nt,Ic as rt,Ko as it,Kr as at,Mo as ot,Nc as st,Ns as ct,On as lt,Oo as ut,Pc as dt,Po as ft,Ps as pt,Qa as mt,Qs as ht,Si as gt,Ss as _t,Tc as vt,Ti as yt,Tn as bt,Vs as xt,Vt as St,Wr as Ct,Xn as wt,Yo as Tt,Zo as Et,Zr as Dt,_c as Ot,_i as kt,_o as At,ao as jt,bc as Mt,bi as Nt,bo as Pt,cc as Ft,ci as It,di as Lt,dn as Rt,ds as zt,ei as Bt,fc as Vt,fi as Ht,gi as Ut,go as Wt,hi as Gt,ic as Kt,jn as qt,js as Jt,kn as Yt,lo as Xt,mi as Zt,ni as Qt,pi as $t,qi as en,ro as tn,si as nn,ti as rn,vc as an,vi as on,vs as sn,wi as cn,wr as ln,xi as un,yi as dn}from"./index-BXrBL_Hb.js";import{t as fn}from"./page-tabs-D2xpUV26.js";import{n as pn,t as mn}from"./use-autosave-R3hEHQQq.js";import{t as hn}from"./page-context-capture-button-C72qIgBg.js";import{t as gn}from"./directory-picker-path-field-Btlldlt3.js";import{d as _n,h as vn,o as yn}from"./skill-api-1hbX3qDC.js";import{t as bn}from"./date-picker-WRFvi7Pu.js";import{t as xn}from"./automations-workspace-CiY_2otj.js";import{i as Sn,n as Cn,r as wn,t as Tn}from"./note-detail-panel-CUGVyo2V.js";import{t as En}from"./dependency-picker-CLun5Tst.js";import{c as Dn,l as On,n as kn,o as An,r as jn,t as X}from"./style-TIDOdKy0.js";var Mn=n(),Z=e(t(),1),Q=r();function Nn(e){let t=(0,Mn.c)(15),{noteId:n,attachmentId:r,className:i}=e,[a,o]=(0,Z.useState)(!1),s;t[0]!==r||t[1]!==n?(s=I(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=J(`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,Q.jsx)(F,{className:`size-4`}),t[5]=n):n=t[5];let r;return t[6]===e?r=t[7]:(r=(0,Q.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=J(`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,Q.jsx)(B,{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 Pn(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 Fn(e){let t=(0,Mn.c)(38),{noteId:n,attachmentId:r,durationSec:i,className:a}=e,{playing:o,loading:s,currentTime:c,duration:l,noteId:u,attachmentId:d}=wt(),f=wt(Ln),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=J(`flex items-center gap-2`,a),t[10]=a,t[11]=C);let w=m?`bg-accent text-on-accent`:`bg-accent/10 text-accent hover:bg-accent/20`,T;t[12]===w?T=t[13]:(T=J(`flex size-7 shrink-0 items-center justify-center rounded-full transition-colors`,w),t[12]=w,t[13]=T);let E=m?`Pause`:`Play`,D;t[14]!==h||t[15]!==m?(D=h?(0,Q.jsx)(W,{className:`size-3.5 animate-spin`}):m?(0,Q.jsx)(K,{className:`size-3.5`}):(0,Q.jsx)(te,{className:`size-3.5 ml-0.5`}),t[14]=h,t[15]=m,t[16]=D):D=t[16];let O;t[17]!==b||t[18]!==S||t[19]!==T||t[20]!==E||t[21]!==D?(O=(0,Q.jsx)(`button`,{type:`button`,onClick:b,onKeyDown:S,className:T,"aria-label":E,children:D}),t[17]=b,t[18]=S,t[19]=T,t[20]=E,t[21]=D,t[22]=O):O=t[22];let k=`${v}%`,A;t[23]===k?A=t[24]:(A=(0,Q.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-accent/10`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-200 ease-linear`,style:{width:k}})}),t[23]=k,t[24]=A);let j;t[25]!==_||t[26]!==p||t[27]!==g?(j=Pn(p&&g>0?g:_),t[25]=_,t[26]=p,t[27]=g,t[28]=j):j=t[28];let M;t[29]===j?M=t[30]:(M=(0,Q.jsx)(`span`,{className:`text-[10px] tabular-nums text-fg-muted`,children:j}),t[29]=j,t[30]=M);let N;t[31]!==A||t[32]!==M?(N=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[A,M]}),t[31]=A,t[32]=M,t[33]=N):N=t[33];let P;return t[34]!==N||t[35]!==C||t[36]!==O?(P=(0,Q.jsxs)(`div`,{className:C,onClick:In,children:[O,N]}),t[34]=N,t[35]=C,t[36]=O,t[37]=P):P=t[37],P}function In(e){return e.stopPropagation()}function Ln(e){return e.toggle}function $(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function Rn(e){let t=(0,Mn.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=$(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)(Gn),h;t[3]!==n.createdAt||t[4]!==m||t[5]!==l?(h=Sn(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=J(`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,Q.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,Q.jsx)(Nn,{noteId:n.id,attachmentId:n.coverAttachmentId}):n.kind===`voice`&&n.voiceAttachmentId?(0,Q.jsx)(Fn,{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,Q.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=J(`truncate text-sm leading-5`,T),t[23]=T,t[24]=E);let D;t[25]!==f||t[26]!==E?(D=(0,Q.jsx)(`p`,{className:E,children:f}),t[25]=f,t[26]=E,t[27]=D):D=t[27];let O;t[28]!==w||t[29]!==D?(O=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,D]}),t[28]=w,t[29]=D,t[30]=O):O=t[30];let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,Q.jsx)(ht,{className:`size-4`}),t[31]=k):k=t[31];let A;t[32]===c.actions?A=t[33]:(A=(0,Q.jsx)(qt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:Wn,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:k})}),t[32]=c.actions,t[33]=A);let j;t[34]!==n.id||t[35]!==n.pinned||t[36]!==a?(j=()=>{a(n.id,!n.pinned).catch(Hn)},t[34]=n.id,t[35]=n.pinned,t[36]=a,t[37]=j):j=t[37];let M;t[38]===n.pinned?M=t[39]:(M=n.pinned?(0,Q.jsx)(et,{className:`size-4`}):(0,Q.jsx)(it,{className:`size-4`}),t[38]=n.pinned,t[39]=M);let N=n.pinned?c.unpin:c.pin,P;t[40]!==j||t[41]!==M||t[42]!==N?(P=(0,Q.jsxs)(Ze,{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:j,children:[M,N]}),t[40]=j,t[41]=M,t[42]=N,t[43]=P):P=t[43];let F;t[44]!==n.id||t[45]!==o?(F=()=>{o(n.id).catch(Vn)},t[44]=n.id,t[45]=o,t[46]=F):F=t[46];let I;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Q.jsx)(rt,{className:`size-4`}),t[47]=I):I=t[47];let L;t[48]!==c.archive||t[49]!==F?(L=(0,Q.jsxs)(Ze,{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:F,children:[I,c.archive]}),t[48]=c.archive,t[49]=F,t[50]=L):L=t[50];let R;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Q.jsx)(Ge,{className:`my-1 h-px bg-edge-subtle`}),t[51]=R):R=t[51];let z;t[52]!==n.id||t[53]!==s?(z=()=>{s(n.id).catch(Bn)},t[52]=n.id,t[53]=s,t[54]=z):z=t[54];let B;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Q.jsx)(Xt,{className:`size-4`}),t[55]=B):B=t[55];let V;t[56]!==c.delete||t[57]!==z?(V=(0,Q.jsxs)(Ze,{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:z,children:[B,c.delete]}),t[56]=c.delete,t[57]=z,t[58]=V):V=t[58];let H;t[59]!==P||t[60]!==L||t[61]!==V?(H=(0,Q.jsx)(lt,{children:(0,Q.jsxs)($e,{className:`z-50 min-w-[140px] rounded-xl border border-edge bg-surface-panel p-1 shadow-lg`,sideOffset:4,align:`end`,onClick:Un,children:[P,L,R,V]})}),t[59]=P,t[60]=L,t[61]=V,t[62]=H):H=t[62];let U;t[63]!==A||t[64]!==H?(U=(0,Q.jsxs)(Yt,{children:[A,H]}),t[63]=A,t[64]=H,t[65]=U):U=t[65];let W;t[66]!==C||t[67]!==O||t[68]!==U?(W=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[C,O,U]}),t[66]=C,t[67]=O,t[68]=U,t[69]=W):W=t[69];let G;t[70]===n.pinned?G=t[71]:(G=n.pinned&&(0,Q.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,Q.jsx)(it,{className:`size-3`})}),t[70]=n.pinned,t[71]=G);let ee;t[72]===n.tags?ee=t[73]:(ee=n.tags?.slice(0,2).map(zn),t[72]=n.tags,t[73]=ee);let K;t[74]===g?K=t[75]:(K=(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-fg-muted`,children:g}),t[74]=g,t[75]=K);let te;t[76]!==G||t[77]!==ee||t[78]!==K?(te=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[G,ee,K]}),t[76]=G,t[77]=ee,t[78]=K,t[79]=te):te=t[79];let ne;return t[80]!==W||t[81]!==te||t[82]!==_||t[83]!==v||t[84]!==b||t[85]!==x||t[86]!==S?(ne=(0,Q.jsxs)(`article`,{role:`button`,tabIndex:0,onClick:_,onKeyDown:v,className:b,"aria-current":x,children:[S,W,te]}),t[80]=W,t[81]=te,t[82]=_,t[83]=v,t[84]=b,t[85]=x,t[86]=S,t[87]=ne):ne=t[87],ne}function zn(e){return(0,Q.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 Bn(){}function Vn(){}function Hn(){}function Un(e){return e.stopPropagation()}function Wn(e){return e.stopPropagation()}function Gn(){return Date.now()}var Kn=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 Jn({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),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)([]),k=(0,Z.useRef)(0),A=(0,Z.useRef)(null),j=(0,Z.useRef)(null),M=(0,Z.useCallback)(()=>{A.current&&=(clearInterval(A.current),null),j.current&&=(clearTimeout(j.current),null),D.current?.getTracks().forEach(e=>e.stop()),D.current=null,E.current=null,O.current=[],b(!1),S(0)},[]);(0,Z.useEffect)(()=>()=>M(),[M]);let N=(0,Z.useCallback)(async()=>{let e=E.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()-k.current)/1e3)),n=e.mimeType||qn()||`audio/webm`,r=new Blob(O.current,{type:n});if(M(),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)},[M,c]),P=(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});D.current=e;let t=qn(),n=t?new MediaRecorder(e,{mimeType:t}):new MediaRecorder(e);E.current=n,O.current=[],k.current=Date.now(),n.ondataavailable=e=>{e.data.size>0&&O.current.push(e.data)},n.start(),b(!0),S(0),A.current=setInterval(()=>{S(Math.round((Date.now()-k.current)/1e3))},250),j.current=setTimeout(()=>{N()},Kn)}catch{M(),l?.()}}},[M,c,l,y,N,C]),F=(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]),I=(0,Z.useCallback)(e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),F())},[F]),L=_||C,R=!!(s||c||p);return(0,Q.jsxs)(`div`,{className:J(`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":L,children:[y?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void N(),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,Q.jsx)(Pt,{className:`size-4 fill-current`,"aria-hidden":!0})}):R?(0,Q.jsxs)(Yt,{children:[(0,Q.jsx)(qt,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,disabled:L,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,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})}),(0,Q.jsx)(lt,{children:(0,Q.jsxs)($e,{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,Q.jsxs)(Ze,{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,Q.jsx)(Jt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),r]}):null,c?(0,Q.jsxs)(Ze,{disabled:f,onSelect:()=>void 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 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,children:[(0,Q.jsx)(ee,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,p?(0,Q.jsxs)(Ze,{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,Q.jsx)(We,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),m]}):null]})})]}):null,y?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate py-1.5 text-sm text-danger`,children:u.replace(`{{seconds}}`,String(x))}):(0,Q.jsx)(`textarea`,{ref:T,value:h,onChange:e=>g(e.target.value),onKeyDown:I,placeholder:e,"aria-label":e,rows:1,disabled:L,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,Q.jsx)(`button`,{type:`button`,disabled:!h.trim()||L||y,onClick:()=>void F(),"aria-label":t,title:t,className:J(`shrink-0 rounded-lg p-2 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,h.trim()&&!L&&!y?`bg-accent text-on-accent hover:bg-accent-hover`:`text-fg-disabled`),children:(0,Q.jsx)(ot,{className:`size-4`,"aria-hidden":!0})})]})}var Yn={statusFilter:`all`,kindFilter:`all`,pinnedOnly:!1},Xn=240,Zn=320,Qn=520,$n=560;function er(e){if(globalThis.localStorage===void 0)return Zn;try{let t=globalThis.localStorage.getItem(e);if(!t)return Zn;let n=Number(t);return Number.isFinite(n)?n:Zn}catch{return Zn}}function tr(e,t){if(globalThis.localStorage!==void 0)try{globalThis.localStorage.setItem(e,String(Math.round(t)))}catch{}}var nr={thought:At,todo:Je,voice:ee,media:Jt,bookmark:vt,mixed:At,task:Je};function rr(e,t){return e.snippet?.trim()?e.snippet:e.coverAttachmentId?t.imageNote:t.noText}function ir(e,t){return e.statusFilter===t.patch.statusFilter&&e.kindFilter===t.patch.kindFilter&&e.pinnedOnly===t.patch.pinnedOnly}function ar(e,t){return`${e.replace(/\/$/,``)}/${encodeURIComponent(t)}`}function or({selectedNoteId:e,basePath:t,managePageHeader:n=!1,showLibrary:r=!0,allowMediaCapture:a=!0,projectId:o,listTitle:s,listDescription:c,emptyText:l,emptyDescription:f,listWidthStorageKey:p=`xopc.notes.listWidth`}){let m=me(e=>e.language),h=ue(m).notes,g=!!fe(e=>e.conversationId),[_,v]=(0,Z.useReducer)(Ie,Yn),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(0),[T,E]=(0,Z.useState)(()=>er(p)),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[N,F]=(0,Z.useState)(null),[I,B]=(0,Z.useState)(null),W=(0,Z.useRef)(null),G=(0,Z.useRef)(null),[ee]=(0,Z.useState)(()=>Date.now()),K=i(),te=(0,Z.useCallback)(e=>{let t=W.current?.clientWidth??window.innerWidth,n=Math.max(Xn,t-$n);return Math.max(Xn,Math.min(Math.min(Qn,n),e))},[]),re=(0,Z.useCallback)(e=>{let t=te(e);E(t),tr(p,t)},[te,p]);(0,Z.useLayoutEffect)(()=>{E(e=>te(e))},[te]);let{data:ae,mutate:q,isLoading:oe}=Ee((0,Z.useMemo)(()=>g?[`notes-list`,o,_.statusFilter,_.kindFilter,_.pinnedOnly]:null,[g,o,_.statusFilter,_.kindFilter,_.pinnedOnly]),()=>R({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}),se=oe&&!ae,ce=ae?.items??[],de=ae?.total??0,he=x.trim(),{data:Ce,isLoading:we}=Ee(g&&y&&he?[`notes-search`,o,he]:null,()=>R({search:he,projectId:o,limit:30,sortBy:`updatedAt`,sortOrder:`desc`})),Te=Ce?.items??[],Y=e?ce.some(t=>t.id===e):!0;(0,Z.useEffect)(()=>{w(0)},[he]),(0,Z.useEffect)(()=>{C>=Te.length&&w(Math.max(0,Te.length-1))},[C,Te.length]),(0,Z.useEffect)(()=>{let e=()=>{q().catch(e=>{F(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})};return window.addEventListener(`note-updated`,e),()=>window.removeEventListener(`note-updated`,e)},[q,h.quickCaptureFailedHint,h.refreshFailed]);let De=en(e=>e.setPageHeader),Oe=en(e=>e.clearPageHeader),Ae=h.noteCount.replace(`{{count}}`,String(de)),je=!r&&de===0&&c?c:Ae,Me=h.searchDialogTitle,Ne=h.searchClose,Pe=h.searchClear,Fe=(0,Z.useMemo)(()=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:J(`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`,ke),"aria-label":Me,children:[(0,Q.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:Me})]}),[Me]);(0,Z.useLayoutEffect)(()=>{if(n)return g?(De({startExtra:null,main:(0,Q.jsxs)(`div`,{className:J(`flex min-w-0 items-center gap-2`,ke),children:[(0,Q.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,children:s??h.title}),Ae?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Ae}):null]}),end:Fe}),()=>Oe()):(Oe(),()=>Oe())},[Oe,g,Fe,s,n,h.title,Ae,e,De]);let Le=(0,Z.useMemo)(()=>({justNow:h.justNow,minutesAgo:h.minutesAgo,today:h.today,yesterday:h.yesterday,daysAgo:h.daysAgo,locale:pe(m)}),[m,h.justNow,h.minutesAgo,h.today,h.yesterday,h.daysAgo]),Re=(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]),ze=Re.find(e=>ir(_,e))??Re[0],Be=s??ze.label,Ve=(0,Z.useCallback)(async e=>{F(null);try{let n=o?await z({markdown:e,kind:`thought`,projectId:o,channel:`web`}):await H(e,`web`);await q(),K(ar(t,n.id))}catch(e){throw F(`${h.quickCaptureFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`),e}},[t,q,h.quickCaptureFailed,h.quickCaptureFailedHint,K,o]),He=(0,Z.useCallback)(async()=>{if(!j){M(!0),F(null);try{let e=await z({markdown:``,kind:`thought`,projectId:o,channel:`web`});v({type:`patch`,patch:Yn}),await q(),B(e.id),K(ar(t,e.id))}catch(e){F(`${h.createBlankFailed}: ${e instanceof Error?e.message:h.createBlankFailedHint}`)}finally{M(!1)}}},[t,j,q,h.createBlankFailed,h.createBlankFailedHint,K,o]),Ue=(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{F(null),await U(t,`web`),await q()}catch(e){F(`${h.imageUploadFailed}: ${e instanceof Error?e.message:h.imageUploadFailedHint}`)}},e.click()},[q,h.imageUploadFailed,h.imageUploadFailedHint]),We=(0,Z.useCallback)(async(e,t)=>{try{F(null),await L(e,t,`web`),await q()}catch(e){F(`${h.voiceUploadFailed}: ${e instanceof Error?e.message:h.voiceUploadFailedHint}`)}},[q,h.voiceUploadFailed,h.voiceUploadFailedHint]),Ge=(0,Z.useCallback)(()=>{F(`${h.voiceCaptureFailed}: ${h.voiceCaptureFailedHint}`)},[h.voiceCaptureFailed,h.voiceCaptureFailedHint]),Ke=(0,Z.useCallback)(async(e,t)=>{F(null);try{await P(e,{pinned:t}),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),qe=(0,Z.useCallback)(async e=>{F(null);try{await P(e,{status:`archived`}),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),Je=(0,Z.useCallback)(async e=>{F(null);try{await V(e),await q()}catch(e){F(`${h.actionFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)}},[q,h.actionFailed,h.quickCaptureFailedHint]),Ye=(0,Z.useCallback)(e=>{K(ar(t,e))},[t,K]),Xe=(0,Z.useCallback)(e=>{K(ar(t,e)),b(!1)},[t,K]),Ze=(0,Z.useCallback)(e=>{if(Te.length){if(e.key===`ArrowDown`)e.preventDefault(),w(e=>Math.min(Te.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=Te[C]??Te[0];t&&Xe(t.id)}}},[C,Xe,Te]),Qe=(0,Z.useCallback)(e=>{e.preventDefault();let t=e.currentTarget,n=G.current;t.setPointerCapture(e.pointerId),O(!0);let r=W.current?.clientWidth??window.innerWidth,i=Math.max(Xn,r-$n),a=Math.min(Qn,i),o=e=>Math.max(Xn,Math.min(a,e)),s=e.clientX,c=o(T),l=e.pointerId,u=0,d=c,f=c;n&&(n.style.transition=`none`,n.style.width=`${c}px`);let m=()=>{u=0,f=d,n&&(n.style.width=`${f}px`)},h=e=>{d=o(c+e.clientX-s),u===0&&(u=window.requestAnimationFrame(m))},g=()=>{u!==0&&(window.cancelAnimationFrame(u),m());try{t.releasePointerCapture(l)}catch{}O(!1),W.current?.style.setProperty(`--notes-list-width`,`${f}px`),n&&(n.style.removeProperty(`transition`),n.style.removeProperty(`width`)),E(f),tr(p,f),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g)};window.addEventListener(`pointermove`,h),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,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(),He())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[He]);let $e=(0,Z.useCallback)(e=>{e.key===`ArrowLeft`?(e.preventDefault(),re(T-16)):e.key===`ArrowRight`?(e.preventDefault(),re(T+16)):e.key===`Home`?(e.preventDefault(),re(Xn)):e.key===`End`&&(e.preventDefault(),re(Qn))},[re,T]);return g?(0,Q.jsxs)(`div`,{ref:W,className:`flex h-full min-h-0 w-full flex-1 overflow-hidden bg-surface-base`,style:{"--notes-list-width":`${T}px`},children:[(0,Q.jsxs)(`section`,{ref:G,className:J(`relative flex min-h-0 w-full shrink-0 flex-col overflow-hidden bg-surface-rail`,!D&&`lg:transition-[width] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,k?`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":k?!0:void 0,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[N?(0,Q.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:N}):null,(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,Q.jsx)(u,{value:ze.id,onChange:e=>{let t=Re.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:Re.map(e=>(0,Q.jsx)(d,{value:e.id,children:e.label},e.id))}):(0,Q.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Be}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:je})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!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,Q.jsx)(Et,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}),(0,Q.jsx)(`button`,{type:`button`,onClick:He,disabled:j,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,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),(0,Q.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,Q.jsx)(ie,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 py-3 [scrollbar-gutter:stable]`,children:se?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3,4].map(e=>(0,Q.jsx)(`div`,{className:`h-20 animate-pulse rounded-lg bg-surface-hover`},e))}):ce.length===0?(0,Q.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,Q.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,Q.jsx)(At,{className:`size-6`,"aria-hidden":!0})}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:e&&!Y?h.noteOutsideCurrentView:l??h.noNotes}),e&&!Y?null:(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:f??h.noNotesDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e&&!Y?(0,Q.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,ce.map((t,n)=>{let r=n>0?Cn(ce[n-1].createdAt):null;return(0,Q.jsxs)(`div`,{children:[Cn(t.createdAt)!==r&&(0,Q.jsx)(`div`,{className:J(`px-3 pb-1.5 pt-2 text-xs font-medium text-fg-muted`,n===0&&`pt-0`),children:wn(t.createdAt,ee,Le)}),(0,Q.jsx)(Rn,{note:t,selected:t.id===e,onPress:Ye,onPin:Ke,onArchive:qe,onDelete:Je,timeLabels:Le,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,Q.jsx)(`div`,{className:`shrink-0 border-t border-edge-subtle p-3`,children:(0,Q.jsx)(Jn,{placeholder:h.quickCapturePlaceholder,submitLabel:h.quickCaptureSubmit,actionsLabel:h.quickCaptureActions,imageLabel:h.quickCaptureImage,voiceLabel:h.quickCaptureVoice,stopRecordingLabel:h.stopRecording,onCapture:Ve,onImagePick:a?Ue:void 0,onVoiceCapture:a?We:void 0,onVoiceError:Ge,recordingLabel:h.recording,discussionCaptureLabel:h.discussionCapture.title,onDiscussionCapture:()=>bt(o)})})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.resizeNotesList,"aria-valuemin":Xn,"aria-valuemax":Qn,"aria-valuenow":Math.round(T),tabIndex:0,onPointerDown:Qe,onDoubleClick:()=>re(Zn),onKeyDown:$e,title:h.resizeNotesList,className:J(`group relative z-10 hidden shrink-0 cursor-col-resize touch-none select-none items-center justify-center bg-transparent hover:bg-surface-hover/60 lg:flex`,`lg:transition-[width,opacity] lg:duration-[280ms] lg:ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:lg:transition-none`,k?`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,Q.jsx)(`span`,{"aria-hidden":!0,className:J(`h-full w-px bg-transparent transition-[background-color,transform] duration-150`,`group-hover:bg-accent/70 group-focus-visible:bg-accent`,D&&`bg-accent scale-x-[2]`)})}),(0,Q.jsxs)(`section`,{className:J(`relative min-w-0 flex-1 bg-surface-base`,!e&&`hidden lg:flex`),children:[k?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>A(!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,Q.jsx)(Et,{className:`size-4`,strokeWidth:1.5,"aria-hidden":!0})}):null,e?(0,Q.jsx)(Tn,{noteId:e,onBack:()=>K(t),onSaved:()=>{q().catch(e=>{F(`${h.refreshFailed}: ${e instanceof Error?e.message:h.quickCaptureFailedHint}`)})},backButtonClassName:`lg:hidden`,clearHeaderOnCleanup:!1,onOpenSearch:()=>b(!0),autoFocus:e===I,onAutoFocusConsumed:()=>B(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-0 flex-1 items-center justify-center px-8 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(At,{className:`mx-auto size-9 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`mt-4 text-base font-semibold text-fg`,children:h.emptyEditorTitle}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h.emptyEditorDescription}),(0,Q.jsxs)(`button`,{type:`button`,onClick:He,disabled:j,className:`mt-5 inline-flex items-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-on-accent transition-colors hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),j?h.creatingBlankNote:h.createBlankNote]})]})})]}),(0,Q.jsx)(Se,{open:y,onOpenChange:b,children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,Q.jsx)(xe,{className:`text-sm font-semibold text-fg`,children:Me}),(0,Q.jsx)(_e,{className:`sr-only`,children:h.searchPlaceholder}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.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":Ne,children:(0,Q.jsx)(le,{className:`size-4`,"aria-hidden":!0})})})]}),(0,Q.jsxs)(`div`,{className:`p-4`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,value:x,onChange:e=>S(e.target.value),onKeyDown:Ze,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,Q.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":Pe,children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,Q.jsx)(`div`,{className:`mt-4 max-h-[min(28rem,calc(100vh-14rem))] overflow-y-auto [scrollbar-gutter:stable]`,children:he?we&&!Ce?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:[1,2,3].map(e=>(0,Q.jsx)(`div`,{className:`h-16 animate-pulse rounded-lg bg-surface-hover`},e))}):Te.length===0?(0,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(At,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchNoResults}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchNoResultsDescription})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-xs text-fg-muted`,children:h.searchResultsCount.replace(`{{count}}`,String(Ce?.total??Te.length))}),Te.map((e,t)=>{let n=nr[e.kind]||At,r=rr(e,{imageNote:h.imageNote,noText:h.noText});return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Xe(e.id),onMouseEnter:()=>w(t),className:J(`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,Q.jsx)(n,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title||r}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:Sn(e.updatedAt,ee,Le)})]}),e.title?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:r}):null,e.tags?.length?(0,Q.jsx)(`span`,{className:`mt-1 flex min-w-0 flex-wrap gap-1`,children:e.tags.slice(0,3).map(e=>(0,Q.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,Q.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Q.jsx)(ie,{className:`size-7 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:h.searchEmptyTitle}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:h.searchEmptyDescription})]})})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,Q.jsx)(At,{className:`size-10 text-fg-muted`}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:h.needToken})]})}function sr(e){return de(he(`/api/projects/${encodeURIComponent(e)}/skills`))}function cr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`))}function lr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/workspace-trust`),{method:`PATCH`,body:JSON.stringify({trusted:t})})}function ur(e,t){let n=new FormData;return n.set(`file`,t),de(he(`/api/projects/${encodeURIComponent(e)}/skills/upload`),{method:`POST`,body:n})}function dr(e,t,n={}){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/marketplace/install`),{method:`POST`,body:JSON.stringify({name:t,...n})})}function fr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/source/install`),{method:`POST`,body:JSON.stringify({source:t})})}function pr(e,t){return de(he(`/api/projects/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}`),{method:`DELETE`})}function mr({projectId:e,copy:t}){let n=me(e=>e.language),[r,i]=(0,Z.useState)([]),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!0),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(null),[M,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(1),[L,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(``),[U,W]=(0,Z.useState)(``),G=(0,Z.useRef)(null),ee=(0,Z.useCallback)(async()=>{x(!0),D(``);try{let t=await sr(e);i(t.items),o(t.inheritedItems),c(t.sources)}catch(e){D(e instanceof Error?e.message:String(e))}finally{x(!1)}},[e]);(0,Z.useEffect)(()=>{ee()},[ee]),(0,Z.useEffect)(()=>{let t=!1;return Nt(e).then(e=>{t||d(e)}).catch(()=>{t||d([])}),()=>{t=!0}},[e]),(0,Z.useEffect)(()=>{if(!p){g(null);return}let e=u.find(e=>e.key===p),t=!1;return g(null),D(``),y(!0),Ct(e?.agentId??e?.routing?.agentId,p,!0).then(e=>{t||g(e)}).catch(e=>{t||D(e instanceof Error?e.message:String(e))}).finally(()=>{t||y(!1)}),()=>{t=!0}},[p,u]),(0,Z.useEffect)(()=>{if(O!==`marketplace`)return;let e=new AbortController,t=window.setTimeout(()=>{B(!0),H(``),yn({q:M,page:F,pageSize:8,sort:`downloads`,signal:e.signal}).then(R).catch(t=>{e.signal.aborted||H(t instanceof Error?t.message:String(t))}).finally(()=>{e.signal.aborted||B(!1)})},250);return()=>{window.clearTimeout(t),e.abort()}},[O,F,M]);async function K(e,t){C(!0),T(t??null),D(``);try{await e(),k(null),W(``),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1),T(null)}}async function te(t){D(``);try{j((await cr(e,t)).skill)}catch(e){D(e instanceof Error?e.message:String(e))}}async function re(n){if(n.removable&&window.confirm(t.removeConfirm.replace(`{{name}}`,n.name))){C(!0);try{await pr(e,n.directoryId),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1)}}}async function ae(){C(!0),D(``);try{await lr(e,!0),await ee()}catch(e){D(e instanceof Error?e.message:String(e))}finally{C(!1)}}let q=s.find(e=>e.origin===`agents-workspace`),oe=new Map(h?.skills.map(e=>[e.name,e]));return(0,Q.jsxs)(`section`,{id:`project-panel-skills`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-skills`,className:`grid content-start gap-4`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-4 shadow-surface`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:t.description})]}),(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.jsxs)(Y,{type:`button`,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t.add,(0,Q.jsx)(an,{className:`size-3.5`,"aria-hidden":!0})]})}),(0,Q.jsx)(Ae,{children:(0,Q.jsxs)(je,{align:`end`,sideOffset:8,className:`z-50 w-72 rounded-lg border border-edge bg-surface-panel p-1.5 shadow-xl`,children:[(0,Q.jsx)(vr,{icon:Wt,title:t.marketplace,hint:t.marketplaceHint,onClick:()=>k(`marketplace`)}),(0,Q.jsx)(vr,{icon:N,title:t.source,hint:t.sourceHint,onClick:()=>k(`source`)}),(0,Q.jsx)(vr,{icon:jt,title:t.upload,hint:t.uploadHint,onClick:()=>G.current?.click()})]})})]}),(0,Q.jsx)(`input`,{ref:G,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:t=>{let n=t.target.files?.[0];n&&K(()=>ur(e,n)),t.target.value=``}})]})}),E?(0,Q.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:E}):null,q?.state===`untrusted`?(0,Q.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,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(zt,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.trustTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.trustHint})]})]}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:S,onClick:()=>void ae(),children:[(0,Q.jsx)(ut,{className:`size-4`,"aria-hidden":!0}),S?t.trusting:t.trustAction]})]}):null,u.length?(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.sessionViewLabel}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:v?t.sessionLoading:p?h?.agentId:t.sessionViewAll})]}),(0,Q.jsx)(f,{value:p,options:u.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,b?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:[0,1,2].map(e=>(0,Q.jsx)(Fe,{className:`h-36 rounded-lg`},e))}):r.length?(0,Q.jsx)(hr,{title:t.localTitle,items:r,copy:t,busy:S,availabilityByName:oe,onPreview:te,onRemove:re}):(0,Q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-edge bg-surface-panel px-6 py-12 text-center`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.empty}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.emptyHint})]}),!b&&a.length?(0,Q.jsx)(hr,{title:t.inheritedTitle,hint:t.inheritedHint,items:a,copy:t,busy:S,availabilityByName:oe,onPreview:te,onRemove:re}):null,(0,Q.jsx)(Se,{open:O!==null,onOpenChange:e=>{e||k(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{className:J(`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-overlay shadow-xl`,O===`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,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:O===`marketplace`?t.marketplace:t.source}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(le,{className:`size-4`})})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:O===`marketplace`?(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.marketplace}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.marketplaceHint}),(0,Q.jsxs)(`div`,{className:`relative mt-3`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.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:M,onChange:e=>{P(e.target.value),I(1)},placeholder:t.marketplacePlaceholder,autoFocus:!0})]}),V?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-300`,children:V}):null,z&&!L?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[0,1,2,3].map(e=>(0,Q.jsx)(Fe,{className:`h-32 rounded-lg`},e))}):L?.items.length?(0,Q.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:L.items.map(i=>{let a=at(i,n),o=i.providerId??L.provider,s=vn(i,o),c=r.some(e=>e.origin===`xopc-workspace`&&(e.directoryId===i.id||e.directoryId===s||e.name===i.name)),l=w===s;return(0,Q.jsxs)(`article`,{className:`group flex min-h-32 gap-3 rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(_n,{name:i.name,className:`size-10`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`h4`,{className:`truncate text-sm font-semibold text-fg`,children:a.displayName}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:a.description||`—`}),(0,Q.jsxs)(`div`,{className:`mt-auto flex items-end justify-between gap-2 pt-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-fg-subtle`,children:[(0,Q.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceDownloads,` `,i.downloads]}),(0,Q.jsx)(Y,{type:`button`,className:`h-8 px-2.5 text-xs`,variant:c?`secondary`:`primary`,disabled:S||c,onClick:()=>void K(()=>dr(e,s,{provider:o}),s),children:c?t.marketplaceInstalled:l?t.installing:t.install})]})]})]},`${o??`default`}:${i.id}`)})}):z?null:(0,Q.jsx)(`p`,{className:`mt-6 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}),L&&L.meta.totalPages>1?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-edge-subtle pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t.marketplacePage.replace(`{{page}}`,String(L.meta.page)).replace(`{{total}}`,String(L.meta.totalPages))}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:z||F<=1,onClick:()=>I(e=>Math.max(1,e-1)),children:[(0,Q.jsx)(Ot,{className:`size-4`}),t.marketplacePrevious]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:z||F>=L.meta.totalPages,onClick:()=>I(e=>e+1),children:[t.marketplaceNext,(0,Q.jsx)(l,{className:`size-4`})]})]})]}):null]}):(0,Q.jsxs)(`section`,{className:`flex h-full flex-col`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:t.sourceHint}),(0,Q.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:U,onChange:e=>W(e.target.value),placeholder:t.sourcePlaceholder,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`mt-auto flex justify-end gap-2 border-t border-edge pt-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,children:t.close})}),(0,Q.jsx)(Y,{type:`button`,disabled:S||!U.trim(),onClick:()=>void K(()=>fr(e,U.trim())),children:S?t.installing:t.install})]})]})})]})]})}),(0,Q.jsx)(Se,{open:!!A,onOpenChange:e=>{e||j(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-50 bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-xl`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:A?.name}),(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 p-0`,children:(0,Q.jsx)(le,{className:`size-4`})})})]}),(0,Q.jsx)(`pre`,{className:`min-h-0 flex-1 overflow-auto whitespace-pre-wrap p-5 text-sm leading-6 text-fg-muted`,children:A?.bodyMarkdown})]})]})})]})}function hr(e){let t=(0,Mn.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,Q.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,Q.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,Q.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,Q.jsxs)(`article`,{className:J(`flex min-h-36 flex-col rounded-lg border border-edge bg-surface-panel p-4`,!e.effective&&`opacity-70`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(rt,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,Q.jsx)(`h4`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:e.name})]}),(0,Q.jsx)(`p`,{className:`mt-2 line-clamp-2 flex-1 text-sm leading-5 text-fg-muted`,children:e.description||e.directoryId}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5 text-[11px] text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:gr(a,e.origin)}),e.writable?null:(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover/70 px-2 py-0.5`,children:a.sourceReadOnly}),e.effective?null:(0,Q.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,Q.jsx)(`span`,{className:J(`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:_r(a,t)}):null]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>void c(e.key),children:[(0,Q.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),a.view]}),e.removable?(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-red-600`,disabled:o,onClick:()=>void l(e),children:[(0,Q.jsx)(Xt,{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,Q.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,Q.jsxs)(`section`,{className:`grid gap-3`,children:[f,m]}),t[22]=f,t[23]=m,t[24]=h):h=t[24],h}function gr(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 _r(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 vr(e){let t=(0,Mn.c)(13),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,Q.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,Q.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,Q.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,Q.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,Q.jsx)(Ne,{asChild:!0,children:(0,Q.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}function yr(e){return{name:e.name,description:e.description??``,status:e.status,defaultAgentId:e.defaultAgentId??``,executionMode:e.executionMode,workspaceRoot:e.workspaceRoot??``,brief:e.brief??``,instructions:e.instructions??``}}function br(e,t,n){let r=yr(t),i=yr(n),a=Object.keys(r).filter(t=>e[t]===r[t]);return{...e,...Object.fromEntries(a.map(e=>[e,i[e]]))}}var xr={active:0,review:1,ready:2,backlog:3,closed:4},Sr={failed:0,blocked:1,waiting:2,verifying:3,running:4,queued:5,cancelled:6,idle:7},Cr={critical:0,high:1,normal:2,low:3};function wr(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=Sr[e.operationalState]-Sr[t.operationalState];if(r!==0)return r;let i=xr[e.phase]-xr[t.phase];if(i!==0)return i;let a=Cr[e.priority]-Cr[t.priority];return a===0?t.updatedAt-e.updatedAt:a}).slice(0,t)}var Tr=[`backlog`,`ready`,`active`,`review`,`closed`];function Er(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 Dr(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 Or(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 kr(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 Ar(e,t){let n=new Set(e.map(e=>e.id)),{outgoing:r,incoming:i}=kr(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 jr(e,t){let{incoming:n}=kr(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 Mr(e,t){let{incoming:n,outgoing:r}=kr(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 Nr={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 Pr(e){let t=(0,Mn.c)(25),{data:n,selected:r}=e,i=n.task,a=i.operationalState===`waiting`||i.operationalState===`blocked`,o=Nr[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=J(`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,Q.jsx)(jn,{type:`target`,position:On.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,Q.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,Q.jsx)(ct,{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,Q.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,Q.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,Q.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,Q.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,Q.jsx)(jn,{type:`source`,position:On.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,Q.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 Fr={taskNode:Pr};function Ir(e){let t=(0,Mn.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?(_=jr(n,r),t[0]=r,t[1]=n,t[2]=_):_=t[2];let y=_,b;t[3]!==y||t[4]!==u||t[5]!==c||t[6]!==n?(b=u?n.filter(e=>y.has(e.id)):c?n:n.filter(Wr),t[3]=y,t[4]=u,t[5]=c,t[6]=n,t[7]=b):b=t[7];let x=b,S;t[8]===x?S=t[9]:(S=new Set(x.map(Ur)),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=Ar(x,T),t[15]=T,t[16]=x,t[17]=E):E=t[17];let D=E,O;t[18]!==f||t[19]!==T?(O=f?Mr(f,T):void 0,t[18]=f,t[19]=T,t[20]=O):O=t[20];let A=O,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(Hr)),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:Dn.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 V,H;t[45]!==R||t[46]!==m?(V=()=>{m&&!R.some(e=>e.id===m)&&h(void 0)},H=[R,m],t[45]=R,t[46]=m,t[47]=V,t[48]=H):(V=t[47],H=t[48]),(0,Z.useEffect)(V,H);let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{let e=window.requestAnimationFrame(()=>{g.current?.fitView({padding:.2,minZoom:.35,maxZoom:1,duration:250})});return()=>window.cancelAnimationFrame(e)},t[49]=U):U=t[49];let W;t[50]!==u||t[51]!==c||t[52]!==x.length?(W=[u,c,x.length],t[50]=u,t[51]=c,t[52]=x.length,t[53]=W):W=t[53],(0,Z.useEffect)(U,W);let G;t[54]===f?G=t[55]:(G=()=>{f&&g.current?.fitView({nodes:[{id:f}],padding:1.5,minZoom:.7,maxZoom:1,duration:250})},t[54]=f,t[55]=G);let ee=G,K;t[56]!==r||t[57]!==o?(K=e=>{if(!e.source||!e.target||e.source===e.target)return;let t=r.filter(t=>t.dependentTaskId===e.target).map(Vr);t.includes(e.source)||o(e.target,[...t,e.source])},t[56]=r,t[57]=o,t[58]=K):K=t[58];let te=K,ne;t[59]!==r||t[60]!==o||t[61]!==m?(ne=()=>{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(Br)))},t[59]=r,t[60]=o,t[61]=m,t[62]=ne):ne=t[62];let re=ne,ie;t[63]===a.connectHint?ie=t[64]:(ie=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.connectHint}),t[63]=a.connectHint,t[64]=ie);let ae=u?`secondary`:`ghost`,q;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(q=()=>d(zr),t[65]=q):q=t[65];let oe=u?a.allTasks:a.blockedChains,se;t[66]!==u||t[67]!==ae||t[68]!==oe?(se=(0,Q.jsx)(Y,{type:`button`,variant:ae,className:`h-8 rounded-lg px-2.5 text-xs`,"aria-pressed":u,onClick:q,children:oe}),t[66]=u,t[67]=ae,t[68]=oe,t[69]=se):se=t[69];let ce;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>l(Rr),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,Q.jsx)(Y,{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,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,onClick:ee,children:[(0,Q.jsx)(tt,{className:`size-3.5`,"aria-hidden":!0}),a.locateTask]}):null,fe;t[75]!==a.removeDependency||t[76]!==re||t[77]!==m?(fe=m?(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs text-danger`,onClick:re,children:a.removeDependency}):null,t[75]=a.removeDependency,t[76]=re,t[77]=m,t[78]=fe):fe=t[78];let pe;t[79]!==se||t[80]!==ue||t[81]!==de||t[82]!==fe?(pe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[se,ue,de,fe]}),t[79]=se,t[80]=ue,t[81]=de,t[82]=fe,t[83]=pe):pe=t[83];let me;t[84]!==ie||t[85]!==pe?(me=(0,Q.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:[ie,pe]}),t[84]=ie,t[85]=pe,t[86]=me):me=t[86];let he=x.length>0?(0,Q.jsxs)(`div`,{className:J(`grid h-[min(42rem,calc(100vh-14rem))] min-h-[28rem]`,M&&`lg:grid-cols-[minmax(0,1fr)_18rem]`),children:[(0,Q.jsxs)(An,{nodes:I,edges:R,nodeTypes:Fr,nodesDraggable:!1,nodesConnectable:!0,elementsSelectable:!0,onNodeClick:(e,t)=>p(t.id),onEdgeClick:(e,t)=>h(t.id),onConnect:te,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,Q.jsx)(X,{color:`var(--color-edge)`,gap:22,size:1}),(0,Q.jsx)(kn,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}),M?(0,Q.jsxs)(`aside`,{className:`overflow-y-auto border-t border-edge bg-surface-panel p-4 lg:border-l lg:border-t-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:a.phases[M.phase]}),(0,Q.jsx)(`h3`,{className:`mt-2 text-sm font-semibold leading-6 text-fg`,children:M.title}),M.operationalState===`blocked`&&M.blockedBy.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg bg-violet-500/8 p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-violet-700 dark:text-violet-300`,children:a.blockedBy.replace(`{{count}}`,String(M.blockedBy.length))}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:M.blockedBy.map(Lr)})]}):null,(0,Q.jsxs)(s,{to:k(i,M.id),className:`mt-4 inline-flex items-center gap-1.5 text-xs font-medium text-accent-fg hover:underline`,children:[(0,Q.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),a.openTask]})]}):null]}):(0,Q.jsx)(`div`,{className:`flex min-h-72 items-center justify-center px-6 text-center text-sm text-fg-muted`,children:a.empty}),ge;return t[87]!==me||t[88]!==he?(ge=(0,Q.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base/40`,children:[me,he]}),t[87]=me,t[88]=he,t[89]=ge):ge=t[89],ge}function Lr(e){return(0,Q.jsx)(`li`,{children:e.title},e.id)}function Rr(e){return!e}function zr(e){return!e}function Br(e){return e.dependencyTaskId}function Vr(e){return e.dependencyTaskId}function Hr(e){return[e.id,e]}function Ur(e){return e.id}function Wr(e){return e.phase!==`closed`}function Gr(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var Kr={backlog:h,ready:h,active:sn,review:tn,closed:m},qr={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 Jr(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===`failed`?`border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-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 Yr(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 Xr(e){let t=(0,Mn.c)(83),{task:n,returnTo:r,copy:i,busy:a,onAction:o,onDragStart:c,onDropBefore:l}=e,u,d,f,h,g,_,v,y,b,x,S,C,w,T,E,D;t[0]!==c||t[1]!==l||t[2]!==r||t[3]!==n?(g=Or(n),_=g!==`review`&&n.allowedCommands.includes(`request_review`)?`review`:void 0,f=n.phase===`closed`,h=!!(n.dueAt&&n.dueAt<Date.now()&&!f),d=f?m:Vt,y=n.priority!==`normal`,v=y||n.operationalState!==`idle`||!!n.latestVerification||n.acceptanceCriteriaCount>0||!!n.dueAt||!!n.nextCheckAt,S=!0,t[20]!==c||t[21]!==n.id?(C=e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,n.id),c(n.id)},t[20]=c,t[21]=n.id,t[22]=C):C=t[22],t[23]===c?w=t[24]:(w=()=>c(``),t[23]=c,t[24]=w),T=Qr,t[25]!==l||t[26]!==n.id?(E=e=>{e.preventDefault(),e.stopPropagation(),l(n.id)},t[25]=l,t[26]=n.id,t[27]=E):E=t[27],D=`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?(b=k(r,n.id),t[28]=r,t[29]=n.id,t[30]=b):b=t[30],x=J(`block min-w-0 p-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,_?`pr-19`:g&&`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]=h,t[8]=g,t[9]=_,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]=D):(u=t[4],d=t[5],f=t[6],h=t[7],g=t[8],_=t[9],v=t[10],y=t[11],b=t[12],x=t[13],S=t[14],C=t[15],w=t[16],T=t[17],E=t[18],D=t[19]);let O=f?`text-emerald-600 dark:text-emerald-400`:`text-fg-subtle`,A;t[31]===O?A=t[32]:(A=J(`mt-0.5 size-4 shrink-0`,O),t[31]=O,t[32]=A);let j;t[33]!==d||t[34]!==A?(j=(0,Q.jsx)(d,{className:A,"aria-hidden":!0}),t[33]=d,t[34]=A,t[35]=j):j=t[35];let M=f?`text-fg-subtle`:`text-fg`,N;t[36]===M?N=t[37]:(N=J(`min-w-0 break-words text-sm font-semibold leading-5`,M),t[36]=M,t[37]=N);let P;t[38]!==N||t[39]!==n.title?(P=(0,Q.jsx)(`h3`,{className:N,children:n.title}),t[38]=N,t[39]=n.title,t[40]=P):P=t[40];let F;t[41]!==j||t[42]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[j,P]}),t[41]=j,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==i||t[45]!==n.attention||t[46]!==n.blockedBy||t[47]!==n.operationalState?(I=n.operationalState===`blocked`&&n.blockedBy.length>0?(0,Q.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,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-medium`,children:[(0,Q.jsx)(ct,{className:`size-3.5`,"aria-hidden":!0}),i.blockedBy.replace(`{{count}}`,String(n.blockedBy.length))]}),(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 leading-5 text-fg-muted`,children:n.blockedBy.map(Zr).join(`、`)})]}):n.attention[0]?(0,Q.jsxs)(`p`,{className:`ml-6.5 mt-2.5 flex items-start gap-1.5 text-xs leading-5 text-fg-muted`,children:[(0,Q.jsx)(p,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,Q.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]=I):I=t[48];let L;t[49]!==i||t[50]!==h||t[51]!==v||t[52]!==y||t[53]!==n.acceptanceCriteriaCount||t[54]!==n.dueAt||t[55]!==n.latestVerification||t[56]!==n.nextCheckAt||t[57]!==n.operationalState||t[58]!==n.priority?(L=v?(0,Q.jsxs)(`div`,{className:`ml-6.5 mt-2.5 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[y?(0,Q.jsx)(`span`,{className:J(`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,Q.jsx)(`span`,{className:J(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Jr(n.operationalState)),children:i.operationalStates[n.operationalState]}),n.latestVerification?(0,Q.jsx)(`span`,{className:J(`inline-flex min-h-6 items-center rounded-md border px-2 font-medium`,Yr(n.latestVerification)),children:i.verification[n.latestVerification]}):null,n.acceptanceCriteriaCount>0?(0,Q.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,Q.jsx)(sn,{className:`size-3`,"aria-hidden":!0}),i.acceptanceCriteria.replace(`{{count}}`,String(n.acceptanceCriteriaCount))]}):null,n.dueAt?(0,Q.jsxs)(`span`,{className:J(`inline-flex min-h-6 items-center gap-1 rounded-md border px-2`,h?`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,Q.jsx)(Mt,{className:`size-3`,"aria-hidden":!0}),ln(new Date(n.dueAt))]}):null,n.nextCheckAt?(0,Q.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,Q.jsx)(Mt,{className:`size-3`,"aria-hidden":!0}),ln(new Date(n.nextCheckAt))]}):null]}):null,t[49]=i,t[50]=h,t[51]=v,t[52]=y,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]=L):L=t[59];let R;t[60]!==u||t[61]!==b||t[62]!==F||t[63]!==I||t[64]!==L||t[65]!==x?(R=(0,Q.jsxs)(u,{to:b,className:x,children:[F,I,L]}),t[60]=u,t[61]=b,t[62]=F,t[63]=I,t[64]=L,t[65]=x,t[66]=R):R=t[66];let z;t[67]!==a||t[68]!==i||t[69]!==o||t[70]!==g||t[71]!==_||t[72]!==n?(z=g?(0,Q.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:[_?(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,_),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[_],title:i.actions[_],children:(0,Q.jsx)(tn,{className:`size-3.5`,"aria-hidden":!0})}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>o(n,g),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[g],title:i.actions[g],children:(0,Q.jsx)(st,{className:`size-3.5`,"aria-hidden":!0})})]}):null,t[67]=a,t[68]=i,t[69]=o,t[70]=g,t[71]=_,t[72]=n,t[73]=z):z=t[73];let B;return t[74]!==R||t[75]!==z||t[76]!==S||t[77]!==C||t[78]!==w||t[79]!==T||t[80]!==E||t[81]!==D?(B=(0,Q.jsxs)(`article`,{draggable:S,onDragStart:C,onDragEnd:w,onDragOver:T,onDrop:E,className:D,children:[R,z]}),t[74]=R,t[75]=z,t[76]=S,t[77]=C,t[78]=w,t[79]=T,t[80]=E,t[81]=D,t[82]=B):B=t[82],B}function Zr(e){return e.title}function Qr(e){e.preventDefault(),e.stopPropagation()}function $r({tasks:e,dependencyEdges:t,returnTo:n,copy:r,onAction:i,onReorder:a,onUndoMove:o,onDependenciesChange:s,onCreate:c,actionBusyId:l,ref:f}){let p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(`board`),[C,w]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(()=>crypto.randomUUID()),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(`normal`),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)([]),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(null),H=me(e=>e.language),U=E({chat:ue(H).chat}),W=Er(e),G=e.filter(e=>e.phase!==`closed`),ee=(e,t)=>void i(e,t),K=async(t,n)=>{let r=e.find(e=>e.id===h);if(g(null),!r||r.id===n)return;let o=W[r.phase],s=o.findIndex(e=>e.id===r.id),c=s>=0?o[s+1]?.id??null:null;if(r.phase===t&&c===n)return;let l=Dr(r,t);r.phase!==t&&!l||l&&!await i(r,l)||await a(r.id,n)&&b({taskId:r.id,phase:r.phase,beforeTaskId:c})},te=async e=>{e.preventDefault();let t=k.trim();if(!(!t||R)){z(!0),V(null);try{let e=P?new Date(`${P}T23:59:59.999`).getTime():void 0;await c({requestId:D,objective:t,priority:j,dependsOnTaskIds:I,attachments:U.wireAttachmentsPayload(),...e===void 0?{}:{dueAt:e}}),A(``),M(`normal`),F(``),L([]),U.clearAttachments(),O(crypto.randomUUID()),w(!1)}catch(e){V(e instanceof Error?e.message:r.createFailed)}finally{z(!1)}}},ne=()=>{O(crypto.randomUUID()),A(``),M(`normal`),F(``),L([]),U.clearAttachments(),V(null),w(!0)};(0,Z.useImperativeHandle)(f,()=>({openCreate:ne})),(0,Z.useEffect)(()=>{if(!y)return;let e=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout(e)},[y]);let re=(0,Z.useCallback)(e=>{let t=m.current;!t||t.pointerId!==e.pointerId||(m.current=null,v(!1),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),ie=(0,Z.useCallback)(e=>{if(e.button!==0||Gr(e.target))return;let t=p.current;t&&(m.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[]),ae=(0,Z.useCallback)(e=>{let t=m.current,n=p.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,v(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]);return(0,Q.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,Q.jsxs)(`div`,{className:`mb-4 flex shrink-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.description})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,Q.jsxs)(`div`,{className:`flex rounded-lg border border-edge bg-surface-panel p-0.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`board`,onClick:()=>S(`board`),className:J(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`board`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(_t,{className:`size-3.5`,"aria-hidden":!0}),r.views.board]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":x===`graph`,onClick:()=>S(`graph`),className:J(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium`,x===`graph`?`bg-surface-hover text-fg`:`text-fg-muted hover:text-fg`),children:[(0,Q.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),r.views.graph]})]})})]}),x===`board`?(0,Q.jsx)(`div`,{ref:p,className:J(`min-h-0 w-full min-w-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain pb-2 [scrollbar-width:thin]`,_?`cursor-grabbing select-none`:`cursor-grab`),onPointerDown:ie,onPointerMove:ae,onPointerUp:re,onPointerCancel:re,onLostPointerCapture:e=>{m.current?.pointerId===e.pointerId&&(m.current=null,v(!1))},children:(0,Q.jsx)(`div`,{className:`grid h-full min-h-0 min-w-[103rem] grid-cols-5 gap-3`,children:Tr.map(t=>{let i=Kr[t],a=W[t];return(0,Q.jsxs)(`section`,{onDragOver:n=>{let r=e.find(e=>e.id===h);r&&(r.phase===t||Dr(r,t))&&n.preventDefault()},onDrop:e=>{e.preventDefault(),K(t,null)},className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-inset/70 p-2.5`,children:[(0,Q.jsxs)(`header`,{className:`mb-2.5 flex shrink-0 items-center gap-2 px-0.5`,children:[(0,Q.jsxs)(`div`,{className:J(`flex items-center gap-1.5 rounded-md px-2 py-1`,qr[t]),children:[(0,Q.jsx)(i,{className:`size-3.5`,"aria-hidden":!0}),(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.phases[t]})]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.length})]}),(0,Q.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,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,Q.jsx)(Xr,{task:e,returnTo:n,copy:r,busy:l===e.id,onAction:ee,onDragStart:g,onDropBefore:e=>void K(t,e)},e.id))})})]},t)})})}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(Ir,{tasks:e,dependencyEdges:t,returnTo:n,copy:{...r.graph,phases:r.phases},onDependenciesChange:s})}),(0,Q.jsx)(Se,{open:C,onOpenChange:e=>{R||w(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:r.createTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r.createDescription})]}),(0,Q.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>void te(e),children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`label`,{htmlFor:`project-task-objective`,className:`font-medium text-fg-muted`,children:r.objective}),(0,Q.jsxs)(`div`,{className:J(`overflow-hidden rounded-lg border border-edge bg-surface-base transition-colors focus-within:border-accent`,U.isDragging&&`border-accent bg-accent-soft/30`),onDragOver:e=>{e.preventDefault(),R||U.setIsDragging(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||U.setIsDragging(!1)},onDrop:e=>{e.preventDefault(),U.setIsDragging(!1),R||U.processFiles(Array.from(e.dataTransfer.files))},children:[(0,Q.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:k,onChange:e=>{A(e.target.value),V(null)},placeholder:r.objectivePlaceholder,maxLength:12e3,disabled:R}),(0,Q.jsx)(T,{attachments:U.attachments,topPadded:!1,onRemove:e=>{R||U.removeAttachment(e)}}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t border-edge-subtle px-2.5 py-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg px-2.5 text-xs`,disabled:R,onClick:()=>U.fileInputRef.current?.click(),children:[(0,Q.jsx)(Tt,{className:`size-3.5`,"aria-hidden":!0}),r.addFiles]}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.attachmentsDescription}),(0,Q.jsx)(`input`,{ref:U.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{U.processFiles(Array.from(e.target.files??[])),e.currentTarget.value=``}})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:r.priority}),(0,Q.jsx)(u,{value:j,onChange:e=>M(e.target.value),disabled:R,children:[`low`,`normal`,`high`,`critical`].map(e=>(0,Q.jsx)(d,{value:e,children:r.priorityOptions[e]},e))})]}),(0,Q.jsxs)(`label`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-fg-muted`,children:[r.dueDate,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(bn,{className:`min-h-10 bg-surface-base`,value:P,onChange:F,disabled:R,ariaLabel:r.dueDate})]})]}),(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,children:[(0,Q.jsxs)(`legend`,{className:`text-sm font-medium text-fg-muted`,children:[r.dependencies,` `,(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:r.optional})]}),(0,Q.jsx)(`p`,{className:`text-xs leading-5 text-fg-subtle`,children:r.dependenciesDescription}),(0,Q.jsx)(En,{candidates:G,selectedIds:I,disabled:R,onChange:L,labels:{link:r.linkDependencies,linked:r.linkedDependencies,searchPlaceholder:r.dependencySearchPlaceholder,noMatches:r.noDependencyMatches,noCandidates:r.noDependencyCandidates,remove:r.removeDependency}})]}),B?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:B}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:R,children:r.cancel})}),(0,Q.jsx)(Y,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:R||!k.trim(),children:R?r.creating:H===`zh`?`保存待安排任务`:`Save for later`})]})]})]})]})}),y?(0,Q.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,Q.jsx)(`span`,{children:r.moved}),(0,Q.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:()=>{let e=y;b(null),o(e.taskId,e.phase,e.beforeTaskId).then(t=>{t||b(e)})},children:r.undo})]}):null]})}var ei=new Set([{id:`overview`,icon:Ye},{id:`tasks`,icon:Kt},{id:`automations`,icon:mt},{id:`files`,icon:xt},{id:`notes`,icon:x},{id:`skills`,icon:ae},{id:`sessions`,icon:G},{id:`progress`,icon:pt},{id:`settings`,icon:Ke}].map(e=>e.id)),ti=`xopc.projectFiles.panelWidthPx`,ni=320,ri=220,ii=560;function ai(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 oi(e){return Math.min(ii,Math.max(ri,Math.round(e)))}function si(){try{let e=window.localStorage.getItem(ti);if(e==null)return ni;let t=Number.parseInt(e,10);return Number.isFinite(t)?oi(t):ni}catch{return ni}}function ci(e){try{window.localStorage.setItem(ti,String(oi(e)))}catch{}}function li(e){return!!(e&&ei.has(e))}function ui(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function di(e,t=``){if(!e)return t;let n=new Date(e);return Number.isNaN(n.getTime())?String(e):ln(n)}function fi(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-inset text-fg-subtle`:`bg-surface-hover text-fg-muted`}function pi(e){let t=(0,Mn.c)(8),{label:n,hint:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Q.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,Q.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,Q.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 mi(e=!1){return J(`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 hi(e){let t=(0,Mn.c)(10),{label:n,value:r,mono:i}=e,a=i===void 0?!1:i,o;t[0]===n?o=t[1]:(o=(0,Q.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=J(`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,Q.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,Q.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 gi(e){return[e.name,e.slug,e.workspaceRoot,e.description,e.brief].filter(Boolean).join(` `).toLowerCase()}function _i(e){let t=e.lastActiveAt??e.updatedAt??e.createdAt,n=t?new Date(t).getTime():0;return Number.isFinite(n)?n:0}function vi(e){return e.trim().replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).pop()??``}function yi(e){let t=e?.body;return t?.code===`workspace_root_missing`&&t.workspaceRoot?t.workspaceRoot:null}function bi(e){let t=e.actor;return t.name?t.name:t.agentId?t.agentId:t.id?t.id:t.conversationId?t.conversationId:t.kind}function xi(e){return e.primaryObject.title?.trim()||e.primaryObject.id}function Si(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 Ci(e){let t=e.sourceChannel?.trim();return t?wi(t):``}function wi(e){let t=e.trim().toLowerCase();return t?t===`tui`?`TUI`:t===`acp`?`ACP`:t===`webchat`?`Webchat`:t:``}function Ti(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 Ei(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 Di(e,t,n){return e.map(e=>e.path===t?{...e,children:n}:e.isDirectory&&e.children?.length?{...e,children:Di(e.children,t,n)}:e)}function Oi({currentProject:e,pm:t,projectsText:n,wd:r}){let a=i(),[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([e]),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`new`),[x,S]=(0,Z.useState)(``),[C,w]=(0,Z.useState)(``),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(!0),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(null),N=(0,Z.useCallback)(async()=>{m(!0),g(null);try{let t=await un({limit:100});u(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){g(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e]);(0,Z.useEffect)(()=>{u(t=>[e,...t.filter(t=>t.id!==e.id)])},[e]),(0,Z.useEffect)(()=>{o&&N()},[N,o]);let P=(0,Z.useMemo)(()=>{let t=d.trim().toLowerCase().split(/\s+/).filter(Boolean);return l.filter(t=>t.id!==e.id).filter(e=>{if(t.length===0)return!0;let n=gi(e);return t.every(e=>n.includes(e))}).sort((e,t)=>_i(t)-_i(e))},[e.id,l,d]),F=e=>t.statuses[e.status]??e.status,I=e=>e.description||e.brief||t.common.defaultWorkspace,L=e=>{b(e),S(``),w(``),A(null),v(!0),s(!1)},R=(0,Z.useCallback)(async(e={})=>{let t=C.trim(),n=x.trim()||(y===`directory`?vi(t):``);if(n){E(!0),A(null),M(null);try{let r=await Ht({autoUnderstand:D,name:n,...t?{workspaceRoot:t}:{},...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}});v(!1),S(``),w(``),O(!0),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:r.id}})),u(e=>[r,...e.filter(e=>e.id!==r.id)]),a(`/projects/${encodeURIComponent(r.id)}`)}catch(e){let t=yi(e);t?(M(t),v(!1)):A(e instanceof Error?e.message:String(e))}finally{E(!1)}}},[y,x,a,C,D]),z=(0,Z.useCallback)(e=>{e.preventDefault(),R()},[R]),B=(0,Z.useCallback)(()=>{R({createWorkspaceRoot:!0})},[R]),V=(0,Z.useCallback)(()=>{M(null),v(!0)},[]),H=e=>{w(e),y===`directory`&&!x.trim()&&S(vi(e))},U=(e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`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,Q.jsx)(c,{className:J(`size-4 text-accent-fg`,!t&&`invisible`),"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:I(e)})]}),(0,Q.jsx)(`span`,{className:J(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:F(e)})]},e.id);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Me,{open:o,onOpenChange:s,children:[(0,Q.jsx)(Pe,{asChild:!0,children:(0,Q.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,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:J(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,fi(e.status)),children:F(e)})]}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-muted`,children:I(e)})]}),(0,Q.jsx)(an,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-data-[state=open]:rotate-180`,"aria-hidden":!0})]})}),(0,Q.jsx)(Ae,{children:(0,Q.jsxs)(je,{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,Q.jsxs)(`label`,{className:`relative block`,children:[(0,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Q.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:d,onChange:e=>f(e.target.value),placeholder:t.projectSwitcher.searchPlaceholder,"aria-label":t.projectSwitcher.searchPlaceholder})]}),(0,Q.jsxs)(`div`,{className:`mt-1 max-h-[min(54vh,24rem)] overflow-y-auto pr-0.5 [scrollbar-gutter:stable]`,children:[(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.current}),U(e,!0),(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-fg-subtle`,children:t.projectSwitcher.recent}),h?(0,Q.jsx)(`div`,{className:`p-2 text-xs text-red-600 dark:text-red-400`,children:h}):null,p&&P.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.loading}):null,!p&&P.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-fg-muted`,children:t.projectSwitcher.noMatches}):null,P.map(e=>U(e,!1))]}),(0,Q.jsxs)(`div`,{className:`mt-1 border-t border-edge-subtle pt-1`,children:[(0,Q.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:()=>L(`new`),children:[(0,Q.jsx)(ne,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.newProject})]}),(0,Q.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:()=>L(`directory`),children:[(0,Q.jsx)(xt,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.openDirectory})]}),(0,Q.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,Q.jsx)(Ke,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.projectSwitcher.manageProjects})]})]})]})})]}),(0,Q.jsx)(Se,{open:_,onOpenChange:e=>!T&&v(e),children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:y===`directory`?t.projectSwitcher.createFromDirectoryTitle:n.createTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm text-fg-muted`,children:y===`directory`?t.projectSwitcher.createFromDirectoryDescription:n.createDescription})]}),(0,Q.jsxs)(`form`,{onSubmit:z,className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[k?(0,Q.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:k}):null,(0,Q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.projectName}),(0,Q.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:x,onChange:e=>S(e.target.value),placeholder:`xopc`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:n.workspaceRoot}),(0,Q.jsx)(gn,{value:C,onChange:H,disabled:T,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,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.workspaceHint})]}),(0,Q.jsx)(nn,{checked:D,onChange:O,disabled:T})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:T,children:n.cancel})}),(0,Q.jsxs)(Y,{type:`submit`,variant:`primary`,className:`rounded-lg`,disabled:T||!(x.trim()||y===`directory`&&vi(C)),children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),n.create]})]})]})]})]})}),(0,Q.jsx)(Se,{open:!!j,onOpenChange:e=>{e||M(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[100] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:n.workspaceMissingTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:j?ui(n.workspaceMissingDescription,{workspace:j}):null})]}),j?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(xt,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:j})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:V,disabled:T,children:n.workspaceMissingBack}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:B,disabled:T,children:[(0,Q.jsx)(nt,{className:`size-4`,"aria-hidden":!0}),n.workspaceMissingCreate]})]})]})]})})]})}function ki(){let{projectId:e=``,tabId:t,noteId:n}=o(),r=i(),[c]=a(),l=me(e=>e.language),f=ue(l),m=f.chat.workingDirectory,h=f.projectDetailPage,_=f.projectsPage,v=en(e=>e.setPageHeader),T=en(e=>e.clearPageHeader),[E,P]=(0,Z.useState)(null),F=(0,Z.useRef)(E);(0,Z.useLayoutEffect)(()=>{F.current=E},[E]);let[I,L]=(0,Z.useState)(null),[R,z]=(0,Z.useState)([]),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)([]),[W,ee]=(0,Z.useState)(0),[K,te]=(0,Z.useState)(!1),[de,fe]=(0,Z.useState)(!1),[pe,he]=(0,Z.useState)(!1),[Ee,ke]=(0,Z.useState)([]),[Ae,je]=(0,Z.useState)(null),Me=(0,Z.useRef)(new Set),[Ne,Pe]=(0,Z.useState)(null),[Ie,We]=(0,Z.useState)(null),[Ge,Je]=(0,Z.useState)(null),[Ze,$e]=(0,Z.useState)(si),[tt,at]=(0,Z.useState)(!1),[ot,st]=(0,Z.useState)(!1),[ct,lt]=(0,Z.useState)(``),[ut,ht]=(0,Z.useState)([]),[_t,vt]=(0,Z.useState)(!1),[bt,Ct]=(0,Z.useState)(null),[wt,Tt]=(0,Z.useState)(!1),[Et,Ot]=(0,Z.useState)(null),[At,jt]=(0,Z.useState)([]),[Mt,Pt]=(0,Z.useState)(``),[zt,Vt]=(0,Z.useState)(!0),[Ht,Wt]=(0,Z.useState)(!1),[qt,Jt]=(0,Z.useState)(!1),[Yt,tn]=(0,Z.useState)(null),[nn,an]=(0,Z.useState)(!1),[sn,ln]=(0,Z.useState)(`fixed`),[un,_n]=(0,Z.useState)(``),[vn,yn]=(0,Z.useState)(null),[bn,Sn]=(0,Z.useState)(!1),[Cn,wn]=(0,Z.useState)(!1),[Tn,En]=(0,Z.useState)(!1),[Dn,On]=(0,Z.useState)(null),kn=(0,Z.useRef)(null),An=(0,Z.useRef)(!1),[jn,X]=(0,Z.useState)(null),[Mn,Nn]=(0,Z.useState)({title:``,reason:``}),[Pn,Fn]=(0,Z.useState)({name:``,description:``,status:`active`,defaultAgentId:``,executionMode:`local_checkout`,workspaceRoot:``,brief:``,instructions:``}),In=(0,Z.useRef)(Pn),Ln=`overview`,$=n?`notes`:li(t)?t:Ln,Rn=(0,Z.useMemo)(()=>A(c.get(`returnTo`),`/projects`,[`/chat`]),[c]),zn=(0,Z.useCallback)(t=>{if(!e)return`/projects`;let n=`/projects/${encodeURIComponent(e)}/${t}`;return Rn===`/projects`?n:j(n,Rn)},[Rn,e]),Bn=(0,Z.useCallback)(t=>{e&&r(zn(t))},[r,e,zn]),Vn=(0,Z.useCallback)(()=>{if($===`tasks`&&kn.current){kn.current.openCreate();return}An.current=!0,Bn(`tasks`)},[Bn,$]);(0,Z.useEffect)(()=>{$!==`tasks`||!An.current||(An.current=!1,kn.current?.openCreate())},[$]);let Hn=(0,Z.useCallback)(t=>{e&&r(zn(t),{replace:!0})},[r,e,zn]),Un=(0,Z.useCallback)(e=>t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||Hn(e)},[Hn]),Wn=(0,Z.useCallback)(e=>e.startsWith(`/chat/`)?`sessions`:e.startsWith(`/notes`)?`notes`:$,[$]);(0,Z.useEffect)(()=>{!e||!t||li(t)||r(zn(Ln),{replace:!0})},[Ln,r,e,zn,t]),(0,Z.useEffect)(()=>{if(!e)return;let t=!1;return Vt(!0),X(null),Promise.all([Gt(e),on(e),Nt(e),Oe().catch(()=>null),dn(e).catch(()=>null)]).then(([e,n,r,i,a])=>{if(t)return;P(e),L(n),z(r),je(a),jt(i?.agents??[]),Pt(e.defaultAgentId??``);let o=yr(e);In.current=o,Fn(o)}).catch(e=>{t||(je(null),X(e instanceof Error?e.message:String(e)))}).finally(()=>{t||Vt(!1)}),()=>{t=!0}},[e]);let Gn=(0,Z.useCallback)(async()=>{e&&L(await on(e))},[e]);(0,Z.useEffect)(()=>{if(zt)return;let t=!0,n=0,r=r=>{let i=r.detail?.id;if(!e||i&&i!==e)return;let a=++n;Promise.all([Gt(e),on(e)]).then(([e,r])=>{if(!t||n!==a)return;let i=F.current;if(!(i?.id===e.id&&i.version>e.version)){if(i?.id===e.id){let t=br(In.current,i,e);In.current=t,Fn(t)}F.current=e,P(e),L(r)}}).catch(e=>{!t||n!==a||e instanceof Error&&`status`in e&&e.status===404&&(P(null),L(null),X(e.message))})};return window.addEventListener(`project-resource-changed`,r),r(new Event(`project-resource-changed`)),()=>{t=!1,window.removeEventListener(`project-resource-changed`,r)}},[e,zt]),(0,Z.useEffect)(()=>{let t,n=n=>{let r=we.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),120))},r=n=>{let r=Ce.safeParse(n.detail);!r.success||r.data.projectId!==e||(window.clearTimeout(t),t=window.setTimeout(()=>void Gn(),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,Gn]);let Kn=(0,Z.useCallback)(async(e,t)=>{On(e.id),X(null);try{let n=await S(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 O(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 w(e.id,r,n.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[I,h.board.actionFailed,Gn]),qn=(0,Z.useCallback)(async t=>{e&&(X(null),await C({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 Gn())},[l,e,Gn]),Jn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{return await y(e,t,(await S(e)).task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Yn=(0,Z.useCallback)(async(e,t,n)=>{On(e),X(null);try{let r=await S(e);return r.task.phase!==t&&(r=await w(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 y(e,n,r.task.version),await Gn(),!0}catch(e){return await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed),!1}finally{On(null)}},[h.board.actionFailed,Gn]),Xn=(0,Z.useCallback)(async(e,t)=>{On(e),X(null);try{await b(e,t,(await S(e)).task.version),await Gn()}catch(e){await Gn().catch(()=>void 0),X(e instanceof Error?e.message:h.board.actionFailed)}finally{On(null)}},[h.board.actionFailed,Gn]),Zn=(0,Z.useCallback)(async()=>{if(E){te(!0),X(null);try{let e=await Ut(E.id,{includeRelated:de,limit:100});U(e.items),ee(e.total)}catch(e){X(e instanceof Error?e.message:String(e))}finally{te(!1)}}},[E,de]);(0,Z.useEffect)(()=>{$===`progress`&&Zn()},[Zn,$]);let Qn=(0,Z.useCallback)(async()=>{if(!E?.effectiveWorkspaceRoot?.trim()){ke([]),Me.current.clear(),Ot(null);return}Tt(!0),Ot(null),Me.current.clear();try{ke(Ei((await kt(E.id,``)).entries)),Me.current.add(``)}catch(e){ke([]),Me.current.clear(),Ot(e instanceof Error?e.message:String(e))}finally{Tt(!1)}},[E]),$n=(0,Z.useCallback)(async e=>{if(!(!E?.effectiveWorkspaceRoot?.trim()||Me.current.has(e))){Me.current.add(e),Ot(null);try{let t=await kt(E.id,e);ke(n=>Di(n,e,Ei(t.entries)))}catch(t){Me.current.delete(e),Ot(t instanceof Error?t.message:String(t))}}},[E]),er=(0,Z.useCallback)(async e=>{if(!E?.effectiveWorkspaceRoot?.trim())return;let t=Ei((await kt(E.id,e)).entries);ke(e?n=>Di(n,e,t):t),Me.current.add(e)},[E]);(0,Z.useEffect)(()=>{$===`files`&&Qn()},[Qn,$]);let tr=ct.trim();(0,Z.useEffect)(()=>{if($!==`files`||!E||!ot||!tr){ht([]),vt(!1),Ct(null);return}let e=!1;vt(!0),Ct(null),ht([]);let t=window.setTimeout(()=>{yt(E.id,tr,50).then(t=>{e||ht(t)}).catch(t=>{e||Ct(t instanceof Error?t.message:String(t))}).finally(()=>{e||vt(!1)})},180);return()=>{e=!0,window.clearTimeout(t)}},[tr,E,ot,$]);let nr=(0,Z.useCallback)(async()=>{if(!E)return;let[e,t]=await Promise.all([Gt(E.id),on(E.id)]);L(t),P(e)},[E]),rr=(0,Z.useCallback)(async e=>{if(e.preventDefault(),!(!E||!Mn.title.trim())){wn(!0),X(null);try{await $t(E.id,{title:Mn.title.trim(),reason:Mn.reason.trim()||void 0}),Nn({title:``,reason:``}),En(!1),await nr()}catch(e){X(e instanceof Error?e.message:String(e))}finally{wn(!1)}}},[Mn.reason,Mn.title,E,nr]),ir=(0,Z.useMemo)(()=>(0,Q.jsx)(s,{to:Rn,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":Rn===`/projects`?h.backToProjects:f.sidebar.back,children:(0,Q.jsx)(dt,{className:`size-4`,"aria-hidden":!0})}),[Rn,f.sidebar.back,h.backToProjects]),ar=(0,Z.useMemo)(()=>E?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(hn,{resource:{kind:`project`,id:E.id,revision:String(E.version)},disabled:Ht||ai(Pn,E)}),(0,Q.jsx)(Y,{asChild:!0,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:`/workflows?tab=library&projectId=${encodeURIComponent(E.id)}`,children:[(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":!0}),h.common.runWorkflow]})}),(0,Q.jsxs)(Y,{variant:`secondary`,className:`h-9 rounded-lg`,onClick:Vn,children:[(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),h.board.create]}),(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,Q.jsxs)(s,{to:D(E.id),state:{forceNewChat:!0,agentId:E.defaultAgentId},onClick:Un(`sessions`),children:[(0,Q.jsx)(G,{className:`size-4`,"aria-hidden":!0}),h.common.newChat]})})]}):null,[Vn,Un,h.board.create,h.common.newChat,h.common.runWorkflow,E,Ht,Pn]);(0,Z.useLayoutEffect)(()=>(v({startExtra:ir,main:E?(0,Q.jsx)(Oi,{currentProject:E,pm:h,projectsText:_,wd:m}):(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:h.fallbackTitle}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:h.fallbackContext})]}),end:ar}),()=>T()),[T,ar,ir,h,E,_,v,m]);function sr(e){P(t=>t?{...t,...e}:null),Pt(e.defaultAgentId??``),dn(e.id).then(je).catch(()=>je(null)),window.dispatchEvent(new CustomEvent(`project-updated`,{detail:{id:e.id}}))}async function cr(e=In.current){if(!(!E||!ai(e,E))){X(null),tn(null);try{let t=await Xe(E.id,{name:e.name.trim(),status:e.status,description:e.description,defaultAgentId:e.defaultAgentId,executionMode:e.executionMode,brief:e.brief,instructions:e.instructions},E.version);sr(t);let n=In.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};In.current=r,Fn(r)}catch(e){let t=yi(e);throw t?tn(t):X(e instanceof Error?e.message:String(e)),e}}}function lr(e){e.preventDefault(),kr.flush()}function ur(e,t=!1){let n={...In.current,...e};In.current=n,Fn(n),t&&kr.saveNow(n)}let dr=(0,Z.useCallback)(()=>{if(!E)return;let e=E.workspaceRoot?.trim()??``;ln(e?`fixed`:`follow`),_n(e||E.effectiveWorkspaceRoot||``),an(!0)},[E]);async function fr(e={}){if(!E)return;let t=sn===`fixed`?un.trim():``;if(!(sn===`fixed`&&!t)){Wt(!0),X(null),tn(null);try{let n=await Xe(E.id,{workspaceRoot:t,...e.createWorkspaceRoot?{createWorkspaceRoot:!0}:{}},E.version);sr(n),ur({workspaceRoot:n.workspaceRoot??``}),an(!1),tn(null)}catch(e){let t=yi(e);t?(tn(t),an(!1)):X(e instanceof Error?e.message:String(e))}finally{Wt(!1)}}}async function pr(){if(!(!E||vn)){yn(`pin`),X(null);try{sr(E.pinnedAt?await Qe(E.id,E.version):await gt(E.id,E.version))}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function hr(){if(!(!E||vn)){yn(`archive`),X(null);try{let e=E.status===`archived`?await qe(E.id,E.version):await Lt(E.id,E.version);sr(e),ur({status:e.status})}catch(e){X(e instanceof Error?e.message:String(e))}finally{yn(null)}}}async function gr(){if(E){Sn(!0),X(null);try{await Zt(E.id,E.version),Jt(!1),r(`/projects`)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Sn(!1)}}}async function _r(){if(!(!E||pe)){he(!0),X(null);try{await cn(E.id)}catch(e){X(e instanceof Error?e.message:String(e))}finally{he(!1)}}}let vr=(0,Z.useCallback)(e=>{Pe(e)},[]),xr=(0,Z.useCallback)((e,t)=>{t||Pe(e)},[]),Sr=(0,Z.useCallback)(async(e,t,n)=>{let r=E?.id;if(r)switch(e){case`preview`:t.isDirectory||Pe(t.path);break;case`download`:if(t.isDirectory)return;try{let e=q(t.path);if(se(ce(e))!==`text`){let n=await Le(t.path,{projectId:r}),i=De(e)??`application/octet-stream`;ze(e,await n.arrayBuffer(),i)}else{let{content:n}=await Re(t.path,{projectId:r});Ve(e,n)}}catch(e){oe(`warning`,e instanceof Error?e.message:String(e),void 0,{duration:4e3})}break;case`copyPath`:try{await Te(t.path)&&oe(`success`,f.workspace.pathCopied,void 0,{duration:2500})}catch{oe(`warning`,f.clipboard.copyFailed,void 0,{duration:4e3})}break;case`openDefault`:await Ue(()=>window.electronAPI?.shell?.openFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWith`:await Ue(()=>window.electronAPI?.shell?.chooseAppAndOpenFileResource?.(t.fileId),f.workspace.openFileFailed);break;case`openWithApp`:if(!n)return;await Ue(()=>window.electronAPI?.shell?.openFileResourceWithApp?.(t.fileId,n),f.workspace.openFileFailed);break;case`revealInFolder`:await Ue(()=>window.electronAPI?.shell?.showFileResourceInFolder?.(t.fileId),f.workspace.revealFileFailed);break;case`trash`:We(t);break;case`delete`:t.isDirectory||Je(t);break;default:break}},[f.clipboard.copyFailed,f.workspace.openFileFailed,f.workspace.pathCopied,f.workspace.revealFileFailed,E?.id]),Cr=(0,Z.useCallback)(async()=>{let e=Ie;if(!e)return;let t=await window.electronAPI?.shell?.trashFileResource?.(e.fileId);if(!t?.ok){oe(`warning`,t?.error??f.workspace.trashFailed,void 0,{duration:4e3});return}Ne===e.path&&Pe(null),We(null),await Qn(),oe(`success`,f.workspace.trashSuccess,void 0,{duration:2500})},[f.workspace.trashFailed,f.workspace.trashSuccess,Ie,Ne,Qn]),Tr=(0,Z.useCallback)(async(e,t)=>{let n=E?.id;if(n)try{await Promise.all(e.map(e=>Be(e,t,{projectId:n}))),await er(t).catch(()=>void 0),oe(`success`,f.workspace.uploadSuccess.replace(`{{count}}`,String(e.length)),void 0,{duration:2500})}catch(e){await er(t).catch(()=>void 0),oe(`warning`,`${f.workspace.uploadFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.uploadFailed,f.workspace.uploadSuccess,E?.id,er]),Er=(0,Z.useCallback)(async()=>{let e=Ge;if(e)try{await He(e.fileId),Ne===e.path&&Pe(null),Je(null);let t=e.path.lastIndexOf(`/`);await er(t<0?``:e.path.slice(0,t)).catch(()=>void 0),oe(`success`,f.workspace.deleteSuccess,void 0,{duration:2500})}catch(e){oe(`warning`,`${f.workspace.deleteFailed}: ${e instanceof Error?e.message:String(e)}`,void 0,{duration:4e3})}},[f.workspace.deleteFailed,f.workspace.deleteSuccess,Ge,Ne,er]),Dr=(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=Ze,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=oi(i+(e.clientX-r)),o===0&&(o=window.requestAnimationFrame(l))},d=()=>{o!==0&&(window.cancelAnimationFrame(o),l());try{t.releasePointerCapture(a)}catch{}at(!1),$e(c),ci(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)},[Ze]);(0,Z.useEffect)(()=>{$!==`files`&&Pe(null)},[e,$]);let Or=!!(E&&ai(Pn,E)),kr=mn({value:E?Pn:null,dirty:Or,onSave:cr,validate:e=>e.name.trim()?null:h.settings.nameRequired});if(zt)return(0,Q.jsx)(`main`,{className:`w-full flex-1 p-3 text-sm text-fg-muted sm:px-5 sm:py-4 xl:px-6`,children:h.loading});if(!E)return(0,Q.jsxs)(`main`,{className:`w-full flex-1 p-3 sm:px-5 sm:py-4 xl:px-6`,children:[(0,Q.jsxs)(s,{to:Rn,className:`inline-flex items-center gap-2 text-sm text-accent-fg hover:underline`,children:[(0,Q.jsx)(dt,{className:`size-4`,"aria-hidden":!0}),Rn===`/projects`?h.backToProjects:f.sidebar.back]}),(0,Q.jsx)(`p`,{className:`mt-6 rounded-lg bg-surface-panel p-4 shadow-surface text-sm text-fg-muted`,children:jn||h.notFound})]});let Ar=R.slice(0,3),jr=I?.blockers??[],Mr=wr(I?.tasks??[]),Nr=I?.tasks.filter(e=>[`queued`,`running`,`waiting`,`verifying`].includes(e.operationalState)).length??0,Pr=e=>h.statuses[e]??e,Fr=e=>ui(h.common.messages,{count:e}),Ir=B.trim().toLowerCase(),Lr=Ir?R.filter(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=e.name?.trim()||h.sessions.fallbackTitle,i=Fr(e.messageCount??0),a=Ci(e);return[r,e.key,n,a,t,i].filter(Boolean).join(` `).toLowerCase().includes(Ir)}):R,Rr=R.length>0&&Lr.length===0,zr=At.find(e=>e.id===E.defaultAgentId)?.name||E.defaultAgentId||h.settings.globalDefaultAgent,Br=At.find(e=>e.id===Pn.defaultAgentId),Vr=E.workspaceRoot?.trim()||``,Hr=E.status===`archived`,Ur=!!E.pinnedAt,Wr=!Vr,Gr=Vr||Br?.workspace||E.effectiveWorkspaceRoot||h.common.defaultWorkspace,Kr=sn===`fixed`?un.trim()||h.settings.workspacePlaceholder:Br?.workspace||E.effectiveWorkspaceRoot||h.common.defaultWorkspace,qr=(sn===`fixed`?un.trim():``)!==Vr&&(sn===`follow`||!!un.trim()),Jr=[{id:`overview`,icon:Ye,label:h.tabs.overview},{id:`tasks`,icon:Kt,label:h.tabs.tasks},{id:`automations`,icon:mt,label:h.tabs.automations},{id:`files`,icon:xt,label:h.tabs.files},{id:`notes`,icon:x,label:h.tabs.notes},{id:`skills`,icon:ae,label:h.tabs.skills},{id:`sessions`,icon:G,label:h.tabs.sessions},{id:`progress`,icon:pt,label:h.tabs.progress}];async function Yr(){if(!Gr)return;let e=await Te(Gr);oe(e?`success`:`warning`,e?f.workspace.pathCopied:f.clipboard.copyFailed,void 0,{duration:e?2500:4e3})}function Xr(){tn(null),an(!0)}return(0,Q.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,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3`,children:[(0,Q.jsx)(fn,{items:Jr,activeTab:$,onChange:Bn,ariaLabel:h.navAria,tabIdPrefix:`project-primary-tab`,className:`min-w-0 flex-1`}),(0,Q.jsxs)(Y,{id:`project-primary-tab-settings`,type:`button`,variant:$===`settings`?`secondary`:`ghost`,className:`h-9 shrink-0 rounded-lg px-3`,"aria-current":$===`settings`?`page`:void 0,onClick:()=>Bn(`settings`),children:[(0,Q.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),h.tabs.settings,Or?(0,Q.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-label":h.settings.unsavedChanges}):null]})]}),jn?(0,Q.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:jn}):null,(0,Q.jsxs)(`div`,{className:J(`mt-3 min-h-0 flex-1`,$===`overview`?`overflow-y-auto pr-1 [scrollbar-gutter:stable] xl:overflow-hidden xl:pr-0`:$===`tasks`?`overflow-hidden`:`overflow-y-auto pr-1 [scrollbar-gutter:stable]`),children:[$===`overview`?(0,Q.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,Q.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,Q.jsx)(It,{projectId:E.id},E.id),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel shadow-surface`,children:[(0,Q.jsx)(`div`,{className:`p-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.directionTitle}),(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:ui(h.overview.activitySummary,{moving:Nr,attention:jr.length})})]}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-3xl text-base font-medium leading-7 text-fg`,children:E.outcome||E.description||E.brief||h.overview.directionFallback}),I?.digest.recommendedAction?(0,Q.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:ui(h.overview.recommendedNext,{action:I.digest.recommendedAction})}):null]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,onClick:()=>void _r(),disabled:pe,children:[(0,Q.jsx)(ft,{className:`size-3.5`,"aria-hidden":!0}),pe?h.overview.savingDigest:h.overview.saveDigest]})]})}),(0,Q.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3.5`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.nextActions}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-muted transition-colors hover:text-fg`,onClick:()=>Bn(`tasks`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle border-t border-edge-subtle`,children:Mr.length?Mr.map(e=>(0,Q.jsxs)(s,{to:k(zn(`overview`),e.id),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsxs)(`span`,{className:J(`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:[h.board.phases[e.phase],e.operationalState===`idle`?``:` · ${h.board.operationalStates[e.operationalState]}`]})]}),e.attention[0]?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e.attention[0].summary}):null]},e.id)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noNextActions})})]})]}),I?.recentResults.length?(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.recentResults})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:I.recentResults.slice(0,3).map(({taskId:e,taskTitle:t,receipt:n})=>(0,Q.jsxs)(s,{to:k(zn(`overview`),e),className:`block px-5 py-3 transition-colors hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),(0,Q.jsxs)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:[h.overview.resultStatuses[n.status],` · `,h.board.verification[n.verification.status]]})]}),(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-3 text-sm leading-5 text-fg-muted`,children:(0,Q.jsx)(M,{content:n.summary,compact:!0})})]},n.runId))})]}):null,E.milestones.length||E.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-4 md:grid-cols-2`,children:[E.milestones.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.milestones})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:E.milestones.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-5 py-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:h.statuses[e.status]})]},e.id))})]}):null,E.recentUpdates.length?(0,Q.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle px-5 py-3.5`,children:(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.projectUpdates})}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:E.recentUpdates.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{className:`px-5 py-3`,children:[(0,Q.jsx)(`p`,{className:`text-sm leading-5 text-fg`,children:e.summary}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.overview.healthLabels[e.health]})]},e.id))})]}):null]}):null]}),(0,Q.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,Q.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-surface-panel p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.overview.attention}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 rounded-lg px-2 text-xs`,"aria-expanded":Tn,onClick:()=>En(e=>!e),children:[(0,Q.jsx)(ne,{className:J(`size-3.5 transition-transform`,Tn&&`rotate-45`),"aria-hidden":!0}),h.overview.addBlocker]})]}),jr.length?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-3`,children:jr.map(e=>{let t=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(p,{className:`size-4 text-amber-600 dark:text-amber-300`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.title})]}),(0,Q.jsxs)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:[h.overview.attentionKinds[e.kind]??e.kind,e.detail?` · ${e.detail}`:e.status?` · ${Pr(e.status)}`:``]})]});return e.href?(0,Q.jsx)(s,{to:e.href,onClick:Un(Wn(e.href)),className:`min-w-0 rounded-md bg-surface-base p-3 hover:bg-surface-hover`,children:t},e.id):(0,Q.jsx)(`div`,{className:`min-w-0 rounded-md bg-surface-base p-3`,children:t},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:h.overview.noBlockedTasks}),Tn?(0,Q.jsxs)(`form`,{onSubmit:rr,className:`mt-4 flex gap-2 border-t border-edge-subtle pt-4`,children:[(0,Q.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:Mn.title,onChange:e=>Nn(t=>({...t,title:e.target.value})),placeholder:h.overview.blockerTitlePlaceholder}),(0,Q.jsx)(Y,{type:`submit`,variant:`secondary`,className:`shrink-0 rounded-lg px-3`,disabled:Cn||!Mn.title.trim(),"aria-label":Cn?h.overview.addingBlocker:h.overview.addBlocker,title:Cn?h.overview.addingBlocker:h.overview.addBlocker,children:(0,Q.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})]}):null]}),(0,Q.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-xl bg-surface-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Ft,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsx)(`h2`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:h.overview.recentSessions})]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-xs font-medium text-accent-fg hover:underline`,onClick:()=>Bn(`sessions`),children:h.common.viewAll})]}),(0,Q.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ar.length?Ar.map(e=>(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`sessions`),className:`block px-4 py-3 hover:bg-surface-hover`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:e.name||e.key}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:di(e.updatedAt)})]}),(e.routing?.agentId||e.agentId)&&(e.routing?.agentId||e.agentId)!==E.defaultAgentId?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.routing?.agentId||e.agentId}):null]},e.key)):(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.overview.noSessions})})]})]})]}):null,$===`tasks`?(0,Q.jsx)($r,{ref:kn,tasks:I?.tasks??[],dependencyEdges:I?.dependencyEdges??[],returnTo:zn(`tasks`),copy:h.board,onAction:Kn,onReorder:Jn,onUndoMove:Yn,onDependenciesChange:Xn,onCreate:qn,actionBusyId:Dn}):null,$===`automations`?(0,Q.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,Q.jsx)(xn,{projectId:E.id,embedded:!0,title:h.automations.title,subtitle:h.automations.hint})}):null,$===`notes`?(0,Q.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,Q.jsx)(or,{selectedNoteId:n,basePath:`/projects/${encodeURIComponent(E.id)}/notes`,showLibrary:!1,allowMediaCapture:!1,projectId:E.id,listTitle:h.notes.title,listDescription:h.notes.hint,emptyText:h.notes.emptyTitle,emptyDescription:h.notes.emptyDescription,listWidthStorageKey:`xopc.projectNotes.listWidth.${E.id}`})}):null,$===`skills`?(0,Q.jsx)(mr,{projectId:E.id,copy:h.skills}):null,$===`files`?(0,Q.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,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl bg-surface-panel`,children:E.effectiveWorkspaceRoot?(0,Q.jsxs)(`div`,{"data-project-files-grid":!0,className:J(`grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[var(--project-files-panel-width)_8px_minmax(0,1fr)]`,tt&&`cursor-col-resize select-none`),style:{"--project-files-panel-width":`${Ze}px`},children:[(0,Q.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-b border-edge bg-surface-panel lg:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 items-center gap-1 bg-surface-hover/30 px-3 text-sm`,children:[Ae?(0,Q.jsx)(Dt,{resourceId:Ae.fileId,displayName:Ae.name}):null,(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,className:J(`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":h.files.search,title:h.files.search,"aria-pressed":ot,children:(0,Q.jsx)(ie,{className:`size-3.5`,"aria-hidden":!0})}),(0,Q.jsx)(rn,{className:`size-7 shrink-0 rounded-md p-0`,loading:wt,label:f.cron.refresh,onClick:()=>void Qn()})]})]}),ot?(0,Q.jsx)(`div`,{className:`shrink-0 bg-surface-hover/20 px-3 py-2`,children:(0,Q.jsxs)(`div`,{className:`flex h-8 items-center gap-2 rounded-md bg-surface-base px-2 focus-within:ring-2 focus-within:ring-accent/30`,children:[(0,Q.jsx)(ie,{className:`size-3.5 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`text`,role:`searchbox`,value:ct,onChange:e=>lt(e.target.value),placeholder:h.files.searchPlaceholder,"aria-label":h.files.searchPlaceholder,className:`min-w-0 flex-1 bg-transparent text-xs text-fg outline-none placeholder:text-fg-subtle`}),(0,Q.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":h.files.clearSearch,title:h.files.clearSearch,onClick:()=>{lt(``),st(!1)},children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})})]})}):null,Et?(0,Q.jsx)(`div`,{className:`bg-red-500/10 px-4 py-3 text-sm text-red-700 dark:text-red-300`,children:Et}):null,tr?(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:_t?(0,Q.jsxs)(`div`,{className:`space-y-2 px-3 py-1`,children:[(0,Q.jsx)(Fe,{className:`h-11 w-full`}),(0,Q.jsx)(Fe,{className:`h-11 w-full`}),(0,Q.jsx)(Fe,{className:`h-11 w-full`})]}):bt?(0,Q.jsxs)(`p`,{className:`px-3 py-2 text-xs text-red-600 dark:text-red-400`,children:[f.workspace.loadError,`: `,bt]}):ut.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-2 text-xs text-fg-muted`,children:h.files.noSearchResults}):ut.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:J(`flex w-full min-w-0 items-center gap-2 px-3 py-2 text-left hover:bg-surface-hover`,Ne===e.path&&`bg-accent-soft text-accent-fg`),onClick:()=>Pe(e.path),title:e.path,children:[(0,Q.jsx)(x,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.name}),(0,Q.jsx)(`span`,{className:`block truncate text-xs text-fg-subtle`,children:e.path})]})]},e.path))}):wt&&Ee.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-6 text-sm text-fg-muted`,children:h.files.loading}):(0,Q.jsx)(Bt,{tree:Ee,selectedPath:Ne,onSelectFile:vr,onSelectEntry:xr,onExpandDir:e=>void $n(e),onAction:Sr,onUploadFiles:(e,t)=>void Tr(e,t),uploadDropHint:f.workspace.dropToUpload,actionLabels:{preview:f.workspace.preview,download:f.workspace.download,copyPath:f.workspace.copyPath,openDefault:f.workspace.openSystemApp,openDirectory:f.workspace.openInFileManager,openWith:f.workspace.openWith,revealInFolder:f.workspace.revealInFolder,trash:f.workspace.moveToTrash,delete:f.workspace.deleteFile,recommendedApps:f.workspace.recommendedApps,desktopUpdateRequired:f.workspace.desktopUpdateRequired},emptyHint:h.files.emptyDirectory})]}),(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":h.files.resizeHandle,className:J(`group hidden cursor-col-resize touch-none items-stretch justify-center bg-transparent transition-colors hover:bg-surface-hover/60 lg:flex`,tt&&`bg-surface-hover/70`),onPointerDown:Dr,children:(0,Q.jsx)(`div`,{className:J(`my-3 w-px rounded-full bg-transparent transition-colors`,`group-hover:bg-edge-strong/55`,tt&&`bg-accent/60`)})}),(0,Q.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-hidden bg-surface-base`,children:Ne?(0,Q.jsx)(St,{filePath:Ne,projectId:E.id,agentId:E.defaultAgentId||Mt||void 0,onClose:()=>Pe(null)}):(0,Q.jsx)(`div`,{className:`flex h-full min-h-[18rem] items-center justify-center px-6 text-center`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Q.jsx)(xt,{className:`mx-auto size-8 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:h.files.previewEmptyTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.files.previewEmptyDescription})]})})})]}):(0,Q.jsxs)(`div`,{className:`grid gap-3 px-4 py-8 text-sm text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:h.files.needWorkspace}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:()=>Bn(`settings`),children:h.files.openSettings})})]})})}):null,$===`sessions`?(0,Q.jsxs)(`section`,{id:`project-panel-sessions`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-sessions`,className:`grid min-h-full content-start gap-3`,children:[R.length?(0,Q.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,Q.jsx)(ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,"aria-hidden":!0}),(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:B,onChange:e=>V(e.currentTarget.value),placeholder:h.sessions.searchPlaceholder,"aria-label":h.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`}),B?(0,Q.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":h.sessions.clearSearch,onClick:()=>V(``),children:(0,Q.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})}):null]}):null,Lr.length?(0,Q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Lr.map(e=>{let t=di(e.updatedAt),n=e.routing?.agentId||e.agentId||h.common.agent,r=Ci(e),i=e.name?.trim()||h.sessions.fallbackTitle,a=Fr(e.messageCount??0);return(0,Q.jsxs)(s,{to:`/chat/${encodeURIComponent(e.key)}`,onClick:Un(`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,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.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,Q.jsx)(G,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,children:i}),r?(0,Q.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,Q.jsxs)(`div`,{className:`mt-auto grid gap-2 pt-4 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.agent,`: `,n]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:a})]}),t?(0,Q.jsxs)(`span`,{className:`truncate rounded-md bg-surface-base px-2 py-1`,children:[h.sessions.updated,`: `,t]}):null]})]},e.key)})}):Rr?(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.noMatches})}):(0,Q.jsx)(`div`,{className:`grid gap-1 rounded-lg bg-surface-panel px-4 py-8 text-center shadow-surface`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.sessions.emptyTitle}),(0,Q.jsx)(`p`,{className:`mx-auto mt-1 max-w-md text-sm leading-6 text-fg-muted`,children:h.sessions.emptyDescription})]})})]}):null,$===`progress`?(0,Q.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,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.progress.title}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ui(h.progress.count,{count:W})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.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,Q.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.currentTarget.checked),className:`size-4 rounded border-edge text-accent focus:ring-accent/30`}),h.progress.includeRelated]}),(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3`,onClick:()=>void Zn(),disabled:K,children:[(0,Q.jsx)(re,{className:J(`size-4`,K&&`animate-spin`),"aria-hidden":!0}),h.common.refresh]})]})]}),(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg bg-surface-panel shadow-surface`,children:K&&H.length===0?(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.loading}):H.length?(0,Q.jsx)(`div`,{className:`divide-y divide-edge`,children:H.map(e=>{let t=h.progress.types[e.type]??e.type,n=h.progress.objectKinds[e.primaryObject.kind]??e.primaryObject.kind,r=Ti(e),i=e.relatedProjects.length>0&&!e.scopes.some(e=>e.scopeKind===`project`&&e.scopeId===E.id);return(0,Q.jsxs)(`article`,{className:`grid gap-2 px-4 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-sm font-medium text-fg`,children:t}),i?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:h.progress.related}):null]}),(0,Q.jsxs)(`p`,{className:`mt-1 min-w-0 truncate text-sm text-fg-muted`,children:[n,`: `,xi(e)]})]}),(0,Q.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,dateTime:new Date(e.createdAt).toISOString(),children:di(e.createdAt)})]}),r?(0,Q.jsx)(`p`,{className:`line-clamp-2 text-sm leading-5 text-fg-muted`,children:r}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[h.progress.actor,`: `,bi(e)]}),(0,Q.jsxs)(`span`,{className:`max-w-full truncate rounded-md bg-surface-base px-2 py-1`,children:[h.progress.source,`: `,Si(e)]})]})]},e.id)})}):(0,Q.jsx)(`div`,{className:`px-4 py-8 text-sm text-fg-muted`,children:h.progress.empty})})]}):null,$===`settings`?(0,Q.jsxs)(`form`,{id:`project-panel-settings`,role:`tabpanel`,"aria-labelledby":`project-primary-tab-settings`,onSubmit:lr,onBlurCapture:kr.onBlurCapture,className:`grid min-h-full content-start gap-4 pb-1`,children:[(0,Q.jsxs)(`section`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.summaryTitle}),(0,Q.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm leading-6 text-fg-muted`,children:h.settings.summaryHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,Q.jsx)(`span`,{className:J(`rounded-full px-2 py-0.5 text-xs font-medium`,fi(Pn.status)),children:h.settings.statuses[Pn.status]}),(0,Q.jsx)(pn,{status:kr.status,error:kr.error})]})]}),(0,Q.jsxs)(`div`,{className:`grid items-start gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.detailsTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.detailsHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(pi,{label:h.settings.name,children:(0,Q.jsx)(`input`,{className:mi(),value:Pn.name,onChange:e=>ur({name:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.defaultAgent,children:(0,Q.jsxs)(u,{className:mi(),value:Pn.defaultAgentId,onChange:e=>ur({defaultAgentId:e.target.value},!0),children:[(0,Q.jsx)(d,{value:``,children:h.settings.globalDefaultAgent}),At.map(e=>(0,Q.jsx)(d,{value:e.id,children:Rt(e,f.agentsSettings)},e.id))]})}),(0,Q.jsx)(pi,{label:h.settings.status,children:Hr?(0,Q.jsx)(`div`,{className:`grid min-h-10 content-center rounded-md border border-edge bg-surface-inset px-3 text-sm text-fg-muted`,children:h.settings.statuses.archived}):(0,Q.jsxs)(u,{className:mi(),value:Pn.status===`archived`?`active`:Pn.status,onChange:e=>ur({status:e.target.value},!0),children:[(0,Q.jsx)(d,{value:`active`,children:h.settings.statuses.active}),(0,Q.jsx)(d,{value:`paused`,children:h.settings.statuses.paused})]})}),(0,Q.jsx)(pi,{label:h.settings.executionMode,hint:h.settings.executionModeHint,children:(0,Q.jsxs)(u,{className:mi(),value:Pn.executionMode,onChange:e=>ur({executionMode:e.target.value},!0),children:[(0,Q.jsx)(d,{value:`managed_worktree`,children:h.settings.executionModeWorktree}),(0,Q.jsx)(d,{value:`local_checkout`,children:h.settings.executionModeLocal})]})}),(0,Q.jsx)(pi,{label:h.settings.description,hint:h.settings.descriptionHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.description,onChange:e=>ur({description:e.target.value})})})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.projectGuidanceTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.projectGuidanceHint})]}),(0,Q.jsx)(pi,{label:h.settings.brief,hint:h.settings.briefHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.brief,onChange:e=>ur({brief:e.target.value})})}),(0,Q.jsx)(pi,{label:h.settings.instructions,hint:h.settings.instructionsHint,children:(0,Q.jsx)(`textarea`,{className:mi(!0),value:Pn.instructions,onChange:e=>ur({instructions:e.target.value})})})]})]}),(0,Q.jsxs)(`aside`,{className:`grid gap-4 xl:sticky xl:top-0`,children:[(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.workspaceRoot}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceIndependentHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`span`,{className:`w-fit rounded-md bg-surface-inset px-2 py-0.5 text-xs font-medium text-fg-muted`,children:Wr?h.settings.workspaceModeFollow:h.settings.workspaceModeFixed}),(0,Q.jsx)(`div`,{className:`break-all font-mono text-xs leading-5 text-fg`,title:Gr,children:Gr}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:()=>void Yr(),children:[(0,Q.jsx)(g,{className:`size-4`,"aria-hidden":!0}),h.settings.copyWorkspacePath]}),Ae?(0,Q.jsx)(Dt,{resourceId:Ae.fileId,displayName:Ae.name}):null,(0,Q.jsxs)(Y,{type:`button`,variant:`secondary`,className:`rounded-lg`,onClick:dr,children:[(0,Q.jsx)(nt,{className:`size-4`,"aria-hidden":!0}),h.settings.migrateWorkspace]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.currentProjectTitle}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.defaultAgent,value:zr}),(0,Q.jsx)(hi,{label:h.settings.pinState,value:Ur?h.settings.pinned:h.settings.notPinned}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Q.jsx)(hi,{label:h.settings.createdAt,value:di(E.createdAt)||h.common.never}),(0,Q.jsx)(hi,{label:h.settings.updatedAt,value:di(E.updatedAt)||h.common.never})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-4 rounded-lg bg-surface-panel p-4 shadow-surface`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:h.settings.managementTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.managementHint})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Ur?h.settings.pinnedTitle:h.settings.pinTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:h.settings.pinHint})]}),(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`pin`,onClick:()=>void pr(),children:[Ur?(0,Q.jsx)(et,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(it,{className:`size-4`,"aria-hidden":!0}),Ur?h.settings.unpinProject:h.settings.pinProject]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 rounded-md border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:Hr?h.settings.restoreTitle:h.settings.archiveTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:Hr?h.settings.restoreHint:h.settings.archiveHint})]}),(0,Q.jsxs)(Y,{type:`button`,variant:Hr?`primary`:`ghost`,className:`w-fit rounded-lg`,disabled:vn===`archive`,onClick:()=>void hr(),children:[Hr?(0,Q.jsx)(re,{className:`size-4`,"aria-hidden":!0}):(0,Q.jsx)(rt,{className:`size-4`,"aria-hidden":!0}),Hr?h.settings.restoreProject:h.settings.archiveProject]})]})]})]}),(0,Q.jsxs)(`section`,{className:`grid gap-3 rounded-lg border border-red-500/20 bg-red-500/5 p-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:h.settings.dangerTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-red-700/80 dark:text-red-200/80`,children:h.settings.dangerHint})]}),(0,Q.jsxs)(Y,{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:()=>Jt(!0),children:[(0,Q.jsx)(Xt,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})]}):null]}),(0,Q.jsx)(Se,{open:qt,onOpenChange:e=>{bn||Jt(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay p-5 shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.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,Q.jsx)(p,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.deleteConfirmTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:E?ui(h.settings.deleteConfirm,{name:E.name}):h.settings.deleteConfirmFallback})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:bn,children:h.common.cancel})}),(0,Q.jsxs)(Y,{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:bn||!E,onClick:()=>void gr(),children:[(0,Q.jsx)(Xt,{className:`size-4`,"aria-hidden":!0}),h.settings.deleteConfirmAction]})]})]})]})}),(0,Q.jsx)(Qt,{open:!!Ie,title:f.workspace.trashConfirmTitle,description:f.workspace.trashConfirmDescription.replace(`{{name}}`,Ie?.name??``),confirmLabel:f.workspace.moveToTrash,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Cr(),onCancel:()=>We(null)}),(0,Q.jsx)(Qt,{open:!!Ge,title:f.workspace.deleteConfirmTitle,description:f.workspace.deleteConfirmDescription.replace(`{{name}}`,Ge?.name??``),confirmLabel:f.workspace.deleteFile,cancelLabel:f.workspace.cancel,destructive:!0,onConfirm:()=>void Er(),onCancel:()=>Je(null)}),(0,Q.jsx)(Se,{open:nn,onOpenChange:e=>{Ht||an(e)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMigrationTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:h.settings.workspaceMigrationDescription})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-4 overflow-y-auto px-5 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2 text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-fg-muted`,children:h.settings.workspaceMode}),(0,Q.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:J(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,sn===`fixed`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:sn===`fixed`,onChange:()=>ln(`fixed`),disabled:Ht}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFixed}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceMigrationFixedHint})]})]}),(0,Q.jsxs)(`label`,{className:J(`flex min-h-10 items-start gap-2 rounded-md border px-3 py-2`,sn===`follow`?`border-accent bg-accent-soft/40 text-fg`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsx)(`input`,{type:`radio`,className:`mt-0.5 size-4`,checked:sn===`follow`,onChange:()=>ln(`follow`),disabled:Ht}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block font-medium`,children:h.settings.workspaceModeFollow}),(0,Q.jsx)(`span`,{className:`block text-xs leading-5 text-fg-subtle`,children:h.settings.workspaceHint})]})]})]})]}),sn===`fixed`?(0,Q.jsx)(gn,{value:un,onChange:_n,disabled:Ht,wd:m,placeholder:h.settings.workspacePlaceholder,inputClassName:mi(),autoFocus:!0}):null,(0,Q.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:h.settings.workspaceMigrationImpact}),(0,Q.jsx)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-subtle`,children:ui(h.settings.workspaceCurrent,{workspace:Kr})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,disabled:Ht,children:h.common.cancel})}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Ht||!qr,onClick:()=>void fr(),children:[(0,Q.jsx)(nt,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMigrationConfirm]})]})]})]})}),(0,Q.jsx)(Se,{open:!!Yt,onOpenChange:e=>{e||tn(null)},children:(0,Q.jsxs)(ye,{children:[(0,Q.jsx)(ge,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,Q.jsxs)(be,{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-overlay shadow-float focus:outline-none`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-4`,children:[(0,Q.jsx)(xe,{className:`text-base font-semibold text-fg`,children:h.settings.workspaceMissingTitle}),(0,Q.jsx)(_e,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:Yt?ui(h.settings.workspaceMissingDescription,{workspace:Yt}):null})]}),Yt?(0,Q.jsx)(`div`,{className:`px-5 py-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-inset px-3 py-2 text-sm text-fg-muted`,children:[(0,Q.jsx)(xt,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:Yt})]})}):null,(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:Xr,disabled:Ht,children:h.settings.workspaceMissingBack}),(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,className:`rounded-lg`,onClick:()=>void fr({createWorkspaceRoot:!0}),disabled:Ht,children:[(0,Q.jsx)(nt,{className:`size-4`,"aria-hidden":!0}),h.settings.workspaceMissingCreate]})]})]})]})})]})}export{ki as ProjectDetailPage};