@runfusion/fusion 0.76.0-beta.3 → 0.77.0-beta.0

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 (175) hide show
  1. package/dist/bin.js +13802 -9587
  2. package/dist/child-process-worker.js +6472 -4028
  3. package/dist/client/.vite/manifest.json +280 -269
  4. package/dist/client/assets/AgentDetailView-0G9qFd4j.js +13 -0
  5. package/dist/client/assets/{AgentDetailView-Cc3ATg8a.css → AgentDetailView-jzgy1BAS.css} +1 -1
  6. package/dist/client/assets/{AgentPermissionPolicyEditor--u9jyUf2.js → AgentPermissionPolicyEditor-BM68g7wo.js} +1 -1
  7. package/dist/client/assets/AgentsView-DkOUZWw4.js +24 -0
  8. package/dist/client/assets/ChatView-BPSm2JIH.js +13 -0
  9. package/dist/client/assets/{CommandCenter-CSRYoveB.js → CommandCenter-DxRSFWNc.js} +26 -26
  10. package/dist/client/assets/CommandCenter-ilm-DbtI.css +1 -0
  11. package/dist/client/assets/{DevServerView-B9So_oYx.js → DevServerView-DO-bqJFE.js} +1 -1
  12. package/dist/client/assets/{DirectoryPicker-BhyDL_2m.js → DirectoryPicker-Cp2gddTE.js} +1 -1
  13. package/dist/client/assets/DocumentsView-D0E-3G96.js +1 -0
  14. package/dist/client/assets/EvalsView-BoFVq5hw.js +1 -0
  15. package/dist/client/assets/ExperimentalAgentOnboardingModal-CS1Sdogm.js +1 -0
  16. package/dist/client/assets/{GoalsView-B6X5_0Ve.js → GoalsView-sybf7JY4.js} +1 -1
  17. package/dist/client/assets/InsightsView-nHa7aShn.js +11 -0
  18. package/dist/client/assets/{MemoryView-DN_3IFmA.css → MemoryView-CdpQqPJJ.css} +1 -1
  19. package/dist/client/assets/MemoryView-D0IG44za.js +3 -0
  20. package/dist/client/assets/{PiExtensionsManager-B8At6fO8.js → PiExtensionsManager-CU76weJe.js} +2 -2
  21. package/dist/client/assets/PluginManager-DyT8XbcG.js +1 -0
  22. package/dist/client/assets/{PullRequestView-B1hZFrWo.js → PullRequestView-CnxWUSen.js} +2 -2
  23. package/dist/client/assets/{ReportModal-C46V_zEa.js → ReportModal-CMrmMQjD.js} +5 -5
  24. package/dist/client/assets/{ResearchView-D8G85BYN.js → ResearchView-BTytQSgy.js} +2 -2
  25. package/dist/client/assets/{SecretsView-CTri9LRK.js → SecretsView-BuSH5J87.js} +1 -1
  26. package/dist/client/assets/SessionTerminal-D04kYRrT.js +2 -0
  27. package/dist/client/assets/SettingsModal-C0FY8MPW.css +1 -0
  28. package/dist/client/assets/{SettingsModal-rUQcSTJp.js → SettingsModal-Dm-ngbRr.js} +1 -1
  29. package/dist/client/assets/{SettingsModal-DmfMotcd.css → SettingsModal-Ds0Yj47X.css} +1 -1
  30. package/dist/client/assets/SettingsModal-xSLhH7Tr.js +21 -0
  31. package/dist/client/assets/{SettingsTextareaRow-BirlBcem.js → SettingsTextareaRow-CHPgocEp.js} +1 -1
  32. package/dist/client/assets/{SetupWizardModal-xnCBM9EL.js → SetupWizardModal-y88aXNIQ.js} +2 -2
  33. package/dist/client/assets/{SkillsView-O5U0ep50.js → SkillsView-CYyQW1Hv.js} +1 -1
  34. package/dist/client/assets/{WorkflowNodeEditor-BX4d2qqF.js → WorkflowNodeEditor-hYeoz1X8.js} +3 -3
  35. package/dist/client/assets/{agent-import-generation-DnqVkPkz.js → agent-import-generation-CjiYXzCr.js} +1 -1
  36. package/dist/client/assets/agentsOrgChartLayout-C0UP_X3z.js +1 -0
  37. package/dist/client/assets/app-BgpuMvTU.js +13 -0
  38. package/dist/client/assets/app-BlexHhbW.js +13 -0
  39. package/dist/client/assets/app-BsuUOR0P.js +13 -0
  40. package/dist/client/assets/app-DQVOujmO.js +13 -0
  41. package/dist/client/assets/app-DjyTRx1N.js +5 -0
  42. package/dist/client/assets/app-Dniggype.js +13 -0
  43. package/dist/client/assets/app-EV-lyZ0T.js +5 -0
  44. package/dist/client/assets/{architectureDiagram-3BPJPVTR-gi467xY0.js → architectureDiagram-3BPJPVTR-Dd6GPcqM.js} +1 -1
  45. package/dist/client/assets/{blockDiagram-GPEHLZMM-B_gpcYiR.js → blockDiagram-GPEHLZMM-CC6pLxlz.js} +1 -1
  46. package/dist/client/assets/{c4Diagram-AAUBKEIU-DeylEYsQ.js → c4Diagram-AAUBKEIU-DxMP_l6y.js} +1 -1
  47. package/dist/client/assets/channel-DlCEMoEf.js +1 -0
  48. package/dist/client/assets/{chunk-2J33WTMH-BL2WY0HN.js → chunk-2J33WTMH-BKYToL43.js} +1 -1
  49. package/dist/client/assets/{chunk-4BX2VUAB-BkLExGMe.js → chunk-4BX2VUAB-Bg6rjQb3.js} +1 -1
  50. package/dist/client/assets/{chunk-55IACEB6-CSTvCF5T.js → chunk-55IACEB6-CPUwbbGa.js} +1 -1
  51. package/dist/client/assets/{chunk-727SXJPM-9J8pKk4x.js → chunk-727SXJPM-DScQBCvv.js} +1 -1
  52. package/dist/client/assets/{chunk-AQP2D5EJ-DXC1vPWr.js → chunk-AQP2D5EJ-DbX7uaXK.js} +1 -1
  53. package/dist/client/assets/{chunk-FMBD7UC4-CFRUb-zD.js → chunk-FMBD7UC4-DvYKea1c.js} +1 -1
  54. package/dist/client/assets/{chunk-ND2GUHAM-B87HFYS8.js → chunk-ND2GUHAM-CH-Tvw7w.js} +1 -1
  55. package/dist/client/assets/{chunk-QZHKN3VN-CTjHiGbd.js → chunk-QZHKN3VN-CbyEvOoM.js} +1 -1
  56. package/dist/client/assets/classDiagram-4FO5ZUOK-Bc92O8Ks.js +1 -0
  57. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-Bc92O8Ks.js +1 -0
  58. package/dist/client/assets/{cose-bilkent-S5V4N54A-D3Edq3L9.js → cose-bilkent-S5V4N54A-BPB5fV3A.js} +1 -1
  59. package/dist/client/assets/{dagre-BM42HDAG-CwwbeQfN.js → dagre-BM42HDAG-CilYJ3rR.js} +1 -1
  60. package/dist/client/assets/{dashboard-view-QxQwJFLz.js → dashboard-view-BnGe8cWo.js} +1 -1
  61. package/dist/client/assets/{dashboard-view-BLAoW3D4.js → dashboard-view-DnVf3tmI.js} +1 -1
  62. package/dist/client/assets/{dashboard-view-DAlJxqiJ.js → dashboard-view-DoLU6FxZ.js} +1 -1
  63. package/dist/client/assets/{dashboard-view-aPzfv99T.js → dashboard-view-dChSM_So.js} +1 -1
  64. package/dist/client/assets/{diagram-2AECGRRQ-koJWWXE4.js → diagram-2AECGRRQ-m9u1Qhyx.js} +1 -1
  65. package/dist/client/assets/{diagram-5GNKFQAL-Yob5cOKT.js → diagram-5GNKFQAL-DVr7Kf0N.js} +1 -1
  66. package/dist/client/assets/{diagram-KO2AKTUF-DelvFSkK.js → diagram-KO2AKTUF-D7sgJDFx.js} +1 -1
  67. package/dist/client/assets/{diagram-LMA3HP47-CMput2h2.js → diagram-LMA3HP47-DNKNDS6r.js} +1 -1
  68. package/dist/client/assets/{diagram-OG6HWLK6-04VXDl79.js → diagram-OG6HWLK6-1Bff4FWn.js} +1 -1
  69. package/dist/client/assets/{erDiagram-TEJ5UH35-C9iP8Uyp.js → erDiagram-TEJ5UH35-DGua1UHN.js} +1 -1
  70. package/dist/client/assets/{flowDiagram-I6XJVG4X-DENQvu_t.js → flowDiagram-I6XJVG4X-UDfDtwsE.js} +1 -1
  71. package/dist/client/assets/{folder-open-D-554oji.js → folder-open-CteOypVk.js} +1 -1
  72. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BqOttZAT.js → ganttDiagram-6RSMTGT7-COdmD328.js} +1 -1
  73. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CDcydi-5.js → gitGraphDiagram-PVQCEYII-SUSls7Kw.js} +1 -1
  74. package/dist/client/assets/index-0ovTXt3t.css +1 -0
  75. package/dist/client/assets/index-DpCHwyiD.js +2818 -0
  76. package/dist/client/assets/{infoDiagram-5YYISTIA-B5LQQnxt.js → infoDiagram-5YYISTIA-e_DloXj7.js} +1 -1
  77. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-DpFEt7D2.js → ishikawaDiagram-YF4QCWOH-DVWqihXg.js} +1 -1
  78. package/dist/client/assets/{journeyDiagram-JHISSGLW-MELtgu22.js → journeyDiagram-JHISSGLW-BcPY-XP0.js} +1 -1
  79. package/dist/client/assets/{kanban-definition-UN3LZRKU-h33PLATd.js → kanban-definition-UN3LZRKU-BCFG2Jle.js} +1 -1
  80. package/dist/client/assets/{mermaid.core-Dk2mUPOq.js → mermaid.core-5yPje9Bi.js} +4 -4
  81. package/dist/client/assets/{mindmap-definition-RKZ34NQL-B_T4O2-B.js → mindmap-definition-RKZ34NQL-DDApeT3K.js} +1 -1
  82. package/dist/client/assets/{pieDiagram-4H26LBE5-B1YIFkRl.js → pieDiagram-4H26LBE5-N61_jyeP.js} +1 -1
  83. package/dist/client/assets/{puzzle-hvecxlpJ.js → puzzle-BkaCP30D.js} +1 -1
  84. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-BoGQR_hO.js → quadrantDiagram-W4KKPZXB-C5qHiApF.js} +1 -1
  85. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BSDmUBIx.js → requirementDiagram-4Y6WPE33-C71okgzt.js} +1 -1
  86. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-Dz_GqOa5.js → sankeyDiagram-5OEKKPKP-B2iKyLjB.js} +1 -1
  87. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-B6twjYUH.js → sequenceDiagram-3UESZ5HK-DfdoYKKk.js} +1 -1
  88. package/dist/client/assets/{shield-alert-BX4WRJOv.js → shield-alert-BNSeDB8l.js} +1 -1
  89. package/dist/client/assets/standing-instructions-template-pZtzo1lK.js +20 -0
  90. package/dist/client/assets/standing-instructions-template-w7Ouw_37.css +1 -0
  91. package/dist/client/assets/{stateDiagram-AJRCARHV-DuwqWLx-.js → stateDiagram-AJRCARHV-lS-sUi12.js} +1 -1
  92. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-Bu8Sk187.js → stateDiagram-v2-BHNVJYJU-DXJNDrV9.js} +1 -1
  93. package/dist/client/assets/{timeline-definition-PNZ67QCA-BS6VnqSI.js → timeline-definition-PNZ67QCA-CCwvX81K.js} +1 -1
  94. package/dist/client/assets/{upload-CaDoyaMW.js → upload-CDovVbu2.js} +1 -1
  95. package/dist/client/assets/useDiscoveredSkillsCache-BYqP-afh.js +1 -0
  96. package/dist/client/assets/{users-C5uCLwVM.js → users-CTqECGLo.js} +1 -1
  97. package/dist/client/assets/{vennDiagram-CIIHVFJN-CUbzqT5Y.js → vennDiagram-CIIHVFJN-DaiR5nv9.js} +1 -1
  98. package/dist/client/assets/{wardley-L42UT6IY-Mv-NotFS.js → wardley-L42UT6IY-hA5IHyPW.js} +1 -1
  99. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-DuYpvLZX.js → wardleyDiagram-YWT4CUSO-CILUNESc.js} +1 -1
  100. package/dist/client/assets/{xychartDiagram-2RQKCTM6-24_7QXdw.js → xychartDiagram-2RQKCTM6-72eNMmjz.js} +1 -1
  101. package/dist/client/index.html +2 -2
  102. package/dist/client/version.json +1 -1
  103. package/dist/droid-cli/package.json +1 -1
  104. package/dist/extension.js +10671 -6904
  105. package/dist/migrations/0059_fn_9037_tasks_source_agent_index.sql +3 -0
  106. package/dist/migrations/0060_fn_9059_workspace_coordination_leases.sql +10 -0
  107. package/dist/pi-claude-cli/package.json +1 -1
  108. package/dist/plugin-sdk/index.d.ts +190 -9
  109. package/dist/plugin-sdk/index.js +74 -28
  110. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +83 -29
  111. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  112. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +83 -29
  113. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  114. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +74 -28
  115. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  116. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +74 -28
  117. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  118. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +1096 -73
  119. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  120. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +74 -28
  121. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  122. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +74 -28
  123. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  124. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +83 -29
  125. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  126. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +302 -71
  127. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  128. package/dist/plugins/fusion-plugin-linear-import/bundled.js +74 -28
  129. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  130. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +83 -29
  131. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  132. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +74 -28
  133. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  134. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +74 -28
  135. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  136. package/dist/plugins/fusion-plugin-quality/bundled.js +176 -46
  137. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  138. package/dist/plugins/fusion-plugin-reports/bundled.js +74 -28
  139. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  140. package/dist/plugins/fusion-plugin-roadmap/bundled.js +74 -28
  141. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  142. package/dist/plugins/fusion-plugin-todos/bundled.js +74 -28
  143. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  144. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +74 -28
  145. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  146. package/package.json +1 -1
  147. package/skill/fusion/references/extension-tools.md +2 -0
  148. package/dist/client/assets/AgentDetailView-T767kKTg.js +0 -13
  149. package/dist/client/assets/AgentsView-6Ifu7qDr.js +0 -24
  150. package/dist/client/assets/ChatView-BV3lixQi.js +0 -13
  151. package/dist/client/assets/CommandCenter-CE4rYjHn.css +0 -1
  152. package/dist/client/assets/DocumentsView-pbERA7O-.js +0 -1
  153. package/dist/client/assets/EvalsView-DJQ4ltCg.js +0 -1
  154. package/dist/client/assets/ExperimentalAgentOnboardingModal-BwJuzkzB.js +0 -1
  155. package/dist/client/assets/InsightsView-CJgI0J7S.js +0 -11
  156. package/dist/client/assets/MemoryView-BHq1AHPu.js +0 -3
  157. package/dist/client/assets/PluginManager-k7hV7_9e.js +0 -1
  158. package/dist/client/assets/SessionTerminal-BRf6r4Vp.js +0 -2
  159. package/dist/client/assets/SettingsModal-B30rPfYC.css +0 -1
  160. package/dist/client/assets/SettingsModal-D0RBeZik.js +0 -21
  161. package/dist/client/assets/agentsOrgChartLayout-CKuzbhFf.js +0 -1
  162. package/dist/client/assets/app-B2FwULu2.js +0 -5
  163. package/dist/client/assets/app-B6nJaqAl.js +0 -13
  164. package/dist/client/assets/app-CGXZeIRc.js +0 -13
  165. package/dist/client/assets/app-CGtkeBF5.js +0 -13
  166. package/dist/client/assets/app-CNzN1Plu.js +0 -13
  167. package/dist/client/assets/app-DLs-f5yM.js +0 -13
  168. package/dist/client/assets/app-DsvtcRUG.js +0 -5
  169. package/dist/client/assets/channel-BoE8DeM4.js +0 -1
  170. package/dist/client/assets/classDiagram-4FO5ZUOK-qnbLX_9_.js +0 -1
  171. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-qnbLX_9_.js +0 -1
  172. package/dist/client/assets/index-CXTd3LAB.css +0 -1
  173. package/dist/client/assets/index-CtYRoouR.js +0 -2818
  174. package/dist/client/assets/standing-instructions-template-BJY317CC.js +0 -20
  175. package/dist/client/assets/standing-instructions-template-Ddi_4TIk.css +0 -1
@@ -0,0 +1 @@
1
+ import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{ag as _e,be as ze,bf as He,bg as ge,bh as Ve,X as me,aS as Qe,bi as Ke,aK as he,P as be,b1 as ye,F as xe,R as fe,aN as Je,a3 as Ye,bj as Xe,bk as Ze,bl as es,bm as ss,bn as ns,bo as is,bp as ts,bq as Q,br as as,bs as ls}from"./index-DpCHwyiD.js";import{D as rs}from"./DirectoryPicker-Cp2gddTE.js";import{u as os}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";import"./folder-open-CteOypVk.js";const us="/api/plugins/fusion-plugin-whatsapp-chat",cs=/^\d+$/;function K(l,c){const g=c?`?projectId=${encodeURIComponent(c)}`:"";return`${us}${l}${g}`}function ds({projectId:l,settings:c}){const[g,n]=d.useState(null),[x,f]=d.useState(null),[A,q]=d.useState(()=>String(c?.pairingPhoneNumber??"")),[G,w]=d.useState(null),[C,R]=d.useState(null),P=d.useCallback(async()=>{try{const m=await fetch(K("/status",l)),o=await m.json();if(!m.ok)throw new Error(o.error??"WhatsApp pairing is unavailable. Enable the plugin and try again.");n(o),f(null)}catch(m){f(m instanceof Error?m.message:String(m))}},[l]);d.useEffect(()=>{P();const m=window.setInterval(()=>void P(),5e3);return()=>window.clearInterval(m)},[P]);const O=async()=>{const m=A.trim();if(!m||!cs.test(m)){w("Enter an E.164 phone number using digits only, without +.");return}R("code"),w(null);try{const o=await fetch(K("/pair-code",l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:m,...l?{projectId:l}:{}})}),B=await o.json();if(!o.ok)throw new Error(B.error??"Could not request a pairing code.");n(h=>({status:"awaiting-code",...h,pairingCode:B.pairingCode})),await P()}catch(o){w(o instanceof Error?o.message:String(o))}finally{R(null)}},U=async()=>{R("logout"),w(null);try{const m=await fetch(K("/logout",l),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l?{projectId:l}:{})});if(!m.ok){const o=await m.json();throw new Error(o.error??"Could not log out from WhatsApp.")}await P()}catch(m){w(m instanceof Error?m.message:String(m))}finally{R(null)}},$=c?.pairingMode==="code"?"code":"qr",N=g?.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:"WhatsApp pairing"}),e.jsx("p",{className:"whatsapp-pairing-description",children:"Pair and monitor this project's WhatsApp connection here."})]}),e.jsx("button",{className:"btn btn-secondary btn-sm",type:"button",onClick:()=>void P(),children:"Refresh status"})]}),e.jsxs("div",{className:`whatsapp-pairing-status whatsapp-pairing-status--${N}`,role:"status","data-testid":"whatsapp-pairing-status",children:[e.jsxs("strong",{children:["Status: ",N]}),g?.jid&&e.jsxs("span",{children:["Connected as ",g.jid]}),(g?.lastError||x)&&e.jsx("span",{className:"field-error",children:g?.lastError??x})]}),N==="awaiting-qr"&&e.jsx("div",{className:"whatsapp-pairing-qr","data-testid":"whatsapp-pairing-qr",children:g?.qrDataUrl?e.jsx("img",{src:g.qrDataUrl,alt:"WhatsApp pairing QR code",className:"whatsapp-pairing-qr-image"}):e.jsx("p",{className:"text-muted",children:"Waiting for a fresh QR code. Keep this panel open and refresh if needed."})}),($==="code"||N==="awaiting-code")&&e.jsxs("div",{className:"whatsapp-pairing-code",children:[e.jsx("label",{htmlFor:"whatsapp-pairing-phone",children:"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:A,onChange:m=>q(m.target.value),inputMode:"numeric"}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>void O(),disabled:C!==null,children:C==="code"?"Requesting code...":"Request pairing code"})]}),g?.pairingCode&&e.jsx("output",{className:"whatsapp-pairing-code-output",children:g.pairingCode})]}),N==="connected"&&e.jsx("p",{className:"whatsapp-pairing-success",children:"WhatsApp is paired and ready to receive messages from allowed senders."}),G&&e.jsx("p",{className:"field-error",children:G}),e.jsx("button",{className:"btn btn-danger",type:"button",onClick:()=>void U(),disabled:C!==null,"data-testid":"whatsapp-pairing-logout",children:C==="logout"?"Logging out...":"Logout and re-pair"}),e.jsxs("aside",{className:"whatsapp-pairing-instructions","aria-label":"WhatsApp pairing instructions","data-testid":"whatsapp-pairing-instructions",children:[e.jsx("h6",{children:"Pairing and configuration"}),e.jsxs("ol",{children:[e.jsx("li",{children:"Install and enable this plugin, then keep this settings panel open."}),e.jsxs("li",{children:["Set ",e.jsx("strong",{children:"Allowed WhatsApp Senders"}),"; an empty list blocks all inbound messages."]}),e.jsxs("li",{children:["Choose ",e.jsx("strong",{children:"QR"})," to scan in WhatsApp Linked Devices, or ",e.jsx("strong",{children:"code"})," to enter a phone number and request a pairing code."]}),e.jsxs("li",{children:["Wait for the status above to become ",e.jsx("strong",{children:"connected"}),"."]}),e.jsx("li",{children:"Use Logout and re-pair to start over. If QR is still pending, wait briefly or refresh status for a new code."})]})]})]})}const Ce="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"},ve=[{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:Ce,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],_={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ps(l){const c=l.settingsSchema,g=c&&Object.keys(c).length>0;return l.id!==Ce?g?c:void 0:g?{...je,...c}:je}function gs(l){const c=new Map,g=[];for(const[n,x]of Object.entries(l))if(x.group){const f=c.get(x.group)??[];f.push([n,x]),c.set(x.group,f)}else g.push([n,x]);return{grouped:c,ungrouped:g}}function we(l,c="plugin-error-text"){return l.state!=="error"||!l.error?null:e.jsx("p",{className:c,title:l.error,children:l.error})}function vs({addToast:l,projectId:c,onPluginsChanged:g}){const{t:n}=os("app"),[x,f]=d.useState([]),[A,q]=d.useState(!0),[G,w]=d.useState(!1),[C,R]=d.useState(""),[P,O]=d.useState(!1),[U,$]=d.useState(!1),[N,m]=d.useState(null),[o,B]=d.useState(null),[h,S]=d.useState({}),[Pe,J]=d.useState(!1),[Y,X]=d.useState(null),[Z,Ee]=d.useState([]),[Re,ee]=d.useState(!0),[se,ne]=d.useState(null),[j,Ie]=d.useState(""),[v,ke]=d.useState(""),[Be,ie]=d.useState(null),F=d.useRef(null),[Ae,z]=d.useState({}),[Fe,te]=d.useState(null),[W,ae]=d.useState(null),{confirm:Le}=_e(),y=d.useCallback(async(s=!1,i)=>{try{s||q(!0);const a=await ze(c);f(i?a.some(r=>r.id===i.id)?a.map(r=>r.id===i.id?i:r):[...a,i]:a)}catch(a){l(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:a instanceof Error?a.message:String(a)}),"error")}finally{s||q(!1)}},[c,l]),I=d.useCallback(async(s=j,i=v)=>{try{ee(!0),ne(null);const a=await He(s,i||void 0,c);Ee(a)}catch(a){const r=a instanceof Error?a.message:String(a);ne(r)}finally{ee(!1)}},[c,v,j]);d.useEffect(()=>{y()},[y]),d.useEffect(()=>(F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{I(j,v)},300),()=>{F.current&&clearTimeout(F.current)}),[I,v,j]),d.useEffect(()=>{const s=ve.filter(a=>a.hasSetup&&x.some(r=>r.id===a.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async a=>{try{const r=await ge(a.id,c);if(i)return;z(p=>({...p,[a.id]:r}))}catch{if(i)return;z(r=>({...r,[a.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=a=>{try{const r=JSON.parse(a.data);if(r.scope==="project"&&(r.projectId??c)!==c)return;switch(r.transition){case"installing":case"enabled":case"disabled":case"settings-updated":I(j,v),f(p=>{const u=p.findIndex(t=>t.id===r.pluginId);if(u>=0){const t=[...p];return t[u]={...t[u],enabled:r.enabled,state:r.state,settings:r.settings,error:r.error},t}else return y(),p});break;case"state-changed":f(p=>{const u=p.findIndex(t=>t.id===r.pluginId);if(u>=0){const t=[...p];return t[u]={...t[u],state:r.state,error:r.error},t}return p});break;case"uninstalled":f(p=>p.filter(u=>u.id!==r.pluginId)),I(j,v);break;case"error":f(p=>{const u=p.findIndex(t=>t.id===r.pluginId);if(u>=0){const t=[...p];return t[u]={...t[u],state:r.state,error:r.error},t}return p});break}}catch{}};return Ve(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{y(),I(j,v)}})},[c,y,I,v,j]);const le=async()=>{if(!C.trim()){l(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{O(!0),await Q({path:C,...U?{aiScanOnLoad:!0}:{}},c),l(n("plugins.installedGlobally","Plugin installed globally"),"success"),w(!1),R(""),$(!1),await y(),g?.()}catch(s){l(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{O(!1)}},qe=async s=>{if(!s.path){l(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),l(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await y(),g?.()}catch(i){l(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{X(null)}},Ge=async s=>{if(!s.path){l(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),l(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await y(),g?.(),await I(j,v)}catch(i){l(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 ls(s.id,c);if(!i.success){l(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}l(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),te(s.id);const a=await ge(s.id,c);z(r=>({...r,[s.id]:a}))}catch(i){l(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 is(s.id,c);if(f(a=>a.map(r=>r.id===i.id?i:r)),i.state==="error"){l(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await y();return}l(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await y(!0,i),g?.()}catch(i){l(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async s=>{try{const i=await ns(s.id,c);f(a=>a.map(r=>r.id===i.id?i:r)),l(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await y(!0,i),g?.()}catch(i){l(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},Oe=async s=>{s.enabled?await V(s):await H(s)},oe=async s=>{try{m(s.id),await ss(s.id,c),l(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await y()}catch(i){l(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{m(null)}},ue=async s=>{if(await Le({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 ts(s.id,c),l(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await y(),g?.(),B(null)}catch(a){l(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:a instanceof Error?a.message:String(a)}),"error")}},Ue=async(s,i)=>{try{await Xe(s.id,{aiScanOnLoad:i},c),l(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await y()}catch(a){l(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:a instanceof Error?a.message:String(a)}),"error")}},$e=async s=>{try{await Ze(s.id,c),l(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await y()}catch(i){l(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},T=async s=>{B(s);try{J(!0);const i=await as(s.id,c);S(i)}catch{S({})}finally{J(!1)}},We=async()=>{if(o)try{await es(o.id,h,c),l(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){l(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(o)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:()=>B(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:o.name}),we(o,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:_[o.state]||_.installed},children:o.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[o.description&&e.jsx("p",{className:"plugin-description",children:o.description}),o.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),o.author]}),o.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:o.homepage,target:"_blank",rel:"noopener noreferrer",children:[o.homepage,e.jsx(Qe,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),o.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:!!o.aiScanOnLoad,onChange:s=>void Ue(o,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void $e(o),children:[e.jsx(Ke,{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.")}),o.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--${o.lastSecurityScan.verdict}`,children:o.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:o.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:o.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:o.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:o.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")}),o.id==="fusion-plugin-whatsapp-chat"&&e.jsx(ds,{projectId:c,settings:h}),Pe?e.jsx("p",{className:"text-muted",children:e.jsx(he,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ps(o);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:a}=gs(s),r=[];a.length>0&&r.push({title:null,entries:a});for(const[p,u]of i.entries())r.push({title:p,entries:u});return r.map(p=>e.jsxs("div",{className:p.title?"plugin-settings-group":void 0,children:[p.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:Ne[p.title]?n(Ne[p.title],p.title):p.title}),p.entries.map(([u,t])=>{const k=`setting-${u}-help`,L=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:[L,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${u}`,value:h[u]??"",onChange:b=>S({...h,[u]:b.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?k:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${u}`,rows:4,value:h[u]??"",onChange:b=>S({...h,[u]:b.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?k:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${u}`,value:h[u]??"",onChange:b=>S({...h,[u]:b.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?k:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${u}`,value:h[u]??"",onChange:b=>S({...h,[u]:Number(b.target.value)}),"aria-describedby":t.description&&!t.required?k:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:h[u]??!1,onChange:b=>S({...h,[u]:b.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${u}`,value:h[u]??"",onChange:b=>S({...h,[u]:b.target.value}),"aria-describedby":t.description&&!t.required?k:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(b=>e.jsx("option",{value:b,children:b},b))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[h[u]?.map((b,E)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:b??"",onChange:M=>{const D=M.target.value,pe=[...h[u]||[]];pe[E]=t.itemType==="number"?Number(D):D,S({...h,[u]:pe})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const D=[...h[u]||[]];D.splice(E,1),S({...h,[u]:D})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(me,{size:14})})]},E)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const b=h[u]||[],E=t.itemType==="number"?0:"";S({...h,[u]:[...b,E]})},children:[e.jsx(be,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:k,className:"form-help",children:t.description})]},u)})]},p.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:We,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:[o.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>oe(o),disabled:N===o.id,children:[e.jsx(ye,{size:14,className:N===o.id?"spin":""}),N===o.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),o.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>V(o),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>H(o),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ue(o),children:[e.jsx(xe,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const ce=new Map(x.map(s=>[s.id,s])),de=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:v,onChange:s=>ke(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:j,onChange:s=>Ie(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Re?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 I(j,v),children:n("plugins.retry","Retry")})]}):Z.length===0?e.jsx("div",{className:"plugin-registry-state",children:j.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),a=Be===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?T(i):y()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Ge(s),disabled:a,children:a?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),Me=()=>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:ve.map(s=>{const i=ce.get(s.id),a=!!i,r=Ae[s.id],p=!!(r&&"setupCheckDeferred"in r&&r.setupCheckDeferred),u=r&&"status"in r?r.status:void 0,t=a&&s.hasSetup&&r?.hasSetup&&!p&&i?.state==="started"&&(u==="not-installed"||u==="error"),k=a&&r?.hasSetup&&u==="installed",L=Fe===s.id,b=!s.path,E=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 ${a?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:a?n("plugins.statusInstalled","Installed"):b?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),E&&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")}),k&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),L&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),p&&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:[E&&i&&e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:()=>void Oe(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"})]}),b?a&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void re(s),disabled:W===s.id||L,children:W===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):a&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void T(i),children:n("plugins.manage","Manage")}):E?null:e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${a&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!a){qe(s);return}if(t){re(s);return}i&&T(i)},disabled:Y===s.id||W===s.id||L,children:a?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 y(),title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(fe,{size:14,className:A?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>w(!0),children:[e.jsx(be,{size:14})," ",n("plugins.install","Install")]})]})]}),G&&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(rs,{value:C,onChange:R,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:U,onChange:s=>$(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:P||!C.trim(),children:P?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{w(!1),R("")},children:n("plugins.cancel","Cancel")})]})]}),A?e.jsx("div",{className:"settings-empty-state",children:e.jsx(he,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[de.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(Je,{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:de.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:_[s.state]||_.installed},children:s.state})]}),we(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>oe(s),disabled:N===s.id,title:n("plugins.reload","Reload"),children:e.jsx(ye,{size:14,className:N===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:()=>T(s),title:n("plugins.settings","Settings"),children:e.jsx(Ye,{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))}),Me(),Te()]})]})}export{je as AGENT_BROWSER_SETTINGS_SCHEMA,Ce as BUILTIN_AGENT_BROWSER_PLUGIN_ID,ve as BUILTIN_PLUGINS,vs as PluginManager,_ 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,a_ as k,a$ as N,b0 as C,b1 as F,b2 as M,b3 as ae,b4 as X,aR as Z,an as K,a as E}from"./index-CtYRoouR.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,a_ as k,a$ as N,b0 as C,b1 as F,b2 as M,b3 as ae,b4 as X,aS as Z,as as K,a as E}from"./index-DpCHwyiD.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:$,loadPullRequests:q}=t,h=n!==void 0,[L,S]=a.useState(null),[i,x]=a.useState(n??null),[v,p]=a.useState(null),[T,I]=a.useState([]),[A,U]=a.useState(null),[u,_]=a.useState(null),[Q,B]=a.useState(!1),[W,j]=a.useState(!1),[Y,G]=a.useState(!1),H=a.useMemo(()=>$??ce(l),[$,l]),O=a.useMemo(()=>q??oe(l),[q,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),G(!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{G(!1)}return}try{p(null),j(!0),x(await J(H(z),"Timed out loading pull request"))}catch(r){p(r instanceof Error?r.message:"Failed to load PR")}finally{j(!1)}},[z,n,h,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{_(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{_(null),B(!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…")})]}):T.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:T.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),S(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:()=>S(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:()=>B(!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(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:S,loadPullRequests:$}=t,h=n!==void 0,[L,q]=a.useState(null),[i,x]=a.useState(n??null),[v,p]=a.useState(null),[T,I]=a.useState([]),[A,U]=a.useState(null),[u,_]=a.useState(null),[Q,B]=a.useState(!1),[W,j]=a.useState(!1),[Y,G]=a.useState(!1),H=a.useMemo(()=>S??ce(l),[S,l]),O=a.useMemo(()=>$??oe(l),[$,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),G(!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{G(!1)}return}try{p(null),j(!0),x(await J(H(z),"Timed out loading pull request"))}catch(r){p(r instanceof Error?r.message:"Failed to load PR")}finally{j(!1)}},[z,n,h,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{_(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{_(null),B(!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…")})]}):T.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:T.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(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:()=>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,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:()=>B(!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};
@@ -1,21 +1,21 @@
1
- import{r as o,j as e,b as se}from"./vendor-react-SZ_qB27O.js";import{c as _,dj as re,dm as Q,aa as le,C as X,dn as ne,dp as oe,q as ce,b3 as ie,bF as he,dq as A,dr as de,ds as Y}from"./index-CtYRoouR.js";import{u as V}from"./vendor-i18n-Duky4gdQ.js";/**
1
+ import{r as o,j as e,b as se}from"./vendor-react-SZ_qB27O.js";import{c as z,dk as re,dn as Q,af as le,C as X,dp as ne,dq as oe,z as ce,b3 as ie,bF as he,dr as A,ds as de,dt as Y}from"./index-DpCHwyiD.js";import{u as V}from"./vendor-i18n-Duky4gdQ.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 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=_("bug",ue);/**
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=z("bug",ue);/**
7
7
  * @license lucide-react v1.7.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
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=_("life-buoy",pe);/**
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=z("life-buoy",pe);/**
12
12
  * @license lucide-react v1.7.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
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"}]],fe=_("moon",we);/**
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"}]],fe=z("moon",we);/**
17
17
  * @license lucide-react v1.7.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const ve=[["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=_("sun",ve);async function G(t,i){const l=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}function ge(t){return G("/api/report/draft",t)}function Ne(t){return G("/api/report/file",t)}function xe(t){return G("/api/report/help",{question:t})}async function ke(t){const i=new FormData;i.append("screenshot",t,"report-screenshot.png");const l=await fetch("/api/report/attachment",{method:"POST",body:i});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}async function Me(){const t=await fetch("/api/report/discussion-categories");if(!t.ok)throw new Error((await t.json().catch(()=>({error:t.statusText}))).error??t.statusText);return t.json()}function $e(t){const i=new URLSearchParams(t.search),l=t.hash.match(/^#\/tasks\/([^/?#]+)/),h=l?.[1]?decodeURIComponent(l[1]):i.get("taskId")??void 0,u=i.get("agentId")??void 0;return h||u?{taskId:h,agentId:u}:void 0}const J=[{value:"light",label:"Light",icon:ye},{value:"dark",label:"Dark",icon:fe},{value:"system",label:"System",icon:re}],P=[{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:"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:"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(t){const i=t.trim();if(/^#[\da-f]{6}$/i.test(i))return i;if(/^#[\da-f]{3}$/i.test(i)){const[,l,h,u]=i;return`#${l}${l}${h}${h}${u}${u}`}return"#000000"}function Ce({value:t={},onChange:i,resolvedThemeMode:l="dark"}){const{t:h}=V("app"),[u,N]=o.useState(!1),s=o.useId(),p=o.useMemo(()=>Q(t),[t]),d=(n,f)=>{i(Q({...p,[n]:f}))},r=u?h("theme.shadcnCustom.collapse","Collapse custom colors"):h("theme.shadcnCustom.show","Show custom colors"),y=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:h("theme.shadcnCustom.title","Custom shadcn colors")}),e.jsx("p",{className:"shadcn-color-picker-description",children:h("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":s,"aria-label":r,title:r,onClick:()=>N(n=>!n),children:e.jsx(y,{size:16,"aria-hidden":"true"})})]}),u?e.jsxs("div",{id:s,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:()=>i({}),children:h("theme.shadcnCustom.reset","Reset custom colors")})}),e.jsx("div",{className:"shadcn-color-picker-grid",children:ne.map(n=>{const f=oe(n,l),x=p[n.cssVar]??f,v=`shadcn-color-${n.cssVar.replace(/^--/,"").replace(/[^a-z0-9]+/gi,"-")}`;return e.jsxs("div",{className:"shadcn-color-picker-row","data-testid":`shadcn-color-${n.cssVar}`,children:[e.jsxs("label",{className:"shadcn-color-picker-label",htmlFor:v,children:[e.jsx("span",{children:h(`theme.shadcnCustom.token.${n.cssVar}`,n.label)}),e.jsx("code",{children:n.cssVar})]}),e.jsxs("div",{className:"shadcn-color-picker-controls",children:[e.jsx("input",{"aria-label":h("theme.shadcnCustom.colorInput","Pick {{label}} color",{label:n.label}),className:"shadcn-color-picker-native",type:"color",value:je(x),onChange:j=>d(n.cssVar,j.currentTarget.value)}),e.jsx("input",{id:v,"aria-label":h("theme.shadcnCustom.hexInput","{{label}} hex color",{label:n.label}),className:"input shadcn-color-picker-hex",type:"text",inputMode:"text",spellCheck:!1,value:x,onChange:j=>d(n.cssVar,j.currentTarget.value)})]})]},n.cssVar)})})]}):null]})}function Se(t){return P.find(i=>i.value===t)??P[0]}function Z(t){return t.trim().normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase()}function O({className:t}){return e.jsxs("span",{className:`theme-option-swatch ${t}`,"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:t,onColorThemeChange:i,themeMode:l,shadcnCustomColors:h={},resolvedThemeMode:u=l==="light"?"light":"dark",onThemeModeChange:N,onShadcnCustomColorsChange:s=()=>{},triggerVariant:p="compact"}){const{t:d}=V("app"),[r,y]=o.useState(!1),[n,f]=o.useState(""),[x,v]=o.useState(t),[j,S]=o.useState(null),I=o.useRef(null),E=o.useRef(null),D=o.useRef(!1),g=o.useRef([]),M=o.useMemo(()=>Se(t),[t]),z=l==="system"?u:l,$=J.find(a=>a.value===z)?.icon,c=l==="system"?d("theme.system","System"):d(`theme.${l}`,l?`${l.charAt(0).toUpperCase()}${l.slice(1)}`:"Dark"),b=d(`theme.colorTheme.${M.value}`,M.label),R=`${d("theme.currentTheme","Current theme")} ${c} / ${b}`,B="theme-dropdown-listbox",H=o.useMemo(()=>P.map(a=>({...a,displayLabel:d(`theme.colorTheme.${a.value}`,a.label)})),[d]),U=Z(n),m=o.useMemo(()=>H.filter(a=>Z(a.displayLabel).includes(U)),[U,H]),q=m.findIndex(a=>a.value===x),L=()=>{y(!1),f(""),v(t),S(null),D.current=!1,g.current=[]};o.useEffect(()=>{if(!r)return;const a=w=>{I.current&&!I.current.contains(w.target)&&L()};return document.addEventListener("pointerdown",a),()=>document.removeEventListener("pointerdown",a)},[r,t]),o.useEffect(()=>{r&&(m.some(a=>a.value===x)||v(m[0]?.value??null))},[x,m,r]),o.useEffect(()=>{if(r){if(j==="pointer"&&D.current)E.current?.focus(),D.current=!1;else if(j==="keyboard"){const a=m.findIndex(w=>w.value===x);g.current[a]?.focus()}}},[x,m,r,j]);const W=a=>{i(a),L()},K=(a,w)=>{if(a==="pointer")D.current=!0,v(t);else{const F=m.some(C=>C.value===t),k=w==="ArrowUp"?m.at(-1)?.value??null:w==="ArrowDown"?m[0]?.value??null:F?t:m[0]?.value??null;v(k)}S(a),y(!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 w=a.key==="ArrowUp"?m.length-1:Math.max(0,q);w<0||!m[w]||(a.preventDefault(),v(m[w].value),g.current[w]?.focus())},te=(a,w,F)=>{if(a.key==="Escape"){a.preventDefault(),L();return}if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault();const k=a.key==="ArrowDown"?1:-1,C=(w+k+m.length)%m.length;v(m[C]?.value??null),g.current[C]?.focus();return}if(a.key==="Home"){a.preventDefault(),v(m[0]?.value??null),g.current[0]?.focus();return}if(a.key==="End"){a.preventDefault();const k=m.length-1;v(m[k]?.value??null),g.current[k]?.focus();return}(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),W(F))};return e.jsxs("div",{className:`theme-dropdown${p==="current-row"?" theme-dropdown--current-row":""}${r?" open":""}`,ref:I,children:[e.jsxs("button",{type:"button",className:`theme-dropdown-trigger btn${p==="current-row"?" theme-dropdown-trigger--current-row":""}`,"aria-label":p==="current-row"?R:void 0,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?B:void 0,onClick:()=>r?L():K("pointer"),onKeyDown:ee,children:[p==="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:d("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&&N?e.jsx("div",{className:"theme-dropdown-modes",role:"radiogroup","aria-label":d("theme.modeLabel","Theme mode"),children:J.map(({value:a,label:w,icon:F})=>e.jsxs("button",{type:"button",className:`theme-dropdown-mode-btn btn btn-sm${l===a?" active":""}`,"aria-pressed":l===a,onClick:()=>N(a),title:d(`theme.${a}Mode`,`${w} mode`),children:[e.jsx(F,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:d(`theme.${a}`,w)})]},a))}):null,t==="shadcn-custom"?e.jsx(Ce,{value:h,onChange:s,resolvedThemeMode:u}):null,r?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:d("theme.filterColorThemes","Filter color themes")}),e.jsx("input",{ref:E,type:"search",className:"input",value:n,placeholder:d("theme.filterColorThemesPlaceholder","Filter color themes"),"aria-label":d("theme.filterColorThemes","Filter color themes"),onChange:a=>f(a.target.value),onKeyDown:ae})]}),m.length?e.jsx("div",{id:B,className:"theme-dropdown-list",role:"listbox","aria-label":d("theme.colorThemeLabel","Color theme"),children:m.map(({value:a,displayLabel:w,className:F},k)=>{const C=t===a;return e.jsxs("button",{ref:T=>{g.current[k]=T},type:"button",className:`theme-dropdown-option${C?" active":""}`,role:"option","aria-selected":C,tabIndex:k===q?0:-1,onClick:()=>W(a),onKeyDown:T=>te(T,k,a),children:[e.jsx(O,{className:F}),e.jsx("span",{className:"theme-dropdown-option-label",children:w}),C?e.jsx(ce,{size:16,"aria-hidden":"true"}):null]},a)})}):e.jsx("p",{className:"theme-dropdown-no-results",children:d("theme.noColorThemes","No color themes found")})]}):null]})}const Ee=[{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 _e({onSelect:t}){const[i,l]=o.useState(!1),[h,u]=o.useState(),N=o.useRef(null),s=o.useRef(null),p=o.useCallback(()=>{const r=N.current?.getBoundingClientRect();r&&u({top:r.bottom,left:r.left,right:window.innerWidth-r.right})},[]);o.useEffect(()=>{if(!i)return;p();const r=()=>p();return window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)}},[i,p]),o.useEffect(()=>{if(!i)return;const r=n=>{const f=n.target;N.current?.contains(f)||s.current?.contains(f)||l(!1)},y=n=>{n.key==="Escape"&&(l(!1),N.current?.focus())};return document.addEventListener("mousedown",r),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",y)}},[i]);const d=i&&h&&typeof document<"u"?se.createPortal(e.jsx("div",{ref:s,className:"report-action-menu__list report-action-menu__list--portal",role:"menu",style:{top:h.top,left:h.left,right:h.right},children:Ee.map(({type:r,label:y,Icon:n})=>e.jsxs("button",{className:"report-action-menu__item",type:"button",role:"menuitem",onClick:()=>{l(!1),t(r)},children:[e.jsx(n,{"aria-hidden":"true"}),y]},r))}),document.body):null;return e.jsxs("div",{className:"report-action-menu",children:[e.jsx("button",{ref:N,className:"btn btn-secondary",type:"button","aria-haspopup":"menu","aria-expanded":i,onClick:()=>l(r=>!r),children:"Report"}),d]})}const De={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 ze({actionType:t,onClose:i,contextRefs:l}){const{t:h}=V("app"),[u,N]=o.useState(""),[s,p]=o.useState(),[d,r]=o.useState(!1),[y,n]=o.useState(),[f,x]=o.useState(!1),[v,j]=o.useState(),[S,I]=o.useState(),[E,D]=o.useState(!1),g=o.useRef(0),M=async c=>{r(!0),n(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(g.current!==c)return;I(R)}catch(b){if(g.current!==c)return;x(!1),n(b instanceof Error?b.message:"We could not capture the current screen.")}finally{g.current===c&&r(!1)}},z=async()=>{if(u.trim()){if(f&&(!S||!E)){n("Capture and confirm local screenshot retention before continuing, or turn attachment off.");return}r(!0),n(void 0);try{if(Y("report"),t==="help"){const c=await xe(u);if(c.answered){p({kind:"help",answer:c.answer});return}}p(await ge({actionType:t,targetType:v,userPrompt:u,contextRefs:l,activityTrace:A(),screenshotArtifactId:f&&E?S:void 0}))}catch{n("We could not prepare your report. Check your connection and try again.")}finally{r(!1)}}},$=async(c,b,R)=>{if(s?.report){r(!0),n(void 0);try{Y("report"),p(await Ne({actionType:t,targetType:v,report:s.report,endorseIssueNumber:c,endorseDiscussionId:b,endorseRoadmapIssueNumber:R,activityTrace:A(),screenshotArtifactId:f&&E?S:void 0}))}catch{n("We could not send your report. Your draft is still here; try again.")}finally{r(!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":`${t} report`,children:[e.jsx("button",{className:"btn-icon report-modal__close",type:"button","aria-label":"Close report",onClick:i,children:"×"}),y&&e.jsx("p",{className:"report-modal__error",role:"alert",children:y}),!s&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t[0].toUpperCase()+t.slice(1)}),e.jsx("label",{htmlFor:"report-prompt",children:De[t]}),e.jsx("textarea",{id:"report-prompt",className:"input",value:u,onChange:c=>N(c.target.value),maxLength:4e3}),e.jsxs("label",{className:"report-modal__screenshot-option",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:c=>{const b=c.target.checked,R=++g.current;x(b),I(void 0),D(!1),b?M(R):r(!1)}})," Store a screenshot locally"]}),f&&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:E,onChange:c=>D(c.target.checked)})," I confirm Fusion may retain this screenshot locally for this report."]}):e.jsx("p",{children:"Capturing and storing locally…"})}),e.jsx("label",{htmlFor:"report-target",children:h("report.targetLabel","Filing target")}),e.jsxs("select",{id:"report-target",className:"input",value:v??"",onChange:c=>j(c.target.value||void 0),children:[e.jsx("option",{value:"",children:h("report.targetInherit","Use configured action target")}),e.jsx("option",{value:"issue",children:h("report.targetIssue","GitHub Issue")}),e.jsx("option",{value:"discussion",children:h("report.targetDiscussion","GitHub Discussion")})]}),e.jsxs("details",{className:"report-modal__activity-trace",children:[e.jsx("summary",{children:"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()||d,onClick:()=>void z(),children:y?"Retry":"Continue"})]}),s?.kind==="draft-ready"&&s.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Review your report"}),e.jsx("label",{htmlFor:"report-review-prompt",children:"Report summary"}),e.jsx("textarea",{id:"report-review-prompt",className:"input",value:s.report.userPrompt,onChange:c=>{const b=c.target.value;p({...s,report:{...s.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-review-body",children:"Structured report"}),e.jsx("textarea",{id:"report-review-body",className:"input",value:s.report.body??"",onChange:c=>p({...s,report:{...s.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:d,onClick:()=>void $(),children:"File report"})]}),s?.kind==="duplicate-found"&&s.issue&&s.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.issue.roadmap?h("report.roadmapDuplicate.title","Already on the roadmap — add your data point?"):"Review data point for a similar open issue"}),e.jsx("a",{href:s.issue.url,target:"_blank",rel:"noreferrer",children:s.issue.title}),e.jsx("label",{htmlFor:"report-duplicate-prompt",children:"Report summary"}),e.jsx("textarea",{id:"report-duplicate-prompt",className:"input",value:s.report.userPrompt,onChange:c=>{const b=c.target.value;p({...s,report:{...s.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-duplicate-body",children:"Structured data point"}),e.jsx("textarea",{id:"report-duplicate-body",className:"input",value:s.report.body??"",onChange:c=>p({...s,report:{...s.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:d,onClick:()=>void $(s.issue.discussionId||s.issue.roadmap?void 0:s.issue.number,s.issue.discussionId,s.issue.roadmap?s.issue.number:void 0),children:"Confirm and add data point"})]}),(s?.kind==="filed"||s?.kind==="endorsed")&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.kind==="filed"&&s.destination==="issue"?"Report filed as an Issue":"Report sent"}),e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer",children:"View on GitHub"}),s.report?.body&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"filed-report",children:"Final report"}),e.jsx("textarea",{id:"filed-report",className:"input",value:s.report.body,readOnly:!0})]})]}),s?.kind==="help"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Suggested help"}),e.jsx("p",{children:s.answer?.summary??s.answer?.content})]}),s?.kind==="unavailable"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",children:s.message}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>{p(void 0),n(void 0)},children:"Return to prompt"})]})]})})}export{me as B,_e as R,J as T,Le as a,ze as b,Me as l,$e as r};
21
+ */const ve=[["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=z("sun",ve);async function G(t,i){const l=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}function ge(t){return G("/api/report/draft",t)}function Ne(t){return G("/api/report/file",t)}function xe(t){return G("/api/report/help",{question:t})}async function ke(t){const i=new FormData;i.append("screenshot",t,"report-screenshot.png");const l=await fetch("/api/report/attachment",{method:"POST",body:i});if(!l.ok)throw new Error((await l.json().catch(()=>({error:l.statusText}))).error??l.statusText);return l.json()}async function Me(){const t=await fetch("/api/report/discussion-categories");if(!t.ok)throw new Error((await t.json().catch(()=>({error:t.statusText}))).error??t.statusText);return t.json()}function $e(t){const i=new URLSearchParams(t.search),l=t.hash.match(/^#\/tasks\/([^/?#]+)/),h=l?.[1]?decodeURIComponent(l[1]):i.get("taskId")??void 0,u=i.get("agentId")??void 0;return h||u?{taskId:h,agentId:u}:void 0}const J=[{value:"light",label:"Light",icon:ye},{value:"dark",label:"Dark",icon:fe},{value:"system",label:"System",icon:re}],P=[{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:"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:"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(t){const i=t.trim();if(/^#[\da-f]{6}$/i.test(i))return i;if(/^#[\da-f]{3}$/i.test(i)){const[,l,h,u]=i;return`#${l}${l}${h}${h}${u}${u}`}return"#000000"}function Ce({value:t={},onChange:i,resolvedThemeMode:l="dark"}){const{t:h}=V("app"),[u,N]=o.useState(!1),s=o.useId(),p=o.useMemo(()=>Q(t),[t]),d=(n,f)=>{i(Q({...p,[n]:f}))},r=u?h("theme.shadcnCustom.collapse","Collapse custom colors"):h("theme.shadcnCustom.show","Show custom colors"),y=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:h("theme.shadcnCustom.title","Custom shadcn colors")}),e.jsx("p",{className:"shadcn-color-picker-description",children:h("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":s,"aria-label":r,title:r,onClick:()=>N(n=>!n),children:e.jsx(y,{size:16,"aria-hidden":"true"})})]}),u?e.jsxs("div",{id:s,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:()=>i({}),children:h("theme.shadcnCustom.reset","Reset custom colors")})}),e.jsx("div",{className:"shadcn-color-picker-grid",children:ne.map(n=>{const f=oe(n,l),x=p[n.cssVar]??f,v=`shadcn-color-${n.cssVar.replace(/^--/,"").replace(/[^a-z0-9]+/gi,"-")}`;return e.jsxs("div",{className:"shadcn-color-picker-row","data-testid":`shadcn-color-${n.cssVar}`,children:[e.jsxs("label",{className:"shadcn-color-picker-label",htmlFor:v,children:[e.jsx("span",{children:h(`theme.shadcnCustom.token.${n.cssVar}`,n.label)}),e.jsx("code",{children:n.cssVar})]}),e.jsxs("div",{className:"shadcn-color-picker-controls",children:[e.jsx("input",{"aria-label":h("theme.shadcnCustom.colorInput","Pick {{label}} color",{label:n.label}),className:"shadcn-color-picker-native",type:"color",value:je(x),onChange:j=>d(n.cssVar,j.currentTarget.value)}),e.jsx("input",{id:v,"aria-label":h("theme.shadcnCustom.hexInput","{{label}} hex color",{label:n.label}),className:"input shadcn-color-picker-hex",type:"text",inputMode:"text",spellCheck:!1,value:x,onChange:j=>d(n.cssVar,j.currentTarget.value)})]})]},n.cssVar)})})]}):null]})}function Se(t){return P.find(i=>i.value===t)??P[0]}function Z(t){return t.trim().normalize("NFD").replace(/\p{Diacritic}/gu,"").toLocaleLowerCase()}function O({className:t}){return e.jsxs("span",{className:`theme-option-swatch ${t}`,"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:t,onColorThemeChange:i,themeMode:l,shadcnCustomColors:h={},resolvedThemeMode:u=l==="light"?"light":"dark",onThemeModeChange:N,onShadcnCustomColorsChange:s=()=>{},triggerVariant:p="compact"}){const{t:d}=V("app"),[r,y]=o.useState(!1),[n,f]=o.useState(""),[x,v]=o.useState(t),[j,S]=o.useState(null),I=o.useRef(null),E=o.useRef(null),D=o.useRef(!1),g=o.useRef([]),M=o.useMemo(()=>Se(t),[t]),_=l==="system"?u:l,$=J.find(a=>a.value===_)?.icon,c=l==="system"?d("theme.system","System"):d(`theme.${l}`,l?`${l.charAt(0).toUpperCase()}${l.slice(1)}`:"Dark"),b=d(`theme.colorTheme.${M.value}`,M.label),R=`${d("theme.currentTheme","Current theme")} ${c} / ${b}`,B="theme-dropdown-listbox",H=o.useMemo(()=>P.map(a=>({...a,displayLabel:d(`theme.colorTheme.${a.value}`,a.label)})),[d]),U=Z(n),m=o.useMemo(()=>H.filter(a=>Z(a.displayLabel).includes(U)),[U,H]),W=m.findIndex(a=>a.value===x),L=()=>{y(!1),f(""),v(t),S(null),D.current=!1,g.current=[]};o.useEffect(()=>{if(!r)return;const a=w=>{I.current&&!I.current.contains(w.target)&&L()};return document.addEventListener("pointerdown",a),()=>document.removeEventListener("pointerdown",a)},[r,t]),o.useEffect(()=>{r&&(m.some(a=>a.value===x)||v(m[0]?.value??null))},[x,m,r]),o.useEffect(()=>{if(r){if(j==="pointer"&&D.current)E.current?.focus(),D.current=!1;else if(j==="keyboard"){const a=m.findIndex(w=>w.value===x);g.current[a]?.focus()}}},[x,m,r,j]);const q=a=>{i(a),L()},K=(a,w)=>{if(a==="pointer")D.current=!0,v(t);else{const F=m.some(C=>C.value===t),k=w==="ArrowUp"?m.at(-1)?.value??null:w==="ArrowDown"?m[0]?.value??null:F?t:m[0]?.value??null;v(k)}S(a),y(!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 w=a.key==="ArrowUp"?m.length-1:Math.max(0,W);w<0||!m[w]||(a.preventDefault(),v(m[w].value),g.current[w]?.focus())},te=(a,w,F)=>{if(a.key==="Escape"){a.preventDefault(),L();return}if(a.key==="ArrowDown"||a.key==="ArrowUp"){a.preventDefault();const k=a.key==="ArrowDown"?1:-1,C=(w+k+m.length)%m.length;v(m[C]?.value??null),g.current[C]?.focus();return}if(a.key==="Home"){a.preventDefault(),v(m[0]?.value??null),g.current[0]?.focus();return}if(a.key==="End"){a.preventDefault();const k=m.length-1;v(m[k]?.value??null),g.current[k]?.focus();return}(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),q(F))};return e.jsxs("div",{className:`theme-dropdown${p==="current-row"?" theme-dropdown--current-row":""}${r?" open":""}`,ref:I,children:[e.jsxs("button",{type:"button",className:`theme-dropdown-trigger btn${p==="current-row"?" theme-dropdown-trigger--current-row":""}`,"aria-label":p==="current-row"?R:void 0,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?B:void 0,onClick:()=>r?L():K("pointer"),onKeyDown:ee,children:[p==="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:d("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&&N?e.jsx("div",{className:"theme-dropdown-modes",role:"radiogroup","aria-label":d("theme.modeLabel","Theme mode"),children:J.map(({value:a,label:w,icon:F})=>e.jsxs("button",{type:"button",className:`theme-dropdown-mode-btn btn btn-sm${l===a?" active":""}`,"aria-pressed":l===a,onClick:()=>N(a),title:d(`theme.${a}Mode`,`${w} mode`),children:[e.jsx(F,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:d(`theme.${a}`,w)})]},a))}):null,t==="shadcn-custom"?e.jsx(Ce,{value:h,onChange:s,resolvedThemeMode:u}):null,r?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:d("theme.filterColorThemes","Filter color themes")}),e.jsx("input",{ref:E,type:"search",className:"input",value:n,placeholder:d("theme.filterColorThemesPlaceholder","Filter color themes"),"aria-label":d("theme.filterColorThemes","Filter color themes"),onChange:a=>f(a.target.value),onKeyDown:ae})]}),m.length?e.jsx("div",{id:B,className:"theme-dropdown-list",role:"listbox","aria-label":d("theme.colorThemeLabel","Color theme"),children:m.map(({value:a,displayLabel:w,className:F},k)=>{const C=t===a;return e.jsxs("button",{ref:T=>{g.current[k]=T},type:"button",className:`theme-dropdown-option${C?" active":""}`,role:"option","aria-selected":C,tabIndex:k===W?0:-1,onClick:()=>q(a),onKeyDown:T=>te(T,k,a),children:[e.jsx(O,{className:F}),e.jsx("span",{className:"theme-dropdown-option-label",children:w}),C?e.jsx(ce,{size:16,"aria-hidden":"true"}):null]},a)})}):e.jsx("p",{className:"theme-dropdown-no-results",children:d("theme.noColorThemes","No color themes found")})]}):null]})}const Ee=[{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 ze({onSelect:t}){const[i,l]=o.useState(!1),[h,u]=o.useState(),N=o.useRef(null),s=o.useRef(null),p=o.useCallback(()=>{const r=N.current?.getBoundingClientRect();r&&u({top:r.bottom,left:r.left,right:window.innerWidth-r.right})},[]);o.useEffect(()=>{if(!i)return;p();const r=()=>p();return window.addEventListener("resize",r),window.addEventListener("scroll",r,!0),()=>{window.removeEventListener("resize",r),window.removeEventListener("scroll",r,!0)}},[i,p]),o.useEffect(()=>{if(!i)return;const r=n=>{const f=n.target;N.current?.contains(f)||s.current?.contains(f)||l(!1)},y=n=>{n.key==="Escape"&&(l(!1),N.current?.focus())};return document.addEventListener("mousedown",r),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",y)}},[i]);const d=i&&h&&typeof document<"u"?se.createPortal(e.jsx("div",{ref:s,className:"report-action-menu__list report-action-menu__list--portal",role:"menu",style:{top:h.top,left:h.left,right:h.right},children:Ee.map(({type:r,label:y,Icon:n})=>e.jsxs("button",{className:"report-action-menu__item",type:"button",role:"menuitem",onClick:()=>{l(!1),t(r)},children:[e.jsx(n,{"aria-hidden":"true"}),y]},r))}),document.body):null;return e.jsxs("div",{className:"report-action-menu",children:[e.jsx("button",{ref:N,className:"btn btn-secondary",type:"button","aria-haspopup":"menu","aria-expanded":i,onClick:()=>l(r=>!r),children:"Report"}),d]})}const De={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:t,onClose:i,contextRefs:l}){const{t:h}=V("app"),[u,N]=o.useState(""),[s,p]=o.useState(),[d,r]=o.useState(!1),[y,n]=o.useState(),[f,x]=o.useState(!1),[v,j]=o.useState(),[S,I]=o.useState(),[E,D]=o.useState(!1),g=o.useRef(0),M=async c=>{r(!0),n(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(g.current!==c)return;I(R)}catch(b){if(g.current!==c)return;x(!1),n(b instanceof Error?b.message:"We could not capture the current screen.")}finally{g.current===c&&r(!1)}},_=async()=>{if(u.trim()){if(f&&(!S||!E)){n("Capture and confirm local screenshot retention before continuing, or turn attachment off.");return}r(!0),n(void 0);try{if(Y("report"),t==="help"){const c=await xe(u);if(c.answered){p({kind:"help",answer:c.answer});return}}p(await ge({actionType:t,targetType:v,userPrompt:u,contextRefs:l,activityTrace:A(),screenshotArtifactId:f&&E?S:void 0}))}catch{n("We could not prepare your report. Check your connection and try again.")}finally{r(!1)}}},$=async(c,b,R)=>{if(s?.report){r(!0),n(void 0);try{Y("report"),p(await Ne({actionType:t,targetType:v,report:s.report,endorseIssueNumber:c,endorseDiscussionId:b,endorseRoadmapIssueNumber:R,activityTrace:A(),screenshotArtifactId:f&&E?S:void 0}))}catch{n("We could not send your report. Your draft is still here; try again.")}finally{r(!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":`${t} report`,children:[e.jsx("button",{className:"btn-icon report-modal__close",type:"button","aria-label":"Close report",onClick:i,children:"×"}),y&&e.jsx("p",{className:"report-modal__error",role:"alert",children:y}),!s&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t[0].toUpperCase()+t.slice(1)}),e.jsx("label",{htmlFor:"report-prompt",children:De[t]}),e.jsx("textarea",{id:"report-prompt",className:"input",value:u,onChange:c=>N(c.target.value),maxLength:4e3}),e.jsxs("label",{className:"report-modal__screenshot-option",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:c=>{const b=c.target.checked,R=++g.current;x(b),I(void 0),D(!1),b?M(R):r(!1)}})," Store a screenshot locally"]}),f&&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:E,onChange:c=>D(c.target.checked)})," I confirm Fusion may retain this screenshot locally for this report."]}):e.jsx("p",{children:"Capturing and storing locally…"})}),e.jsx("label",{htmlFor:"report-target",children:h("report.targetLabel","Filing target")}),e.jsxs("select",{id:"report-target",className:"input",value:v??"",onChange:c=>j(c.target.value||void 0),children:[e.jsx("option",{value:"",children:h("report.targetInherit","Use configured action target")}),e.jsx("option",{value:"issue",children:h("report.targetIssue","GitHub Issue")}),e.jsx("option",{value:"discussion",children:h("report.targetDiscussion","GitHub Discussion")})]}),e.jsxs("details",{className:"report-modal__activity-trace",children:[e.jsx("summary",{children:"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()||d,onClick:()=>void _(),children:y?"Retry":"Continue"})]}),s?.kind==="draft-ready"&&s.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Review your report"}),e.jsx("label",{htmlFor:"report-review-prompt",children:"Report summary"}),e.jsx("textarea",{id:"report-review-prompt",className:"input",value:s.report.userPrompt,onChange:c=>{const b=c.target.value;p({...s,report:{...s.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-review-body",children:"Structured report"}),e.jsx("textarea",{id:"report-review-body",className:"input",value:s.report.body??"",onChange:c=>p({...s,report:{...s.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:d,onClick:()=>void $(),children:"File report"})]}),s?.kind==="duplicate-found"&&s.issue&&s.report&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.issue.roadmap?h("report.roadmapDuplicate.title","Already on the roadmap — add your data point?"):"Review data point for a similar open issue"}),e.jsx("a",{href:s.issue.url,target:"_blank",rel:"noreferrer",children:s.issue.title}),e.jsx("label",{htmlFor:"report-duplicate-prompt",children:"Report summary"}),e.jsx("textarea",{id:"report-duplicate-prompt",className:"input",value:s.report.userPrompt,onChange:c=>{const b=c.target.value;p({...s,report:{...s.report,userPrompt:b}})}}),e.jsx("label",{htmlFor:"report-duplicate-body",children:"Structured data point"}),e.jsx("textarea",{id:"report-duplicate-body",className:"input",value:s.report.body??"",onChange:c=>p({...s,report:{...s.report,body:c.target.value}})}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:d,onClick:()=>void $(s.issue.discussionId||s.issue.roadmap?void 0:s.issue.number,s.issue.discussionId,s.issue.roadmap?s.issue.number:void 0),children:"Confirm and add data point"})]}),(s?.kind==="filed"||s?.kind==="endorsed")&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.kind==="filed"&&s.destination==="issue"?"Report filed as an Issue":"Report sent"}),e.jsx("a",{href:s.url,target:"_blank",rel:"noreferrer",children:"View on GitHub"}),s.report?.body&&e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"filed-report",children:"Final report"}),e.jsx("textarea",{id:"filed-report",className:"input",value:s.report.body,readOnly:!0})]})]}),s?.kind==="help"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Suggested help"}),e.jsx("p",{children:s.answer?.summary??s.answer?.content})]}),s?.kind==="unavailable"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",children:s.message}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>{p(void 0),n(void 0)},children:"Return to prompt"})]})]})})}export{me as B,ze as R,J as T,Le as a,_e as b,Me as l,$e as r};
@@ -1,2 +1,2 @@
1
- import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{ap as Q,aq as ue,ar as he,cK as me,cZ as Se,av as ce,c_ as _e,bh as je,c$ as Y,aW as we,d0 as ke,d1 as Ne,d2 as Ce,d3 as Ee,d4 as Ae,d5 as Te,d6 as Pe,cO as Le,d7 as Ie,d8 as Fe,d9 as Me,da as De,aX as qe,ag as He,V as Oe,aI as pe,L as Ue,aJ as Ve}from"./index-CtYRoouR.js";import{u as fe}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const $e="builtin",X={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function ie(a){const n=a?.researchGlobalDefaults,l=a?.researchSettings;return{enabled:l?.enabled??a?.researchEnabled??a?.researchGlobalEnabled??!0,searchProvider:l?.searchProvider??n?.searchProvider??a?.researchGlobalWebSearchProvider??$e,synthesisProvider:l?.synthesisProvider??n?.synthesisProvider,synthesisModelId:l?.synthesisModelId??n?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:l?.enabledSources?.pageFetch??n?.enabledSources?.pageFetch??X.pageFetch,github:l?.enabledSources?.github??n?.enabledSources?.github??X.github,localDocs:l?.enabledSources?.localDocs??n?.enabledSources?.localDocs??X.localDocs,llmSynthesis:l?.enabledSources?.llmSynthesis??n?.enabledSources?.llmSynthesis??X.llmSynthesis},limits:{maxConcurrentRuns:l?.limits?.maxConcurrentRuns??a?.researchMaxConcurrentRuns??a?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:l?.limits?.maxSourcesPerRun??n?.maxSourcesPerRun??a?.researchMaxSourcesPerRun??a?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:l?.limits?.maxDurationMs??a?.researchDefaultTimeout??a?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:l?.limits?.requestTimeoutMs??a?.researchGlobalFetchTimeoutMs??3e4},defaultExportFormat:n?.defaultExportFormat??"markdown"}}function be(a){const n=typeof a.id=="string"?a.id.trim():"";if(n)return n;const l=f=>f.trim().replace(/\s+/g," ").toLowerCase(),m=[l(a.heading??""),l(a.content??""),...[...a.sources??[]].map(l).filter(Boolean).sort()].join(`
2
- `);let s=2166136261;for(let f=0;f<m.length;f+=1)s^=m.charCodeAt(f),s=Math.imul(s,16777619);return`finding-${(s>>>0).toString(16).padStart(8,"0")}`}const Ge=300,Be=4e3,We=["queued","running","cancelling","retry_waiting"];function le(a,n){if(a instanceof Le){const l=a;return{message:a.message,status:a.status,code:l.researchCode??"INTERNAL_ERROR",setupHint:l.setupHint,retryable:l.retryable}}return a instanceof Error?{message:a.message,code:"INTERNAL_ERROR"}:{message:n,code:"INTERNAL_ERROR"}}function ze(a){if(!a)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const n=We.includes(a.status),l=a.status==="queued"||a.status==="running",m=a.lifecycle?.retryable,s=a.status==="failed"||a.status==="timed_out",f=!!(s&&m);let x;return!l&&n?x="Run is already transitioning":!l&&a.status==="completed"?x="Completed runs cannot be cancelled":!l&&a.status==="cancelled"?x="Run is already cancelled":!l&&a.status==="retry_exhausted"?x="Retry attempts exhausted":!l&&a.status==="failed"?x="Failed runs cannot be cancelled":!l&&a.status==="timed_out"&&(x="Timed out runs cannot be cancelled"),!f&&s&&m===!1&&(x=a.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:l,retryable:f,isTransitioning:n,blockingReason:x}}function Ke(a){const n=a?.projectId,l=n??"",m=`${he.RESEARCH_RUNS_PREFIX}${l}`,s=`${he.RESEARCH_SELECTED_ID_PREFIX}${l}`,f=Q(m,{maxAgeMs:ue}),x=Q(s,{maxAgeMs:me}),r=c.useRef(Array.isArray(f)&&f.length>0),[D,M]=c.useState(()=>Array.isArray(f)?f:[]),[h,A]=c.useState(x??null),[P,w]=c.useState(null),[U,q]=c.useState({available:!0}),[V,L]=c.useState(!(Array.isArray(f)&&f.length>0)),[G,H]=c.useState(null),[B,k]=c.useState(null),[N,I]=c.useState(""),_=c.useRef(0),R=c.useRef(0),C=c.useRef(n);c.useEffect(()=>{C.current!==n&&(C.current=n,R.current++);const o=Q(m,{maxAgeMs:ue}),d=Q(s,{maxAgeMs:me}),p=Array.isArray(o)&&o.length>0;M(Array.isArray(o)?o:[]),A(d??null),w(null),L(!p),r.current=p},[n,m,s]);const S=c.useCallback(async(o=N)=>{const d=++_.current,p=n;r.current||L(!0),H(null),k(null);try{const y=await Se({q:o||void 0,limit:100},p);if(d!==_.current||p!==n)return;M(y.runs),ce(m,y.runs,{maxBytes:5e5}),r.current=!0,q(y.availability),h&&!y.runs.some(g=>g.id===h)&&(A(null),ce(s,null,{maxBytes:5e5}),w(null))}catch(y){if(d!==_.current||p!==n)return;const g=le(y,"Failed to load research runs");H(g.message),k(g)}finally{d===_.current&&L(!1)}},[n,m,N,s,h]),i=c.useCallback(async o=>{const d=await _e(o,n);return w(d.run),q(d.availability),d.run},[n]);c.useEffect(()=>{r.current||L(!0);const o=window.setTimeout(()=>{S(N)},Ge);return()=>window.clearTimeout(o)},[S,N]),c.useEffect(()=>{if(!h){w(null);return}i(h)},[i,h]),c.useEffect(()=>{const o=R.current,d=()=>R.current!==o,p=n?`?projectId=${encodeURIComponent(n)}`:"";let y=!0;const g=()=>{!y||d()||(S(),h&&i(h))},j=`/api/events${p}`,$=je(j,{events:{"research:run:created":g,"research:run:updated":g,"research:run:completed":g,"research:run:failed":g,"research:run:cancelled":g},onReconnect:()=>{Y({view:"useResearch",trigger:"sse-reconnect",projectId:n,replayAttempted:!1,sseChannel:j}),g()}});return Y({view:"useResearch",trigger:"sse-open",projectId:n,replayAttempted:!1,sseChannel:j}),()=>{y=!1,$()}},[n,S,h,i]);const E=c.useCallback(()=>{S(),h&&i(h)},[S,h,i]);we(E,Be);const T=c.useCallback(o=>{A(o),ce(s,o,{maxBytes:5e5})},[s]);return{runs:D,selectedRun:P,selectedRunId:h,setSelectedRunId:T,availability:U,loading:V,error:G,searchQuery:N,setSearchQuery:I,refresh:S,createRun:o=>Pe(o,n),cancelRun:async o=>{try{k(null);const d=await Te(o,n);return h===o&&w(d.run),await S(),d}catch(d){const p=le(d,"Failed to cancel run");throw k(p),p}},retryRun:async o=>{try{k(null);const d=await Ae(o,n);return h===o&&w(d.run),await S(),d}catch(d){const p=le(d,"Failed to retry run");throw k(p),p}},exportRun:(o,d)=>Ee(o,d,n),createTaskFromRun:(o,d,p,y,g,j)=>Ce(o,{title:d,findingId:p,description:y,priority:g,attachExport:j},n),attachRunToTask:(o,d,p,y)=>Ne(o,{taskId:d,findingId:p,attachExport:y},n),promoteFinding:(o,d)=>ke(o,d,n),uiError:B,runActionState:ze(P),statusCounts:D.reduce((o,d)=>(o[d.status]+=1,o),{queued:0,running:0,cancelling:0,retry_waiting:0,completed:0,failed:0,cancelled:0,timed_out:0,retry_exhausted:0})}}function Qe({open:a,mode:n,run:l,finding:m,projectId:s,onClose:f,onConfirm:x}){const{t:r}=fe("app");Ie(a);const[D,M]=c.useState(!1),[h,A]=c.useState(""),[P,w]=c.useState(""),[U,q]=c.useState("normal"),[V,L]=c.useState(""),[G,H]=c.useState([]),[B,k]=c.useState(!1),[N,I]=c.useState(!1),{boardWorkflows:_}=Fe({projectId:s}),R=c.useMemo(()=>{const i=new Map;for(const E of _?.workflows??[])for(const T of E.columns)i.has(T.id)||i.set(T.id,T.flags);return E=>Me(i.get(E),E)},[_]),C=c.useMemo(()=>{const i=(m.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${m.heading||r("research.defaultFindingHeading","Research finding")} — ${i}`.trim()},[m.content,m.heading,r]);c.useEffect(()=>{a&&(M(!1),A(`Research: ${m.heading||l.title}`),w(C),q("normal"),L(""))},[a,n,m.heading,C,l.title]),c.useEffect(()=>{if(!a||n!=="enrich")return;let i=!1;return H([]),k(!0),De(50,0,s).then(E=>{i||H(E.filter(T=>!R(T.column)))}).finally(()=>{i||k(!1)}),()=>{i=!0}},[a,n,s,R]);const S=V.trim();return a?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:f,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n==="create"?r("research.createTaskTitle","Create task from finding"):r("research.enrichTaskTitle","Enrich existing task")}),e.jsx("button",{className:"modal-close",type:"button","aria-label":r("actions.close","Close"),onClick:f,children:"×"})]}),e.jsxs("div",{className:"research-task-action-modal__body",children:[e.jsxs("div",{className:"card research-task-action-modal__preview",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.runLabel","Run:")," "]})," ",l.id]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.findingLabel","Finding:")," "]})," ",m.id,m.heading?` — ${m.heading}`:""]}),e.jsx("p",{children:C||r("research.noPreview","No preview available.")})]}),n==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.titleLabel","Title"),e.jsx("input",{className:"input",value:h,onChange:i=>A(i.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.descriptionLabel","Description"),e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:P,onChange:i=>w(i.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.priorityLabel","Priority"),e.jsxs("select",{className:"select",value:U,onChange:i=>q(i.target.value),children:[e.jsx("option",{value:"low",children:r("research.priorityLow","Low")}),e.jsx("option",{value:"normal",children:r("research.priorityNormal","Normal")}),e.jsx("option",{value:"high",children:r("research.priorityHigh","High")}),e.jsx("option",{value:"urgent",children:r("research.priorityUrgent","Urgent")})]})]})]}):e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.targetTaskLabel","Target task"),e.jsx("input",{className:"input",list:"research-task-action-task-list",value:V,placeholder:B?r("research.loadingTasks","Loading tasks…"):r("research.enterTaskId","Enter task ID"),onChange:i=>L(i.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:G.map(i=>e.jsx("option",{value:i.id,children:i.title},i.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:i=>M(i.target.checked)}),e.jsx("span",{children:r("research.attachExport","Attach markdown export artifact")})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:f,children:r("actions.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:N||n==="enrich"&&!S,onClick:()=>{I(!0),x({taskId:n==="enrich"?S:void 0,title:n==="create"?h.trim():void 0,description:n==="create"?P.trim():void 0,priority:n==="create"?U:void 0,attachExport:D}).finally(()=>I(!1))},children:n==="create"?r("research.createTaskButton","Create Task"):r("research.enrichTaskButton","Enrich Task")})]})]})}):null}const Xe=["web-search","page-fetch","github","local-docs","llm-synthesis"],Ye={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"};function Je(a){return{"web-search":a("research.providerWebSearch","Web Search"),"page-fetch":a("research.providerPageFetch","Page Fetch"),github:a("research.providerGitHub","GitHub"),"local-docs":a("research.providerLocalDocs","Local Docs"),"llm-synthesis":a("research.providerLlmSynthesis","LLM Synthesis")}}let oe=!1;function cs({projectId:a,addToast:n,onOpenSettings:l,readinessVersion:m=0}){const{t:s}=fe("app"),f=Je(s);c.useEffect(()=>(Y({view:"ResearchView",trigger:oe?"route-active":"remount",projectId:a,replayAttempted:!1}),oe=!1,()=>{oe=!0,Y({view:"ResearchView",trigger:"route-inactive",projectId:a,replayAttempted:!1})}),[a]);const{runs:x,selectedRun:r,selectedRunId:D,setSelectedRunId:M,availability:h,loading:A,error:P,searchQuery:w,setSearchQuery:U,createRun:q,cancelRun:V,retryRun:L,exportRun:G,createTaskFromRun:H,attachRunToTask:B,promoteFinding:k,statusCounts:N,refresh:I,uiError:_,runActionState:R}=Ke({projectId:a}),[C,S]=c.useState(""),[i,E]=c.useState(()=>ie(void 0)),[T,o]=c.useState([]),[d,p]=c.useState(!1),[y,g]=c.useState([]),[j,$]=c.useState(null),[O,K]=c.useState(null),[J,ve]=c.useState(""),Z=h.supportedProviders??Xe,ee=i.searchProvider,se=t=>t==="web-search"?!0:i.enabledSources[Ye[t]];c.useEffect(()=>{const t=Z.filter(u=>se(u));g(u=>{const b=u.filter(v=>t.includes(v));return b.length>0?b:t})},[i.enabledSources,Z]),c.useEffect(()=>{let t=!1;return Promise.all([qe(a),He().catch(()=>({providers:[]}))]).then(([u,b])=>{t||(E(ie(u)),o(b.providers.filter(v=>v.type==="api_key").map(v=>({id:v.id,authenticated:v.authenticated}))))}).catch(()=>{t||E(ie(void 0))}),()=>{t=!0}},[a,m]);const xe=c.useMemo(()=>r?r.status:s("research.noRunSelected","No run selected"),[r,s]),ye=c.useMemo(()=>r?r.status==="queued"||r.status==="retry_waiting"?"status-dot status-dot--pending":r.status==="running"?"status-dot status-dot--connecting":r.status==="completed"?"status-dot status-dot--online":r.status==="failed"||r.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[r]),re=h.supportedExportFormats??["markdown","json","html"],te=c.useMemo(()=>new Map(T.map(t=>[t.id,t.authenticated])),[T]),ae=c.useMemo(()=>{const t=new Set;return i.enabledSources.webSearch&&ee&&t.add(ee),i.enabledSources.llmSynthesis&&i.synthesisProvider&&t.add(i.synthesisProvider),[...t].filter(u=>te.has(u))},[i.enabledSources.llmSynthesis,i.enabledSources.webSearch,i.synthesisProvider,ee,te]).find(t=>te.get(t)!==!0),W=c.useMemo(()=>h.available?i.enabled?ae?{reason:s("research.missingApiKey","Missing API key for {{provider}}.",{provider:ae}),details:s("research.addCredentialsHint","Add provider credentials in Authentication settings."),settingsSection:"authentication"}:null:{reason:s("research.disabled","Research is disabled for this project."),details:s("research.enableResearchHint","Enable project research settings to create runs."),settingsSection:"research-project"}:{reason:h.reason??s("research.unavailable","Research is unavailable for this project."),details:h.setupInstructions,settingsSection:"research-project"},[h.available,h.reason,h.setupInstructions,i.enabled,ae,s]),z=async(t,u,b)=>{$(t);try{await u(),n?.(b,"success"),await I()}catch(v){n?.(v instanceof Error?v.message:s("research.actionFailed","Action failed"),"error")}finally{$(null)}},ne=async t=>{if(r){$(`export-${t}`);try{const u=await G(r.id,t),b=new Blob([u.content],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(b),F=document.createElement("a");F.href=v,F.download=u.filename,document.body.appendChild(F),F.click(),F.remove(),URL.revokeObjectURL(v),n?.(s("research.exportedFile","Exported {{filename}}",{filename:u.filename}),"success")}catch(u){n?.(u instanceof Error?u.message:s("research.exportFailed","Export failed"),"error")}finally{$(null)}}},ge=async()=>{if(C.trim()){p(!0);try{const t=y.filter(b=>se(b));if(t.length===0){p(!1),n?.(s("research.noSourcesAvailable","No enabled research sources are available for this project."),"error");return}const u=await q({query:C.trim(),providers:t});M(u.run.id),S(""),n?.(s("research.runCreated","Research run created"),"success"),await I()}catch(t){n?.(t instanceof Error?t.message:s("research.createRunFailed","Failed to create run"),"error")}finally{p(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":s("research.viewLabel","Research view"),children:[e.jsx(Oe,{icon:pe,title:s("research.title","Research"),actions:e.jsx("button",{className:"btn",type:"button",onClick:()=>void I(),children:s("actions.refresh","Refresh")})}),e.jsx("p",{className:"research-view__subtitle",children:s("research.subtitle","Cited search and synthesis runs: gather sources, fetch content, and synthesize findings.")}),W?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:W.reason}),W.details&&e.jsx("p",{children:W.details}),e.jsx("p",{children:s("research.currentDefaults","Current defaults: provider {{provider}}, max sources {{maxSources}}",{provider:i.searchProvider??s("research.notSet","(not set)"),maxSources:i.limits.maxSourcesPerRun})}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void I(),children:s("actions.refresh","Refresh")}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>l?.(W.settingsSection),children:s("actions.openSettings","Open Settings")})]})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"research-view__layout",children:[e.jsx("aside",{className:"research-view__sidebar card",children:e.jsxs("div",{className:"research-view__sidebar-content",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:s("research.queryLabel","Query")}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:C,onChange:t=>S(t.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("research.providersLabel","Providers")}),e.jsx("div",{className:"research-view__providers",children:Z.map(t=>{const u=se(t),b=t==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:b||y.includes(t),disabled:b||!u,onChange:()=>{b||!u||g(v=>v.includes(t)?v.filter(F=>F!==t):[...v,t])}}),e.jsxs("span",{children:[f[t]??t,b?e.jsx("span",{className:"research-view__provider-lock",children:s("research.alwaysOn","Always on")}):null]})]},t)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!C.trim()||d,onClick:()=>void ge(),children:[d?e.jsx(Ue,{className:"animate-spin",size:14}):null,s("research.createRun","Create Run")]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:s("actions.search","Search")}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(pe,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:s("research.searchRunsPlaceholder","Search runs"),value:w,onChange:t=>U(t.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:x.map(t=>e.jsxs("button",{type:"button",className:`research-view__history-item card${D===t.id?" research-view__history-item--active":""}`,onClick:()=>M(t.id),children:[e.jsx("span",{className:"card-id",children:t.id}),e.jsx("span",{children:t.title})]},t.id))})]})}),e.jsxs("div",{className:"research-view__reader card",children:[A&&e.jsx("p",{"data-testid":"research-state-loading",children:e.jsx(Ve,{label:s("research.loadingRuns","Loading research runs…")})}),!A&&P&&e.jsx("p",{"data-testid":"research-state-error",children:P}),!A&&!P&&x.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:s("research.noRunsYet","No research runs yet")}),e.jsxs("div",{className:"research-view__reader-content",children:[r&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:ye}),e.jsx("strong",{children:xe})]}),e.jsx("h3",{className:"research-view__run-title",children:r.title}),e.jsx("p",{className:"research-view__run-query",children:r.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:r.results?.summary??s("research.noSummaryYet","No summary yet.")}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",title:R.cancelable?void 0:R.blockingReason,disabled:j==="cancel"||j==="retry"||!R.cancelable,onClick:()=>void z("cancel",()=>V(r.id),s("research.runCancelled","Run cancelled")),children:s("actions.cancel","Cancel")}),e.jsx("button",{className:"btn",type:"button",title:R.retryable?void 0:R.blockingReason,disabled:j==="cancel"||j==="retry"||!R.retryable,onClick:()=>void z("retry",()=>L(r.id),s("research.runRetried","Run retried")),children:s("actions.retry","Retry")}),re.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void ne("markdown"),children:s("research.exportMd","Export MD")}),re.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void ne("json"),children:s("research.exportJson","Export JSON")}),re.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void ne("html"),children:s("research.exportHtml","Export HTML")})]}),r.error&&e.jsx("p",{className:"research-view__error",children:r.error}),_&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:_.message}),_.setupHint&&e.jsx("p",{children:_.setupHint}),_.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l?.("authentication"),children:s("research.openAuthSettings","Open Authentication Settings")}),_.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l?.("research-project"),children:s("research.openResearchSettings","Open Research Settings")})]}),R.blockingReason&&e.jsx("p",{className:"research-view__run-query",children:R.blockingReason}),Array.isArray(r.results?.findings)&&r.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:r.results.findings.map(t=>{const u=be(t);return e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:t.heading}),e.jsx("p",{children:t.content}),e.jsxs("div",{className:"research-view__actions research-view__finding-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",type:"button",onClick:()=>K({mode:"create",findingId:u}),children:s("research.createTask","Create Task")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>K({mode:"enrich",findingId:u}),children:s("research.enrichTask","Enrich Task")}),e.jsx("input",{className:"input","aria-label":s("research.destinationSlice","Destination slice ID"),value:J,onChange:b=>ve(b.target.value),placeholder:s("research.destinationSlice","Destination slice ID")}),e.jsx("button",{className:"btn btn-sm",type:"button",disabled:r.status!=="completed"||!J.trim()||j===`promote-${u}`,onClick:()=>void z(`promote-${u}`,()=>k(r.id,{findingId:u,sliceId:J.trim()}),s("research.findingPromoted","Finding promoted to roadmap")),children:s("research.promoteFinding","Promote to roadmap")})]})]},u)})}),Array.isArray(r.results?.citations)&&r.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:r.results.citations.map(t=>e.jsx("li",{children:e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:t})},t))}),r.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("research.runHistory","Run history")}),e.jsx("ul",{className:"research-view__events",children:r.events.map(t=>e.jsx("li",{children:t.message},t.id))})]})]}),!r&&x.length>0&&e.jsx("p",{children:s("research.selectRunToViewDetails","Select a run to view details.")}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statRunning","Running")}),e.jsx("div",{className:"research-view__stat-value",children:N.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statCompleted","Completed")}),e.jsx("div",{className:"research-view__stat-value",children:N.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statFailed","Failed")}),e.jsx("div",{className:"research-view__stat-value",children:N.failed})]})]})]})]})]})}),r&&O&&(()=>{const t=r.results?.findings?.findIndex(b=>be(b)===O.findingId)??-1,u=t>=0?r.results.findings[t]:null;return u?e.jsx(Qe,{open:!0,mode:O.mode,run:r,finding:{id:O.findingId,heading:u.heading,content:u.content},projectId:a,onClose:()=>K(null),onConfirm:async({taskId:b,title:v,description:F,priority:Re,attachExport:de})=>{O.mode==="create"?await z("create-task",()=>H(r.id,v,O.findingId,F,Re,de),s("research.taskCreatedFromResearch","Task created from research")):b&&await z("attach-task",()=>B(r.id,b,O.findingId,de),s("research.taskEnrichedFromResearch","Task enriched from research")),K(null)}}):null})()]})}export{cs as ResearchView};
1
+ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{r as Y,e as ue,S as he,cJ as me,cY as Se,b as ce,cZ as _e,bh as je,c_ as X,aX as we,c$ as ke,d0 as Ne,d1 as Ce,d2 as Ee,d3 as Ae,d4 as Te,d5 as Pe,cN as Le,d6 as Fe,d7 as Ie,d8 as Me,d9 as De,aY as He,al as qe,V as Ue,aJ as pe,L as Oe,aK as Ve}from"./index-DpCHwyiD.js";import{u as fe}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const $e="builtin",Q={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function ie(a){const n=a?.researchGlobalDefaults,l=a?.researchSettings;return{enabled:l?.enabled??a?.researchEnabled??a?.researchGlobalEnabled??!0,searchProvider:l?.searchProvider??n?.searchProvider??a?.researchGlobalWebSearchProvider??$e,synthesisProvider:l?.synthesisProvider??n?.synthesisProvider,synthesisModelId:l?.synthesisModelId??n?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:l?.enabledSources?.pageFetch??n?.enabledSources?.pageFetch??Q.pageFetch,github:l?.enabledSources?.github??n?.enabledSources?.github??Q.github,localDocs:l?.enabledSources?.localDocs??n?.enabledSources?.localDocs??Q.localDocs,llmSynthesis:l?.enabledSources?.llmSynthesis??n?.enabledSources?.llmSynthesis??Q.llmSynthesis},limits:{maxConcurrentRuns:l?.limits?.maxConcurrentRuns??a?.researchMaxConcurrentRuns??a?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:l?.limits?.maxSourcesPerRun??n?.maxSourcesPerRun??a?.researchMaxSourcesPerRun??a?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:l?.limits?.maxDurationMs??a?.researchDefaultTimeout??a?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:l?.limits?.requestTimeoutMs??a?.researchGlobalFetchTimeoutMs??3e4},defaultExportFormat:n?.defaultExportFormat??"markdown"}}function be(a){const n=typeof a.id=="string"?a.id.trim():"";if(n)return n;const l=f=>f.trim().replace(/\s+/g," ").toLowerCase(),m=[l(a.heading??""),l(a.content??""),...[...a.sources??[]].map(l).filter(Boolean).sort()].join(`
2
+ `);let s=2166136261;for(let f=0;f<m.length;f+=1)s^=m.charCodeAt(f),s=Math.imul(s,16777619);return`finding-${(s>>>0).toString(16).padStart(8,"0")}`}const Ge=300,Be=4e3,We=["queued","running","cancelling","retry_waiting"];function le(a,n){if(a instanceof Le){const l=a;return{message:a.message,status:a.status,code:l.researchCode??"INTERNAL_ERROR",setupHint:l.setupHint,retryable:l.retryable}}return a instanceof Error?{message:a.message,code:"INTERNAL_ERROR"}:{message:n,code:"INTERNAL_ERROR"}}function ze(a){if(!a)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const n=We.includes(a.status),l=a.status==="queued"||a.status==="running",m=a.lifecycle?.retryable,s=a.status==="failed"||a.status==="timed_out",f=!!(s&&m);let x;return!l&&n?x="Run is already transitioning":!l&&a.status==="completed"?x="Completed runs cannot be cancelled":!l&&a.status==="cancelled"?x="Run is already cancelled":!l&&a.status==="retry_exhausted"?x="Retry attempts exhausted":!l&&a.status==="failed"?x="Failed runs cannot be cancelled":!l&&a.status==="timed_out"&&(x="Timed out runs cannot be cancelled"),!f&&s&&m===!1&&(x=a.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:l,retryable:f,isTransitioning:n,blockingReason:x}}function Ke(a){const n=a?.projectId,l=n??"",m=`${he.RESEARCH_RUNS_PREFIX}${l}`,s=`${he.RESEARCH_SELECTED_ID_PREFIX}${l}`,f=Y(m,{maxAgeMs:ue}),x=Y(s,{maxAgeMs:me}),r=c.useRef(Array.isArray(f)&&f.length>0),[D,M]=c.useState(()=>Array.isArray(f)?f:[]),[h,A]=c.useState(x??null),[P,w]=c.useState(null),[O,H]=c.useState({available:!0}),[V,L]=c.useState(!(Array.isArray(f)&&f.length>0)),[G,q]=c.useState(null),[B,k]=c.useState(null),[N,F]=c.useState(""),_=c.useRef(0),R=c.useRef(0),C=c.useRef(n);c.useEffect(()=>{C.current!==n&&(C.current=n,R.current++);const o=Y(m,{maxAgeMs:ue}),d=Y(s,{maxAgeMs:me}),p=Array.isArray(o)&&o.length>0;M(Array.isArray(o)?o:[]),A(d??null),w(null),L(!p),r.current=p},[n,m,s]);const S=c.useCallback(async(o=N)=>{const d=++_.current,p=n;r.current||L(!0),q(null),k(null);try{const y=await Se({q:o||void 0,limit:100},p);if(d!==_.current||p!==n)return;M(y.runs),ce(m,y.runs,{maxBytes:5e5}),r.current=!0,H(y.availability),h&&!y.runs.some(g=>g.id===h)&&(A(null),ce(s,null,{maxBytes:5e5}),w(null))}catch(y){if(d!==_.current||p!==n)return;const g=le(y,"Failed to load research runs");q(g.message),k(g)}finally{d===_.current&&L(!1)}},[n,m,N,s,h]),i=c.useCallback(async o=>{const d=await _e(o,n);return w(d.run),H(d.availability),d.run},[n]);c.useEffect(()=>{r.current||L(!0);const o=window.setTimeout(()=>{S(N)},Ge);return()=>window.clearTimeout(o)},[S,N]),c.useEffect(()=>{if(!h){w(null);return}i(h)},[i,h]),c.useEffect(()=>{const o=R.current,d=()=>R.current!==o,p=n?`?projectId=${encodeURIComponent(n)}`:"";let y=!0;const g=()=>{!y||d()||(S(),h&&i(h))},j=`/api/events${p}`,$=je(j,{events:{"research:run:created":g,"research:run:updated":g,"research:run:completed":g,"research:run:failed":g,"research:run:cancelled":g},onReconnect:()=>{X({view:"useResearch",trigger:"sse-reconnect",projectId:n,replayAttempted:!1,sseChannel:j}),g()}});return X({view:"useResearch",trigger:"sse-open",projectId:n,replayAttempted:!1,sseChannel:j}),()=>{y=!1,$()}},[n,S,h,i]);const E=c.useCallback(()=>{S(),h&&i(h)},[S,h,i]);we(E,Be);const T=c.useCallback(o=>{A(o),ce(s,o,{maxBytes:5e5})},[s]);return{runs:D,selectedRun:P,selectedRunId:h,setSelectedRunId:T,availability:O,loading:V,error:G,searchQuery:N,setSearchQuery:F,refresh:S,createRun:o=>Pe(o,n),cancelRun:async o=>{try{k(null);const d=await Te(o,n);return h===o&&w(d.run),await S(),d}catch(d){const p=le(d,"Failed to cancel run");throw k(p),p}},retryRun:async o=>{try{k(null);const d=await Ae(o,n);return h===o&&w(d.run),await S(),d}catch(d){const p=le(d,"Failed to retry run");throw k(p),p}},exportRun:(o,d)=>Ee(o,d,n),createTaskFromRun:(o,d,p,y,g,j)=>Ce(o,{title:d,findingId:p,description:y,priority:g,attachExport:j},n),attachRunToTask:(o,d,p,y)=>Ne(o,{taskId:d,findingId:p,attachExport:y},n),promoteFinding:(o,d)=>ke(o,d,n),uiError:B,runActionState:ze(P),statusCounts:D.reduce((o,d)=>(o[d.status]+=1,o),{queued:0,running:0,cancelling:0,retry_waiting:0,completed:0,failed:0,cancelled:0,timed_out:0,retry_exhausted:0})}}function Ye({open:a,mode:n,run:l,finding:m,projectId:s,onClose:f,onConfirm:x}){const{t:r}=fe("app");Fe(a);const[D,M]=c.useState(!1),[h,A]=c.useState(""),[P,w]=c.useState(""),[O,H]=c.useState("normal"),[V,L]=c.useState(""),[G,q]=c.useState([]),[B,k]=c.useState(!1),[N,F]=c.useState(!1),{boardWorkflows:_}=Ie({projectId:s}),R=c.useMemo(()=>{const i=new Map;for(const E of _?.workflows??[])for(const T of E.columns)i.has(T.id)||i.set(T.id,T.flags);return E=>Me(i.get(E),E)},[_]),C=c.useMemo(()=>{const i=(m.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${m.heading||r("research.defaultFindingHeading","Research finding")} — ${i}`.trim()},[m.content,m.heading,r]);c.useEffect(()=>{a&&(M(!1),A(`Research: ${m.heading||l.title}`),w(C),H("normal"),L(""))},[a,n,m.heading,C,l.title]),c.useEffect(()=>{if(!a||n!=="enrich")return;let i=!1;return q([]),k(!0),De(50,0,s).then(E=>{i||q(E.filter(T=>!R(T.column)))}).finally(()=>{i||k(!1)}),()=>{i=!0}},[a,n,s,R]);const S=V.trim();return a?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:f,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n==="create"?r("research.createTaskTitle","Create task from finding"):r("research.enrichTaskTitle","Enrich existing task")}),e.jsx("button",{className:"modal-close",type:"button","aria-label":r("actions.close","Close"),onClick:f,children:"×"})]}),e.jsxs("div",{className:"research-task-action-modal__body",children:[e.jsxs("div",{className:"card research-task-action-modal__preview",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.runLabel","Run:")," "]})," ",l.id]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[r("research.findingLabel","Finding:")," "]})," ",m.id,m.heading?` — ${m.heading}`:""]}),e.jsx("p",{children:C||r("research.noPreview","No preview available.")})]}),n==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.titleLabel","Title"),e.jsx("input",{className:"input",value:h,onChange:i=>A(i.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.descriptionLabel","Description"),e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:P,onChange:i=>w(i.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.priorityLabel","Priority"),e.jsxs("select",{className:"select",value:O,onChange:i=>H(i.target.value),children:[e.jsx("option",{value:"low",children:r("research.priorityLow","Low")}),e.jsx("option",{value:"normal",children:r("research.priorityNormal","Normal")}),e.jsx("option",{value:"high",children:r("research.priorityHigh","High")}),e.jsx("option",{value:"urgent",children:r("research.priorityUrgent","Urgent")})]})]})]}):e.jsxs("label",{className:"research-task-action-modal__field",children:[r("research.targetTaskLabel","Target task"),e.jsx("input",{className:"input",list:"research-task-action-task-list",value:V,placeholder:B?r("research.loadingTasks","Loading tasks…"):r("research.enterTaskId","Enter task ID"),onChange:i=>L(i.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:G.map(i=>e.jsx("option",{value:i.id,children:i.title},i.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:i=>M(i.target.checked)}),e.jsx("span",{children:r("research.attachExport","Attach markdown export artifact")})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:f,children:r("actions.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:N||n==="enrich"&&!S,onClick:()=>{F(!0),x({taskId:n==="enrich"?S:void 0,title:n==="create"?h.trim():void 0,description:n==="create"?P.trim():void 0,priority:n==="create"?O:void 0,attachExport:D}).finally(()=>F(!1))},children:n==="create"?r("research.createTaskButton","Create Task"):r("research.enrichTaskButton","Enrich Task")})]})]})}):null}const Qe=["web-search","page-fetch","github","local-docs","llm-synthesis"],Xe={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"};function Je(a){return{"web-search":a("research.providerWebSearch","Web Search"),"page-fetch":a("research.providerPageFetch","Page Fetch"),github:a("research.providerGitHub","GitHub"),"local-docs":a("research.providerLocalDocs","Local Docs"),"llm-synthesis":a("research.providerLlmSynthesis","LLM Synthesis")}}let oe=!1;function cs({projectId:a,addToast:n,onOpenSettings:l,readinessVersion:m=0}){const{t:s}=fe("app"),f=Je(s);c.useEffect(()=>(X({view:"ResearchView",trigger:oe?"route-active":"remount",projectId:a,replayAttempted:!1}),oe=!1,()=>{oe=!0,X({view:"ResearchView",trigger:"route-inactive",projectId:a,replayAttempted:!1})}),[a]);const{runs:x,selectedRun:r,selectedRunId:D,setSelectedRunId:M,availability:h,loading:A,error:P,searchQuery:w,setSearchQuery:O,createRun:H,cancelRun:V,retryRun:L,exportRun:G,createTaskFromRun:q,attachRunToTask:B,promoteFinding:k,statusCounts:N,refresh:F,uiError:_,runActionState:R}=Ke({projectId:a}),[C,S]=c.useState(""),[i,E]=c.useState(()=>ie(void 0)),[T,o]=c.useState([]),[d,p]=c.useState(!1),[y,g]=c.useState([]),[j,$]=c.useState(null),[U,K]=c.useState(null),[J,ve]=c.useState(""),Z=h.supportedProviders??Qe,ee=i.searchProvider,se=t=>t==="web-search"?!0:i.enabledSources[Xe[t]];c.useEffect(()=>{const t=Z.filter(u=>se(u));g(u=>{const b=u.filter(v=>t.includes(v));return b.length>0?b:t})},[i.enabledSources,Z]),c.useEffect(()=>{let t=!1;return Promise.all([He(a),qe().catch(()=>({providers:[]}))]).then(([u,b])=>{t||(E(ie(u)),o(b.providers.filter(v=>v.type==="api_key").map(v=>({id:v.id,authenticated:v.authenticated}))))}).catch(()=>{t||E(ie(void 0))}),()=>{t=!0}},[a,m]);const xe=c.useMemo(()=>r?r.status:s("research.noRunSelected","No run selected"),[r,s]),ye=c.useMemo(()=>r?r.status==="queued"||r.status==="retry_waiting"?"status-dot status-dot--pending":r.status==="running"?"status-dot status-dot--connecting":r.status==="completed"?"status-dot status-dot--online":r.status==="failed"||r.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[r]),re=h.supportedExportFormats??["markdown","json","html"],te=c.useMemo(()=>new Map(T.map(t=>[t.id,t.authenticated])),[T]),ae=c.useMemo(()=>{const t=new Set;return i.enabledSources.webSearch&&ee&&t.add(ee),i.enabledSources.llmSynthesis&&i.synthesisProvider&&t.add(i.synthesisProvider),[...t].filter(u=>te.has(u))},[i.enabledSources.llmSynthesis,i.enabledSources.webSearch,i.synthesisProvider,ee,te]).find(t=>te.get(t)!==!0),W=c.useMemo(()=>h.available?i.enabled?ae?{reason:s("research.missingApiKey","Missing API key for {{provider}}.",{provider:ae}),details:s("research.addCredentialsHint","Add provider credentials in Authentication settings."),settingsSection:"authentication"}:null:{reason:s("research.disabled","Research is disabled for this project."),details:s("research.enableResearchHint","Enable project research settings to create runs."),settingsSection:"research-project"}:{reason:h.reason??s("research.unavailable","Research is unavailable for this project."),details:h.setupInstructions,settingsSection:"research-project"},[h.available,h.reason,h.setupInstructions,i.enabled,ae,s]),z=async(t,u,b)=>{$(t);try{await u(),n?.(b,"success"),await F()}catch(v){n?.(v instanceof Error?v.message:s("research.actionFailed","Action failed"),"error")}finally{$(null)}},ne=async t=>{if(r){$(`export-${t}`);try{const u=await G(r.id,t),b=new Blob([u.content],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(b),I=document.createElement("a");I.href=v,I.download=u.filename,document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(v),n?.(s("research.exportedFile","Exported {{filename}}",{filename:u.filename}),"success")}catch(u){n?.(u instanceof Error?u.message:s("research.exportFailed","Export failed"),"error")}finally{$(null)}}},ge=async()=>{if(C.trim()){p(!0);try{const t=y.filter(b=>se(b));if(t.length===0){p(!1),n?.(s("research.noSourcesAvailable","No enabled research sources are available for this project."),"error");return}const u=await H({query:C.trim(),providers:t});M(u.run.id),S(""),n?.(s("research.runCreated","Research run created"),"success"),await F()}catch(t){n?.(t instanceof Error?t.message:s("research.createRunFailed","Failed to create run"),"error")}finally{p(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":s("research.viewLabel","Research view"),children:[e.jsx(Ue,{icon:pe,title:s("research.title","Research"),actions:e.jsx("button",{className:"btn",type:"button",onClick:()=>void F(),children:s("actions.refresh","Refresh")})}),e.jsx("p",{className:"research-view__subtitle",children:s("research.subtitle","Cited search and synthesis runs: gather sources, fetch content, and synthesize findings.")}),W?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:W.reason}),W.details&&e.jsx("p",{children:W.details}),e.jsx("p",{children:s("research.currentDefaults","Current defaults: provider {{provider}}, max sources {{maxSources}}",{provider:i.searchProvider??s("research.notSet","(not set)"),maxSources:i.limits.maxSourcesPerRun})}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void F(),children:s("actions.refresh","Refresh")}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>l?.(W.settingsSection),children:s("actions.openSettings","Open Settings")})]})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"research-view__layout",children:[e.jsx("aside",{className:"research-view__sidebar card",children:e.jsxs("div",{className:"research-view__sidebar-content",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:s("research.queryLabel","Query")}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:C,onChange:t=>S(t.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:s("research.providersLabel","Providers")}),e.jsx("div",{className:"research-view__providers",children:Z.map(t=>{const u=se(t),b=t==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:b||y.includes(t),disabled:b||!u,onChange:()=>{b||!u||g(v=>v.includes(t)?v.filter(I=>I!==t):[...v,t])}}),e.jsxs("span",{children:[f[t]??t,b?e.jsx("span",{className:"research-view__provider-lock",children:s("research.alwaysOn","Always on")}):null]})]},t)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!C.trim()||d,onClick:()=>void ge(),children:[d?e.jsx(Oe,{className:"animate-spin",size:14}):null,s("research.createRun","Create Run")]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:s("actions.search","Search")}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(pe,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:s("research.searchRunsPlaceholder","Search runs"),value:w,onChange:t=>O(t.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:x.map(t=>e.jsxs("button",{type:"button",className:`research-view__history-item card${D===t.id?" research-view__history-item--active":""}`,onClick:()=>M(t.id),children:[e.jsx("span",{className:"card-id",children:t.id}),e.jsx("span",{children:t.title})]},t.id))})]})}),e.jsxs("div",{className:"research-view__reader card",children:[A&&e.jsx("p",{"data-testid":"research-state-loading",children:e.jsx(Ve,{label:s("research.loadingRuns","Loading research runs…")})}),!A&&P&&e.jsx("p",{"data-testid":"research-state-error",children:P}),!A&&!P&&x.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:s("research.noRunsYet","No research runs yet")}),e.jsxs("div",{className:"research-view__reader-content",children:[r&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:ye}),e.jsx("strong",{children:xe})]}),e.jsx("h3",{className:"research-view__run-title",children:r.title}),e.jsx("p",{className:"research-view__run-query",children:r.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:r.results?.summary??s("research.noSummaryYet","No summary yet.")}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",title:R.cancelable?void 0:R.blockingReason,disabled:j==="cancel"||j==="retry"||!R.cancelable,onClick:()=>void z("cancel",()=>V(r.id),s("research.runCancelled","Run cancelled")),children:s("actions.cancel","Cancel")}),e.jsx("button",{className:"btn",type:"button",title:R.retryable?void 0:R.blockingReason,disabled:j==="cancel"||j==="retry"||!R.retryable,onClick:()=>void z("retry",()=>L(r.id),s("research.runRetried","Run retried")),children:s("actions.retry","Retry")}),re.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void ne("markdown"),children:s("research.exportMd","Export MD")}),re.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void ne("json"),children:s("research.exportJson","Export JSON")}),re.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void ne("html"),children:s("research.exportHtml","Export HTML")})]}),r.error&&e.jsx("p",{className:"research-view__error",children:r.error}),_&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:_.message}),_.setupHint&&e.jsx("p",{children:_.setupHint}),_.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l?.("authentication"),children:s("research.openAuthSettings","Open Authentication Settings")}),_.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l?.("research-project"),children:s("research.openResearchSettings","Open Research Settings")})]}),R.blockingReason&&e.jsx("p",{className:"research-view__run-query",children:R.blockingReason}),Array.isArray(r.results?.findings)&&r.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:r.results.findings.map(t=>{const u=be(t);return e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:t.heading}),e.jsx("p",{children:t.content}),e.jsxs("div",{className:"research-view__actions research-view__finding-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",type:"button",onClick:()=>K({mode:"create",findingId:u}),children:s("research.createTask","Create Task")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>K({mode:"enrich",findingId:u}),children:s("research.enrichTask","Enrich Task")}),e.jsx("input",{className:"input","aria-label":s("research.destinationSlice","Destination slice ID"),value:J,onChange:b=>ve(b.target.value),placeholder:s("research.destinationSlice","Destination slice ID")}),e.jsx("button",{className:"btn btn-sm",type:"button",disabled:r.status!=="completed"||!J.trim()||j===`promote-${u}`,onClick:()=>void z(`promote-${u}`,()=>k(r.id,{findingId:u,sliceId:J.trim()}),s("research.findingPromoted","Finding promoted to roadmap")),children:s("research.promoteFinding","Promote to roadmap")})]})]},u)})}),Array.isArray(r.results?.citations)&&r.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:r.results.citations.map(t=>e.jsx("li",{children:e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:t})},t))}),r.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("research.runHistory","Run history")}),e.jsx("ul",{className:"research-view__events",children:r.events.map(t=>e.jsx("li",{children:t.message},t.id))})]})]}),!r&&x.length>0&&e.jsx("p",{children:s("research.selectRunToViewDetails","Select a run to view details.")}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statRunning","Running")}),e.jsx("div",{className:"research-view__stat-value",children:N.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statCompleted","Completed")}),e.jsx("div",{className:"research-view__stat-value",children:N.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:s("research.statFailed","Failed")}),e.jsx("div",{className:"research-view__stat-value",children:N.failed})]})]})]})]})]})}),r&&U&&(()=>{const t=r.results?.findings?.findIndex(b=>be(b)===U.findingId)??-1,u=t>=0?r.results.findings[t]:null;return u?e.jsx(Ye,{open:!0,mode:U.mode,run:r,finding:{id:U.findingId,heading:u.heading,content:u.content},projectId:a,onClose:()=>K(null),onConfirm:async({taskId:b,title:v,description:I,priority:Re,attachExport:de})=>{U.mode==="create"?await z("create-task",()=>q(r.id,v,U.findingId,I,Re,de),s("research.taskCreatedFromResearch","Task created from research")):b&&await z("attach-task",()=>B(r.id,b,U.findingId,de),s("research.taskEnrichedFromResearch","Task enriched from research")),K(null)}}):null})()]})}export{cs as ResearchView};