@runfusion/fusion 0.77.0-beta.6 → 0.77.0-beta.8

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 (170) hide show
  1. package/dist/bin.js +42896 -39460
  2. package/dist/child-process-worker.js +7535 -4556
  3. package/dist/client/.vite/manifest.json +267 -330
  4. package/dist/client/assets/{AgentDetailView-oyY72uSo.js → AgentDetailView-DsMRc-aH.js} +4 -4
  5. package/dist/client/assets/{AgentPermissionPolicyEditor-C3Qo9p1M.js → AgentPermissionPolicyEditor-BXJ52YpO.js} +2 -2
  6. package/dist/client/assets/{AgentsView-M2MhTIGW.js → AgentsView-DO-25nlB.js} +4 -4
  7. package/dist/client/assets/{CommandCenter-CpcAt6jt.js → CommandCenter-BMXMg_I2.js} +18 -18
  8. package/dist/client/assets/DevServerView-DAeL5TYz.js +1 -0
  9. package/dist/client/assets/DirectoryPicker-Cw-XRjAa.js +1 -0
  10. package/dist/client/assets/DocumentsView-CusClN9u.js +1 -0
  11. package/dist/client/assets/EvalsView-gNdeUDww.js +1 -0
  12. package/dist/client/assets/ExperimentalAgentOnboardingModal-Bmzbqzhs.js +1 -0
  13. package/dist/client/assets/{GoalsView-DPj59B3l.js → GoalsView-J8JMsoLn.js} +1 -1
  14. package/dist/client/assets/{InsightsView-QLJNkKJp.js → InsightsView-BVbv56K0.js} +3 -3
  15. package/dist/client/assets/{MemoryView-CDCS-1ig.js → MemoryView-DNvJFoDu.js} +1 -1
  16. package/dist/client/assets/{PiExtensionsManager-DktXXrmF.js → PiExtensionsManager-BPMexS34.js} +2 -2
  17. package/dist/client/assets/PluginManager-DGEv-ptu.js +1 -0
  18. package/dist/client/assets/{PullRequestView-CkObT6e3.js → PullRequestView-CF7fx-Uo.js} +2 -2
  19. package/dist/client/assets/ReportModal-B8S5BFgn.js +21 -0
  20. package/dist/client/assets/ReportModal-Dx3f2aj7.css +1 -0
  21. package/dist/client/assets/{ResearchView-CryFrV8l.js → ResearchView-CBeXsevy.js} +1 -1
  22. package/dist/client/assets/{SecretsView-9YcNW_fo.js → SecretsView-Dmi9wZkv.js} +1 -1
  23. package/dist/client/assets/SettingsModal-D2kXP7Um.js +21 -0
  24. package/dist/client/assets/{SettingsModal-llkoaJev.js → SettingsModal-DSW3xnGk.js} +1 -1
  25. package/dist/client/assets/{SettingsTextareaRow-B_Legu-A.js → SettingsTextareaRow-CLab4Vcd.js} +1 -1
  26. package/dist/client/assets/SetupWizardModal-Ct6juX9x.js +2 -0
  27. package/dist/client/assets/{SkillsView-CSeauwIw.js → SkillsView-Dn0bwT6i.js} +1 -1
  28. package/dist/client/assets/WorkflowNodeEditor-cvReMlG-.js +8 -0
  29. package/dist/client/assets/{agent-import-generation-CttglSmZ.js → agent-import-generation-C8_ewVzC.js} +1 -1
  30. package/dist/client/assets/{agentsOrgChartLayout-f-9mwRbD.js → agentsOrgChartLayout-p1i6XROQ.js} +1 -1
  31. package/dist/client/assets/{app-C_PTWuI1.js → app-BOvA34XN.js} +3 -3
  32. package/dist/client/assets/{app-BBSLJDbV.js → app-Bic4iWXQ.js} +3 -3
  33. package/dist/client/assets/{app-Bvr57EZQ.js → app-BlbH7Tir.js} +2 -2
  34. package/dist/client/assets/{app-DwvelD-n.js → app-C6TctczU.js} +3 -3
  35. package/dist/client/assets/{app-DRW5hIgr.js → app-D3qZmEIu.js} +3 -3
  36. package/dist/client/assets/{app-BKwOvuxE.js → app-DLnMkUt5.js} +2 -2
  37. package/dist/client/assets/{app-DKx18PHE.js → app-mNy0DeDM.js} +3 -3
  38. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DA_Hm_di.js → architectureDiagram-3BPJPVTR-CzCk1QdH.js} +1 -1
  39. package/dist/client/assets/{blockDiagram-GPEHLZMM-JF7K8CcV.js → blockDiagram-GPEHLZMM-74Rj-5ov.js} +1 -1
  40. package/dist/client/assets/{c4Diagram-AAUBKEIU-DN-wklCP.js → c4Diagram-AAUBKEIU-B570qYH-.js} +1 -1
  41. package/dist/client/assets/channel-DWAK5y-J.js +1 -0
  42. package/dist/client/assets/{chunk-2J33WTMH-ChtjU8Cu.js → chunk-2J33WTMH-DejJkxt6.js} +1 -1
  43. package/dist/client/assets/{chunk-4BX2VUAB-dJL0n3nn.js → chunk-4BX2VUAB-DlgxkBuE.js} +1 -1
  44. package/dist/client/assets/{chunk-55IACEB6-Bfg-QB9A.js → chunk-55IACEB6-XCfE8PwC.js} +1 -1
  45. package/dist/client/assets/{chunk-727SXJPM-BHPPwYUS.js → chunk-727SXJPM-D-nDw0Bi.js} +1 -1
  46. package/dist/client/assets/{chunk-AQP2D5EJ-DIIpPUQN.js → chunk-AQP2D5EJ-C4KySao0.js} +1 -1
  47. package/dist/client/assets/{chunk-FMBD7UC4-D230R32b.js → chunk-FMBD7UC4-CXKdLygA.js} +1 -1
  48. package/dist/client/assets/{chunk-ND2GUHAM-0Lhp5CRv.js → chunk-ND2GUHAM-bNYWWGVJ.js} +1 -1
  49. package/dist/client/assets/{chunk-QZHKN3VN-BxbHBfKJ.js → chunk-QZHKN3VN-cfBQJ-MX.js} +1 -1
  50. package/dist/client/assets/classDiagram-4FO5ZUOK-WTkXRkfm.js +1 -0
  51. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-WTkXRkfm.js +1 -0
  52. package/dist/client/assets/{common-13IRj_PO.js → common-BsNuuNOe.js} +1 -1
  53. package/dist/client/assets/{common-BBynATth.js → common-CASsTuSW.js} +1 -1
  54. package/dist/client/assets/{common-BG-vw0tL.js → common-CfyFt5OG.js} +1 -1
  55. package/dist/client/assets/{common-DSo46rnH.js → common-DS98trLj.js} +1 -1
  56. package/dist/client/assets/common-DeoHWJCq.js +1 -0
  57. package/dist/client/assets/common-PpMdoH5r.js +1 -0
  58. package/dist/client/assets/{common-vpHuuvkd.js → common-cN--mrmm.js} +1 -1
  59. package/dist/client/assets/{cose-bilkent-S5V4N54A-3vEwhfYz.js → cose-bilkent-S5V4N54A-CiZrg3mQ.js} +1 -1
  60. package/dist/client/assets/{dagre-BM42HDAG-Br44UsdY.js → dagre-BM42HDAG-Bckph2U4.js} +1 -1
  61. package/dist/client/assets/{dashboard-view-_EglxMDl.js → dashboard-view-CN_fkDM1.js} +1 -1
  62. package/dist/client/assets/{dashboard-view-BldxxYfz.js → dashboard-view-CVYHQZwx.js} +1 -1
  63. package/dist/client/assets/dashboard-view-DDRKwfFs.js +1 -0
  64. package/dist/client/assets/{dashboard-view-CcPcELPx.js → dashboard-view-IuPjDVGa.js} +2 -2
  65. package/dist/client/assets/{diagram-2AECGRRQ-CLNxbHUP.js → diagram-2AECGRRQ-Bnaurex7.js} +1 -1
  66. package/dist/client/assets/{diagram-5GNKFQAL-D3cNAeQH.js → diagram-5GNKFQAL-BKz1omVN.js} +1 -1
  67. package/dist/client/assets/{diagram-KO2AKTUF-DkX7h6to.js → diagram-KO2AKTUF-C51lEZwo.js} +1 -1
  68. package/dist/client/assets/{diagram-LMA3HP47-6iQIiYUr.js → diagram-LMA3HP47-BYm5gql7.js} +1 -1
  69. package/dist/client/assets/{diagram-OG6HWLK6-Caje3229.js → diagram-OG6HWLK6-B9CFA4ha.js} +1 -1
  70. package/dist/client/assets/{erDiagram-TEJ5UH35-BkU-1HB1.js → erDiagram-TEJ5UH35-BLyCSssl.js} +1 -1
  71. package/dist/client/assets/{flowDiagram-I6XJVG4X-BRx3V6RE.js → flowDiagram-I6XJVG4X-yDVmpkro.js} +1 -1
  72. package/dist/client/assets/{folder-open-BaSOBfk2.js → folder-open-Cf2NA9nV.js} +1 -1
  73. package/dist/client/assets/{ganttDiagram-6RSMTGT7-D9f1kH3t.js → ganttDiagram-6RSMTGT7-mC9YPFcx.js} +1 -1
  74. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CQwmZcRd.js → gitGraphDiagram-PVQCEYII-DS0bEccv.js} +1 -1
  75. package/dist/client/assets/index-BjM7LxzY.js +2805 -0
  76. package/dist/client/assets/index-DcKIzuMk.css +1 -0
  77. package/dist/client/assets/{infoDiagram-5YYISTIA-DYWBkGjG.js → infoDiagram-5YYISTIA-CuuNZITP.js} +1 -1
  78. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Df0Nzvh4.js → ishikawaDiagram-YF4QCWOH-MBSaC94m.js} +1 -1
  79. package/dist/client/assets/{journeyDiagram-JHISSGLW-bSvrZSyZ.js → journeyDiagram-JHISSGLW-DkaAow9E.js} +1 -1
  80. package/dist/client/assets/{kanban-definition-UN3LZRKU-yHJ101M8.js → kanban-definition-UN3LZRKU-DSf5OLtq.js} +1 -1
  81. package/dist/client/assets/{mermaid.core-Bc_0VLJw.js → mermaid.core-HmTn21MF.js} +4 -4
  82. package/dist/client/assets/{mindmap-definition-RKZ34NQL-DWRnMguM.js → mindmap-definition-RKZ34NQL-sv0Dl8aI.js} +1 -1
  83. package/dist/client/assets/{pieDiagram-4H26LBE5-Ds-DEOqr.js → pieDiagram-4H26LBE5-BDK2IQNq.js} +1 -1
  84. package/dist/client/assets/{puzzle-CdYF81IT.js → puzzle-D00mP67o.js} +1 -1
  85. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-Bz-j2fkf.js → quadrantDiagram-W4KKPZXB-CiWAhwf1.js} +1 -1
  86. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BaQ_PaZ-.js → requirementDiagram-4Y6WPE33-DwC99D35.js} +1 -1
  87. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-pUCz8V4-.js → sankeyDiagram-5OEKKPKP-CQn8z721.js} +1 -1
  88. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-CFwUMspe.js → sequenceDiagram-3UESZ5HK-B0CT8-vw.js} +1 -1
  89. package/dist/client/assets/{standing-instructions-template-Crocrob7.js → standing-instructions-template-BIBO_Prr.js} +2 -2
  90. package/dist/client/assets/{stateDiagram-AJRCARHV-CHZwo-vd.js → stateDiagram-AJRCARHV-BYAB_dFF.js} +1 -1
  91. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-BTvKaIZR.js → stateDiagram-v2-BHNVJYJU-Cd19uJBk.js} +1 -1
  92. package/dist/client/assets/{timeline-definition-PNZ67QCA-Cn3XIoz2.js → timeline-definition-PNZ67QCA-DQLh8XkY.js} +1 -1
  93. package/dist/client/assets/{upload--GqImz6h.js → upload-D4pkNOz2.js} +1 -1
  94. package/dist/client/assets/{users-B0h1q4x6.js → users-COgviS_S.js} +1 -1
  95. package/dist/client/assets/{vennDiagram-CIIHVFJN-CS0FNVU_.js → vennDiagram-CIIHVFJN-BmwG1Wud.js} +1 -1
  96. package/dist/client/assets/{wardley-L42UT6IY-DdYkfF5d.js → wardley-L42UT6IY-BiO7jkmj.js} +1 -1
  97. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-B_rFmPCh.js → wardleyDiagram-YWT4CUSO-Dq0IPg5H.js} +1 -1
  98. package/dist/client/assets/{xychartDiagram-2RQKCTM6-CCoaCgmc.js → xychartDiagram-2RQKCTM6-BlMOlSBc.js} +1 -1
  99. package/dist/client/index.html +13 -6
  100. package/dist/client/theme-data.css +85 -0
  101. package/dist/client/version.json +1 -1
  102. package/dist/droid-cli/package.json +1 -1
  103. package/dist/extension.js +42201 -38907
  104. package/dist/migrations/0065_fn_149_review_convergence_stage.sql +3 -0
  105. package/dist/pi-claude-cli/package.json +1 -1
  106. package/dist/plugin-sdk/index.d.ts +62 -11
  107. package/dist/plugin-sdk/index.js +140 -46
  108. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +195 -49
  109. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  110. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +140 -46
  111. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  112. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +140 -46
  113. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  114. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +140 -46
  115. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  116. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +140 -46
  117. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  118. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +140 -46
  119. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  120. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +140 -46
  121. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  122. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +140 -46
  123. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  124. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +140 -46
  125. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  126. package/dist/plugins/fusion-plugin-linear-import/bundled.js +140 -46
  127. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  128. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +140 -46
  129. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  130. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +140 -46
  131. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  132. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +140 -46
  133. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  134. package/dist/plugins/fusion-plugin-quality/bundled.js +140 -46
  135. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  136. package/dist/plugins/fusion-plugin-reports/bundled.js +140 -46
  137. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  138. package/dist/plugins/fusion-plugin-roadmap/bundled.js +140 -46
  139. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  140. package/dist/plugins/fusion-plugin-todos/bundled.js +140 -46
  141. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  142. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +140 -46
  143. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  144. package/package.json +1 -1
  145. package/skill/fusion/references/engine-tools.md +5 -5
  146. package/dist/client/assets/ChatView-DS4XiCm_.css +0 -1
  147. package/dist/client/assets/ChatView-zKrUSqiQ.js +0 -13
  148. package/dist/client/assets/DevServerView-CjTneoG7.js +0 -1
  149. package/dist/client/assets/DirectoryPicker-BY6V5HLV.js +0 -1
  150. package/dist/client/assets/DocumentsView-RDK56-qg.js +0 -1
  151. package/dist/client/assets/EvalsView-DKK4ceUW.js +0 -1
  152. package/dist/client/assets/ExperimentalAgentOnboardingModal-DiBPZVwC.js +0 -1
  153. package/dist/client/assets/PluginManager-CQ3iEFMq.js +0 -1
  154. package/dist/client/assets/ReportModal-B5LTdDgi.js +0 -21
  155. package/dist/client/assets/ReportModal-lzN_xrnM.css +0 -1
  156. package/dist/client/assets/SessionTerminal-2ZSXmOkG.css +0 -1
  157. package/dist/client/assets/SessionTerminal-BWsA9puD.js +0 -2
  158. package/dist/client/assets/SettingsModal-CL6aiXiI.js +0 -21
  159. package/dist/client/assets/SetupWizardModal-DLA4UAGp.js +0 -2
  160. package/dist/client/assets/WorkflowNodeEditor-CGgMiiWy.js +0 -8
  161. package/dist/client/assets/channel-CwFfFSI9.js +0 -1
  162. package/dist/client/assets/classDiagram-4FO5ZUOK-C8dZsxxX.js +0 -1
  163. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C8dZsxxX.js +0 -1
  164. package/dist/client/assets/common-DbOCE-0i.js +0 -1
  165. package/dist/client/assets/common-DnXF4Jmj.js +0 -1
  166. package/dist/client/assets/dashboard-view-B0OM3KYC.js +0 -1
  167. package/dist/client/assets/index-B8PcG8AJ.js +0 -2774
  168. package/dist/client/assets/index-Dki2LBAp.css +0 -1
  169. package/dist/client/assets/shield-alert-4qeU3_Rm.js +0 -6
  170. package/dist/client/assets/useDiscoveredSkillsCache-BEHgTFai.js +0 -1
@@ -1,3 +1,3 @@
1
- import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{u as $e,f as we,a as ke,s as Ke,i as _e,t as Ue,b as Ce,c as Ee,d as Be,e as Qe,g as We,h as Ve}from"./SettingsModal-llkoaJev.js";import{a as ee,w as te,dc as Ye,a_ as Xe,V as Ze,dd as Je,L as _,aL as Fe}from"./index-B8PcG8AJ.js";import{u as Ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function pe(i){const s=Object.entries(i).flatMap(([r,t])=>Array.isArray(t)?t.filter(Boolean).map(c=>[r,c]):t===void 0||t===""?[]:[[r,String(t)]]);return s.length?`?${s.map(([r,t])=>`${encodeURIComponent(r)}=${encodeURIComponent(t)}`).join("&")}`:""}function et(i){return ee(te("/knowledge/graph/status",i))}function tt(i,s={}){return ee(te(`/knowledge/graph/nodes${pe(s)}`,i))}function st(i,s){return ee(te(`/knowledge/graph/node${pe({id:s})}`,i))}function Ae(i,s){return ee(te(`/knowledge/graph/neighbors${pe(s)}`,i))}function at(i,s){return ee(te(`/knowledge/graph/path${pe(s)}`,i))}function nt(i,s=!1){return ee(te("/knowledge/graph/build",i),{method:"POST",body:JSON.stringify({force:s})})}const J=".fusion/memory/MEMORY.md",rt=5e4,lt="0 3 * * *",it="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??rt,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??lt,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??it}}function Me(i,s){return i.some(r=>r.path===s)?s:i.find(r=>r.path===J)?.path??i[0]?.path??J}function ot(i={}){const{projectId:s}=i,[r,t]=n.useState(null),[c,v]=n.useState(!0),[d,M]=n.useState(!1),[E,k]=n.useState(()=>ge({})),[f,w]=n.useState(!0),[m,a]=n.useState(!1),[h,F]=n.useState([]),[U,G]=n.useState(!0),[N,D]=n.useState(J),[I,R]=n.useState(""),[se,B]=n.useState(!1),[p,g]=n.useState(!1),[H,L]=n.useState(!1),[S,P]=n.useState(!1),[Y,T]=n.useState(!1),[x,Q]=n.useState(null),[u,y]=n.useState(!0),[b,W]=n.useState(!1),[le,ae]=n.useState(!1),{status:ne,loading:be,refresh:$}=$e({projectId:s}),re=n.useCallback(o=>{R(o),g(!0)},[]),X=n.useCallback(async o=>{B(!0);try{const{content:j}=await we(o,s);D(o),R(j),g(!1)}finally{B(!1)}},[s]),q=n.useCallback(async()=>{G(!0);try{const{files:o}=await ke(s);if(F(o),o.length===0){D(J),R(""),g(!1);return}const j=Me(o,N);j!==N&&await X(j)}finally{G(!1)}},[s,N,X]);n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ee(s);o||(t(A.content),M(A.exists),v(!1))}catch{o||(t(null),M(!1),v(!1))}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){w(!0);try{const A=await Xe(s);o||k(ge(A))}catch{o||k(ge({}))}finally{o||w(!1)}}return j(),()=>{o=!0}},[s]);const ie=n.useRef(N);n.useEffect(()=>{ie.current=N},[N]),n.useEffect(()=>{let o=!1;async function j(){G(!0);try{const{files:A}=await ke(s);if(o)return;if(F(A),A.length===0){D(J),R(""),g(!1);return}const ue=Me(A,ie.current),{content:je}=await we(ue,s);if(o)return;D(ue),R(je),g(!1)}catch{o||(F([]),D(J),R(""),g(!1))}finally{o||G(!1)}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ce(s);o||(Q(A),y(!1))}catch{o||(Q(null),y(!1))}}return j(),()=>{o=!0}},[s]);const oe=n.useCallback(async o=>{a(!0);try{const j=await Ye(o,s);k(ge(j))}finally{a(!1)}},[s]),me=n.useCallback(async o=>{await X(o)},[X]),ce=n.useCallback(async()=>{if(p){L(!0);try{await Ke(N,I,s),g(!1),await q()}finally{L(!1)}}},[I,p,N,s,q]),de=n.useCallback(async()=>{ae(!0);try{const o=await _e(s);return await $(),o}finally{ae(!1)}},[s,$]),he=n.useCallback(async o=>Ue(o,s),[s]),Z=n.useCallback(async()=>{try{const o=await Ce(s);Q(o)}catch{Q(null)}},[s]),K=n.useCallback(async()=>{try{const o=await Ee(s);t(o.content),M(o.exists)}catch{t(null),M(!1)}},[s]),z=n.useCallback(async o=>{await Be(o,s),await K()},[s,K]),xe=n.useCallback(async()=>{P(!0);try{const o=await Qe(s);return await Promise.all([K(),Z()]),{success:o.success,summary:o.summary}}finally{P(!1)}},[s,K,Z]),V=n.useCallback(async()=>{T(!0);try{return await We(s)}finally{T(!1)}},[s]),fe=n.useCallback(async o=>{W(!0);try{const j=await Ve(o,s),A=j.path??o;D(A),R(j.content),g(!1),await q()}finally{W(!1)}},[s,q]);return{insightsContent:r,insightsLoading:c,insightsExists:d,refreshInsights:K,saveInsights:z,memorySettings:E,settingsLoading:f,savingMemorySettings:m,saveMemorySettings:oe,memoryFiles:h,memoryFilesLoading:U,selectedFilePath:N,selectedFileContent:I,selectedFileLoading:se,selectedFileDirty:p,setSelectedFileContent:re,selectFile:me,saveSelectedFile:ce,savingSelectedFile:H,reloadMemoryFiles:q,backendStatus:ne,backendLoading:be,extractInsights:xe,extracting:S,triggerDreamNow:V,dreamRunning:Y,auditReport:x,auditLoading:u,refreshAudit:Z,compactMemory:fe,compacting:b,installQmdAction:de,installingQmd:le,testRetrieval:he}}const De={limit:50,offset:0};function mt({projectId:i,enabled:s}){const[r,t]=n.useState(null),[c,v]=n.useState(De),[d,M]=n.useState(null),[E,k]=n.useState(null),[f,w]=n.useState(null),[m,a]=n.useState({direction:"both",depth:1}),[h,F]=n.useState(null),[U,G]=n.useState({fromId:"",toId:"",maxHops:6}),[N,D]=n.useState(null),[I,R]=n.useState(!1),[se,B]=n.useState(!1),[p,g]=n.useState(null),H=n.useRef(0),L=n.useRef(0),S=n.useRef(0),P=n.useCallback(async()=>{try{const u=await et(i);t(u),G(y=>({...y,maxHops:u.pathLimits.defaultMaxHops}))}catch(u){g(u instanceof Error?u.message:String(u))}},[i]);n.useEffect(()=>{P()},[s,P]),n.useEffect(()=>{if(!r?.available)return;const u=++H.current;R(!0);const y=window.setTimeout(()=>void tt(i,c).then(b=>{u===H.current&&M(b)}).catch(b=>{u===H.current&&g(b instanceof Error?b.message:String(b))}).finally(()=>{u===H.current&&R(!1)}),250);return()=>window.clearTimeout(y)},[s,c,i,r?.available]);const Y=n.useCallback(async(u=E)=>{if(!u)return;const y=++L.current;try{const b=await Ae(i,{nodeId:u,...m});y===L.current&&F(b)}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i,E]),T=n.useCallback(async u=>{const y=++L.current;k(u);try{const[b,W]=await Promise.all([st(i,u),Ae(i,{nodeId:u,...m})]);y===L.current&&(w(b),F(W))}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i]),x=n.useCallback(async()=>{const u=++S.current;D(null),g(null);try{const y=await at(i,U);u===S.current&&D(y)}catch(y){u===S.current&&g(y instanceof Error?y.message:String(y))}},[U,i]),Q=n.useCallback(async(u=!1)=>{B(!0);try{await nt(i,u),await P()}catch(y){g(y instanceof Error?y.message:String(y))}finally{B(!1)}},[i,P]);return{status:r,filters:c,setFilters:v,nodes:d,loading:I,selectedId:E,detail:f,selectNode:T,neighborOptions:m,setNeighborOptions:a,neighborResults:h,refreshNeighbors:Y,pathInput:U,setPathInput:G,pathResult:N,findPath:x,rebuild:Q,rebuilding:se,refreshStatus:P,error:p,clearFilters:()=>v(De)}}const ct=["file","module","symbol","doc-concept","rationale"],dt=["function","class","interface","type-alias","enum","variable","namespace","alias"],ht=["contains","imports","re-exports","relates-to","rationale-supports"];function ve({id:i,onSelect:s}){return e.jsx("button",{type:"button",className:"btn btn-ghost knowledge-graph-endpoint",onClick:()=>s(i),children:i})}function Ie({title:i,edges:s,total:r,endpoint:t,onSelect:c}){const{t:v}=Ne("app");return e.jsxs("section",{className:"knowledge-graph-edge-list",children:[e.jsxs("h4",{children:[i," ",e.jsx("span",{children:v("knowledgeGraph.showingOf","showing {{shown}} of {{total}}",{shown:s.length,total:r})})]}),s.length===0?e.jsx("p",{className:"knowledge-graph-muted",children:v("knowledgeGraph.none","None")}):e.jsx("ul",{children:s.map(d=>e.jsxs("li",{children:[e.jsx("span",{children:d.kind}),e.jsx("span",{className:`knowledge-graph-provenance knowledge-graph-provenance--${d.provenance}`,children:d.provenance}),e.jsx(ve,{id:d[t],onSelect:c})]},d.id))})]})}function ut({projectId:i,addToast:s}){const{t:r}=Ne("app"),t=mt({projectId:i,enabled:!0}),[c,v]=n.useState(!1);if(n.useEffect(()=>{t.error&&s(t.error,"error")},[s,t.error]),!t.status&&t.error)return e.jsx("div",{className:"knowledge-graph-panel knowledge-graph-error","data-testid":"knowledge-graph-error",children:t.error});if(!t.status)return e.jsx("div",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-loading",children:r("memory.graphLoading","Loading knowledge graph…")});if(!t.status.available)return e.jsxs("div",{className:"knowledge-graph-panel knowledge-graph-empty","data-testid":"knowledge-graph-no-graph",children:[e.jsxs("p",{children:[r("memory.graphUnavailable","Graph unavailable"),": ",t.status.recoveryReason]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.rebuild(!1),children:r("memory.graphBuild","Build graph")})]});const d=a=>t.setFilters({...t.filters,...a,offset:0}),M=a=>{const h=t.filters.kinds??[];d({kinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},E=a=>{const h=t.neighborOptions.edgeKinds??[];t.setNeighborOptions({...t.neighborOptions,edgeKinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},k=t.selectedId,f=t.status.pathLimits,w=t.pathResult?.outcome==="found"?t.pathResult.path:null,m=t.pathResult?.outcome==="found"?t.pathResult.hops:void 0;return e.jsxs("section",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-panel",children:[e.jsxs("header",{className:"knowledge-graph-status card",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.status.nodeCount," ",r("memory.graphNodes","nodes")," · ",t.status.edgeCount," ",r("memory.graphEdges","edges")]}),e.jsx("span",{children:t.status.graphDir})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.nodeKinds","Node kinds")}),e.jsx("dd",{children:Object.entries(t.status.nodeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.edgeKinds","Edge kinds")}),e.jsx("dd",{children:Object.entries(t.status.edgeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.provenance","Provenance")}),e.jsx("dd",{children:Object.entries(t.status.provenanceCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]})]}),e.jsxs("label",{className:"knowledge-graph-toggle",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:a=>v(a.target.checked)})," ",r("memory.graphForce","Force rebuild")]}),e.jsx("button",{type:"button",className:"btn",disabled:t.rebuilding,onClick:()=>void t.rebuild(c),children:t.rebuilding?r("memory.graphRebuilding","Rebuilding…"):r("memory.graphRebuild","Rebuild")})]}),e.jsxs("section",{className:"knowledge-graph-filters card","aria-label":r("memory.graphFilters","Graph filters"),children:[e.jsx("div",{className:"knowledge-graph-kind-options",children:ct.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.filters.kinds??[]).includes(a),onChange:()=>M(a)})," ",a]},a))}),e.jsx("input",{className:"input","aria-label":"Path prefix",placeholder:"Path prefix",value:t.filters.pathPrefix??"",onChange:a=>d({pathPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Node id prefix",placeholder:"Node id prefix",value:t.filters.idPrefix??"",onChange:a=>d({idPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Name regex",placeholder:"Name regex",value:t.filters.namePattern??"",onChange:a=>d({namePattern:a.target.value})}),e.jsxs("select",{className:"select","aria-label":"FNXC area",value:t.filters.fnxcArea??"",onChange:a=>d({fnxcArea:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allFnxcAreas","All FNXC areas")}),t.status.fnxcAreas?.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Symbol kind",value:t.filters.symbolKind??"",onChange:a=>d({symbolKind:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allSymbolKinds","All symbol kinds")}),dt.map(a=>e.jsx("option",{children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Owner",value:t.filters.owner??"",onChange:a=>d({owner:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allOwners","All owners")}),e.jsx("option",{value:"file",children:r("knowledgeGraph.ownerFile","file")}),e.jsx("option",{value:"derived",children:r("knowledgeGraph.ownerDerived","derived")})]}),e.jsx("select",{className:"select","aria-label":"Result limit",value:t.filters.limit??50,onChange:a=>d({limit:Number(a.target.value)}),children:[25,50,100,200].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.limitResults","{{limit}} results",{limit:a})},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t.clearFilters,children:r("memory.graphClearFilters","Clear filters")})]}),e.jsxs("div",{className:"knowledge-graph-layout",children:[e.jsxs("section",{className:"card knowledge-graph-results",children:[e.jsxs("h3",{children:[t.nodes?.total??0," ",r("memory.graphResults","results")]}),t.loading?e.jsx("p",{"data-testid":"knowledge-graph-searching",children:r("knowledgeGraph.searching","Searching…")}):t.nodes?.nodes.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{children:t.nodes.nodes.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.selectNode(a.id),children:[e.jsxs("strong",{children:[a.kind,": ",a.name]}),e.jsxs("span",{children:[a.id," · ",a.ownerPath,":",a.source.line]})]})},a.id))}),e.jsxs("div",{className:"knowledge-graph-pagination",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:!t.filters.offset,onClick:()=>d({offset:Math.max(0,(t.filters.offset??0)-(t.filters.limit??50))}),children:r("knowledgeGraph.previous","Previous")}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:(t.filters.offset??0)+(t.filters.limit??50)>=(t.nodes?.total??0),onClick:()=>d({offset:(t.filters.offset??0)+(t.filters.limit??50)}),children:r("knowledgeGraph.next","Next")})]})]}):e.jsx("p",{"data-testid":"knowledge-graph-no-results",children:r("memory.graphNoResults","No matching nodes.")})]}),e.jsx("section",{className:"card knowledge-graph-detail",children:t.detail?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:t.detail.node.name}),e.jsx("p",{children:t.detail.node.id}),e.jsxs("p",{children:[t.detail.node.ownerPath,":",t.detail.node.source.line]}),e.jsx(Ie,{title:r("knowledgeGraph.outgoing","Outgoing"),edges:t.detail.outgoing,total:t.detail.outgoingTotal,endpoint:"to",onSelect:a=>void t.selectNode(a)}),e.jsx(Ie,{title:r("knowledgeGraph.incoming","Incoming"),edges:t.detail.incoming,total:t.detail.incomingTotal,endpoint:"from",onSelect:a=>void t.selectNode(a)})]}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.selectNodeHint","Select a node to inspect its edges.")})})]}),t.detail&&e.jsxs("section",{className:"knowledge-graph-neighbors card",children:[e.jsx("h3",{children:r("knowledgeGraph.neighbors","Neighbors")}),e.jsxs("select",{className:"select","aria-label":"Neighbor direction",value:t.neighborOptions.direction,onChange:a=>t.setNeighborOptions({...t.neighborOptions,direction:a.target.value}),children:[e.jsx("option",{value:"out",children:r("knowledgeGraph.outgoing","Outgoing")}),e.jsx("option",{value:"in",children:r("knowledgeGraph.incoming","Incoming")}),e.jsx("option",{value:"both",children:r("knowledgeGraph.bothDirections","Both directions")})]}),e.jsx("select",{className:"select","aria-label":"Neighbor depth",value:t.neighborOptions.depth,onChange:a=>t.setNeighborOptions({...t.neighborOptions,depth:Number(a.target.value)}),children:[1,2,3].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.depth","Depth {{depth}}",{depth:a})},a))}),e.jsx("div",{className:"knowledge-graph-kind-options",children:ht.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.neighborOptions.edgeKinds??[]).includes(a),onChange:()=>E(a)})," ",a]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.refreshNeighbors(),children:r("knowledgeGraph.refreshNeighbors","Refresh neighbors")}),t.neighborResults?.neighbors.length?e.jsx("ul",{children:t.neighborResults.neighbors.map(a=>e.jsxs("li",{children:[e.jsx("span",{children:r("knowledgeGraph.distance","distance {{distance}}",{distance:a.distance})}),e.jsx(ve,{id:a.node.id,onSelect:h=>void t.selectNode(h)})]},a.node.id))}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.noNeighbors","No neighbors found.")})]}),e.jsxs("section",{className:"knowledge-graph-path card",children:[e.jsx("h3",{children:r("knowledgeGraph.shortestPath","Shortest path")}),e.jsx("input",{className:"input","aria-label":"From node id",placeholder:"From node id",value:t.pathInput.fromId,onChange:a=>t.setPathInput({...t.pathInput,fromId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"To node id",placeholder:"To node id",value:t.pathInput.toId,onChange:a=>t.setPathInput({...t.pathInput,toId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Maximum hops",type:"number",min:"1",max:f.maxHops,value:t.pathInput.maxHops,onChange:a=>t.setPathInput({...t.pathInput,maxHops:Number(a.target.value)})}),k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,fromId:k}),children:r("knowledgeGraph.useSelectedFrom","Use selected as from")}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,toId:k}),children:r("knowledgeGraph.useSelectedTo","Use selected as to")})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.findPath(),children:r("knowledgeGraph.findPath","Find path")}),w&&e.jsxs("div",{"data-testid":"knowledge-graph-path-found",children:[e.jsx("strong",{children:r("knowledgeGraph.hops","{{count}} hops",{count:m})}),e.jsx("div",{className:"knowledge-graph-path-chain",children:w.nodes.map((a,h)=>e.jsxs("span",{children:[e.jsx(ve,{id:a.id,onSelect:F=>void t.selectNode(F)}),h<w.edges.length&&e.jsx("em",{children:w.edges[h].kind})]},a.id))})]}),t.pathResult?.outcome==="not-found"&&e.jsx("p",{"data-testid":"knowledge-graph-path-not-found",children:r("knowledgeGraph.noPath","No path exists between these nodes.")}),t.pathResult?.outcome==="limit-reached"&&e.jsxs("div",{"data-testid":"knowledge-graph-path-limit-reached",children:[e.jsx("p",{children:r("knowledgeGraph.pathLimitReached","No path found within {{maxHops}} hops; {{limit}} was reached.",{maxHops:t.pathResult.maxHops,limit:t.pathResult.limit})}),t.pathInput.maxHops<f.maxHops&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,maxHops:Math.min(f.maxHops,t.pathInput.maxHops+1)}),children:r("knowledgeGraph.raiseHopLimit","Raise hop limit")})]}),t.error&&e.jsx("p",{"data-testid":"knowledge-graph-path-error",className:"knowledge-graph-error",children:t.error})]})]})}const yt={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},gt=72;function pt(i,s){if(i.length<=s)return i;const r=Math.max(1,s-1),t=Math.ceil(r/2),c=Math.floor(r/2);return`${i.slice(0,t)}…${i.slice(i.length-c)}`}function bt(i){const s=`${i.label} — ${i.path}`;return pt(s,gt)}function xt(i){if(!i)return[];const s=[],r=i.split(/(?=^## )/m);for(const t of r){const c=t.trim();if(!c)continue;const v=c.match(/^##\s+(.+?)(\n|$)/);if(v){const d=v[1].trim(),M=yt[d]??d.toLowerCase(),E=c.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),k=E.split(`
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{u as $e,f as we,a as ke,s as Ke,i as _e,t as Ue,b as Ce,c as Ee,d as Be,e as Qe,g as We,h as Ve}from"./SettingsModal-DSW3xnGk.js";import{a as ee,w as te,c$ as Ye,aL as Xe,V as Ze,d0 as Je,L as _,aw as Fe}from"./index-BjM7LxzY.js";import{u as Ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function pe(i){const s=Object.entries(i).flatMap(([r,t])=>Array.isArray(t)?t.filter(Boolean).map(c=>[r,c]):t===void 0||t===""?[]:[[r,String(t)]]);return s.length?`?${s.map(([r,t])=>`${encodeURIComponent(r)}=${encodeURIComponent(t)}`).join("&")}`:""}function et(i){return ee(te("/knowledge/graph/status",i))}function tt(i,s={}){return ee(te(`/knowledge/graph/nodes${pe(s)}`,i))}function st(i,s){return ee(te(`/knowledge/graph/node${pe({id:s})}`,i))}function Ae(i,s){return ee(te(`/knowledge/graph/neighbors${pe(s)}`,i))}function at(i,s){return ee(te(`/knowledge/graph/path${pe(s)}`,i))}function nt(i,s=!1){return ee(te("/knowledge/graph/build",i),{method:"POST",body:JSON.stringify({force:s})})}const J=".fusion/memory/MEMORY.md",rt=5e4,lt="0 3 * * *",it="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??rt,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??lt,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??it}}function Me(i,s){return i.some(r=>r.path===s)?s:i.find(r=>r.path===J)?.path??i[0]?.path??J}function ot(i={}){const{projectId:s}=i,[r,t]=n.useState(null),[c,v]=n.useState(!0),[d,M]=n.useState(!1),[E,k]=n.useState(()=>ge({})),[f,w]=n.useState(!0),[m,a]=n.useState(!1),[h,F]=n.useState([]),[U,G]=n.useState(!0),[N,D]=n.useState(J),[I,R]=n.useState(""),[se,B]=n.useState(!1),[p,g]=n.useState(!1),[H,L]=n.useState(!1),[S,P]=n.useState(!1),[Y,T]=n.useState(!1),[x,Q]=n.useState(null),[u,y]=n.useState(!0),[b,W]=n.useState(!1),[le,ae]=n.useState(!1),{status:ne,loading:be,refresh:$}=$e({projectId:s}),re=n.useCallback(o=>{R(o),g(!0)},[]),X=n.useCallback(async o=>{B(!0);try{const{content:j}=await we(o,s);D(o),R(j),g(!1)}finally{B(!1)}},[s]),q=n.useCallback(async()=>{G(!0);try{const{files:o}=await ke(s);if(F(o),o.length===0){D(J),R(""),g(!1);return}const j=Me(o,N);j!==N&&await X(j)}finally{G(!1)}},[s,N,X]);n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ee(s);o||(t(A.content),M(A.exists),v(!1))}catch{o||(t(null),M(!1),v(!1))}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){w(!0);try{const A=await Xe(s);o||k(ge(A))}catch{o||k(ge({}))}finally{o||w(!1)}}return j(),()=>{o=!0}},[s]);const ie=n.useRef(N);n.useEffect(()=>{ie.current=N},[N]),n.useEffect(()=>{let o=!1;async function j(){G(!0);try{const{files:A}=await ke(s);if(o)return;if(F(A),A.length===0){D(J),R(""),g(!1);return}const ue=Me(A,ie.current),{content:je}=await we(ue,s);if(o)return;D(ue),R(je),g(!1)}catch{o||(F([]),D(J),R(""),g(!1))}finally{o||G(!1)}}return j(),()=>{o=!0}},[s]),n.useEffect(()=>{let o=!1;async function j(){try{const A=await Ce(s);o||(Q(A),y(!1))}catch{o||(Q(null),y(!1))}}return j(),()=>{o=!0}},[s]);const oe=n.useCallback(async o=>{a(!0);try{const j=await Ye(o,s);k(ge(j))}finally{a(!1)}},[s]),me=n.useCallback(async o=>{await X(o)},[X]),ce=n.useCallback(async()=>{if(p){L(!0);try{await Ke(N,I,s),g(!1),await q()}finally{L(!1)}}},[I,p,N,s,q]),de=n.useCallback(async()=>{ae(!0);try{const o=await _e(s);return await $(),o}finally{ae(!1)}},[s,$]),he=n.useCallback(async o=>Ue(o,s),[s]),Z=n.useCallback(async()=>{try{const o=await Ce(s);Q(o)}catch{Q(null)}},[s]),K=n.useCallback(async()=>{try{const o=await Ee(s);t(o.content),M(o.exists)}catch{t(null),M(!1)}},[s]),z=n.useCallback(async o=>{await Be(o,s),await K()},[s,K]),xe=n.useCallback(async()=>{P(!0);try{const o=await Qe(s);return await Promise.all([K(),Z()]),{success:o.success,summary:o.summary}}finally{P(!1)}},[s,K,Z]),V=n.useCallback(async()=>{T(!0);try{return await We(s)}finally{T(!1)}},[s]),fe=n.useCallback(async o=>{W(!0);try{const j=await Ve(o,s),A=j.path??o;D(A),R(j.content),g(!1),await q()}finally{W(!1)}},[s,q]);return{insightsContent:r,insightsLoading:c,insightsExists:d,refreshInsights:K,saveInsights:z,memorySettings:E,settingsLoading:f,savingMemorySettings:m,saveMemorySettings:oe,memoryFiles:h,memoryFilesLoading:U,selectedFilePath:N,selectedFileContent:I,selectedFileLoading:se,selectedFileDirty:p,setSelectedFileContent:re,selectFile:me,saveSelectedFile:ce,savingSelectedFile:H,reloadMemoryFiles:q,backendStatus:ne,backendLoading:be,extractInsights:xe,extracting:S,triggerDreamNow:V,dreamRunning:Y,auditReport:x,auditLoading:u,refreshAudit:Z,compactMemory:fe,compacting:b,installQmdAction:de,installingQmd:le,testRetrieval:he}}const De={limit:50,offset:0};function mt({projectId:i,enabled:s}){const[r,t]=n.useState(null),[c,v]=n.useState(De),[d,M]=n.useState(null),[E,k]=n.useState(null),[f,w]=n.useState(null),[m,a]=n.useState({direction:"both",depth:1}),[h,F]=n.useState(null),[U,G]=n.useState({fromId:"",toId:"",maxHops:6}),[N,D]=n.useState(null),[I,R]=n.useState(!1),[se,B]=n.useState(!1),[p,g]=n.useState(null),H=n.useRef(0),L=n.useRef(0),S=n.useRef(0),P=n.useCallback(async()=>{try{const u=await et(i);t(u),G(y=>({...y,maxHops:u.pathLimits.defaultMaxHops}))}catch(u){g(u instanceof Error?u.message:String(u))}},[i]);n.useEffect(()=>{P()},[s,P]),n.useEffect(()=>{if(!r?.available)return;const u=++H.current;R(!0);const y=window.setTimeout(()=>void tt(i,c).then(b=>{u===H.current&&M(b)}).catch(b=>{u===H.current&&g(b instanceof Error?b.message:String(b))}).finally(()=>{u===H.current&&R(!1)}),250);return()=>window.clearTimeout(y)},[s,c,i,r?.available]);const Y=n.useCallback(async(u=E)=>{if(!u)return;const y=++L.current;try{const b=await Ae(i,{nodeId:u,...m});y===L.current&&F(b)}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i,E]),T=n.useCallback(async u=>{const y=++L.current;k(u);try{const[b,W]=await Promise.all([st(i,u),Ae(i,{nodeId:u,...m})]);y===L.current&&(w(b),F(W))}catch(b){y===L.current&&g(b instanceof Error?b.message:String(b))}},[m,i]),x=n.useCallback(async()=>{const u=++S.current;D(null),g(null);try{const y=await at(i,U);u===S.current&&D(y)}catch(y){u===S.current&&g(y instanceof Error?y.message:String(y))}},[U,i]),Q=n.useCallback(async(u=!1)=>{B(!0);try{await nt(i,u),await P()}catch(y){g(y instanceof Error?y.message:String(y))}finally{B(!1)}},[i,P]);return{status:r,filters:c,setFilters:v,nodes:d,loading:I,selectedId:E,detail:f,selectNode:T,neighborOptions:m,setNeighborOptions:a,neighborResults:h,refreshNeighbors:Y,pathInput:U,setPathInput:G,pathResult:N,findPath:x,rebuild:Q,rebuilding:se,refreshStatus:P,error:p,clearFilters:()=>v(De)}}const ct=["file","module","symbol","doc-concept","rationale"],dt=["function","class","interface","type-alias","enum","variable","namespace","alias"],ht=["contains","imports","re-exports","relates-to","rationale-supports"];function ve({id:i,onSelect:s}){return e.jsx("button",{type:"button",className:"btn btn-ghost knowledge-graph-endpoint",onClick:()=>s(i),children:i})}function Ie({title:i,edges:s,total:r,endpoint:t,onSelect:c}){const{t:v}=Ne("app");return e.jsxs("section",{className:"knowledge-graph-edge-list",children:[e.jsxs("h4",{children:[i," ",e.jsx("span",{children:v("knowledgeGraph.showingOf","showing {{shown}} of {{total}}",{shown:s.length,total:r})})]}),s.length===0?e.jsx("p",{className:"knowledge-graph-muted",children:v("knowledgeGraph.none","None")}):e.jsx("ul",{children:s.map(d=>e.jsxs("li",{children:[e.jsx("span",{children:d.kind}),e.jsx("span",{className:`knowledge-graph-provenance knowledge-graph-provenance--${d.provenance}`,children:d.provenance}),e.jsx(ve,{id:d[t],onSelect:c})]},d.id))})]})}function ut({projectId:i,addToast:s}){const{t:r}=Ne("app"),t=mt({projectId:i,enabled:!0}),[c,v]=n.useState(!1);if(n.useEffect(()=>{t.error&&s(t.error,"error")},[s,t.error]),!t.status&&t.error)return e.jsx("div",{className:"knowledge-graph-panel knowledge-graph-error","data-testid":"knowledge-graph-error",children:t.error});if(!t.status)return e.jsx("div",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-loading",children:r("memory.graphLoading","Loading knowledge graph…")});if(!t.status.available)return e.jsxs("div",{className:"knowledge-graph-panel knowledge-graph-empty","data-testid":"knowledge-graph-no-graph",children:[e.jsxs("p",{children:[r("memory.graphUnavailable","Graph unavailable"),": ",t.status.recoveryReason]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.rebuild(!1),children:r("memory.graphBuild","Build graph")})]});const d=a=>t.setFilters({...t.filters,...a,offset:0}),M=a=>{const h=t.filters.kinds??[];d({kinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},E=a=>{const h=t.neighborOptions.edgeKinds??[];t.setNeighborOptions({...t.neighborOptions,edgeKinds:h.includes(a)?h.filter(F=>F!==a):[...h,a]})},k=t.selectedId,f=t.status.pathLimits,w=t.pathResult?.outcome==="found"?t.pathResult.path:null,m=t.pathResult?.outcome==="found"?t.pathResult.hops:void 0;return e.jsxs("section",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-panel",children:[e.jsxs("header",{className:"knowledge-graph-status card",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.status.nodeCount," ",r("memory.graphNodes","nodes")," · ",t.status.edgeCount," ",r("memory.graphEdges","edges")]}),e.jsx("span",{children:t.status.graphDir})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.nodeKinds","Node kinds")}),e.jsx("dd",{children:Object.entries(t.status.nodeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.edgeKinds","Edge kinds")}),e.jsx("dd",{children:Object.entries(t.status.edgeKindCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("knowledgeGraph.provenance","Provenance")}),e.jsx("dd",{children:Object.entries(t.status.provenanceCounts??{}).map(([a,h])=>`${a}: ${h}`).join(" · ")||"—"})]})]}),e.jsxs("label",{className:"knowledge-graph-toggle",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:a=>v(a.target.checked)})," ",r("memory.graphForce","Force rebuild")]}),e.jsx("button",{type:"button",className:"btn",disabled:t.rebuilding,onClick:()=>void t.rebuild(c),children:t.rebuilding?r("memory.graphRebuilding","Rebuilding…"):r("memory.graphRebuild","Rebuild")})]}),e.jsxs("section",{className:"knowledge-graph-filters card","aria-label":r("memory.graphFilters","Graph filters"),children:[e.jsx("div",{className:"knowledge-graph-kind-options",children:ct.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.filters.kinds??[]).includes(a),onChange:()=>M(a)})," ",a]},a))}),e.jsx("input",{className:"input","aria-label":"Path prefix",placeholder:"Path prefix",value:t.filters.pathPrefix??"",onChange:a=>d({pathPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Node id prefix",placeholder:"Node id prefix",value:t.filters.idPrefix??"",onChange:a=>d({idPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Name regex",placeholder:"Name regex",value:t.filters.namePattern??"",onChange:a=>d({namePattern:a.target.value})}),e.jsxs("select",{className:"select","aria-label":"FNXC area",value:t.filters.fnxcArea??"",onChange:a=>d({fnxcArea:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allFnxcAreas","All FNXC areas")}),t.status.fnxcAreas?.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Symbol kind",value:t.filters.symbolKind??"",onChange:a=>d({symbolKind:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allSymbolKinds","All symbol kinds")}),dt.map(a=>e.jsx("option",{children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Owner",value:t.filters.owner??"",onChange:a=>d({owner:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:r("knowledgeGraph.allOwners","All owners")}),e.jsx("option",{value:"file",children:r("knowledgeGraph.ownerFile","file")}),e.jsx("option",{value:"derived",children:r("knowledgeGraph.ownerDerived","derived")})]}),e.jsx("select",{className:"select","aria-label":"Result limit",value:t.filters.limit??50,onChange:a=>d({limit:Number(a.target.value)}),children:[25,50,100,200].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.limitResults","{{limit}} results",{limit:a})},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t.clearFilters,children:r("memory.graphClearFilters","Clear filters")})]}),e.jsxs("div",{className:"knowledge-graph-layout",children:[e.jsxs("section",{className:"card knowledge-graph-results",children:[e.jsxs("h3",{children:[t.nodes?.total??0," ",r("memory.graphResults","results")]}),t.loading?e.jsx("p",{"data-testid":"knowledge-graph-searching",children:r("knowledgeGraph.searching","Searching…")}):t.nodes?.nodes.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{children:t.nodes.nodes.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.selectNode(a.id),children:[e.jsxs("strong",{children:[a.kind,": ",a.name]}),e.jsxs("span",{children:[a.id," · ",a.ownerPath,":",a.source.line]})]})},a.id))}),e.jsxs("div",{className:"knowledge-graph-pagination",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:!t.filters.offset,onClick:()=>d({offset:Math.max(0,(t.filters.offset??0)-(t.filters.limit??50))}),children:r("knowledgeGraph.previous","Previous")}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:(t.filters.offset??0)+(t.filters.limit??50)>=(t.nodes?.total??0),onClick:()=>d({offset:(t.filters.offset??0)+(t.filters.limit??50)}),children:r("knowledgeGraph.next","Next")})]})]}):e.jsx("p",{"data-testid":"knowledge-graph-no-results",children:r("memory.graphNoResults","No matching nodes.")})]}),e.jsx("section",{className:"card knowledge-graph-detail",children:t.detail?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:t.detail.node.name}),e.jsx("p",{children:t.detail.node.id}),e.jsxs("p",{children:[t.detail.node.ownerPath,":",t.detail.node.source.line]}),e.jsx(Ie,{title:r("knowledgeGraph.outgoing","Outgoing"),edges:t.detail.outgoing,total:t.detail.outgoingTotal,endpoint:"to",onSelect:a=>void t.selectNode(a)}),e.jsx(Ie,{title:r("knowledgeGraph.incoming","Incoming"),edges:t.detail.incoming,total:t.detail.incomingTotal,endpoint:"from",onSelect:a=>void t.selectNode(a)})]}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.selectNodeHint","Select a node to inspect its edges.")})})]}),t.detail&&e.jsxs("section",{className:"knowledge-graph-neighbors card",children:[e.jsx("h3",{children:r("knowledgeGraph.neighbors","Neighbors")}),e.jsxs("select",{className:"select","aria-label":"Neighbor direction",value:t.neighborOptions.direction,onChange:a=>t.setNeighborOptions({...t.neighborOptions,direction:a.target.value}),children:[e.jsx("option",{value:"out",children:r("knowledgeGraph.outgoing","Outgoing")}),e.jsx("option",{value:"in",children:r("knowledgeGraph.incoming","Incoming")}),e.jsx("option",{value:"both",children:r("knowledgeGraph.bothDirections","Both directions")})]}),e.jsx("select",{className:"select","aria-label":"Neighbor depth",value:t.neighborOptions.depth,onChange:a=>t.setNeighborOptions({...t.neighborOptions,depth:Number(a.target.value)}),children:[1,2,3].map(a=>e.jsx("option",{value:a,children:r("knowledgeGraph.depth","Depth {{depth}}",{depth:a})},a))}),e.jsx("div",{className:"knowledge-graph-kind-options",children:ht.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.neighborOptions.edgeKinds??[]).includes(a),onChange:()=>E(a)})," ",a]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.refreshNeighbors(),children:r("knowledgeGraph.refreshNeighbors","Refresh neighbors")}),t.neighborResults?.neighbors.length?e.jsx("ul",{children:t.neighborResults.neighbors.map(a=>e.jsxs("li",{children:[e.jsx("span",{children:r("knowledgeGraph.distance","distance {{distance}}",{distance:a.distance})}),e.jsx(ve,{id:a.node.id,onSelect:h=>void t.selectNode(h)})]},a.node.id))}):e.jsx("p",{className:"knowledge-graph-muted",children:r("knowledgeGraph.noNeighbors","No neighbors found.")})]}),e.jsxs("section",{className:"knowledge-graph-path card",children:[e.jsx("h3",{children:r("knowledgeGraph.shortestPath","Shortest path")}),e.jsx("input",{className:"input","aria-label":"From node id",placeholder:"From node id",value:t.pathInput.fromId,onChange:a=>t.setPathInput({...t.pathInput,fromId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"To node id",placeholder:"To node id",value:t.pathInput.toId,onChange:a=>t.setPathInput({...t.pathInput,toId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Maximum hops",type:"number",min:"1",max:f.maxHops,value:t.pathInput.maxHops,onChange:a=>t.setPathInput({...t.pathInput,maxHops:Number(a.target.value)})}),k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,fromId:k}),children:r("knowledgeGraph.useSelectedFrom","Use selected as from")}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,toId:k}),children:r("knowledgeGraph.useSelectedTo","Use selected as to")})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.findPath(),children:r("knowledgeGraph.findPath","Find path")}),w&&e.jsxs("div",{"data-testid":"knowledge-graph-path-found",children:[e.jsx("strong",{children:r("knowledgeGraph.hops","{{count}} hops",{count:m})}),e.jsx("div",{className:"knowledge-graph-path-chain",children:w.nodes.map((a,h)=>e.jsxs("span",{children:[e.jsx(ve,{id:a.id,onSelect:F=>void t.selectNode(F)}),h<w.edges.length&&e.jsx("em",{children:w.edges[h].kind})]},a.id))})]}),t.pathResult?.outcome==="not-found"&&e.jsx("p",{"data-testid":"knowledge-graph-path-not-found",children:r("knowledgeGraph.noPath","No path exists between these nodes.")}),t.pathResult?.outcome==="limit-reached"&&e.jsxs("div",{"data-testid":"knowledge-graph-path-limit-reached",children:[e.jsx("p",{children:r("knowledgeGraph.pathLimitReached","No path found within {{maxHops}} hops; {{limit}} was reached.",{maxHops:t.pathResult.maxHops,limit:t.pathResult.limit})}),t.pathInput.maxHops<f.maxHops&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,maxHops:Math.min(f.maxHops,t.pathInput.maxHops+1)}),children:r("knowledgeGraph.raiseHopLimit","Raise hop limit")})]}),t.error&&e.jsx("p",{"data-testid":"knowledge-graph-path-error",className:"knowledge-graph-error",children:t.error})]})]})}const yt={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},gt=72;function pt(i,s){if(i.length<=s)return i;const r=Math.max(1,s-1),t=Math.ceil(r/2),c=Math.floor(r/2);return`${i.slice(0,t)}…${i.slice(i.length-c)}`}function bt(i){const s=`${i.label} — ${i.path}`;return pt(s,gt)}function xt(i){if(!i)return[];const s=[],r=i.split(/(?=^## )/m);for(const t of r){const c=t.trim();if(!c)continue;const v=c.match(/^##\s+(.+?)(\n|$)/);if(v){const d=v[1].trim(),M=yt[d]??d.toLowerCase(),E=c.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),k=E.split(`
2
2
  `).reduce((f,w)=>{const m=w.trim();return/^[-*]\s+/.test(w)?f.push(m.replace(/^[-*]\s+/,"")):m.length>0&&f.length>0&&(f[f.length-1]=`${f[f.length-1]}
3
3
  ${w.trimEnd()}`),f},[]);(k.length>0||E.length>0)&&s.push({name:d,key:M,items:k.length>0?k:E.length>0?[E]:[],expanded:!0})}}return s}function ft(i){if(!i)return null;const s=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return s?s[1]:null}function jt(i){return i.reduce((s,r)=>s+r.items.length,0)}function Ft({projectId:i,addToast:s,onSendSelectionToTask:r}){const{t}=Ne("app"),[c,v]=n.useState("working"),[d,M]=n.useState(new Set),[E,k]=n.useState(!1),[f,w]=n.useState(null),[m,a]=n.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[h,F]=n.useState(""),[U,G]=n.useState(!1),[N,D]=n.useState(null),{insightsContent:I,insightsLoading:R,insightsExists:se,saveInsights:B,memorySettings:p,settingsLoading:g,saveMemorySettings:H,savingMemorySettings:L,backendStatus:S,backendLoading:P,extractInsights:Y,extracting:T,auditReport:x,auditLoading:Q,refreshAudit:u,compactMemory:y,compacting:b,installQmdAction:W,installingQmd:le,testRetrieval:ae,memoryFiles:ne,memoryFilesLoading:be,selectedFilePath:$,selectedFileContent:re,selectedFileLoading:X,selectedFileDirty:q,setSelectedFileContent:ie,selectFile:oe,saveSelectedFile:me,savingSelectedFile:ce,reloadMemoryFiles:de,triggerDreamNow:he,dreamRunning:Z}=ot({projectId:i});n.useEffect(()=>{a(p)},[p]);const K=n.useMemo(()=>m.memoryEnabled!==p.memoryEnabled||m.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled||m.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars||m.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule||m.memoryDreamsEnabled!==p.memoryDreamsEnabled||m.memoryDreamsSchedule!==p.memoryDreamsSchedule,[m,p]),z=n.useMemo(()=>ne.find(l=>l.path===$),[ne,$]),xe=z?z.layer==="long-term"?t("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):z.layer==="daily"?t("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):t("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):t("memory.editorDefaultDescription","Edits the selected memory file."),V=n.useMemo(()=>xt(I),[I]),fe=n.useMemo(()=>jt(V),[V]),o=n.useMemo(()=>ft(I),[I]),j=n.useCallback(l=>{M(C=>{const O=new Set(C);return O.has(l)?O.delete(l):O.add(l),O})},[]),A=n.useCallback(async l=>{try{await oe(l)}catch{s(t("memory.loadFileFailed","Failed to load memory file"),"error")}},[oe,s]),ue=n.useCallback(async()=>{try{await me(),s(t("memory.memorySaved","Memory saved"),"success")}catch{s(t("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,s]),je=n.useCallback(async()=>{if(!K)return;const l={};m.memoryEnabled!==p.memoryEnabled&&(l.memoryEnabled=m.memoryEnabled),m.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled&&(l.memoryAutoSummarizeEnabled=m.memoryAutoSummarizeEnabled),m.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars&&(l.memoryAutoSummarizeThresholdChars=m.memoryAutoSummarizeThresholdChars),m.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule&&(l.memoryAutoSummarizeSchedule=m.memoryAutoSummarizeSchedule),m.memoryDreamsEnabled!==p.memoryDreamsEnabled&&(l.memoryDreamsEnabled=m.memoryDreamsEnabled),m.memoryDreamsSchedule!==p.memoryDreamsSchedule&&(l.memoryDreamsSchedule=m.memoryDreamsSchedule);try{await H(l),s(t("memory.settingsSaved","Memory settings saved"),"success")}catch{s(t("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[K,m,p,H,s]),Re=n.useCallback(async()=>{try{const l=await W();s(l.qmdAvailable?t("memory.qmdInstallSuccess","qmd installed successfully"):t("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),l.qmdAvailable?"success":"info")}catch{s(t("memory.installQmdFailed","Failed to install qmd"),"error")}},[W,s]),Le=n.useCallback(async()=>{G(!0),D(null);try{const l=await ae(h);D(l),s(l.qmdAvailable?t("memory.retrievalTestComplete","Memory retrieval test complete"):t("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),l.qmdAvailable?"success":"info")}catch{s(t("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{G(!1)}},[h,ae,s]),ze=n.useCallback(async()=>{try{await he(),s(t("memory.dreamProcessingComplete","Dream processing completed"),"success"),await de()}catch(l){s(l instanceof Error?l.message:t("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[he,de,s]),Pe=n.useCallback(async()=>{try{await y($),s(t("memory.fileCompacted","Memory file compacted"),"success")}catch{s(t("memory.compactFailed","Failed to compact memory"),"error")}},[y,$,s]),Se=n.useCallback(async()=>{try{const l=await Y();s(l.summary,"success")}catch(l){s(l instanceof Error?l.message:t("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[Y,s]),Ge=n.useCallback(async()=>{if(f!==null)try{await B(f),k(!1),w(null),s(t("memory.insightsSaved","Insights saved"),"success")}catch{s(t("memory.saveInsightsFailed","Failed to save insights"),"error")}},[f,B,s]),qe=n.useCallback(()=>{w(I??""),k(!0)},[I]),Oe=n.useCallback(()=>{k(!1),w(null)},[]),He=!P&&S!==null,ye=S?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ze,{icon:Je,title:t("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":c==="working",className:`memory-view-tab${c==="working"?" memory-view-tab--active":""}`,onClick:()=>v("working"),"data-testid":"memory-tab-working",children:t("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="insights",className:`memory-view-tab${c==="insights"?" memory-view-tab--active":""}`,onClick:()=>v("insights"),"data-testid":"memory-tab-insights",children:t("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="graph",className:`memory-view-tab${c==="graph"?" memory-view-tab--active":""}`,onClick:()=>v("graph"),"data-testid":"memory-tab-graph",children:t("memory.tabGraph","Knowledge Graph")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="engines",className:`memory-view-tab${c==="engines"?" memory-view-tab--active":""}`,onClick:()=>v("engines"),"data-testid":"memory-tab-engines",children:t("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[c==="graph"&&e.jsx(ut,{projectId:i,addToast:s}),c==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[He&&!ye&&e.jsx("div",{className:"memory-readonly-banner",children:t("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),be||X?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:t("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:$,onChange:l=>{A(l.target.value)},disabled:q,children:ne.map(l=>e.jsx("option",{value:l.path,title:`${l.label} — ${l.path}`,children:bt(l)},l.path))}),e.jsx("small",{children:q?t("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):t("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),z&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:z.layer==="long-term"?t("memory.layerLongTerm","Long-term"):z.layer==="daily"?t("memory.layerDaily","Daily"):t("memory.layerDreams","Dreams")}),e.jsx("strong",{children:z.path}),e.jsx("small",{children:t("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:z.size.toLocaleString(),updatedAt:new Date(z.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:z?.label||t("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:xe}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:re,onChange:ie,readOnly:!ye,filePath:$,forceToolbarActionsVisible:!0,onSendSelectionToTask:r})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:t("memory.charCount","{{count}} characters",{count:re.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ye&&re.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Pe,disabled:b||q,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.compacting","Compacting…")]}):t("memory.compactSelectedFile","Compact Selected File")}),q&&ye&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:t("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:m.memoryDreamsEnabled,onChange:l=>{a(C=>({...C,memoryDreamsEnabled:l.target.checked}))},disabled:!m.memoryEnabled||g}),t("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:t("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),m.memoryEnabled&&m.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:t("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:m.memoryDreamsSchedule,onChange:l=>{a(C=>({...C,memoryDreamsSchedule:l.target.value}))},placeholder:"0 4 * * *",disabled:g}),e.jsx("small",{children:t("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:ze,disabled:Z||!m.memoryDreamsEnabled,children:Z?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.dreaming","Dreaming…")]}):t("memory.dreamNow","Dream Now")}),e.jsx("small",{children:t("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:m.memoryAutoSummarizeEnabled,onChange:l=>{a(C=>({...C,memoryAutoSummarizeEnabled:l.target.checked}))},disabled:!m.memoryEnabled||g}),t("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:t("memory.autoSummarizeHint","Automatically compacts memory when it exceeds the threshold on a schedule.")})]}),m.memoryEnabled&&m.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:t("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:m.memoryAutoSummarizeThresholdChars,onChange:l=>{a(C=>({...C,memoryAutoSummarizeThresholdChars:parseInt(l.target.value,10)||5e4}))},min:1e3,disabled:g}),e.jsx("small",{children:t("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:t("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:m.memoryAutoSummarizeSchedule,onChange:l=>{a(C=>({...C,memoryAutoSummarizeSchedule:l.target.value}))},placeholder:"0 3 * * *",disabled:g}),e.jsx("small",{children:t("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!m.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:t("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),K&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:je,disabled:L||g,children:L?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("memory.saveSettings","Save Settings")})})]})]})]}),c==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:R?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingInsights","Loading insights…")})]}):E?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:f??"",onChange:w,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:r})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Oe,children:t("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ge,children:t("memory.saveInsights","Save Insights")})]})]}):!se||V.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:t("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:t("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:Se,disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:fe}),e.jsx("div",{className:"memory-stat-label",children:t("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:V.length}),e.jsx("div",{className:"memory-stat-label",children:t("memory.categories","Categories")})]}),o&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:o}),e.jsx("div",{className:"memory-stat-label",children:t("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Se,disabled:T,children:T?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:qe,children:t("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:V.map(l=>{const C=!d.has(l.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>j(l.key),role:"button",tabIndex:0,onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),j(l.key))},children:[e.jsx("h4",{children:l.name}),e.jsx("span",{className:"memory-category-count",children:l.items.length})]}),C&&e.jsx("div",{className:"memory-category-items",children:l.items.map((O,Te)=>e.jsx("div",{className:"memory-insight-item",children:O.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Te))})]},l.key)})})]})}),c==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:P||Q?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(_,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:t("memory.qmdIntegrationTitle","QMD Integration")}),S?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:t("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):S?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[t("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:S.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Re,disabled:le,children:le?t("memory.installing","Installing…"):t("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:t("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdCheckingAvailability","Checking qmd availability…")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:t("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:h,onChange:l=>F(l.target.value),placeholder:t("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Le,disabled:U,children:U?t("memory.testing","Testing…"):t("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:t("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),N&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:t("memory.testResultCount",'{{count}} result for "{{query}}"',{count:N.results.length,query:N.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:t("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:N.qmdAvailable?t("memory.qmdStatusAvailable","available"):t("memory.qmdStatusMissing","missing"),fallbackStatus:N.usedFallback?t("memory.localFallbackUsed","local fallback used"):t("memory.qmdPathUsed","qmd path used")})}),N.results.length>0?e.jsx("ul",{children:N.results.map((l,C)=>e.jsxs("li",{children:[e.jsxs("span",{children:[l.path,":",l.lineStart]}),e.jsx("p",{children:l.snippet})]},`${l.path}-${l.lineStart}-${C}`))}):e.jsx("small",{children:t("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:S?.currentBackend==="file"?t("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):S?.currentBackend==="readonly"?t("memory.backendReadonly","Read-Only"):S?.currentBackend==="qmd"?t("memory.backendQmd","QMD (Quantized Memory Distillation)"):S?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[S?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capReadable","Readable")}),S?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capWritable","Writable")}),S?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capAtomicWrites","Atomic Writes")}),S?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capPersistent","Persistent")})]})]}),x&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:t("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${x.health}`,children:x.health==="healthy"?t("memory.healthHealthy","Healthy"):x.health==="warning"?t("memory.healthWarning","Warning"):t("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.sectionCount","{{count}} sections",{count:x.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.insightCount","{{count}} insights",{count:x.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:x.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:t("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:t("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:x.extraction.summary||t("memory.insightsExtracted","{{count}} insights extracted",{count:x.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:x.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:t("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:t("memory.pruningNotNeeded","Not needed")})}),x.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:x.pruning.reason})]})]}),x&&x.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:x.checks.map(l=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:l.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:l.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:l.name}),e.jsx("div",{className:"memory-health-detail",children:l.details})]})]},l.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>u(),children:t("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:t("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{s(t("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:t("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{Ft as MemoryView};
@@ -1,6 +1,6 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as V,ba as Y,bb as Z,bc as T,R as L,aK as D,aN as P,P as ee,C as se,k as ae,F as ie,aI as B,bd as ne,be as te,bf as I,X as re}from"./index-B8PcG8AJ.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as $}from"./puzzle-CdYF81IT.js";import{B as A}from"./AgentPermissionPolicyEditor-C3Qo9p1M.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as J,aY as Q,aZ as V,a_ as T,R as L,av as D,ay as P,P as ee,C as se,g as ae,x as ie,at as B,a$ as ne,b0 as te,b1 as $,X as re}from"./index-BjM7LxzY.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as _}from"./puzzle-D00mP67o.js";import{B as A}from"./AgentPermissionPolicyEditor-BXJ52YpO.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],G=V("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,H]=l.useState(null),[b,y]=l.useState(!0),[N,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[K,O]=l.useState(new Set),[m,W]=l.useState([]),[v,R]=l.useState(!0),[_,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!0);const s=await Y();H(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{y(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await Z(x);W(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),q=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{O(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},J=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await I({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Q=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await I({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>Q(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:b,children:e.jsx(L,{size:16,className:b?"spin":""})})})]}),b?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:N}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:N||!h.trim(),children:[e.jsx(ee,{size:14}),N?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=pe(i),f=xe(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=K.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>J(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx($,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),$,"extensions"),u(a("piManager.sectionSkills","Skills"),A,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),G,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${oe(s.source)}`,children:de(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void q(s),disabled:_,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
6
+ */const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],G=J("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function be({addToast:n,projectId:x}){const{t:a}=le("app"),[c,H]=l.useState(null),[N,y]=l.useState(!0),[v,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[I,O]=l.useState(new Set),[m,W]=l.useState([]),[b,R]=l.useState(!0),[q,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!0);const s=await Q();H(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{y(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await V(x);W(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),K=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{O(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Y=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await $({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Z=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await $({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>Z(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:v}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:v||!h.trim(),children:[e.jsx(ee,{size:14}),v?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=pe(i),f=xe(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=I.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Y(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(_,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),_,"extensions"),u(a("piManager.sectionSkills","Skills"),A,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),G,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:b,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:b?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),b?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${oe(s.source)}`,children:de(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void K(s),disabled:q,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{be as PiExtensionsManager};
@@ -0,0 +1 @@
1
+ import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{W as ze,b2 as He,b3 as Ve,b4 as ge,b5 as Qe,X as me,aF as Ke,b6 as Je,av as he,P as be,aR as ye,x as xe,R as fe,ay as Ye,aM as Xe,b7 as Ze,b8 as es,b9 as ss,ba as ns,bb as is,bc as ts,bd as as,be as Q,bf as ls,bg as rs}from"./index-BjM7LxzY.js";import{D as os}from"./DirectoryPicker-Cw-XRjAa.js";import{u as Ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";import"./folder-open-Cf2NA9nV.js";const us="/api/plugins/fusion-plugin-whatsapp-chat",cs=/^\d+$/;function K(r,c){const p=c?`?projectId=${encodeURIComponent(c)}`:"";return`${us}${r}${p}`}function ps({projectId:r,settings:c}){const{t:p}=Ce("app"),[n,x]=d.useState(null),[f,F]=d.useState(null),[L,_]=d.useState(()=>String(c?.pairingPhoneNumber??"")),[A,w]=d.useState(null),[P,k]=d.useState(null),v=d.useCallback(async()=>{try{const a=await fetch(K("/status",r)),y=await a.json();if(!a.ok)throw new Error(y.error??"WhatsApp pairing is unavailable. Enable the plugin and try again.");x(y),F(null)}catch(a){F(a instanceof Error?a.message:String(a))}},[r]);d.useEffect(()=>{v();const a=window.setInterval(()=>void v(),5e3);return()=>window.clearInterval(a)},[v]);const O=async()=>{const a=L.trim();if(!a||!cs.test(a)){w("Enter an E.164 phone number using digits only, without +.");return}k("code"),w(null);try{const y=await fetch(K("/pair-code",r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:a,...r?{projectId:r}:{}})}),m=await y.json();if(!y.ok)throw new Error(m.error??"Could not request a pairing code.");x(j=>({status:"awaiting-code",...j,pairingCode:m.pairingCode})),await v()}catch(y){w(y instanceof Error?y.message:String(y))}finally{k(null)}},U=async()=>{k("logout"),w(null);try{const a=await fetch(K("/logout",r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r?{projectId:r}:{})});if(!a.ok){const y=await a.json();throw new Error(y.error??"Could not log out from WhatsApp.")}await v()}catch(a){w(a instanceof Error?a.message:String(a))}finally{k(null)}},B=c?.pairingMode==="code"?"code":"qr",R=n?.status??"starting";return e.jsxs("section",{className:"whatsapp-pairing-panel","aria-labelledby":"whatsapp-pairing-heading",children:[e.jsxs("div",{className:"whatsapp-pairing-heading-row",children:[e.jsxs("div",{children:[e.jsx("h5",{id:"whatsapp-pairing-heading",className:"plugin-detail-section-heading",children:p("whatsapp.pairing","WhatsApp pairing")}),e.jsx("p",{className:"whatsapp-pairing-description",children:p("whatsapp.description","Pair and monitor this project's WhatsApp connection here.")})]}),e.jsx("button",{className:"btn btn-secondary btn-sm",type:"button",onClick:()=>void v(),children:p("whatsapp.refreshStatus","Refresh status")})]}),e.jsxs("div",{className:`whatsapp-pairing-status whatsapp-pairing-status--${R}`,role:"status","data-testid":"whatsapp-pairing-status",children:[e.jsxs("strong",{children:[p("whatsapp.status","Status:")," ",R]}),n?.jid&&e.jsx("span",{children:p("whatsapp.connectedAs","Connected as {{jid}}",{jid:n.jid})}),(n?.lastError||f)&&e.jsx("span",{className:"field-error",children:n?.lastError??f})]}),R==="awaiting-qr"&&e.jsx("div",{className:"whatsapp-pairing-qr","data-testid":"whatsapp-pairing-qr",children:n?.qrDataUrl?e.jsx("img",{src:n.qrDataUrl,alt:p("whatsapp.qrCode","WhatsApp pairing QR code"),className:"whatsapp-pairing-qr-image"}):e.jsx("p",{className:"text-muted",children:p("whatsapp.waitingQr","Waiting for a fresh QR code. Keep this panel open and refresh if needed.")})}),(B==="code"||R==="awaiting-code")&&e.jsxs("div",{className:"whatsapp-pairing-code",children:[e.jsx("label",{htmlFor:"whatsapp-pairing-phone",children:p("whatsapp.phoneNumber","Phone number (E.164 digits without +)")}),e.jsxs("div",{className:"whatsapp-pairing-code-controls",children:[e.jsx("input",{id:"whatsapp-pairing-phone",className:"input",value:L,onChange:a=>_(a.target.value),inputMode:"numeric"}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>void O(),disabled:P!==null,children:P==="code"?p("whatsapp.requestingCode","Requesting code..."):p("whatsapp.requestPairingCode","Request pairing code")})]}),n?.pairingCode&&e.jsx("output",{className:"whatsapp-pairing-code-output",children:n.pairingCode})]}),R==="connected"&&e.jsx("p",{className:"whatsapp-pairing-success",children:p("whatsapp.connectedSuccess","WhatsApp is paired and ready to receive messages from allowed senders.")}),A&&e.jsx("p",{className:"field-error",children:A}),e.jsx("button",{className:"btn btn-danger",type:"button",onClick:()=>void U(),disabled:P!==null,"data-testid":"whatsapp-pairing-logout",children:P==="logout"?p("whatsapp.loggingOut","Logging out..."):p("whatsapp.logoutRepair","Logout and re-pair")}),e.jsxs("aside",{className:"whatsapp-pairing-instructions","aria-label":p("whatsapp.instructionsLabel","WhatsApp pairing instructions"),"data-testid":"whatsapp-pairing-instructions",children:[e.jsx("h6",{children:p("whatsapp.pairingConfiguration","Pairing and configuration")}),e.jsxs("ol",{children:[e.jsx("li",{children:p("whatsapp.installPlugin","Install and enable this plugin, then keep this settings panel open.")}),e.jsx("li",{children:p("whatsapp.allowedSenders","Set {{label}}; an empty list blocks all inbound messages.",{label:"Allowed WhatsApp Senders"})}),e.jsx("li",{children:p("whatsapp.choosePairingMethod","Choose {{qr}} to scan in WhatsApp Linked Devices, or {{code}} to enter a phone number and request a pairing code.",{qr:"QR",code:"code"})}),e.jsx("li",{children:p("whatsapp.waitConnected","Wait for the status above to become {{status}}.",{status:"connected"})}),e.jsx("li",{children:p("whatsapp.repairInstructions","Use Logout and re-pair to start over. If QR is still pending, wait briefly or refresh status for a new code.")})]})]})]})}const Pe="fusion-plugin-agent-browser",je={enabled:{type:"boolean",label:"Enable Agent Browser",group:"General"},installChannel:{type:"enum",label:"Install Channel",enumValues:["stable","beta","nightly"],defaultValue:"stable",group:"General"},commandTimeoutMs:{type:"number",label:"Command Timeout (ms)",defaultValue:12e4,group:"General"},headlessMode:{type:"boolean",label:"Headless Mode",defaultValue:!0,group:"Browser"},allowedDomains:{type:"array",label:"Allowed Domains",itemType:"string",group:"Browser"},promptExecutorSystem:{type:"string",label:"Executor System Prompt",multiline:!0,group:"Prompt Contributions"},promptExecutorTask:{type:"string",label:"Executor Task Prompt",multiline:!0,group:"Prompt Contributions"},promptTriage:{type:"string",label:"Triage Prompt",multiline:!0,group:"Prompt Contributions"},promptReviewer:{type:"string",label:"Reviewer Prompt",multiline:!0,group:"Prompt Contributions"},promptHeartbeat:{type:"string",label:"Heartbeat Prompt",multiline:!0,group:"Prompt Contributions"},skillExposure:{type:"enum",label:"Skill Exposure",enumValues:["none","selected","all"],defaultValue:"selected",group:"Skills"}},Ne={General:"plugins.agentBrowser.groupGeneral",Browser:"plugins.agentBrowser.groupBrowser","Prompt Contributions":"plugins.agentBrowser.groupPromptContributions",Skills:"plugins.agentBrowser.groupSkills"},Se={"Enable Agent Browser":"plugins.agentBrowser.labelEnabled","Install Channel":"plugins.agentBrowser.labelInstallChannel","Command Timeout (ms)":"plugins.agentBrowser.labelCommandTimeoutMs","Headless Mode":"plugins.agentBrowser.labelHeadlessMode","Allowed Domains":"plugins.agentBrowser.labelAllowedDomains","Executor System Prompt":"plugins.agentBrowser.labelPromptExecutorSystem","Executor Task Prompt":"plugins.agentBrowser.labelPromptExecutorTask","Triage Prompt":"plugins.agentBrowser.labelPromptTriage","Reviewer Prompt":"plugins.agentBrowser.labelPromptReviewer","Heartbeat Prompt":"plugins.agentBrowser.labelPromptHeartbeat","Skill Exposure":"plugins.agentBrowser.labelSkillExposure"},we=[{id:"fusion-plugin-hermes-runtime",name:"Hermes Runtime",description:"Runtime provider for Hermes CLI-backed execution.",category:"runtime",path:"./plugins/fusion-plugin-hermes-runtime",experimental:!0},{id:"fusion-plugin-paperclip-runtime",name:"Paperclip Runtime",description:"Runtime provider for Paperclip agent connections.",category:"runtime",path:"./plugins/fusion-plugin-paperclip-runtime"},{id:"fusion-plugin-openclaw-runtime",name:"OpenClaw Runtime",description:"Runtime provider for OpenClaw execution.",category:"runtime",path:"./plugins/fusion-plugin-openclaw-runtime",experimental:!0},{id:"fusion-plugin-droid-runtime",name:"Droid Runtime",description:"Runtime provider for Droid CLI execution.",category:"runtime",path:"./plugins/fusion-plugin-droid-runtime",experimental:!0},{id:"fusion-plugin-dependency-graph",name:"Dependency Graph",description:"Dashboard plugin for task dependency graph visualization.",category:"integration",path:"./plugins/fusion-plugin-dependency-graph"},{id:"fusion-plugin-reports",name:"Reports",description:"View report history, compare runs side-by-side, and export standalone HTML summaries.",category:"integration",path:"./plugins/fusion-plugin-reports"},{id:"fusion-plugin-whatsapp-chat",name:"WhatsApp Chat",description:"Pairs to WhatsApp Web (multi-device) with QR or pairing code, then bridges direct chats to a Fusion agent.",category:"integration",path:"./plugins/fusion-plugin-whatsapp-chat"},{id:"fusion-plugin-cli-printing-press",name:"CLI Printing Press",description:"Guided wizard for drafting external service CLI definitions.",category:"integration",path:"./plugins/fusion-plugin-cli-printing-press"},{id:"fusion-plugin-compound-engineering",name:"Compound Engineering",description:"A dedicated dashboard surface for compound-engineering artifacts and interactive ce-* sessions.",category:"integration",path:"./plugins/fusion-plugin-compound-engineering"},{id:"fusion-plugin-quality",name:"Quality",description:"Task QA tab and Quality hub: preview servers, test runs, reports, screenshots, and suggested cases.",category:"integration",path:"./plugins/fusion-plugin-quality"},{id:"fusion-plugin-linear-import",name:"Linear Import",description:"Browse Linear issues and import selected issues as Fusion triage tasks through plugin-owned settings.",category:"integration",path:"./plugins/fusion-plugin-linear-import"},{id:Pe,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],T={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ds(r){const c=r.settingsSchema,p=c&&Object.keys(c).length>0;return r.id!==Pe?p?c:void 0:p?{...je,...c}:je}function gs(r){const c=new Map,p=[];for(const[n,x]of Object.entries(r))if(x.group){const f=c.get(x.group)??[];f.push([n,x]),c.set(x.group,f)}else p.push([n,x]);return{grouped:c,ungrouped:p}}function ve(r,c="plugin-error-text"){return r.state!=="error"||!r.error?null:e.jsx("p",{className:c,title:r.error,children:r.error})}function ws({addToast:r,projectId:c,onPluginsChanged:p}){const{t:n}=Ce("app"),[x,f]=d.useState([]),[F,L]=d.useState(!0),[_,A]=d.useState(!1),[w,P]=d.useState(""),[k,v]=d.useState(!1),[O,U]=d.useState(!1),[B,R]=d.useState(null),[a,y]=d.useState(null),[m,j]=d.useState({}),[Re,J]=d.useState(!1),[Y,X]=d.useState(null),[Z,Ee]=d.useState([]),[Ie,ee]=d.useState(!0),[se,ne]=d.useState(null),[N,ke]=d.useState(""),[S,Be]=d.useState(""),[Ae,ie]=d.useState(null),q=d.useRef(null),[Fe,z]=d.useState({}),[Le,te]=d.useState(null),[W,ae]=d.useState(null),{confirm:qe}=ze(),b=d.useCallback(async(s=!1,i)=>{try{s||L(!0);const l=await He(c);f(i?l.some(o=>o.id===i.id)?l.map(o=>o.id===i.id?i:o):[...l,i]:l)}catch(l){r(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}finally{s||L(!1)}},[c,r]),E=d.useCallback(async(s=N,i=S)=>{try{ee(!0),ne(null);const l=await Ve(s,i||void 0,c);Ee(l)}catch(l){const o=l instanceof Error?l.message:String(l);ne(o)}finally{ee(!1)}},[c,S,N]);d.useEffect(()=>{b()},[b]),d.useEffect(()=>(q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{E(N,S)},300),()=>{q.current&&clearTimeout(q.current)}),[E,S,N]),d.useEffect(()=>{const s=we.filter(l=>l.hasSetup&&x.some(o=>o.id===l.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async l=>{try{const o=await ge(l.id,c);if(i)return;z(g=>({...g,[l.id]:o}))}catch{if(i)return;z(o=>({...o,[l.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{i=!0}},[x,c]);const De=d.useRef([]);De.current=x,d.useEffect(()=>{const s=c?`?projectId=${encodeURIComponent(c)}`:"",i=l=>{try{const o=JSON.parse(l.data);if(o.scope==="project"&&(o.projectId??c)!==c)return;switch(o.transition){case"installing":case"enabled":case"disabled":case"settings-updated":E(N,S),f(g=>{const u=g.findIndex(t=>t.id===o.pluginId);if(u>=0){const t=[...g];return t[u]={...t[u],enabled:o.enabled,state:o.state,settings:o.settings,error:o.error},t}else return b(),g});break;case"state-changed":f(g=>{const u=g.findIndex(t=>t.id===o.pluginId);if(u>=0){const t=[...g];return t[u]={...t[u],state:o.state,error:o.error},t}return g});break;case"uninstalled":f(g=>g.filter(u=>u.id!==o.pluginId)),E(N,S);break;case"error":f(g=>{const u=g.findIndex(t=>t.id===o.pluginId);if(u>=0){const t=[...g];return t[u]={...t[u],state:o.state,error:o.error},t}return g});break}}catch{}};return Qe(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{b(),E(N,S)}})},[c,b,E,S,N]);const le=async()=>{if(!w.trim()){r(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{v(!0),await Q({path:w,...O?{aiScanOnLoad:!0}:{}},c),r(n("plugins.installedGlobally","Plugin installed globally"),"success"),A(!1),P(""),U(!1),await b(),p?.()}catch(s){r(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{v(!1)}},Ge=async s=>{if(!s.path){r(n("plugins.builtinNoPackage","{{name}} is built in and does not have an installable package yet",{name:s.name}),"warning");return}try{X(s.id),await Q({path:s.path},c),r(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await b(),p?.()}catch(i){r(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{X(null)}},Oe=async s=>{if(!s.path){r(n("plugins.registryNotInstallable","{{name}} is not available for one-click install yet",{name:s.name}),"warning");return}try{ie(s.id),await Q({path:s.path},c),r(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await b(),p?.(),await E(N,S)}catch(i){r(n("plugins.registryInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{ie(null)}},re=async s=>{try{ae(s.id);const i=await rs(s.id,c);if(!i.success){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}r(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),te(s.id);const l=await ge(s.id,c);z(o=>({...o,[s.id]:l}))}catch(i){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{ae(null),te(null)}},H=async s=>{try{const i=await ts(s.id,c);if(f(l=>l.map(o=>o.id===i.id?i:o)),i.state==="error"){r(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await b();return}r(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await b(!0,i),p?.()}catch(i){r(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async s=>{try{const i=await is(s.id,c);f(l=>l.map(o=>o.id===i.id?i:o)),r(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await b(!0,i),p?.()}catch(i){r(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Ue=async s=>{s.enabled?await V(s):await H(s)},oe=async s=>{try{R(s.id),await ns(s.id,c),r(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await b()}catch(i){r(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{R(null)}},ue=async s=>{if(await qe({title:n("plugins.uninstallTitle","Uninstall Plugin Globally"),message:n("plugins.uninstallConfirm",'Are you sure you want to uninstall "{{name}}" globally (all projects)?',{name:s.name}),danger:!0}))try{await as(s.id,c),r(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await b(),p?.(),y(null)}catch(l){r(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},We=async(s,i)=>{try{await Ze(s.id,{aiScanOnLoad:i},c),r(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await b()}catch(l){r(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},$e=async s=>{try{await es(s.id,c),r(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await b()}catch(i){r(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},$=async s=>{y(s);try{J(!0);const i=await ls(s.id,c);j(i)}catch{j({})}finally{J(!1)}},Me=async()=>{if(a)try{await ss(a.id,m,c),r(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){r(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(a)return e.jsxs("div",{className:"plugin-manager-detail","data-testid":"plugin-manager-detail",children:[e.jsxs("div",{className:"plugin-manager-detail-header",children:[e.jsx("button",{className:"btn-icon",onClick:()=>y(null),"aria-label":n("plugins.backToList","Back to plugin list"),children:e.jsx(me,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsxs("div",{className:"plugin-detail-title-copy",children:[e.jsx("h4",{className:"plugin-detail-name",children:a.name}),ve(a,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:T[a.state]||T.installed},children:a.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[a.description&&e.jsx("p",{className:"plugin-description",children:a.description}),a.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),a.author]}),a.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:n("plugins.homepage","Homepage:")}),e.jsxs("a",{href:a.homepage,target:"_blank",rel:"noopener noreferrer",children:[a.homepage,e.jsx(Ke,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),a.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.securityScan","Security Scan")}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!a.aiScanOnLoad,onChange:s=>void We(a,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void $e(a),children:[e.jsx(Je,{size:14})," ",n("plugins.rescanAndReload","Rescan and Reload")]})]}),e.jsx("p",{className:"text-muted",children:n("plugins.aiScanHint","Turning this on only updates configuration. Use Rescan and Reload to run it now.")}),a.lastSecurityScan?e.jsxs("div",{className:"plugin-security-results",children:[e.jsxs("div",{className:"plugin-security-header",children:[e.jsx("span",{className:`plugin-state-badge plugin-security-badge plugin-security-badge--${a.lastSecurityScan.verdict}`,children:a.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:a.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:a.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:a.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:a.lastSecurityScan.findings.map((s,i)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${i}`))})]})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noSecurityScan","No security scan has been run yet.")})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.settings","Settings")}),a.id==="fusion-plugin-whatsapp-chat"&&e.jsx(ps,{projectId:c,settings:m}),Re?e.jsx("p",{className:"text-muted",children:e.jsx(he,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ds(a);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:l}=gs(s),o=[];l.length>0&&o.push({title:null,entries:l});for(const[g,u]of i.entries())o.push({title:g,entries:u});return o.map(g=>e.jsxs("div",{className:g.title?"plugin-settings-group":void 0,children:[g.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:Ne[g.title]?n(Ne[g.title],g.title):g.title}),g.entries.map(([u,t])=>{const I=`setting-${u}-help`,D=t.label?Se[t.label]?n(Se[t.label],t.label):t.label:u;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${u}`,children:[D,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${u}`,value:m[u]??"",onChange:h=>j({...m,[u]:h.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?I:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${u}`,rows:4,value:m[u]??"",onChange:h=>j({...m,[u]:h.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?I:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${u}`,value:m[u]??"",onChange:h=>j({...m,[u]:h.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?I:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${u}`,value:m[u]??"",onChange:h=>j({...m,[u]:Number(h.target.value)}),"aria-describedby":t.description&&!t.required?I:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m[u]??!1,onChange:h=>j({...m,[u]:h.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${u}`,value:m[u]??"",onChange:h=>j({...m,[u]:h.target.value}),"aria-describedby":t.description&&!t.required?I:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(h=>e.jsx("option",{value:h,children:h},h))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[m[u]?.map((h,C)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:h??"",onChange:M=>{const G=M.target.value,de=[...m[u]||[]];de[C]=t.itemType==="number"?Number(G):G,j({...m,[u]:de})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const G=[...m[u]||[]];G.splice(C,1),j({...m,[u]:G})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(me,{size:14})})]},C)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const h=m[u]||[],C=t.itemType==="number"?0:"";j({...m,[u]:[...h,C]})},children:[e.jsx(be,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:I,className:"form-help",children:t.description})]},u)})]},g.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:Me,children:n("plugins.saveSettings","Save Settings")})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noConfigurableSettings","No configurable settings.")})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[a.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>oe(a),disabled:B===a.id,children:[e.jsx(ye,{size:14,className:B===a.id?"spin":""}),B===a.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),a.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>V(a),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>H(a),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ue(a),children:[e.jsx(xe,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const ce=new Map(x.map(s=>[s.id,s])),pe=x,Te=()=>e.jsxs("section",{className:"plugin-registry-section","aria-label":n("plugins.browseRegistry","Browse Registry"),children:[e.jsxs("div",{className:"plugin-registry-header",children:[e.jsxs("div",{className:"plugin-registry-heading-copy",children:[e.jsx("h4",{className:"plugin-registry-heading",children:n("plugins.browseRegistry","Browse Registry")}),e.jsx("p",{className:"plugin-registry-description",children:n("plugins.registryDescription","Discover curated runtimes and integrations that can be added to this Fusion workspace.")})]}),e.jsxs("div",{className:"plugin-registry-controls",children:[e.jsxs("label",{className:"plugin-registry-category-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.registryCategory","Registry category")}),e.jsxs("select",{className:"select plugin-registry-category-select",value:S,onChange:s=>Be(s.target.value),"aria-label":n("plugins.registryCategory","Registry category"),children:[e.jsx("option",{value:"",children:n("plugins.registryCategoryAll","All Categories")}),e.jsx("option",{value:"runtime",children:n("plugins.registryCategoryRuntime","Runtime")}),e.jsx("option",{value:"integration",children:n("plugins.registryCategoryIntegration","Integration")})]})]}),e.jsxs("label",{className:"plugin-registry-search-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.searchRegistry","Search registry")}),e.jsx("input",{className:"input plugin-registry-search-input",type:"search",value:N,onChange:s=>ke(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Ie?e.jsxs("div",{className:"plugin-registry-state",role:"status",children:[e.jsx(fe,{size:14,className:"spin"}),n("plugins.registryLoading","Loading registry...")]}):se?e.jsxs("div",{className:"plugin-registry-state plugin-registry-state--error",role:"alert",children:[e.jsx("span",{children:n("plugins.registryLoadFailed","Failed to load registry: {{error}}",{error:se})}),e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-retry",onClick:()=>void E(N,S),children:n("plugins.retry","Retry")})]}):Z.length===0?e.jsx("div",{className:"plugin-registry-state",children:N.trim()?n("plugins.registryEmptySearch","No registry plugins match your search."):n("plugins.registryEmpty","No registry plugins are available.")}):e.jsx("div",{className:"plugin-registry-list","aria-label":n("plugins.registryPluginResults","Registry plugin results"),children:Z.map(s=>{const i=ce.get(s.id),l=Ae===s.id;return e.jsxs("div",{className:"plugin-registry-item",children:[e.jsxs("div",{className:"plugin-registry-meta",children:[e.jsxs("div",{className:"plugin-registry-title-row",children:[e.jsx("span",{className:"plugin-registry-name",children:s.name}),e.jsxs("span",{className:"plugin-registry-version",children:["v",s.version]}),e.jsx("span",{className:"plugin-registry-badge",children:s.category}),s.installed&&e.jsxs("span",{className:"plugin-registry-status plugin-registry-status--installed",children:[n("plugins.statusInstalled","Installed"),s.installedVersion&&s.installedVersion!==s.version?` · v${s.installedVersion}`:""]})]}),e.jsx("span",{className:"plugin-registry-description-text",children:s.description}),e.jsx("span",{className:"plugin-registry-author",children:n("plugins.registryByAuthor","By {{author}}",{author:s.author})})]}),e.jsx("div",{className:"plugin-registry-actions",children:s.installed?e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-action",onClick:()=>{i?$(i):b()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Oe(s),disabled:l,children:l?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),_e=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":n("plugins.builtinPlugins","Built-in Plugins"),children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:n("plugins.builtinPlugins","Built-in Plugins")}),e.jsx("p",{className:"plugin-builtins-description",children:n("plugins.builtinPluginsCatalog","Built-in plugin catalog for runtimes and integrations.")})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":n("plugins.builtinPluginRecommendations","Built-in plugin recommendations"),children:we.map(s=>{const i=ce.get(s.id),l=!!i,o=Fe[s.id],g=!!(o&&"setupCheckDeferred"in o&&o.setupCheckDeferred),u=o&&"status"in o?o.status:void 0,t=l&&s.hasSetup&&o?.hasSetup&&!g&&i?.state==="started"&&(u==="not-installed"||u==="error"),I=l&&o?.hasSetup&&u==="installed",D=Le===s.id,h=!s.path,C=s.category==="runtime",M=i?.enabled;return e.jsxs("div",{className:"plugin-builtins-item",children:[e.jsxs("div",{className:"plugin-builtins-meta",children:[e.jsx("span",{className:"plugin-builtins-name",children:s.name}),s.experimental&&e.jsx("span",{className:"plugin-builtins-runtime-badge",children:n("plugins.experimental","Experimental")}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${l?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:l?n("plugins.statusInstalled","Installed"):h?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),C&&M===!1&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.builtinDisabled","Disabled")}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.setupRequired","Setup required")}),I&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),D&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),g&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:n("plugins.startPluginToCheckSetup","Start plugin to check setup")}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),e.jsxs("div",{className:"plugin-builtins-actions",children:[C&&i&&e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:()=>void Ue(i),"aria-label":i.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),h?l&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void re(s),disabled:W===s.id||D,children:W===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):l&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void $(i),children:n("plugins.manage","Manage")}):C?null:e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${l&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!l){Ge(s);return}if(t){re(s);return}i&&$(i)},disabled:Y===s.id||W===s.id||D,children:l?t?W===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup"):n("plugins.manage","Manage"):Y===s.id?n("plugins.installing","Installing..."):n("plugins.installNamed","Install {{name}}",{name:s.name})})]})]},s.id)})})]});return e.jsxs("div",{className:"plugin-manager","data-testid":"plugin-manager",children:[e.jsxs("div",{className:"plugin-manager-header",children:[e.jsx("span",{className:"plugin-manager-header-title",children:n("plugins.installedPlugins","Installed Plugins")}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:()=>void b(),title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(fe,{size:14,className:F?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>A(!0),children:[e.jsx(be,{size:14})," ",n("plugins.install","Install")]})]})]}),_&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsx("p",{className:"plugin-install-hint",children:n("plugins.installHint","Browse to a plugin package root (contains manifest.json) or a built dist directory.")}),e.jsx(os,{value:w,onChange:P,placeholder:n("plugins.installPathPlaceholder","Absolute path to plugin directory or dist folder"),onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),le())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:O,onChange:s=>U(s.target.checked)}),n("plugins.enableAiSecurityScan","Enable AI security scan on load")]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:le,disabled:k||!w.trim(),children:k?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{A(!1),P("")},children:n("plugins.cancel","Cancel")})]})]}),F?e.jsx("div",{className:"settings-empty-state",children:e.jsx(he,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[pe.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(Ye,{size:32,className:"text-muted"}),e.jsx("p",{children:n("plugins.noPluginsInstalled","No plugins installed.")}),e.jsx("p",{className:"text-muted",children:n("plugins.noPluginsHint","Install a plugin to get started, or use the built-in catalog below.")})]}):e.jsx("div",{className:"plugin-list",children:pe.map(s=>e.jsxs("div",{className:"plugin-item",children:[e.jsx("div",{className:"plugin-info",children:e.jsxs("div",{className:"plugin-copy",children:[e.jsxs("div",{className:"plugin-copy-header",children:[e.jsx("span",{className:"plugin-name",children:s.name}),e.jsxs("span",{className:"plugin-version text-muted",children:["v",s.version]}),e.jsx("span",{className:"plugin-state-badge",style:{color:T[s.state]||T.installed},children:s.state})]}),ve(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>oe(s),disabled:B===s.id,title:n("plugins.reload","Reload"),children:e.jsx(ye,{size:14,className:B===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?V(s):H(s),"aria-label":s.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>$(s),title:n("plugins.settings","Settings"),children:e.jsx(Xe,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>ue(s),title:n("plugins.uninstallGloballyTitle","Uninstall globally"),children:e.jsx(xe,{size:14})})]})]},s.id))}),_e(),Te()]})]})}export{je as AGENT_BROWSER_SETTINGS_SCHEMA,Pe as BUILTIN_AGENT_BROWSER_PLUGIN_ID,we as BUILTIN_PLUGINS,ws as PluginManager,T as STATE_COLORS};
@@ -1,6 +1,6 @@
1
- import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{c as te,V as ie,b0 as k,b1 as N,b2 as C,b3 as F,b4 as M,b5 as ae,b6 as X,aU as Z,as as K,a as E}from"./index-B8PcG8AJ.js";import{u as ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{c as te,V as ie,aO as k,aP as b,aQ as C,aR as F,aS as M,aT as ae,aU as Q,aF as X,a8 as Z,a as E}from"./index-BjM7LxzY.js";import{u as ne}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const le=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],de=te("thumbs-up",le);function ce(t){return async s=>{const n=t?`?projectId=${encodeURIComponent(t)}`:"";return(await E(`/pull-requests/${s}${n}`)).pullRequest}}function oe(t){return async()=>{const s=t?`?projectId=${encodeURIComponent(t)}`:"";return(await E(`/pull-requests${s}`)).pullRequests}}function pe(t){return async(s,n,o)=>(await E(`/pull-requests/${n}/${s==="automerge"?"automerge":s}`,{method:"POST",body:JSON.stringify({...o??{},...t?{projectId:t}:{}}),headers:{"content-type":"application/json"}})).pullRequest}function V({rollup:t}){return t==="success"?e.jsx(K,{size:14,className:"pr-icon-success"}):t==="failure"?e.jsx(X,{size:14,className:"pr-icon-failure"}):t==="pending"?e.jsx(C,{size:14,className:"pr-icon-pending"}):e.jsx("span",{className:"pr-icon-none",children:"—"})}const ue=15e3;async function J(t,s){const n=new Promise((o,l)=>setTimeout(()=>l(new Error(s)),ue));return Promise.race([t,n])}function fe(t){const{t:s}=ne("app"),{detail:n,pullRequestId:o,projectId:l,onAction:R,loadPullRequest:q,loadPullRequests:S}=t,h=n!==void 0,[L,T]=a.useState(null),[i,x]=a.useState(n??null),[v,p]=a.useState(null),[$,I]=a.useState([]),[A,U]=a.useState(null),[u,B]=a.useState(null),[Q,G]=a.useState(!1),[W,j]=a.useState(!1),[Y,H]=a.useState(!1),_=a.useMemo(()=>q??ce(l),[q,l]),O=a.useMemo(()=>S??oe(l),[S,l]),D=a.useMemo(()=>R??pe(l),[R,l]),z=o??L??void 0,ee=!h&&!o&&!L,se=!h&&!o&&!!L,f=a.useCallback(async()=>{if(h){x(n??null),p(null),j(!1);return}if(!z){try{p(null),U(null),H(!0),x(null),I(await J(O(),"Timed out loading pull requests"))}catch(r){I([]),U(r instanceof Error?r.message:s("pr.view.listError","Failed to load pull requests"))}finally{H(!1)}return}try{p(null),j(!0),x(await J(_(z),"Timed out loading pull request"))}catch(r){p(r instanceof Error?r.message:"Failed to load PR")}finally{j(!1)}},[z,n,h,_,O,s]);a.useEffect(()=>{f()},[f]),a.useEffect(()=>{if(h)return;const r=()=>void f();return window.addEventListener("fusion:store-changed",r),()=>window.removeEventListener("fusion:store-changed",r)},[h,f]);const g=a.useCallback(async(r,re)=>{if(i)try{B(r),p(null);const w=await D(r,i.id,re);x(w)}catch(w){p(w instanceof Error?w.message:`Action ${r} failed`)}finally{B(null),G(!1)}},[i,D]),d=e.jsx(ie,{icon:k,title:s("pr.view.title","Pull Requests")});if(ee)return A?e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-list-error",children:[d,e.jsxs("div",{className:"pr-list-state pr-list-state--error",children:[e.jsx(N,{size:16})," ",A]})]}):Y?e.jsxs("div",{className:"pr-view pr-view--loading","data-testid":"pr-list-loading",children:[d,e.jsx("div",{className:"pr-list-state",children:s("pr.view.listLoading","Loading pull requests…")})]}):$.length===0?e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-list-empty",children:[d,e.jsxs("div",{className:"pr-list-state",children:[e.jsx(k,{size:16})," ",s("pr.view.listEmpty","No active pull requests to show.")]})]}):e.jsxs("div",{className:"pr-view","data-testid":"pr-list",children:[d,e.jsx("div",{className:"pr-list-title",children:s("pr.view.listTitle","Active pull requests")}),e.jsx("div",{className:"pr-list-items",children:$.map(r=>e.jsxs("button",{type:"button",className:"pr-list-item","data-testid":"pr-list-item","aria-label":s("pr.view.listItemLabel","Open pull request {{repo}} {{number}}",{repo:r.repo,number:r.prNumber!=null?`#${r.prNumber}`:r.headBranch}),onClick:()=>{p(null),j(!0),T(r.id)},children:[e.jsxs("span",{className:"pr-list-item-main",children:[e.jsx("span",{className:"pr-list-item-repo",children:r.repo}),r.prNumber!=null&&e.jsxs("span",{className:"pr-list-item-number",children:["#",r.prNumber]}),e.jsx("span",{className:"pr-list-item-branch",children:r.headBranch})]}),e.jsxs("span",{className:"pr-list-item-meta",children:[e.jsx("span",{className:`pr-identity-state pr-identity-state--${r.state}`,children:r.state}),e.jsxs("span",{className:"pr-list-item-checks",children:[e.jsx(V,{rollup:r.summary.checksRollup})," ",r.summary.checksRollup]})]})]},r.id))})]});if(v&&!i)return e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-view-error",children:[e.jsx(N,{size:16})," ",v]});if(!i)return W?e.jsx("div",{className:"pr-view pr-view--loading","data-testid":"pr-view-loading",children:s("pr.view.loading","Loading PR…")}):e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-view-empty",children:[e.jsx(k,{size:16})," ",s("pr.view.empty","No pull request to show.")]});const{state:c,summary:m}=i,b=se?e.jsx("button",{type:"button",className:"pr-back-to-list btn","data-testid":"pr-back-to-list",onClick:()=>T(null),children:s("pr.view.backToList","Back to list")}):null;if(c==="creating")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"creating",children:[d,b,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-placeholder","data-testid":"pr-creating",children:[e.jsx(C,{size:16})," ",s("pr.view.creating","Creating PR…")]})]});if(c==="failed")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"failed",children:[d,b,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-error-reason","data-testid":"pr-failed",children:[e.jsx(N,{size:16,className:"pr-icon-failure"}),e.jsx("span",{children:i.failureReason??s("pr.view.creationFailed","PR creation failed")})]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry-create",disabled:u==="retry-create",onClick:()=>void g("retry-create"),children:[e.jsx(F,{size:14})," ",s("pr.view.retryCreation","Retry PR creation")]})}),v&&e.jsx("div",{className:"pr-inline-error",children:v})]});if(i.unverified)return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"unverified",children:[d,b,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-notice pr-notice--unverified","data-testid":"pr-unverified",children:[e.jsx(C,{size:16})," ",s("pr.view.verifyingGithub","Verifying with GitHub…")]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action","data-testid":"pr-merge",disabled:!0,title:s("pr.view.mergeDisabledUntilVerified","Merge is disabled until GitHub verifies this PR"),children:[e.jsx(M,{size:14})," ",s("pr.view.merge","Merge")]})})]});const P=m.conflicting;return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":c,children:[d,b,e.jsx(y,{detail:i}),c==="responding"&&e.jsxs("div",{className:"pr-banner pr-banner--responding","data-testid":"pr-responding",children:[e.jsx(ae,{size:16})," ",s("pr.view.responsePending","Response run in progress — {{count}} threads pending",{count:m.pendingThreads})]}),e.jsxs("div",{className:"pr-action-bar","data-testid":"pr-action-bar",children:[e.jsxs("button",{type:"button",className:"pr-action pr-action--approve","data-testid":"pr-approve",disabled:c==="responding"||u==="approve",onClick:()=>void g("approve"),children:[e.jsx(de,{size:14})," ",s("pr.view.approve","Approve")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry",disabled:c==="responding"||u==="retry",title:c==="responding"?s("pr.view.responseAlreadyInProgress","A response run is already in progress"):void 0,onClick:()=>void g("retry"),children:[e.jsx(F,{size:14})," ",s("pr.view.requestRetry","Request retry")]}),Q?e.jsxs("button",{type:"button",className:"pr-action pr-action--merge-confirm","data-testid":"pr-merge-confirm",disabled:u==="merge",onClick:()=>void g("merge"),children:[e.jsx(M,{size:14})," ",s("pr.view.confirmMerge","Confirm merge")]}):e.jsxs("button",{type:"button",className:"pr-action pr-action--merge","data-testid":"pr-merge",disabled:P||c==="responding"||u==="merge",title:P?s("pr.view.resolveConflictsBeforeMerge","Resolve conflicts on GitHub before merging"):void 0,onClick:()=>G(!0),children:[e.jsx(M,{size:14})," ",s("pr.view.merge","Merge")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--close","data-testid":"pr-close",disabled:u==="close",onClick:()=>void g("close"),children:[e.jsx(X,{size:14})," ",s("pr.view.close","Close")]}),e.jsxs("label",{className:"pr-automerge-toggle","data-testid":"pr-automerge",children:[e.jsx("input",{type:"checkbox",checked:i.autoMerge,disabled:u==="automerge",onChange:r=>void g("automerge",{enabled:r.target.checked})}),e.jsx("span",{children:s("pr.view.autoMerge","Auto-merge")}),e.jsx("span",{className:"pr-automerge-gate","data-testid":"pr-automerge-gate",children:m.autoMergeReason})]})]}),P&&i.prUrl&&e.jsxs("a",{className:"pr-conflict-link","data-testid":"pr-conflict-link",href:i.prUrl,target:"_blank",rel:"noopener noreferrer",children:[s("pr.view.resolveConflictsOnGithub","Resolve conflicts on GitHub")," ",e.jsx(Z,{size:12})]}),e.jsxs("div",{className:"pr-summary","data-testid":"pr-summary",children:[e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-mergeable",children:[s("pr.view.mergeableLabel","Mergeable:")," ",m.mergeable]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-review",children:[s("pr.view.reviewLabel","Review:")," ",m.reviewDecision??s("pr.view.none","none")]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-checks",children:[e.jsx(V,{rollup:m.checksRollup})," ",m.checksRollup]})]}),e.jsx("div",{className:"pr-threads","data-testid":"pr-threads",children:i.threads.length===0?e.jsx("div",{className:"pr-threads-empty",children:s("pr.view.noReviewThreads","No review threads.")}):i.threads.map(r=>e.jsxs("div",{className:`pr-thread pr-thread--${r.outcome} ${r.outcome==="disagreed"?"pr-thread--agent-disagreement":""}`,"data-testid":`pr-thread-${r.outcome}`,"data-agent-disagreement":r.outcome==="disagreed"?"true":"false",children:[e.jsxs("div",{className:"pr-thread-head",children:[r.outcome==="pending"&&e.jsxs("span",{className:"pr-thread-pending",children:[e.jsx(C,{size:12})," ",s("pr.view.threadPending","pending")]}),r.outcome==="disagreed"&&e.jsxs("span",{className:"pr-thread-disagreed",children:[e.jsx(N,{size:12})," ",s("pr.view.agentDisagreed","agent disagreed")]}),r.outcome==="fixed"&&e.jsxs("span",{className:"pr-thread-fixed",children:[e.jsx(K,{size:12})," ",s("pr.view.threadFixed","fixed")]}),e.jsx("span",{className:"pr-thread-id",children:r.threadId})]}),r.fixCommitSha&&e.jsx("div",{className:"pr-thread-reply","data-testid":"pr-thread-reply",children:s("pr.view.agentReplyFix","Agent reply — fix {{sha}}",{sha:r.fixCommitSha.slice(0,8)})})]},`${r.threadId}:${r.headOid}`))}),v&&e.jsx("div",{className:"pr-inline-error",children:v})]})}function y({detail:t}){return e.jsxs("div",{className:"pr-identity","data-testid":"pr-identity",children:[e.jsx(k,{size:16}),e.jsx("span",{className:"pr-identity-repo",children:t.repo}),t.prNumber!=null?t.prUrl?e.jsxs("a",{className:"pr-identity-number",href:t.prUrl,target:"_blank",rel:"noopener noreferrer",children:["#",t.prNumber," ",e.jsx(Z,{size:12})]}):e.jsxs("span",{className:"pr-identity-number",children:["#",t.prNumber]}):null,e.jsx("span",{className:"pr-identity-branch",children:t.headBranch}),e.jsx("span",{className:`pr-identity-state pr-identity-state--${t.state}`,children:t.state})]})}export{fe as PullRequestView};
6
+ */const le=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],de=te("thumbs-up",le);function ce(t){return async s=>{const n=t?`?projectId=${encodeURIComponent(t)}`:"";return(await E(`/pull-requests/${s}${n}`)).pullRequest}}function oe(t){return async()=>{const s=t?`?projectId=${encodeURIComponent(t)}`:"";return(await E(`/pull-requests${s}`)).pullRequests}}function pe(t){return async(s,n,o)=>(await E(`/pull-requests/${n}/${s==="automerge"?"automerge":s}`,{method:"POST",body:JSON.stringify({...o??{},...t?{projectId:t}:{}}),headers:{"content-type":"application/json"}})).pullRequest}function V({rollup:t}){return t==="success"?e.jsx(Z,{size:14,className:"pr-icon-success"}):t==="failure"?e.jsx(Q,{size:14,className:"pr-icon-failure"}):t==="pending"?e.jsx(C,{size:14,className:"pr-icon-pending"}):e.jsx("span",{className:"pr-icon-none",children:"—"})}const ue=15e3;async function J(t,s){const n=new Promise((o,l)=>setTimeout(()=>l(new Error(s)),ue));return Promise.race([t,n])}function fe(t){const{t:s}=ne("app"),{detail:n,pullRequestId:o,projectId:l,onAction:R,loadPullRequest:S,loadPullRequests:T}=t,h=n!==void 0,[L,q]=a.useState(null),[i,x]=a.useState(n??null),[v,p]=a.useState(null),[$,I]=a.useState([]),[A,U]=a.useState(null),[u,B]=a.useState(null),[K,G]=a.useState(!1),[W,j]=a.useState(!1),[Y,H]=a.useState(!1),O=a.useMemo(()=>S??ce(l),[S,l]),_=a.useMemo(()=>T??oe(l),[T,l]),D=a.useMemo(()=>R??pe(l),[R,l]),P=o??L??void 0,ee=!h&&!o&&!L,se=!h&&!o&&!!L,f=a.useCallback(async()=>{if(h){x(n??null),p(null),j(!1);return}if(!P){try{p(null),U(null),H(!0),x(null),I(await J(_(),"Timed out loading pull requests"))}catch(r){I([]),U(r instanceof Error?r.message:s("pr.view.listError","Failed to load pull requests"))}finally{H(!1)}return}try{p(null),j(!0),x(await J(O(P),"Timed out loading pull request"))}catch(r){p(r instanceof Error?r.message:"Failed to load PR")}finally{j(!1)}},[P,n,h,O,_,s]);a.useEffect(()=>{f()},[f]),a.useEffect(()=>{if(h)return;const r=()=>void f();return window.addEventListener("fusion:store-changed",r),()=>window.removeEventListener("fusion:store-changed",r)},[h,f]);const g=a.useCallback(async(r,re)=>{if(i)try{B(r),p(null);const N=await D(r,i.id,re);x(N)}catch(N){p(N instanceof Error?N.message:`Action ${r} failed`)}finally{B(null),G(!1)}},[i,D]),d=e.jsx(ie,{icon:k,title:s("pr.view.title","Pull Requests")});if(ee)return A?e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-list-error",children:[d,e.jsxs("div",{className:"pr-list-state pr-list-state--error",children:[e.jsx(b,{size:16})," ",A]})]}):Y?e.jsxs("div",{className:"pr-view pr-view--loading","data-testid":"pr-list-loading",children:[d,e.jsx("div",{className:"pr-list-state",children:s("pr.view.listLoading","Loading pull requests…")})]}):$.length===0?e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-list-empty",children:[d,e.jsxs("div",{className:"pr-list-state",children:[e.jsx(k,{size:16})," ",s("pr.view.listEmpty","No active pull requests to show.")]})]}):e.jsxs("div",{className:"pr-view","data-testid":"pr-list",children:[d,e.jsx("div",{className:"pr-list-title",children:s("pr.view.listTitle","Active pull requests")}),e.jsx("div",{className:"pr-list-items",children:$.map(r=>e.jsxs("button",{type:"button",className:"pr-list-item","data-testid":"pr-list-item","aria-label":s("pr.view.listItemLabel","Open pull request {{repo}} {{number}}",{repo:r.repo,number:r.prNumber!=null?`#${r.prNumber}`:r.headBranch}),onClick:()=>{p(null),j(!0),q(r.id)},children:[e.jsxs("span",{className:"pr-list-item-main",children:[e.jsx("span",{className:"pr-list-item-repo",children:r.repo}),r.prNumber!=null&&e.jsxs("span",{className:"pr-list-item-number",children:["#",r.prNumber]}),e.jsx("span",{className:"pr-list-item-branch",children:r.headBranch})]}),e.jsxs("span",{className:"pr-list-item-meta",children:[e.jsx("span",{className:`pr-identity-state pr-identity-state--${r.state}`,children:r.state}),e.jsxs("span",{className:"pr-list-item-checks",children:[e.jsx(V,{rollup:r.summary.checksRollup})," ",r.summary.checksRollup]})]})]},r.id))})]});if(v&&!i)return e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-view-error",children:[e.jsx(b,{size:16})," ",v]});if(!i)return W?e.jsx("div",{className:"pr-view pr-view--loading","data-testid":"pr-view-loading",children:s("pr.view.loading","Loading PR…")}):e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-view-empty",children:[e.jsx(k,{size:16})," ",s("pr.view.empty","No pull request to show.")]});const{state:c,summary:m}=i,w=se?e.jsx("button",{type:"button",className:"pr-back-to-list btn","data-testid":"pr-back-to-list",onClick:()=>q(null),children:s("pr.view.backToList","Back to list")}):null;if(c==="creating")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"creating",children:[d,w,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-placeholder","data-testid":"pr-creating",children:[e.jsx(C,{size:16})," ",s("pr.view.creating","Creating PR…")]})]});if(c==="failed")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"failed",children:[d,w,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-error-reason","data-testid":"pr-failed",children:[e.jsx(b,{size:16,className:"pr-icon-failure"}),e.jsx("span",{children:i.failureReason??s("pr.view.creationFailed","PR creation failed")})]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry-create",disabled:u==="retry-create",onClick:()=>void g("retry-create"),children:[e.jsx(F,{size:14})," ",s("pr.view.retryCreation","Retry PR creation")]})}),v&&e.jsx("div",{className:"pr-inline-error",children:v})]});if(i.unverified)return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"unverified",children:[d,w,e.jsx(y,{detail:i}),e.jsxs("div",{className:"pr-notice pr-notice--unverified","data-testid":"pr-unverified",children:[e.jsx(C,{size:16})," ",s("pr.view.verifyingGithub","Verifying with GitHub…")]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action","data-testid":"pr-merge",disabled:!0,title:s("pr.view.mergeDisabledUntilVerified","Merge is disabled until GitHub verifies this PR"),children:[e.jsx(M,{size:14})," ",s("pr.view.merge","Merge")]})})]});const z=m.conflicting;return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":c,children:[d,w,e.jsx(y,{detail:i}),c==="responding"&&e.jsxs("div",{className:"pr-banner pr-banner--responding","data-testid":"pr-responding",children:[e.jsx(ae,{size:16})," ",s("pr.view.responsePending","Response run in progress — {{count}} threads pending",{count:m.pendingThreads})]}),e.jsxs("div",{className:"pr-action-bar","data-testid":"pr-action-bar",children:[e.jsxs("button",{type:"button",className:"pr-action pr-action--approve","data-testid":"pr-approve",disabled:c==="responding"||u==="approve",onClick:()=>void g("approve"),children:[e.jsx(de,{size:14})," ",s("pr.view.approve","Approve")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry",disabled:c==="responding"||u==="retry",title:c==="responding"?s("pr.view.responseAlreadyInProgress","A response run is already in progress"):void 0,onClick:()=>void g("retry"),children:[e.jsx(F,{size:14})," ",s("pr.view.requestRetry","Request retry")]}),K?e.jsxs("button",{type:"button",className:"pr-action pr-action--merge-confirm","data-testid":"pr-merge-confirm",disabled:u==="merge",onClick:()=>void g("merge"),children:[e.jsx(M,{size:14})," ",s("pr.view.confirmMerge","Confirm merge")]}):e.jsxs("button",{type:"button",className:"pr-action pr-action--merge","data-testid":"pr-merge",disabled:z||c==="responding"||u==="merge",title:z?s("pr.view.resolveConflictsBeforeMerge","Resolve conflicts on GitHub before merging"):void 0,onClick:()=>G(!0),children:[e.jsx(M,{size:14})," ",s("pr.view.merge","Merge")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--close","data-testid":"pr-close",disabled:u==="close",onClick:()=>void g("close"),children:[e.jsx(Q,{size:14})," ",s("pr.view.close","Close")]}),e.jsxs("label",{className:"pr-automerge-toggle","data-testid":"pr-automerge",children:[e.jsx("input",{type:"checkbox",checked:i.autoMerge,disabled:u==="automerge",onChange:r=>void g("automerge",{enabled:r.target.checked})}),e.jsx("span",{children:s("pr.view.autoMerge","Auto-merge")}),e.jsx("span",{className:"pr-automerge-gate","data-testid":"pr-automerge-gate",children:m.autoMergeReason})]})]}),z&&i.prUrl&&e.jsxs("a",{className:"pr-conflict-link","data-testid":"pr-conflict-link",href:i.prUrl,target:"_blank",rel:"noopener noreferrer",children:[s("pr.view.resolveConflictsOnGithub","Resolve conflicts on GitHub")," ",e.jsx(X,{size:12})]}),e.jsxs("div",{className:"pr-summary","data-testid":"pr-summary",children:[e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-mergeable",children:[s("pr.view.mergeableLabel","Mergeable:")," ",m.mergeable]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-review",children:[s("pr.view.reviewLabel","Review:")," ",m.reviewDecision??s("pr.view.none","none")]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-checks",children:[e.jsx(V,{rollup:m.checksRollup})," ",m.checksRollup]})]}),e.jsx("div",{className:"pr-threads","data-testid":"pr-threads",children:i.threads.length===0?e.jsx("div",{className:"pr-threads-empty",children:s("pr.view.noReviewThreads","No review threads.")}):i.threads.map(r=>e.jsxs("div",{className:`pr-thread pr-thread--${r.outcome} ${r.outcome==="disagreed"?"pr-thread--agent-disagreement":""}`,"data-testid":`pr-thread-${r.outcome}`,"data-agent-disagreement":r.outcome==="disagreed"?"true":"false",children:[e.jsxs("div",{className:"pr-thread-head",children:[r.outcome==="pending"&&e.jsxs("span",{className:"pr-thread-pending",children:[e.jsx(C,{size:12})," ",s("pr.view.threadPending","pending")]}),r.outcome==="disagreed"&&e.jsxs("span",{className:"pr-thread-disagreed",children:[e.jsx(b,{size:12})," ",s("pr.view.agentDisagreed","agent disagreed")]}),r.outcome==="fixed"&&e.jsxs("span",{className:"pr-thread-fixed",children:[e.jsx(Z,{size:12})," ",s("pr.view.threadFixed","fixed")]}),e.jsx("span",{className:"pr-thread-id",children:r.threadId})]}),r.fixCommitSha&&e.jsx("div",{className:"pr-thread-reply","data-testid":"pr-thread-reply",children:s("pr.view.agentReplyFix","Agent reply — fix {{sha}}",{sha:r.fixCommitSha.slice(0,8)})})]},`${r.threadId}:${r.headOid}`))}),v&&e.jsx("div",{className:"pr-inline-error",children:v})]})}function y({detail:t}){return e.jsxs("div",{className:"pr-identity","data-testid":"pr-identity",children:[e.jsx(k,{size:16}),e.jsx("span",{className:"pr-identity-repo",children:t.repo}),t.prNumber!=null?t.prUrl?e.jsxs("a",{className:"pr-identity-number",href:t.prUrl,target:"_blank",rel:"noopener noreferrer",children:["#",t.prNumber," ",e.jsx(X,{size:12})]}):e.jsxs("span",{className:"pr-identity-number",children:["#",t.prNumber]}):null,e.jsx("span",{className:"pr-identity-branch",children:t.headBranch}),e.jsx("span",{className:`pr-identity-state pr-identity-state--${t.state}`,children:t.state})]})}export{fe as PullRequestView};
@@ -0,0 +1,21 @@
1
+ import{r as n,j as e,b as se}from"./vendor-react-SZ_qB27O.js";import{c as T,da as re,dd as Q,U as le,C as X,de as oe,df as ne,q as ce,aT as ie,bt as he,dg as A,dh as de,di as Y}from"./index-BjM7LxzY.js";import{u as _}from"./vendor-i18n-Duky4gdQ.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ue=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],me=T("bug",ue);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const pe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]],be=T("life-buoy",pe);/**
12
+ * @license lucide-react v1.7.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const we=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ve=T("moon",we);/**
17
+ * @license lucide-react v1.7.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const fe=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ye=T("sun",fe);async function G(s,d){const l=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}function ge(s){return G("/api/report/draft",s)}function Ne(s){return G("/api/report/file",s)}function xe(s){return G("/api/report/help",{question:s})}async function ke(s){const d=new FormData;d.append("screenshot",s,"report-screenshot.png");const l=await fetch("/api/report/attachment",{method:"POST",body:d});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}async function Me(){const s=await fetch("/api/report/discussion-categories");if(!s.ok)throw new Error((await s.json().catch(()=>({error:s.statusText}))).error??s.statusText);return s.json()}function $e(s){const d=new URLSearchParams(s.search),l=s.hash.match(/^#\/tasks\/([^/?#]+)/),r=l?.[1]?decodeURIComponent(l[1]):d.get("taskId")??void 0,u=d.get("agentId")??void 0;return r||u?{taskId:r,agentId:u}:void 0}const J=[{value:"light",label:"Light",icon:ye},{value:"dark",label:"Dark",icon:ve},{value:"system",label:"System",icon:re}],V=[{value:"default",label:"Fusion Legacy",className:"theme-swatch-default"},{value:"ocean",label:"Ocean",className:"theme-swatch-ocean"},{value:"forest",label:"Forest",className:"theme-swatch-forest"},{value:"sunset",label:"Sunset",className:"theme-swatch-sunset"},{value:"zen",label:"Zen",className:"theme-swatch-zen"},{value:"berry",label:"Berry",className:"theme-swatch-berry"},{value:"high-contrast",label:"High Contrast",className:"theme-swatch-high-contrast"},{value:"industrial",label:"Industrial",className:"theme-swatch-industrial"},{value:"monochrome",label:"Mono",className:"theme-swatch-monochrome"},{value:"slate",label:"Slate",className:"theme-swatch-slate"},{value:"ash",label:"Ash",className:"theme-swatch-ash"},{value:"air",label:"Air",className:"theme-swatch-air"},{value:"graphite",label:"Graphite",className:"theme-swatch-graphite"},{value:"silver",label:"Silver",className:"theme-swatch-silver"},{value:"solarized",label:"Solarized",className:"theme-swatch-solarized"},{value:"factory",label:"Factory",className:"theme-swatch-factory"},{value:"factory-mono",label:"Factory Mono",className:"theme-swatch-factory-mono"},{value:"ayu",label:"Ayu",className:"theme-swatch-ayu"},{value:"one-dark",label:"One Dark",className:"theme-swatch-one-dark"},{value:"nord",label:"Nord",className:"theme-swatch-nord"},{value:"dracula",label:"Dracula",className:"theme-swatch-dracula"},{value:"gruvbox",label:"Gruvbox",className:"theme-swatch-gruvbox"},{value:"tokyo-night",label:"Tokyo Night",className:"theme-swatch-tokyo-night"},{value:"catppuccin-mocha",label:"Catppuccin Mocha",className:"theme-swatch-catppuccin-mocha"},{value:"github-dark",label:"GitHub Dark",className:"theme-swatch-github-dark"},{value:"everforest",label:"Everforest",className:"theme-swatch-everforest"},{value:"rose-pine",label:"Rosé Pine",className:"theme-swatch-rose-pine"},{value:"kanagawa",label:"Kanagawa",className:"theme-swatch-kanagawa"},{value:"night-owl",label:"Night Owl",className:"theme-swatch-night-owl"},{value:"palenight",label:"Palenight",className:"theme-swatch-palenight"},{value:"monokai-pro",label:"Monokai Pro",className:"theme-swatch-monokai-pro"},{value:"slime",label:"Slime",className:"theme-swatch-slime"},{value:"brutalist",label:"Brutalist",className:"theme-swatch-brutalist"},{value:"neon-city",label:"Neon City",className:"theme-swatch-neon-city"},{value:"parchment",label:"Parchment",className:"theme-swatch-parchment"},{value:"medieval",label:"Medieval",className:"theme-swatch-medieval"},{value:"terminal",label:"Terminal",className:"theme-swatch-terminal"},{value:"glass",label:"Glass",className:"theme-swatch-glass"},{value:"glass-silver",label:"Glass Silver",className:"theme-swatch-glass-silver"},{value:"horizon",label:"Horizon",className:"theme-swatch-horizon"},{value:"vitesse",label:"Vitesse",className:"theme-swatch-vitesse"},{value:"outrun",label:"Outrun",className:"theme-swatch-outrun"},{value:"snazzy",label:"Snazzy",className:"theme-swatch-snazzy"},{value:"porple",label:"Porple",className:"theme-swatch-porple"},{value:"espresso",label:"Espresso",className:"theme-swatch-espresso"},{value:"mars",label:"Mars",className:"theme-swatch-mars"},{value:"poimandres",label:"Poimandres",className:"theme-swatch-poimandres"},{value:"ember",label:"Ember",className:"theme-swatch-ember"},{value:"rust",label:"Rust",className:"theme-swatch-rust"},{value:"copper",label:"Copper",className:"theme-swatch-copper"},{value:"foundry",label:"Foundry",className:"theme-swatch-foundry"},{value:"carbon",label:"Carbon",className:"theme-swatch-carbon"},{value:"sandstone",label:"Sandstone",className:"theme-swatch-sandstone"},{value:"lagoon",label:"Lagoon",className:"theme-swatch-lagoon"},{value:"frost",label:"Frost",className:"theme-swatch-frost"},{value:"lavender",label:"Lavender",className:"theme-swatch-lavender"},{value:"neon-bloom",label:"Neon Bloom",className:"theme-swatch-neon-bloom"},{value:"sepia",label:"Sepia",className:"theme-swatch-sepia"},{value:"cobalt",label:"Cobalt",className:"theme-swatch-cobalt"},{value:"clay",label:"Clay",className:"theme-swatch-clay"},{value:"moss",label:"Moss",className:"theme-swatch-moss"},{value:"aurora",label:"Aurora",className:"theme-swatch-aurora"},{value:"calm",label:"Calm",className:"theme-swatch-calm"},{value:"dawn",label:"Dawn",className:"theme-swatch-dawn"},{value:"sage",label:"Sage",className:"theme-swatch-sage"},{value:"midnight",label:"Midnight",className:"theme-swatch-midnight"},{value:"velvet",label:"Velvet",className:"theme-swatch-velvet"},{value:"iceberg",label:"Iceberg",className:"theme-swatch-iceberg"},{value:"factory-dark",label:"Factory Dark",className:"theme-swatch-factory-dark"},{value:"factory-light",label:"Factory Light",className:"theme-swatch-factory-light"},{value:"shadcn",label:"Shadcn",className:"theme-swatch-shadcn"},{value:"shadcn-ember",label:"Shadcn Ember (Default)",className:"theme-swatch-shadcn-ember"},{value:"shadcn-custom",label:"Shadcn Custom",className:"theme-swatch-shadcn-custom"},{value:"shadcn-blue",label:"Shadcn Blue",className:"theme-swatch-shadcn-blue"},{value:"shadcn-green",label:"Shadcn Green",className:"theme-swatch-shadcn-green"},{value:"shadcn-red",label:"Shadcn Red",className:"theme-swatch-shadcn-red"},{value:"shadcn-purple",label:"Shadcn Purple",className:"theme-swatch-shadcn-purple"},{value:"shadcn-pink",label:"Shadcn Pink",className:"theme-swatch-shadcn-pink"},{value:"shadcn-orange",label:"Shadcn Orange",className:"theme-swatch-shadcn-orange"},{value:"shadcn-yellow",label:"Shadcn Yellow",className:"theme-swatch-shadcn-yellow"},{value:"shadcn-mono",label:"Shadcn Mono",className:"theme-swatch-shadcn-mono"},{value:"shadcn-mono-red",label:"Shadcn Mono Red",className:"theme-swatch-shadcn-mono-red"},{value:"shadcn-mono-blue",label:"Shadcn Mono Blue",className:"theme-swatch-shadcn-mono-blue"},{value:"shadcn-mono-green",label:"Shadcn Mono Green",className:"theme-swatch-shadcn-mono-green"},{value:"shadcn-mono-purple",label:"Shadcn Mono Purple",className:"theme-swatch-shadcn-mono-purple"},{value:"shadcn-mono-pink",label:"Shadcn Mono Pink",className:"theme-swatch-shadcn-mono-pink"},{value:"shadcn-mono-orange",label:"Shadcn Mono Orange",className:"theme-swatch-shadcn-mono-orange"},{value:"shadcn-mono-yellow",label:"Shadcn Mono Yellow",className:"theme-swatch-shadcn-mono-yellow"},{value:"shadcn-black",label:"Shadcn Black",className:"theme-swatch-shadcn-black"},{value:"shadcn-gray",label:"Shadcn Gray",className:"theme-swatch-shadcn-gray"},{value:"shadcn-gray-blue",label:"Shadcn Gray Blue",className:"theme-swatch-shadcn-gray-blue"}];function je(s){const d=s.trim();if(/^#[\da-f]{6}$/i.test(d))return d;if(/^#[\da-f]{3}$/i.test(d)){const[,l,r,u]=d;return`#${l}${l}${r}${r}${u}${u}`}return"#000000"}function Ce({value:s={},onChange:d,resolvedThemeMode:l="dark"}){const{t:r}=_("app"),[u,j]=n.useState(!1),t=n.useId(),w=n.useMemo(()=>Q(s),[s]),h=(o,v)=>{d(Q({...w,[o]:v}))},m=u?r("theme.shadcnCustom.collapse","Collapse custom colors"):r("theme.shadcnCustom.show","Show custom colors"),i=u?le:X;return e.jsxs("section",{className:"shadcn-color-picker card","data-testid":"shadcn-color-picker","aria-labelledby":"shadcn-color-picker-title",children:[e.jsxs("div",{className:"shadcn-color-picker-header",children:[e.jsxs("div",{className:"shadcn-color-picker-heading",children:[e.jsx("h3",{id:"shadcn-color-picker-title",className:"shadcn-color-picker-title",children:r("theme.shadcnCustom.title","Custom shadcn colors")}),e.jsx("p",{className:"shadcn-color-picker-description",children:r("theme.shadcnCustom.description","Override shadcn design tokens with hex colors. Blank tokens use the theme defaults.")})]}),e.jsx("button",{type:"button",className:"btn btn-icon btn-sm shadcn-color-picker-toggle","aria-expanded":u,"aria-controls":t,"aria-label":m,title:m,onClick:()=>j(o=>!o),children:e.jsx(i,{size:16,"aria-hidden":"true"})})]}),u?e.jsxs("div",{id:t,className:"shadcn-color-picker-controls-panel","data-testid":"shadcn-color-picker-controls",children:[e.jsx("div",{className:"shadcn-color-picker-actions",children:e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>d({}),children:r("theme.shadcnCustom.reset","Reset custom colors")})}),e.jsx("div",{className:"shadcn-color-picker-grid",children:oe.map(o=>{const v=ne(o,l),g=w[o.cssVar]??v,y=`shadcn-color-${o.cssVar.replace(/^--/,"").replace(/[^a-z0-9]+/gi,"-")}`;return e.jsxs("div",{className:"shadcn-color-picker-row","data-testid":`shadcn-color-${o.cssVar}`,children:[e.jsxs("label",{className:"shadcn-color-picker-label",htmlFor:y,children:[e.jsx("span",{children:r(`theme.shadcnCustom.token.${o.cssVar}`,o.label)}),e.jsx("code",{children:o.cssVar})]}),e.jsxs("div",{className:"shadcn-color-picker-controls",children:[e.jsx("input",{"aria-label":r("theme.shadcnCustom.colorInput","Pick {{label}} color",{label:o.label}),className:"shadcn-color-picker-native",type:"color",value:je(g),onChange:k=>h(o.cssVar,k.currentTarget.value)}),e.jsx("input",{id:y,"aria-label":r("theme.shadcnCustom.hexInput","{{label}} hex color",{label:o.label}),className:"input shadcn-color-picker-hex",type:"text",inputMode:"text",spellCheck:!1,value:g,onChange:k=>h(o.cssVar,k.currentTarget.value)})]})]},o.cssVar)})})]}):null]})}function Se(s){return V.find(d=>d.value===s)??V[0]}function Z(s){return s.trim().normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase()}function O({className:s}){return e.jsxs("span",{className:`theme-option-swatch ${s}`,"aria-hidden":"true",children:[e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-1"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-2"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-3"}),e.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-4"})]})}function Le({colorTheme:s,onColorThemeChange:d,themeMode:l,shadcnCustomColors:r={},resolvedThemeMode:u=l==="light"?"light":"dark",onThemeModeChange:j,onShadcnCustomColorsChange:t=()=>{},triggerVariant:w="compact"}){const{t:h}=_("app"),[m,i]=n.useState(!1),[o,v]=n.useState(""),[g,y]=n.useState(s),[k,S]=n.useState(null),I=n.useRef(null),D=n.useRef(null),E=n.useRef(!1),N=n.useRef([]),M=n.useMemo(()=>Se(s),[s]),z=l==="system"?u:l,$=J.find(a=>a.value===z)?.icon,c=l==="system"?h("theme.system","System"):h(`theme.${l}`,l?`${l.charAt(0).toUpperCase()}${l.slice(1)}`:"Dark"),b=h(`theme.colorTheme.${M.value}`,M.label),R=`${h("theme.currentTheme","Current theme")} ${c} / ${b}`,H="theme-dropdown-listbox",B=n.useMemo(()=>V.map(a=>({...a,displayLabel:h(`theme.colorTheme.${a.value}`,a.label)})),[h]),U=Z(o),p=n.useMemo(()=>B.filter(a=>Z(a.displayLabel).includes(U)),[U,B]),W=p.findIndex(a=>a.value===g),L=()=>{i(!1),v(""),y(s),S(null),E.current=!1,N.current=[]};n.useEffect(()=>{if(!m)return;const a=f=>{I.current&&!I.current.contains(f.target)&&L()};return document.addEventListener("pointerdown",a),()=>document.removeEventListener("pointerdown",a)},[m,s]),n.useEffect(()=>{m&&(p.some(a=>a.value===g)||y(p[0]?.value??null))},[g,p,m]),n.useEffect(()=>{if(m){if(k==="pointer"&&E.current)D.current?.focus(),E.current=!1;else if(k==="keyboard"){const a=p.findIndex(f=>f.value===g);N.current[a]?.focus()}}},[g,p,m,k]);const q=a=>{d(a),L()},K=(a,f)=>{if(a==="pointer")E.current=!0,y(s);else{const F=p.some(C=>C.value===s),x=f==="ArrowUp"?p.at(-1)?.value??null:f==="ArrowDown"?p[0]?.value??null:F?s:p[0]?.value??null;y(x)}S(a),i(!0)},ee=a=>{(a.key==="ArrowDown"||a.key==="ArrowUp"||a.key==="Enter"||a.key===" ")&&(a.preventDefault(),K("keyboard",a.key))},ae=a=>{if(a.key==="Escape"){a.preventDefault(),L();return}if(a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const f=a.key==="ArrowUp"?p.length-1:Math.max(0,W);f<0||!p[f]||(a.preventDefault(),y(p[f].value),N.current[f]?.focus())},te=(a,f,F)=>{if(a.key==="Escape"){a.preventDefault(),L();return}if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault();const x=a.key==="ArrowDown"?1:-1,C=(f+x+p.length)%p.length;y(p[C]?.value??null),N.current[C]?.focus();return}if(a.key==="Home"){a.preventDefault(),y(p[0]?.value??null),N.current[0]?.focus();return}if(a.key==="End"){a.preventDefault();const x=p.length-1;y(p[x]?.value??null),N.current[x]?.focus();return}(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),q(F))};return e.jsxs("div",{className:`theme-dropdown${w==="current-row"?" theme-dropdown--current-row":""}${m?" open":""}`,ref:I,children:[e.jsxs("button",{type:"button",className:`theme-dropdown-trigger btn${w==="current-row"?" theme-dropdown-trigger--current-row":""}`,"aria-label":w==="current-row"?R:void 0,"aria-haspopup":"listbox","aria-expanded":m,"aria-controls":m?H:void 0,onClick:()=>m?L():K("pointer"),onKeyDown:ee,children:[w==="current-row"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"theme-dropdown-current-row-icon","aria-hidden":"true",children:$?e.jsx($,{size:20}):null}),e.jsxs("span",{className:"theme-dropdown-current-row-info",children:[e.jsx("span",{className:"theme-dropdown-current-row-label",children:h("theme.currentTheme","Current theme")}),e.jsxs("span",{className:"theme-dropdown-current-row-value",children:[c," / ",b]})]}),e.jsx(O,{className:M.className})]}):e.jsxs(e.Fragment,{children:[e.jsx(O,{className:M.className}),e.jsx("span",{className:"theme-dropdown-trigger-label",children:b})]}),e.jsx(X,{size:16,"aria-hidden":"true"})]}),l&&j?e.jsx("div",{className:"theme-dropdown-modes",role:"radiogroup","aria-label":h("theme.modeLabel","Theme mode"),children:J.map(({value:a,label:f,icon:F})=>e.jsxs("button",{type:"button",className:`theme-dropdown-mode-btn btn btn-sm${l===a?" active":""}`,"aria-pressed":l===a,onClick:()=>j(a),title:h(`theme.${a}Mode`,`${f} mode`),children:[e.jsx(F,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:h(`theme.${a}`,f)})]},a))}):null,s==="shadcn-custom"?e.jsx(Ce,{value:r,onChange:t,resolvedThemeMode:u}):null,m?e.jsxs("div",{className:"theme-dropdown-popover",role:"presentation",children:[e.jsxs("label",{className:"theme-dropdown-filter",children:[e.jsx("span",{className:"sr-only",children:h("theme.filterColorThemes","Filter color themes")}),e.jsx("input",{ref:D,type:"search",className:"input",value:o,placeholder:h("theme.filterColorThemesPlaceholder","Filter color themes"),"aria-label":h("theme.filterColorThemes","Filter color themes"),onChange:a=>v(a.target.value),onKeyDown:ae})]}),p.length?e.jsx("div",{id:H,className:"theme-dropdown-list",role:"listbox","aria-label":h("theme.colorThemeLabel","Color theme"),children:p.map(({value:a,displayLabel:f,className:F},x)=>{const C=s===a;return e.jsxs("button",{ref:P=>{N.current[x]=P},type:"button",className:`theme-dropdown-option${C?" active":""}`,role:"option","aria-selected":C,tabIndex:x===W?0:-1,onClick:()=>q(a),onKeyDown:P=>te(P,x,a),children:[e.jsx(O,{className:F}),e.jsx("span",{className:"theme-dropdown-option-label",children:f}),C?e.jsx(ce,{size:16,"aria-hidden":"true"}):null]},a)})}):e.jsx("p",{className:"theme-dropdown-no-results",children:h("theme.noColorThemes","No color themes found")})]}):null]})}const De=[{type:"bug",label:"Report bug",Icon:me},{type:"feedback",label:"Send feedback",Icon:ie},{type:"idea",label:"Share idea",Icon:he},{type:"help",label:"Get help",Icon:be}];function Te({onSelect:s}){const{t:d}=_("app"),[l,r]=n.useState(!1),[u,j]=n.useState(),t=n.useRef(null),w=n.useRef(null),h=n.useCallback(()=>{const i=t.current?.getBoundingClientRect();i&&j({top:i.bottom,left:i.left,right:window.innerWidth-i.right})},[]);n.useEffect(()=>{if(!l)return;h();const i=()=>h();return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[l,h]),n.useEffect(()=>{if(!l)return;const i=v=>{const g=v.target;t.current?.contains(g)||w.current?.contains(g)||r(!1)},o=v=>{v.key==="Escape"&&(r(!1),t.current?.focus())};return document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[l]);const m=l&&u&&typeof document<"u"?se.createPortal(e.jsx("div",{ref:w,className:"report-action-menu__list report-action-menu__list--portal",role:"menu",style:{top:u.top,left:u.left,right:u.right},children:De.map(({type:i,label:o,Icon:v})=>e.jsxs("button",{className:"report-action-menu__item",type:"button",role:"menuitem",onClick:()=>{r(!1),s(i)},children:[e.jsx(v,{"aria-hidden":"true"}),d(`report.actions.${i}`,o)]},i))}),document.body):null;return e.jsxs("div",{className:"report-action-menu",children:[e.jsx("button",{ref:t,className:"btn btn-secondary",type:"button","aria-haspopup":"menu","aria-expanded":l,onClick:()=>r(i=>!i),children:d("report.menu","Report")}),m]})}const Ee={bug:"What went wrong?",feedback:"What would you like to share?",idea:"What would you like Fusion to do?",help:"What would you like help with?"};function _e({actionType:s,onClose:d,contextRefs:l}){const{t:r}=_("app"),[u,j]=n.useState(""),[t,w]=n.useState(),[h,m]=n.useState(!1),[i,o]=n.useState(),[v,g]=n.useState(!1),[y,k]=n.useState(),[S,I]=n.useState(),[D,E]=n.useState(!1),N=n.useRef(0),M=async c=>{m(!0),o(void 0);try{const b=await de();if(!b)throw new Error("Screen capture was unavailable or denied.");const{artifactId:R}=await ke(b);if(N.current!==c)return;I(R)}catch(b){if(N.current!==c)return;g(!1),o(b instanceof Error?b.message:"We could not capture the current screen.")}finally{N.current===c&&m(!1)}},z=async()=>{if(u.trim()){if(v&&(!S||!D)){o("Capture and confirm local screenshot retention before continuing, or turn attachment off.");return}m(!0),o(void 0);try{if(Y("report"),s==="help"){const c=await xe(u);if(c.answered){w({kind:"help",answer:c.answer});return}}w(await ge({actionType:s,targetType:y,userPrompt:u,contextRefs:l,activityTrace:A(),screenshotArtifactId:v&&D?S:void 0}))}catch{o("We could not prepare your report. Check your connection and try again.")}finally{m(!1)}}},$=async(c,b,R)=>{if(t?.report){m(!0),o(void 0);try{Y("report"),w(await Ne({actionType:s,targetType:y,report:t.report,endorseIssueNumber:c,endorseDiscussionId:b,endorseRoadmapIssueNumber:R,activityTrace:A(),screenshotArtifactId:v&&D?S:void 0}))}catch{o("We could not send your report. Your draft is still here; try again.")}finally{m(!1)}}};return e.jsx("div",{className:"report-modal-backdrop",role:"presentation",children:e.jsxs("section",{className:"card report-modal",role:"dialog","aria-modal":"true","aria-label":`${s} report`,children:[e.jsx("button",{className:"btn-icon report-modal__close",type:"button","aria-label":r("report.close","Close report"),onClick:d,children:"×"}),i&&e.jsx("p",{className:"report-modal__error",role:"alert",children:i}),!t&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s[0].toUpperCase()+s.slice(1)}),e.jsx("label",{htmlFor:"report-prompt",children:Ee[s]}),e.jsx("textarea",{id:"report-prompt",className:"input",value:u,onChange:c=>j(c.target.value),maxLength:4e3}),e.jsxs("label",{className:"report-modal__screenshot-option",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:c=>{const b=c.target.checked,R=++N.current;g(b),I(void 0),E(!1),b?M(R):m(!1)}})," ",r("report.storeScreenshot","Store a screenshot locally")]}),v&&e.jsx("div",{className:"report-modal__screenshot-preview",children:S?e.jsxs("label",{className:"report-modal__screenshot-option",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:c=>E(c.target.checked)})," ",r("report.confirmScreenshotRetention","I confirm Fusion may retain this screenshot locally for this report.")]}):e.jsx("p",{children:r("report.capturingScreenshot","Capturing and storing locally…")})}),e.jsx("label",{htmlFor:"report-target",children:r("report.targetLabel","Filing target")}),e.jsxs("select",{id:"report-target",className:"input",value:y??"",onChange:c=>k(c.target.value||void 0),children:[e.jsx("option",{value:"",children:r("report.targetInherit","Use configured action target")}),e.jsx("option",{value:"issue",children:r("report.targetIssue","GitHub Issue")}),e.jsx("option",{value:"discussion",children:r("report.targetDiscussion","GitHub Discussion")})]}),e.jsxs("details",{className:"report-modal__activity-trace",children:[e.jsx("summary",{children:r("report.activityTrace","Activity trace to send")}),e.jsx("ul",{children:A().map((c,b)=>e.jsx("li",{children:c},`${c}-${b}`))})]}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:!u.trim()||h,onClick:()=>void z(),children:i?"Retry":"Continue"})]}),t?.kind==="draft-ready"&&t.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:r("report.review","Review your report")}),e.jsx("label",{htmlFor:"report-review-prompt",children:r("report.summary","Report summary")}),e.jsx("textarea",{id:"report-review-prompt",className:"input",value:t.report.userPrompt,onChange:c=>{const b=c.target.value;w({...t,report:{...t.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-review-body",children:r("report.structured","Structured report")}),e.jsx("textarea",{id:"report-review-body",className:"input",value:t.report.body??"",onChange:c=>w({...t,report:{...t.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:h,onClick:()=>void $(),children:r("report.file","File report")})]}),t?.kind==="duplicate-found"&&t.issue&&t.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t.issue.roadmap?r("report.roadmapDuplicate.title","Already on the roadmap — add your data point?"):r("report.duplicateReview","Review data point for a similar open issue")}),e.jsx("a",{href:t.issue.url,target:"_blank",rel:"noreferrer",children:t.issue.title}),e.jsx("label",{htmlFor:"report-duplicate-prompt",children:r("report.summary","Report summary")}),e.jsx("textarea",{id:"report-duplicate-prompt",className:"input",value:t.report.userPrompt,onChange:c=>{const b=c.target.value;w({...t,report:{...t.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-duplicate-body",children:r("report.structuredDataPoint","Structured data point")}),e.jsx("textarea",{id:"report-duplicate-body",className:"input",value:t.report.body??"",onChange:c=>w({...t,report:{...t.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:h,onClick:()=>void $(t.issue.discussionId||t.issue.roadmap?void 0:t.issue.number,t.issue.discussionId,t.issue.roadmap?t.issue.number:void 0),children:r("report.confirmDataPoint","Confirm and add data point")})]}),(t?.kind==="filed"||t?.kind==="endorsed")&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t.kind==="filed"&&t.destination==="issue"?"Report filed as an Issue":"Report sent"}),e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",children:r("report.viewGitHub","View on GitHub")}),t.report?.body&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"filed-report",children:r("report.final","Final report")}),e.jsx("textarea",{id:"filed-report",className:"input",value:t.report.body,readOnly:!0})]})]}),t?.kind==="help"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:r("report.suggestedHelp","Suggested help")}),e.jsx("p",{children:t.answer?.summary??t.answer?.content})]}),t?.kind==="unavailable"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",children:t.message}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>{w(void 0),o(void 0)},children:r("report.returnToPrompt","Return to prompt")})]})]})})}export{me as B,Te as R,J as T,Le as a,_e as b,Me as l,$e as r};