@lovelybunch/api 1.0.76-alpha.8 → 1.0.76

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 (185) hide show
  1. package/dist/lib/git.d.ts +3 -0
  2. package/dist/lib/git.js +35 -0
  3. package/dist/routes/api/v1/ai/route.js +214 -152
  4. package/dist/routes/api/v1/config/route.js +13 -9
  5. package/dist/routes/api/v1/context/agents/route.js +159 -0
  6. package/dist/routes/api/v1/context/index.js +6 -4
  7. package/dist/routes/api/v1/context/memory/route.js +163 -0
  8. package/dist/routes/api/v1/context/team/route.js +159 -0
  9. package/dist/routes/api/v1/git/index.js +27 -1
  10. package/dist/routes/api/v1/jobs/[id]/route.d.ts +26 -32
  11. package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
  12. package/dist/routes/api/v1/jobs/route.d.ts +33 -33
  13. package/dist/routes/api/v1/jobs/route.js +17 -2
  14. package/dist/routes/api/v1/mcp/index.js +194 -21
  15. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  16. package/package.json +4 -4
  17. package/static/assets/ActivityPage-sJEQn6DK.js +1 -0
  18. package/static/assets/AgentsContextEditPage-DU3qIXk9.js +9 -0
  19. package/static/assets/AgentsContextPage-tJ-LhFYb.js +1 -0
  20. package/static/assets/{ApiKeysSettingsPage-BhaH6ZYP.js → ApiKeysSettingsPage-Bg84BQHV.js} +2 -2
  21. package/static/assets/{AuthSettingsPage-D0MQlHyh.js → AuthSettingsPage-Bwr7uP3z.js} +1 -1
  22. package/static/assets/{CallbackPage-Bz4m3_W8.js → CallbackPage-BFn0Np2S.js} +1 -1
  23. package/static/assets/CodePage-kp4s3wCJ.js +2 -0
  24. package/static/assets/{CollapsibleSection-CxX11hr-.js → CollapsibleSection-CNs1mvsZ.js} +1 -1
  25. package/static/assets/{DashboardPage-B3HR1UM7.js → DashboardPage-DMJSzzgD.js} +9 -19
  26. package/static/assets/{GitPage-Dm36PRw_.js → GitPage-uqene8zj.js} +3 -3
  27. package/static/assets/{GitSettingsPage-CRWcjgVI.js → GitSettingsPage-CLswbZsT.js} +2 -2
  28. package/static/assets/{IdentityPage-YCkmdyzR.js → IdentityPage-BDTPXEo7.js} +2 -2
  29. package/static/assets/{ImplementationStepsEditor-u3dPxmKW.js → ImplementationStepsEditor-D4cvhPhz.js} +2 -2
  30. package/static/assets/IntegrationsSettingsPage-o7NXZGt9.js +1 -0
  31. package/static/assets/JobDetailPage-DuEiPz6X.js +1 -0
  32. package/static/assets/KnowledgeDetailPage-DFVud_VC.js +1 -0
  33. package/static/assets/{KnowledgeEditPage-DhrF6UPg.js → KnowledgeEditPage-XG6HKK7E.js} +1 -1
  34. package/static/assets/{KnowledgePage-_gZhpTe3.js → KnowledgePage-B2zI3xwW.js} +2 -2
  35. package/static/assets/{LoginPage-Cc1Ac2j4.js → LoginPage-CUJRxwXy.js} +1 -1
  36. package/static/assets/MailInboxPage-BlCG-tba.js +1 -0
  37. package/static/assets/MailProcessingModal-BJIdHOqK.js +1 -0
  38. package/static/assets/MailReadPage-MoNo_gmW.js +1 -0
  39. package/static/assets/{MailSentPage-Dj63oQ5D.js → MailSentPage-QzpuIJmT.js} +1 -1
  40. package/static/assets/{McpSettingsPage-DYZ0QNbp.js → McpSettingsPage-BZcCGkGM.js} +1 -1
  41. package/static/assets/MemoryEditPage-DXSQoCT4.js +13 -0
  42. package/static/assets/MemoryPage-oBnyuvSf.js +1 -0
  43. package/static/assets/NewKnowledgePage-deMsezK8.js +1 -0
  44. package/static/assets/{NewSkillPage-BEn18f2A.js → NewSkillPage-DRYWdrlV.js} +1 -1
  45. package/static/assets/{NewTaskPage-CSlncpI5.js → NewTaskPage-B6xdic5_.js} +2 -2
  46. package/static/assets/{NotFoundPage-C4x0lGai.js → NotFoundPage-Bxu9uKFO.js} +1 -1
  47. package/static/assets/{NotificationsSettingsPage-C9YnfRlj.js → NotificationsSettingsPage-CLgtsCVM.js} +1 -1
  48. package/static/assets/{PromptsSettingsPage-Chc4da1S.js → PromptsSettingsPage-BWaELCjG.js} +1 -1
  49. package/static/assets/{ResourceDetailPage-DDYKQxpM.js → ResourceDetailPage-CMPDRdVM.js} +1 -1
  50. package/static/assets/ResourcesPage-DspYILfG.js +41 -0
  51. package/static/assets/{RoleEditPage-Ccfu1tn1.js → RoleEditPage-DXtzicVZ.js} +1 -1
  52. package/static/assets/{RolePage-CcdEUjSm.js → RolePage-DafGURGp.js} +1 -1
  53. package/static/assets/{RulesSettingsPage-Cz1g_eAj.js → RulesSettingsPage-E8V9cexV.js} +1 -1
  54. package/static/assets/RunDetailPage-DsxkqFst.js +1 -0
  55. package/static/assets/SchedulePage-B2YvNDHr.js +4 -0
  56. package/static/assets/{SkillDetailPage-sJg-L8A8.js → SkillDetailPage-CWkqSfuT.js} +1 -1
  57. package/static/assets/{SkillEditPage-BksV7GmD.js → SkillEditPage-DwyebzFV.js} +1 -1
  58. package/static/assets/{SkillsPage-CwarkJmZ.js → SkillsPage-CauK65X_.js} +2 -2
  59. package/static/assets/{SkillsSettingsPage-DTnBlBdE.js → SkillsSettingsPage-DXMRv3jR.js} +1 -1
  60. package/static/assets/{SourceInput-CWazIr6v.js → SourceInput-C0iKqbQ1.js} +1 -1
  61. package/static/assets/{TagInput-Bgyxb_JU.js → TagInput-Ct-WRvTs.js} +1 -1
  62. package/static/assets/{TaskDetailPage-DlmG1kZR.js → TaskDetailPage-CApk2iBh.js} +1 -1
  63. package/static/assets/{TaskEditPage-BnpNeed_.js → TaskEditPage-NgOVShfK.js} +1 -1
  64. package/static/assets/{TasksPage-CXeTMpgy.js → TasksPage-BoPrP_Rl.js} +3 -3
  65. package/static/assets/TeamEditPage-ChY6mYm8.js +9 -0
  66. package/static/assets/TeamPage-DH-dJhFG.js +1 -0
  67. package/static/assets/{TerminalPage-BLcPt381.js → TerminalPage-CRhcscF2.js} +1 -1
  68. package/static/assets/TerminalSessionPage-CSCQg2sn.js +3 -0
  69. package/static/assets/{UserPreferencesPage-BNwEqlRW.js → UserPreferencesPage-DxCSWJnS.js} +1 -1
  70. package/static/assets/{UserSettingsPage-BRafqkiD.js → UserSettingsPage-DKkOLNPV.js} +1 -1
  71. package/static/assets/UtilitiesPage-CBNSvixW.js +1 -0
  72. package/static/assets/{alert-Ci2-OWZ_.js → alert-Dw_RSroN.js} +1 -1
  73. package/static/assets/{arrow-down-C6Flf0DF.js → arrow-down-UClxXzT-.js} +1 -1
  74. package/static/assets/{arrow-left-7TCkaJlN.js → arrow-left-DWmf9YJp.js} +1 -1
  75. package/static/assets/{arrow-up-down-tqbfiBy6.js → arrow-up-down-Btc3okb3.js} +1 -1
  76. package/static/assets/{arrow-up-DeQAxOPq.js → arrow-up-fLCh7Hvh.js} +1 -1
  77. package/static/assets/{badge-D4vHU_w_.js → badge-vIqE5SOP.js} +1 -1
  78. package/static/assets/{browser-modal-BiaqhKHm.js → browser-modal-DgMJTsMd.js} +2 -2
  79. package/static/assets/{card-xkODbJy-.js → card-DPLdBoa5.js} +1 -1
  80. package/static/assets/{chevron-left-CvpfJBPQ.js → chevron-left-CiNaLX-v.js} +1 -1
  81. package/static/assets/{chevron-up-BB-6OS4z.js → chevron-up-DFd-7wxW.js} +1 -1
  82. package/static/assets/{chevrons-up-CLKrQHMU.js → chevrons-up-BfU70OcQ.js} +1 -1
  83. package/static/assets/{circle-alert-lnP0-w3N.js → circle-alert-Mv00T-P2.js} +1 -1
  84. package/static/assets/{circle-check-big-Dbo-OmWQ.js → circle-check-big-BEY1IoIP.js} +1 -1
  85. package/static/assets/{circle-check-BPkEav83.js → circle-check-xMiP6SLO.js} +1 -1
  86. package/static/assets/{circle-play-BbtBIeo3.js → circle-play-iZZwaGbV.js} +1 -1
  87. package/static/assets/{circle-x-BBwi8e5G.js → circle-x-z3iynaE7.js} +1 -1
  88. package/static/assets/{clipboard-Ce816tAO.js → clipboard-C8wZRPDH.js} +1 -1
  89. package/static/assets/{clock-BIeoO5Mt.js → clock-C_9shc08.js} +1 -1
  90. package/static/assets/{code-DTW3giBe.js → code-DH-sRhus.js} +1 -1
  91. package/static/assets/{download-BgKxfry9.js → download-CE8b59ER.js} +1 -1
  92. package/static/assets/{external-link--RjKXREe.js → external-link-DPyKt8NE.js} +1 -1
  93. package/static/assets/{eye--K-OgK7L.js → eye-BpGD-yoS.js} +1 -1
  94. package/static/assets/{folder-git-2-Bgv7r0zC.js → folder-git-2-BIw4zbmy.js} +1 -1
  95. package/static/assets/globe-CUo7eHKN.js +6 -0
  96. package/static/assets/{index-Di7xMYoG.js → index-B07hel4U.js} +1 -1
  97. package/static/assets/{index-DF_KNbKf.js → index-BCwmQxLC.js} +1 -1
  98. package/static/assets/{index-D9xZafJb.js → index-BOKaM9K-.js} +1 -1
  99. package/static/assets/{index-Cd5hBt4x.js → index-BaR4iUzg.js} +1 -1
  100. package/static/assets/index-BcCuKdbf.css +1 -0
  101. package/static/assets/{index-Db5-BoCU.js → index-Bfb3OTwj.js} +1 -1
  102. package/static/assets/{index-Do92mBFr.js → index-Bkt1rQVV.js} +1 -1
  103. package/static/assets/{index-BD9UBXsr.js → index-C65b3D5_.js} +1 -1
  104. package/static/assets/{index-BbrX1XcC.js → index-CGbmjmEy.js} +1 -1
  105. package/static/assets/{index-4RuWYO4M.js → index-CTouvf2d.js} +1 -1
  106. package/static/assets/{index-Dt_WtbUU.js → index-Cdwx6Zps.js} +1 -1
  107. package/static/assets/{index-iIFwHD3L.js → index-ClO9-JVh.js} +1 -1
  108. package/static/assets/{index-BteQHbZ1.js → index-CpJ0uBf3.js} +1 -1
  109. package/static/assets/{index-LMsLdXw_.js → index-CsBxEWw5.js} +1 -1
  110. package/static/assets/{index-CW9pK_cZ.js → index-DZAYfTI2.js} +1 -1
  111. package/static/assets/{index-BkEdELOI.js → index-Dkr9CBL7.js} +1 -1
  112. package/static/assets/{index-BQYB8kWb.js → index-DnZKG-_7.js} +1 -1
  113. package/static/assets/index-UXL5-kaP.js +497 -0
  114. package/static/assets/{index-Ch4GVR8L.js → index-iB8oed57.js} +1 -1
  115. package/static/assets/{index-R44k73Ca.js → index-jaRIZ6SY.js} +1 -1
  116. package/static/assets/{info-DgZN3xWF.js → info-D-UNBNx2.js} +1 -1
  117. package/static/assets/{label-DvPENm3h.js → label-8VKluf9w.js} +1 -1
  118. package/static/assets/{markdown-editor-DpZxV-fa.js → markdown-editor-DBdRsbP2.js} +3 -3
  119. package/static/assets/{message-square-CoaQYehb.js → message-square-CO8kDUed.js} +1 -1
  120. package/static/assets/{paperclip-ChugoOAp.js → paperclip-DlLXZbru.js} +1 -1
  121. package/static/assets/{pause-m9YcgxdE.js → pause-zSiaxJBu.js} +1 -1
  122. package/static/assets/{play-DtFz_MLh.js → play-DVBhRokt.js} +1 -1
  123. package/static/assets/{radio-group-C5Te9bVb.js → radio-group-CThYUcA4.js} +1 -1
  124. package/static/assets/{refresh-cw-B1bWW9Rg.js → refresh-cw-tXYl1ePu.js} +1 -1
  125. package/static/assets/{search-CPOHeeUa.js → search-BxF7Wwex.js} +1 -1
  126. package/static/assets/{select-B1v2u6hQ.js → select-CyHFRA1Y.js} +1 -1
  127. package/static/assets/server-lRxThHjr.js +6 -0
  128. package/static/assets/{switch-Bf1Cq3P6.js → switch-BUpDbrux.js} +1 -1
  129. package/static/assets/tabs-DkvCmQEX.js +1 -0
  130. package/static/assets/{tag-Cz4z82t0.js → tag-CkcZNLnh.js} +1 -1
  131. package/static/assets/{terminal-preview-DTUohQ5b.js → terminal-preview-CLWDhoOZ.js} +1 -1
  132. package/static/assets/triangle-alert-CmjG_mbF.js +6 -0
  133. package/static/assets/{use-terminal-CFbQv1ie.js → use-terminal-D3iV7-iC.js} +1 -1
  134. package/static/assets/{video-B6ZJ-Epb.js → video-CY_dOujm.js} +1 -1
  135. package/static/index.html +2 -2
  136. package/dist/lib/mcp-client.d.ts +0 -39
  137. package/dist/lib/mcp-client.js +0 -131
  138. package/dist/routes/api/v1/ai/tools.d.ts +0 -17
  139. package/dist/routes/api/v1/ai/tools.js +0 -931
  140. package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts +0 -1
  141. package/dist/routes/api/v1/context/knowledge/[filename]/index.js +0 -1
  142. package/dist/routes/api/v1/context/knowledge/[filename]/route.js +0 -254
  143. package/dist/routes/api/v1/context/knowledge/index.d.ts +0 -1
  144. package/dist/routes/api/v1/context/knowledge/index.js +0 -1
  145. package/dist/routes/api/v1/context/knowledge/route.js +0 -176
  146. package/dist/routes/api/v1/proposals/[id]/route.d.ts +0 -337
  147. package/dist/routes/api/v1/proposals/[id]/route.js +0 -165
  148. package/dist/routes/api/v1/proposals/index.d.ts +0 -3
  149. package/dist/routes/api/v1/proposals/index.js +0 -10
  150. package/dist/routes/api/v1/proposals/route.d.ts +0 -315
  151. package/dist/routes/api/v1/proposals/route.js +0 -129
  152. package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts +0 -3
  153. package/dist/routes/api/v1/terminal/[proposalId]/create/index.js +0 -5
  154. package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts +0 -10
  155. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +0 -27
  156. package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js +0 -5
  157. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts +0 -10
  158. package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js +0 -21
  159. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts +0 -3
  160. package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js +0 -5
  161. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts +0 -10
  162. package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js +0 -21
  163. package/static/assets/ActivityPage-uL-Qknui.js +0 -1
  164. package/static/assets/ArchitectureEditPage-BWKyKi3T.js +0 -21
  165. package/static/assets/ArchitecturePage-Dtm0OAac.js +0 -1
  166. package/static/assets/CodePage-BuO2K_xx.js +0 -2
  167. package/static/assets/IntegrationsSettingsPage-Z8xCUmX9.js +0 -1
  168. package/static/assets/JobDetailPage-B8Za82RA.js +0 -1
  169. package/static/assets/KnowledgeDetailPage-CR9c4_WD.js +0 -1
  170. package/static/assets/MailInboxPage-B_h1Kz4D.js +0 -1
  171. package/static/assets/MailProcessingModal-D_qEwqmL.js +0 -6
  172. package/static/assets/MailReadPage-_q-xk_cX.js +0 -1
  173. package/static/assets/NewKnowledgePage-BEVMYnKG.js +0 -9
  174. package/static/assets/ProjectEditPage-X0-4mEAS.js +0 -11
  175. package/static/assets/ProjectPage-D8OX1GKt.js +0 -1
  176. package/static/assets/ResourcesPage-BmOpgt3L.js +0 -41
  177. package/static/assets/SchedulePage-CGxZHEL-.js +0 -4
  178. package/static/assets/TerminalSessionPage-CeAd8IAy.js +0 -8
  179. package/static/assets/UtilitiesPage-BPX_Unxu.js +0 -1
  180. package/static/assets/index-DH_vXhd4.css +0 -1
  181. package/static/assets/index-PyVlsLW8.js +0 -487
  182. package/static/assets/tabs-DAbCZiFC.js +0 -1
  183. /package/dist/routes/api/v1/context/{knowledge/[filename] → agents}/route.d.ts +0 -0
  184. /package/dist/routes/api/v1/context/{knowledge → memory}/route.d.ts +0 -0
  185. /package/dist/routes/api/v1/{terminal/[proposalId]/destroy/index.d.ts → context/team/route.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ import{u as ce,a as de,r as i,j as e,B as r,T as oe,n as M,X as me,F as xe,_ as he,D as ue,b as fe,d as pe,f as je,k as ge,a4 as B,a5 as R,a6 as H,a7 as L,a8 as O,a9 as _,o as ve,A as T}from"./index-UXL5-kaP.js";import{C as g,b as Ne,a as G,c as ye}from"./card-DPLdBoa5.js";import{B as U}from"./badge-vIqE5SOP.js";import{u as we}from"./use-terminal-D3iV7-iC.js";import{T as Se}from"./terminal-preview-CLWDhoOZ.js";import{S as Ce,a as be,b as ke,c as Ae,d as w}from"./select-CyHFRA1Y.js";import{b as De,e as Me,d as Te,c as Ie,a as $e}from"./pipeline-builders-Bkf0wt_O.js";import{R as Ee}from"./refresh-cw-tXYl1ePu.js";import{C as Pe,a as ze}from"./chevrons-up-BfU70OcQ.js";import{P as Fe}from"./play-DVBhRokt.js";import{C as Be}from"./code-DH-sRhus.js";import{C as Re}from"./chevron-up-DFd-7wxW.js";import{S as He}from"./server-lRxThHjr.js";import"./xterm-DTxiCjtJ.js";import"./index-DnZKG-_7.js";const Le=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function ts(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:S,createSession:V,destroySession:K}=we(),{toast:v}=de(),[$,W]=i.useState([]),[q,X]=i.useState(!0),[j,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[f,J]=i.useState("claude"),[E,Q]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[p,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{S()},[S]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.id,name:l?.metadata?.name||l.id,mcpServers:Le(l?.metadata?.metadata?.mcpServers)}));se(d),C(l=>l.filter(F=>d.some(le=>le.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.mcpServers.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>j[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>j[s.id]),ne=async s=>{await K(s)?(v({title:"Session closed",description:s}),setTimeout(()=>S(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},re=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:f,mcpServersMap:Z,selectedMcpServers:p,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";f==="claude"?a=De(t):f==="gemini"?a=Me(t):f==="codex"?a=Te(t):f==="droid"?a=Ie(t):f==="kiro"&&(a=$e(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>S(),disabled:b,children:[e.jsx(Ee,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(Be,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":j[s.id]?"Hide preview":"Show preview",title:j[s.id]?"Hide preview":"Show preview",children:j[s.id]?e.jsx(Re,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(me,{className:"h-4 w-4"})})]})]}),j[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(Se,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(Ne,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(G,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(G,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ye,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
2
+ `).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(xe,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(he,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(ue,{open:A,onOpenChange:N,children:e.jsxs(fe,{className:"max-w-lg",children:[e.jsxs(pe,{children:[e.jsx(je,{children:"Start Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Agent"}),e.jsxs(Ce,{value:f,onValueChange:s=>J(s),children:[e.jsx(be,{className:"w-full",children:e.jsx(ke,{placeholder:"Select coding agent"})}),e.jsxs(Ae,{children:[e.jsx(w,{value:"claude",children:"Claude Code"}),e.jsx(w,{value:"gemini",children:"Google Gemini"}),e.jsx(w,{value:"codex",children:"OpenAI Codex"}),e.jsx(w,{value:"droid",children:"Factory Droid"}),e.jsx(w,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C(u.map(t=>t.id))},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(_,{checked:o.includes(s.id),onCheckedChange:t=>{C(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[p.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[p.length===0?"Select MCP servers...":p.length===h.length?"All servers selected":`${p.length} server${p.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(_,{checked:p.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(ve,{value:E,onChange:s=>Q(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(r,{onClick:re,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{ts as default};
@@ -1 +1 @@
1
- import{r as x,j as e,e as a,n as m}from"./index-PyVlsLW8.js";function u({title:n,description:t,icon:r,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:n}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
1
+ import{r as x,j as e,e as a,n as m}from"./index-UXL5-kaP.js";function u({title:n,description:t,icon:r,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:n}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
@@ -1,51 +1,41 @@
1
- import{c as y,u as Re,a as Le,r as l,j as e,D as De,b as _e,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as qe,G as Ie,F as Pe,k as ue,Z as ze,l as We,m as Fe,T as ce,n as Ve,o as Be,L as N,P as Ee,M as $e,K as A,p as g,A as Ke}from"./index-PyVlsLW8.js";import{C as x,a as u,b as R,c as L,d as ie}from"./card-xkODbJy-.js";import{B as Ge}from"./badge-D4vHU_w_.js";import{g as He}from"./status-utils-PwF3DXLL.js";import{L as Oe}from"./label-DvPENm3h.js";import{S as oe,a as de,b as me,c as he,d as E}from"./select-B1v2u6hQ.js";import{u as Ye}from"./use-terminal-CFbQv1ie.js";import{T as Qe}from"./terminal-preview-DTUohQ5b.js";import{C as Ue}from"./circle-check-BPkEav83.js";import{C as Ze}from"./chevron-left-CvpfJBPQ.js";import{S as Je}from"./search-CPOHeeUa.js";import{C as Xe}from"./code-DTW3giBe.js";import{F as es}from"./folder-git-2-Bgv7r0zC.js";import{E as ss}from"./external-link--RjKXREe.js";import{P as ts}from"./play-DtFz_MLh.js";import{C as as}from"./clock-BIeoO5Mt.js";import{C as ns}from"./circle-check-big-Dbo-OmWQ.js";import"./index-BQYB8kWb.js";import"./chevron-up-BB-6OS4z.js";import"./xterm-DTxiCjtJ.js";/**
1
+ import{c as b,u as Re,a as Le,r as l,j as e,D as De,b as Ie,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as Pe,G as _e,F as qe,k as ue,Z as We,l as ze,m as Fe,T as ce,n as Ve,o as Be,L as v,P as Ee,M as Ke,K as A,p as g,q as $e,A as Ge}from"./index-UXL5-kaP.js";import{C as h,a as u,b as R,c as L,d as ie}from"./card-DPLdBoa5.js";import{B as He}from"./badge-vIqE5SOP.js";import{g as Oe}from"./status-utils-PwF3DXLL.js";import{L as Ye}from"./label-8VKluf9w.js";import{S as oe,a as de,b as me,c as xe,d as E}from"./select-CyHFRA1Y.js";import{u as Qe}from"./use-terminal-D3iV7-iC.js";import{T as Ue}from"./terminal-preview-CLWDhoOZ.js";import{C as Ze}from"./circle-check-xMiP6SLO.js";import{C as Je}from"./chevron-left-CiNaLX-v.js";import{S as Xe}from"./search-BxF7Wwex.js";import{G as es}from"./globe-CUo7eHKN.js";import{C as ss}from"./code-DH-sRhus.js";import{F as ts}from"./folder-git-2-BIw4zbmy.js";import{E as as}from"./external-link-DPyKt8NE.js";import{P as ns}from"./play-DVBhRokt.js";import{C as rs}from"./clock-C_9shc08.js";import{C as ls}from"./circle-check-big-BEY1IoIP.js";import"./index-DnZKG-_7.js";import"./chevron-up-DFd-7wxW.js";import"./xterm-DTxiCjtJ.js";/**
2
2
  * @license lucide-react v0.542.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 rs=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ls=y("brain",rs);/**
6
+ */const cs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],is=b("chart-line",cs);/**
7
7
  * @license lucide-react v0.542.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 cs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],is=y("chart-line",cs);/**
11
+ */const os=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ds=b("database",os);/**
12
12
  * @license lucide-react v0.542.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 os=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ds=y("database",os);/**
16
+ */const ms=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]],xs=b("file-chart-column-increasing",ms);/**
17
17
  * @license lucide-react v0.542.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 ms=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]],hs=y("file-chart-column-increasing",ms);/**
21
+ */const hs=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],W=b("file-plus-2",hs);/**
22
22
  * @license lucide-react v0.542.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const xs=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],z=y("file-plus-2",xs);/**
26
+ */const us=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ps=b("palette",us);/**
27
27
  * @license lucide-react v0.542.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const us=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ps=y("globe",us);/**
31
+ */const fs=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],js=b("rocket",fs);/**
32
32
  * @license lucide-react v0.542.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const fs=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],js=y("palette",fs);/**
36
+ */const gs=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],ys=b("test-tube",gs);/**
37
37
  * @license lucide-react v0.542.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const gs=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],ys=y("rocket",gs);/**
42
- * @license lucide-react v0.542.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const vs=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],Ns=y("test-tube",vs);/**
47
- * @license lucide-react v0.542.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const bs=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ws=y("wand-sparkles",bs),ks={Rocket:ys,FolderGit2:es,FileBarChart:hs,FilePlus2:z,Calendar:Fe,Sparkles:G,Settings:We,Zap:ze,Code:Xe,Bot:ue,FileText:Pe,GitBranch:Ie,ChartLine:is,Shield:qe,Database:ds,TestTube:Ns,Palette:js,Globe:ps},Cs={blue:{bg:"bg-gradient-to-br from-blue-500/30 to-blue-600/15",icon:"text-blue-400",border:"border-blue-500/40 hover:border-blue-500/60"},purple:{bg:"bg-gradient-to-br from-purple-500/30 to-purple-600/15",icon:"text-purple-400",border:"border-purple-500/40 hover:border-purple-500/60"},green:{bg:"bg-gradient-to-br from-emerald-500/30 to-emerald-600/15",icon:"text-emerald-400",border:"border-emerald-500/40 hover:border-emerald-500/60"},orange:{bg:"bg-gradient-to-br from-orange-500/30 to-orange-600/15",icon:"text-orange-400",border:"border-orange-500/40 hover:border-orange-500/60"},pink:{bg:"bg-gradient-to-br from-pink-500/30 to-pink-600/15",icon:"text-pink-400",border:"border-pink-500/40 hover:border-pink-500/60"}},xe={setup:"Setup",analysis:"Analysis",automation:"Automation",coding:"Coding"};function $(i){return ks[i]||G}function K(i){return Cs[i||"blue"]}function Ss(i,b){let m=i.replace(/\{\{#if (\w+)\}\}(.*?)\{\{\/if\}\}/g,(S,j,M)=>b[j]?.trim()?M.replace(/\{\{(\w+)\}\}/g,(w,t)=>b[t]||""):"");return m=m.replace(/\{\{(\w+)\}\}/g,(S,j)=>b[j]||""),m}function Ms({open:i,onOpenChange:b,workflows:m}){const S=Re(),{loading:j,createSession:M,destroySession:D}=Ye(),{toast:w}=Le(),[t,n]=l.useState(null),[h,v]=l.useState(0),[o,_]=l.useState(""),[r,k]=l.useState("all"),[p,T]=l.useState({}),[H,O]=l.useState(!1),[q,Y]=l.useState(null),[pe,Q]=l.useState(null),[W,fe]=l.useState(!1),U=l.useMemo(()=>{const s=new Set(m.map(a=>a.category));return Array.from(s)},[m]),C=l.useMemo(()=>m.filter(s=>{const a=o===""||s.title.toLowerCase().includes(o.toLowerCase())||s.description.toLowerCase().includes(o.toLowerCase()),c=r==="all"||s.category===r;return a&&c}),[m,o,r]),Z=l.useMemo(()=>o||r!=="all"?[]:m.filter(s=>s.featured),[m,o,r]),J=l.useMemo(()=>o||r!=="all"?C:C.filter(s=>!s.featured),[C,o,r]),X=s=>{n(s),v(0);const a={};s.params?.forEach(c=>{c.defaultValue&&(a[c.id]=c.defaultValue)}),T(a)},je=()=>{h>0?v(h-1):(n(null),T({}))},ge=()=>{t&&h<t.steps.length-1&&v(h+1)},I=()=>{n(null),v(0),_(""),k("all"),T({}),Y(null),Q(null),b(!1)},P=(s,a)=>{T(c=>({...c,[s]:a}))},F=l.useMemo(()=>t?.params?t.params.filter(s=>s.required).every(s=>p[s.id]?.trim()):!0,[t,p]),V=l.useMemo(()=>t?.command?Ss(t.command,p):"",[t,p]),ye=async()=>{if(!V)return;const s=`wizard-${Date.now()}`;O(!0);try{const a=await M(s,V);a?(w({title:"Session started",description:s}),Y(a),Q(s)):w({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{O(!1)}},ve=s=>{const a=$(s.icon),c=K(s.color);return e.jsx(x,{className:f("cursor-pointer transition-all duration-200 hover:scale-[1.02]",c.bg,c.border),onClick:()=>X(s),children:e.jsxs(u,{className:"p-4 flex flex-col items-center text-center h-full",children:[e.jsx("div",{className:f("w-12 h-12 rounded-xl flex items-center justify-center mb-3","bg-background/50 backdrop-blur-sm"),children:e.jsx(a,{className:f("h-6 w-6",c.icon)})}),e.jsx("h3",{className:"text-sm font-semibold line-clamp-2",children:s.title})]})},s.id)},Ne=s=>{const a=$(s.icon),c=K(s.color);return e.jsx(x,{className:"cursor-pointer hover:bg-accent hover:border-accent-foreground/20 transition-colors",onClick:()=>X(s),children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",c.bg),children:e.jsx(a,{className:f("h-5 w-5",c.icon)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description})]}),e.jsx(le,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})]})})},s.id)},be=()=>e.jsxs("div",{className:"flex h-[600px]",children:[e.jsxs("div",{className:"w-56 border-r pr-4 flex flex-col space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(B,{placeholder:"Search workflows...",value:o,onChange:s=>_(s.target.value),className:"pl-9"})]}),e.jsxs(oe,{value:r,onValueChange:k,children:[e.jsx(de,{children:e.jsx(me,{placeholder:"All categories"})}),e.jsxs(he,{children:[e.jsx(E,{value:"all",children:"All categories"}),U.map(s=>e.jsx(E,{value:s,children:xe[s]||s},s))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 px-1",children:"Categories"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{onClick:()=>k("all"),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r==="all"?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:"All Workflows"}),U.map(s=>e.jsx("button",{onClick:()=>k(s),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r===s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:xe[s]||s},s))]})]})]}),e.jsxs("div",{className:"flex-1 pl-4",children:[e.jsxs(te,{className:"mb-4",children:[e.jsx(ae,{className:"text-2xl",children:"Getting Started"}),e.jsx(ne,{children:"Choose a workflow to get started with Coconut. We'll guide you through each step."})]}),e.jsx(re,{className:"h-[500px] pr-4",children:e.jsxs("div",{className:"space-y-6",children:[Z.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3 flex items-center",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Featured"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 p-1",children:Z.map(ve)})]}),(J.length>0||o||r!=="all")&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:o||r!=="all"?`Results (${C.length})`:"All Workflows"}),e.jsx("div",{className:"space-y-2",children:C.length>0?(o||r!=="all"?C:J).map(Ne):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{children:"No workflows found matching your search."})})})]})]})})]})]}),we=s=>e.jsx("div",{className:"space-y-4",children:s.content&&e.jsxs("div",{className:"space-y-4",children:[s.content.text&&e.jsx(x,{children:e.jsx(u,{className:"p-4",children:e.jsx("p",{className:"text-sm leading-relaxed",children:s.content.text})})}),s.content.image&&e.jsx(x,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("img",{src:s.content.image.src,alt:s.content.image.alt,className:"w-full rounded-md border"}),s.content.image.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.image.caption})]})})}),s.content.video&&e.jsx(x,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"relative rounded-md overflow-hidden border bg-muted",children:e.jsx("video",{src:s.content.video.src,poster:s.content.video.poster,controls:!0,className:"w-full",children:"Your browser does not support the video tag."})}),s.content.video.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.video.caption})]})})})]})}),ke=()=>t?.params?e.jsx("div",{className:"space-y-4",children:t.params.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Oe,{htmlFor:s.id,children:[s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.type==="text"&&e.jsx(B,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value)}),s.type==="textarea"&&e.jsx(Be,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value),rows:4}),s.type==="number"&&e.jsx(B,{id:s.id,type:"number",placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value)}),s.type==="select"&&s.options&&e.jsxs(oe,{value:p[s.id]||"",onValueChange:a=>P(s.id,a),children:[e.jsx(de,{children:e.jsx(me,{placeholder:s.placeholder||"Select..."})}),e.jsx(he,{children:s.options.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s.id))}):null,Ce=()=>t?.command?q?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Terminal Output"})]}),e.jsx(Qe,{sessionId:q,heightPx:220,maxScrollback:500})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(d,{onClick:()=>{I(),S(`/terminal/${pe}`)},variant:"secondary",className:"flex-1",children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Open in Terminal"]}),e.jsx(d,{onClick:async()=>{q&&await D(q),I()},className:"flex-1 bg-green-600 hover:bg-green-700",children:"Done"})]})]}):e.jsxs("div",{className:"space-y-6",children:[t.params&&t.params.length>0&&e.jsx(x,{children:e.jsxs(u,{className:"p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Configuration"}),e.jsx("div",{className:"space-y-2",children:t.params.map(s=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[s.label,":"]}),e.jsx("span",{className:"font-medium truncate ml-2 max-w-[200px]",children:p[s.id]||e.jsx("span",{className:"text-muted-foreground italic",children:"Not set"})})]},s.id))})]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(d,{onClick:ye,disabled:j||H||!F,className:"flex-1",children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),H?"Starting...":"Run"]})}),!F&&e.jsx("p",{className:"text-sm text-destructive text-center",children:"Please fill in all required fields before running."}),e.jsx(x,{children:e.jsxs(u,{className:"p-4",children:[e.jsxs("button",{type:"button",onClick:()=>fe(!W),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Command"})]}),e.jsx(Ve,{className:f("h-4 w-4 text-muted-foreground transition-transform",W&&"rotate-180")})]}),W&&e.jsx("div",{className:"bg-muted rounded-md p-3 overflow-x-auto mt-3",children:e.jsx("code",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:V})})]})})]}):null,Se=()=>{if(!t)return null;const s=t.steps[h],a=s.type||"info",c=h===t.steps.length-1,Me=$(t.icon),ee=K(t.color),Te=()=>{switch(a){case"params":return ke();case"confirm":return Ce();case"info":default:return we(s)}},Ae=c&&!t.command&&a==="info";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(te,{children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",ee.bg),children:e.jsx(Me,{className:f("h-5 w-5",ee.icon)})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ae,{className:"text-xl",children:t.title}),e.jsxs(ne,{children:["Step ",h+1," of ",t.steps.length]})]})]}),e.jsx("div",{className:"flex items-center space-x-2 pt-2",children:t.steps.map((Ls,se)=>e.jsx("div",{className:f("h-1.5 flex-1 rounded-full transition-colors",se<=h?"bg-primary":"bg-muted")},se))})]}),e.jsx(re,{className:"h-[450px] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.description})]}),Te(),Ae&&e.jsx(x,{className:"bg-primary/5 border-primary/20",children:e.jsxs(u,{className:"p-4 flex items-center space-x-3",children:[e.jsx(Ue,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("p",{className:"text-sm font-medium",children:`You've completed this workflow! Click "Finish" to close this wizard.`})]})})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsx(d,{variant:"ghost",onClick:I,children:"Cancel"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(d,{variant:"outline",onClick:je,children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),h===0?"Back to Workflows":"Previous"]}),a!=="confirm"&&(c?e.jsx(d,{onClick:I,children:"Finish"}):e.jsxs(d,{onClick:ge,disabled:a==="params"&&!F,children:["Next",e.jsx(le,{className:"ml-2 h-4 w-4"})]}))]})]})]})};return e.jsx(De,{open:i,onOpenChange:b,children:e.jsx(_e,{className:"max-w-4xl max-h-[90vh]",children:t?Se():be()})})}const Ts=[{id:"new-project",title:"Start Building a New Website",description:"Scaffold a ready-to-go Vite + React + TypeScript project with Tailwind CSS",icon:"Rocket",category:"setup",featured:!0,color:"blue",command:"npx -y http://registry.coconut.dev/registry/blueprints/coconut-vite-starter-1.0.1.tgz",steps:[{type:"info",title:"Start Building a New Website",description:"Get up and running with a modern web stack in seconds",content:{text:"This wizard scaffolds a ready-to-go Vite + React + TypeScript project with Tailwind CSS and React Router. Perfect for quick experiments, agent-driven prototypes, or Coconut sandboxes. You'll have a fully configured development environment with hot reloading, routing, and styling out of the box."}},{type:"confirm",title:"Create Your Project",description:"Run the scaffolding command to set up your new website"}]},{id:"company-sentiment-analysis",title:"Daily Company Sentiment Analysis",description:"Monitor a company's online presence with automated daily sentiment analysis",icon:"ChartLine",category:"automation",featured:!0,color:"orange",command:'npx -y http://registry.coconut.dev/utils/coconut-research-sentiment-analysis-1.0.2.tgz --company "{{company}}" --url "{{url}}"{{#if socialPlatforms}} --social-platforms "{{socialPlatforms}}"{{/if}}{{#if keywords}} --keywords "{{keywords}}"{{/if}}',params:[{id:"company",label:"Company Name",type:"text",placeholder:"e.g., Acme Corp",required:!0},{id:"url",label:"Company Website URL",type:"text",placeholder:"e.g., https://acme.com",required:!0},{id:"socialPlatforms",label:"Social Platforms (optional)",type:"text",placeholder:"e.g., twitter,linkedin,reddit",required:!1},{id:"keywords",label:"Keywords to Track (optional)",type:"text",placeholder:"e.g., product launch,customer feedback",required:!1}],steps:[{type:"info",title:"Daily Company Sentiment Analysis",description:"Learn how automated sentiment monitoring works",content:{text:"This wizard creates a scheduled job that monitors a company's online presence daily (Monday–Friday). It uses web scraping to gather sentiment data and generates comprehensive reports including overall sentiment score, key themes, notable mentions, and trend analysis over time."}},{type:"params",title:"Configure Analysis",description:"Enter the company details and optional filters"},{type:"confirm",title:"Review and Create Job",description:"Confirm your settings and create the sentiment analysis job"}]}],As={workflows:Ts},Rs=As.workflows;function Js(){const[i,b]=l.useState({total:0,inReview:0,approved:0}),[m,S]=l.useState([]),[j,M]=l.useState(!0),[D,w]=l.useState(!1);return l.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),w(!0)),(n.metaKey||n.ctrlKey)&&n.key==="i"&&(n.preventDefault(),window.location.href="/tasks/new"),(n.metaKey||n.ctrlKey)&&n.key==="u"&&(n.preventDefault(),window.location.href="/knowledge"),(n.metaKey||n.ctrlKey)&&n.key==="e"&&(n.preventDefault(),window.location.href="/agents")};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),l.useEffect(()=>{(async()=>{try{const h=await(await fetch(`${Ke}/api/v1/tasks`)).json();if(h.success&&h.data){const v=h.data,o={total:v.length,inReview:v.filter(r=>r.status==="review").length,approved:v.filter(r=>r.status==="ready"||r.status==="done").length},_=v.sort((r,k)=>{const p=new Date(r.metadata?.updatedAt||r.metadata?.createdAt||0);return new Date(k.metadata?.updatedAt||k.metadata?.createdAt||0).getTime()-p.getTime()}).slice(0,5);b(o),S(_)}}catch(n){console.error("Failed to fetch task stats:",n)}finally{M(!1)}})()},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Home"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage change tasks and take quick actions"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(N,{to:"/tasks",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"All Tasks"}),e.jsx(z,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.total===0?"No tasks yet":`${i.total} task${i.total!==1?"s":""}`})]})]})}),e.jsx(N,{to:"/tasks?status=review",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"In Review"}),e.jsx(as,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(N,{to:"/tasks?status=ready",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"Ready / Done"}),e.jsx(ns,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.approved}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ready to implement"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(x,{children:[e.jsxs(R,{children:[e.jsx(L,{children:"Recent Tasks"}),e.jsx(ie,{children:"Recently created or updated tasks"})]}),e.jsx(u,{children:j?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]},t))}):m.length>0?e.jsxs("div",{className:"space-y-4 overflow-hidden",children:[m.map(t=>e.jsx(N,{to:`/tasks/${t.id}`,className:"block",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 p-3 rounded-lg border hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(Ge,{variant:He(t.status),children:t.status})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium line-clamp-2 sm:truncate",children:t.title||t.intent}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[t.author.name," • ",new Date(t.metadata?.updatedAt||t.metadata?.createdAt||"").toLocaleDateString()]})]})]})},t.id)),e.jsx("div",{className:"pt-2",children:e.jsx(d,{variant:"outline",size:"sm",asChild:!0,className:"w-full",children:e.jsx(N,{to:"/tasks",children:"View All Tasks"})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(z,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),e.jsx(d,{asChild:!0,className:"mt-4",children:e.jsxs(N,{to:"/tasks/new",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})]}),e.jsxs(x,{className:"flex flex-col",children:[e.jsxs(R,{children:[e.jsx(L,{children:"Quick Actions"}),e.jsx(ie,{children:"Common tasks and operations"})]}),e.jsx(u,{className:"flex flex-col flex-1",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{variant:"default",className:"w-full justify-between",onClick:()=>window.dispatchEvent(new CustomEvent("open-assistant-expanded")),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"Chat with Assistant"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"L"})]})]}),e.jsxs(d,{variant:"outline",className:"w-full justify-between",onClick:()=>w(!0),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ws,{className:"mr-2 h-4 w-4"}),"Launch Wizard"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"K"})]})]}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(N,{to:"/tasks/new",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),"Create a Task"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"I"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(N,{to:"/knowledge",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ls,{className:"mr-2 h-4 w-4"}),"View Knowledge"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"U"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(N,{to:"/agents",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Start an Agent"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"E"})]})]})})]})})]})]}),e.jsx(Ms,{open:D,onOpenChange:w,workflows:Rs})]})}export{Js as default};
41
+ */const vs=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Ns=b("wand-sparkles",vs),bs={Rocket:js,FolderGit2:ts,FileBarChart:xs,FilePlus2:W,Calendar:Fe,Sparkles:G,Settings:ze,Zap:We,Code:ss,Bot:ue,FileText:qe,GitBranch:_e,ChartLine:is,Shield:Pe,Database:ds,TestTube:ys,Palette:ps,Globe:es},ws={blue:{bg:"bg-gradient-to-br from-blue-500/30 to-blue-600/15",icon:"text-blue-400",border:"border-blue-500/40 hover:border-blue-500/60"},purple:{bg:"bg-gradient-to-br from-purple-500/30 to-purple-600/15",icon:"text-purple-400",border:"border-purple-500/40 hover:border-purple-500/60"},green:{bg:"bg-gradient-to-br from-emerald-500/30 to-emerald-600/15",icon:"text-emerald-400",border:"border-emerald-500/40 hover:border-emerald-500/60"},orange:{bg:"bg-gradient-to-br from-orange-500/30 to-orange-600/15",icon:"text-orange-400",border:"border-orange-500/40 hover:border-orange-500/60"},pink:{bg:"bg-gradient-to-br from-pink-500/30 to-pink-600/15",icon:"text-pink-400",border:"border-pink-500/40 hover:border-pink-500/60"}},he={setup:"Setup",analysis:"Analysis",automation:"Automation",coding:"Coding"};function K(i){return bs[i]||G}function $(i){return ws[i||"blue"]}function ks(i,N){let m=i.replace(/\{\{#if (\w+)\}\}(.*?)\{\{\/if\}\}/g,(S,j,M)=>N[j]?.trim()?M.replace(/\{\{(\w+)\}\}/g,(w,t)=>N[t]||""):"");return m=m.replace(/\{\{(\w+)\}\}/g,(S,j)=>N[j]||""),m}function Cs({open:i,onOpenChange:N,workflows:m}){const S=Re(),{loading:j,createSession:M,destroySession:D}=Qe(),{toast:w}=Le(),[t,n]=l.useState(null),[x,y]=l.useState(0),[o,I]=l.useState(""),[r,k]=l.useState("all"),[p,T]=l.useState({}),[H,O]=l.useState(!1),[P,Y]=l.useState(null),[pe,Q]=l.useState(null),[z,fe]=l.useState(!1),U=l.useMemo(()=>{const s=new Set(m.map(a=>a.category));return Array.from(s)},[m]),C=l.useMemo(()=>m.filter(s=>{const a=o===""||s.title.toLowerCase().includes(o.toLowerCase())||s.description.toLowerCase().includes(o.toLowerCase()),c=r==="all"||s.category===r;return a&&c}),[m,o,r]),Z=l.useMemo(()=>o||r!=="all"?[]:m.filter(s=>s.featured),[m,o,r]),J=l.useMemo(()=>o||r!=="all"?C:C.filter(s=>!s.featured),[C,o,r]),X=s=>{n(s),y(0);const a={};s.params?.forEach(c=>{c.defaultValue&&(a[c.id]=c.defaultValue)}),T(a)},je=()=>{x>0?y(x-1):(n(null),T({}))},ge=()=>{t&&x<t.steps.length-1&&y(x+1)},_=()=>{n(null),y(0),I(""),k("all"),T({}),Y(null),Q(null),N(!1)},q=(s,a)=>{T(c=>({...c,[s]:a}))},F=l.useMemo(()=>t?.params?t.params.filter(s=>s.required).every(s=>p[s.id]?.trim()):!0,[t,p]),V=l.useMemo(()=>t?.command?ks(t.command,p):"",[t,p]),ye=async()=>{if(!V)return;const s=`wizard-${Date.now()}`;O(!0);try{const a=await M(s,V);a?(w({title:"Session started",description:s}),Y(a),Q(s)):w({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{O(!1)}},ve=s=>{const a=K(s.icon),c=$(s.color);return e.jsx(h,{className:f("cursor-pointer transition-all duration-200 hover:scale-[1.02]",c.bg,c.border),onClick:()=>X(s),children:e.jsxs(u,{className:"p-4 flex flex-col items-center text-center h-full",children:[e.jsx("div",{className:f("w-12 h-12 rounded-xl flex items-center justify-center mb-3","bg-background/50 backdrop-blur-sm"),children:e.jsx(a,{className:f("h-6 w-6",c.icon)})}),e.jsx("h3",{className:"text-sm font-semibold line-clamp-2",children:s.title})]})},s.id)},Ne=s=>{const a=K(s.icon),c=$(s.color);return e.jsx(h,{className:"cursor-pointer hover:bg-accent hover:border-accent-foreground/20 transition-colors",onClick:()=>X(s),children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",c.bg),children:e.jsx(a,{className:f("h-5 w-5",c.icon)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description})]}),e.jsx(le,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})]})})},s.id)},be=()=>e.jsxs("div",{className:"flex h-[600px]",children:[e.jsxs("div",{className:"w-56 border-r pr-4 flex flex-col space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(B,{placeholder:"Search workflows...",value:o,onChange:s=>I(s.target.value),className:"pl-9"})]}),e.jsxs(oe,{value:r,onValueChange:k,children:[e.jsx(de,{children:e.jsx(me,{placeholder:"All categories"})}),e.jsxs(xe,{children:[e.jsx(E,{value:"all",children:"All categories"}),U.map(s=>e.jsx(E,{value:s,children:he[s]||s},s))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 px-1",children:"Categories"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{onClick:()=>k("all"),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r==="all"?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:"All Workflows"}),U.map(s=>e.jsx("button",{onClick:()=>k(s),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r===s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:he[s]||s},s))]})]})]}),e.jsxs("div",{className:"flex-1 pl-4",children:[e.jsxs(te,{className:"mb-4",children:[e.jsx(ae,{className:"text-2xl",children:"Getting Started"}),e.jsx(ne,{children:"Choose a workflow to get started with Coconut. We'll guide you through each step."})]}),e.jsx(re,{className:"h-[500px] pr-4",children:e.jsxs("div",{className:"space-y-6",children:[Z.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3 flex items-center",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Featured"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 p-1",children:Z.map(ve)})]}),(J.length>0||o||r!=="all")&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:o||r!=="all"?`Results (${C.length})`:"All Workflows"}),e.jsx("div",{className:"space-y-2",children:C.length>0?(o||r!=="all"?C:J).map(Ne):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{children:"No workflows found matching your search."})})})]})]})})]})]}),we=s=>e.jsx("div",{className:"space-y-4",children:s.content&&e.jsxs("div",{className:"space-y-4",children:[s.content.text&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsx("p",{className:"text-sm leading-relaxed",children:s.content.text})})}),s.content.image&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("img",{src:s.content.image.src,alt:s.content.image.alt,className:"w-full rounded-md border"}),s.content.image.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.image.caption})]})})}),s.content.video&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"relative rounded-md overflow-hidden border bg-muted",children:e.jsx("video",{src:s.content.video.src,poster:s.content.video.poster,controls:!0,className:"w-full",children:"Your browser does not support the video tag."})}),s.content.video.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.video.caption})]})})})]})}),ke=()=>t?.params?e.jsx("div",{className:"space-y-4",children:t.params.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ye,{htmlFor:s.id,children:[s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.type==="text"&&e.jsx(B,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value)}),s.type==="textarea"&&e.jsx(Be,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value),rows:4}),s.type==="number"&&e.jsx(B,{id:s.id,type:"number",placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value)}),s.type==="select"&&s.options&&e.jsxs(oe,{value:p[s.id]||"",onValueChange:a=>q(s.id,a),children:[e.jsx(de,{children:e.jsx(me,{placeholder:s.placeholder||"Select..."})}),e.jsx(xe,{children:s.options.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s.id))}):null,Ce=()=>t?.command?P?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Terminal Output"})]}),e.jsx(Ue,{sessionId:P,heightPx:220,maxScrollback:500})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(d,{onClick:()=>{_(),S(`/terminal/${pe}`)},variant:"secondary",className:"flex-1",children:[e.jsx(as,{className:"h-4 w-4 mr-2"}),"Open in Terminal"]}),e.jsx(d,{onClick:async()=>{P&&await D(P),_()},className:"flex-1 bg-green-600 hover:bg-green-700",children:"Done"})]})]}):e.jsxs("div",{className:"space-y-6",children:[t.params&&t.params.length>0&&e.jsx(h,{children:e.jsxs(u,{className:"p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Configuration"}),e.jsx("div",{className:"space-y-2",children:t.params.map(s=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[s.label,":"]}),e.jsx("span",{className:"font-medium truncate ml-2 max-w-[200px]",children:p[s.id]||e.jsx("span",{className:"text-muted-foreground italic",children:"Not set"})})]},s.id))})]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(d,{onClick:ye,disabled:j||H||!F,className:"flex-1",children:[e.jsx(ns,{className:"h-4 w-4 mr-2"}),H?"Starting...":"Run"]})}),!F&&e.jsx("p",{className:"text-sm text-destructive text-center",children:"Please fill in all required fields before running."}),e.jsx(h,{children:e.jsxs(u,{className:"p-4",children:[e.jsxs("button",{type:"button",onClick:()=>fe(!z),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Command"})]}),e.jsx(Ve,{className:f("h-4 w-4 text-muted-foreground transition-transform",z&&"rotate-180")})]}),z&&e.jsx("div",{className:"bg-muted rounded-md p-3 overflow-x-auto mt-3",children:e.jsx("code",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:V})})]})})]}):null,Se=()=>{if(!t)return null;const s=t.steps[x],a=s.type||"info",c=x===t.steps.length-1,Me=K(t.icon),ee=$(t.color),Te=()=>{switch(a){case"params":return ke();case"confirm":return Ce();case"info":default:return we(s)}},Ae=c&&!t.command&&a==="info";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(te,{children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",ee.bg),children:e.jsx(Me,{className:f("h-5 w-5",ee.icon)})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ae,{className:"text-xl",children:t.title}),e.jsxs(ne,{children:["Step ",x+1," of ",t.steps.length]})]})]}),e.jsx("div",{className:"flex items-center space-x-2 pt-2",children:t.steps.map((As,se)=>e.jsx("div",{className:f("h-1.5 flex-1 rounded-full transition-colors",se<=x?"bg-primary":"bg-muted")},se))})]}),e.jsx(re,{className:"h-[450px] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.description})]}),Te(),Ae&&e.jsx(h,{className:"bg-primary/5 border-primary/20",children:e.jsxs(u,{className:"p-4 flex items-center space-x-3",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("p",{className:"text-sm font-medium",children:`You've completed this workflow! Click "Finish" to close this wizard.`})]})})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsx(d,{variant:"ghost",onClick:_,children:"Cancel"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(d,{variant:"outline",onClick:je,children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),x===0?"Back to Workflows":"Previous"]}),a!=="confirm"&&(c?e.jsx(d,{onClick:_,children:"Finish"}):e.jsxs(d,{onClick:ge,disabled:a==="params"&&!F,children:["Next",e.jsx(le,{className:"ml-2 h-4 w-4"})]}))]})]})]})};return e.jsx(De,{open:i,onOpenChange:N,children:e.jsx(Ie,{className:"max-w-4xl max-h-[90vh]",children:t?Se():be()})})}const Ss=[{id:"new-project",title:"Start Building a New Website",description:"Scaffold a ready-to-go Vite + React + TypeScript project with Tailwind CSS",icon:"Rocket",category:"setup",featured:!0,color:"blue",command:"npx -y http://registry.coconut.dev/registry/blueprints/coconut-vite-starter-1.0.1.tgz",steps:[{type:"info",title:"Start Building a New Website",description:"Get up and running with a modern web stack in seconds",content:{text:"This wizard scaffolds a ready-to-go Vite + React + TypeScript project with Tailwind CSS and React Router. Perfect for quick experiments, agent-driven prototypes, or Coconut sandboxes. You'll have a fully configured development environment with hot reloading, routing, and styling out of the box."}},{type:"confirm",title:"Create Your Project",description:"Run the scaffolding command to set up your new website"}]},{id:"company-sentiment-analysis",title:"Daily Company Sentiment Analysis",description:"Monitor a company's online presence with automated daily sentiment analysis",icon:"ChartLine",category:"automation",featured:!0,color:"orange",command:'npx -y http://registry.coconut.dev/utils/coconut-research-sentiment-analysis-1.0.2.tgz --company "{{company}}" --url "{{url}}"{{#if socialPlatforms}} --social-platforms "{{socialPlatforms}}"{{/if}}{{#if keywords}} --keywords "{{keywords}}"{{/if}}',params:[{id:"company",label:"Company Name",type:"text",placeholder:"e.g., Acme Corp",required:!0},{id:"url",label:"Company Website URL",type:"text",placeholder:"e.g., https://acme.com",required:!0},{id:"socialPlatforms",label:"Social Platforms (optional)",type:"text",placeholder:"e.g., twitter,linkedin,reddit",required:!1},{id:"keywords",label:"Keywords to Track (optional)",type:"text",placeholder:"e.g., product launch,customer feedback",required:!1}],steps:[{type:"info",title:"Daily Company Sentiment Analysis",description:"Learn how automated sentiment monitoring works",content:{text:"This wizard creates a scheduled job that monitors a company's online presence daily (Monday–Friday). It uses web scraping to gather sentiment data and generates comprehensive reports including overall sentiment score, key themes, notable mentions, and trend analysis over time."}},{type:"params",title:"Configure Analysis",description:"Enter the company details and optional filters"},{type:"confirm",title:"Review and Create Job",description:"Confirm your settings and create the sentiment analysis job"}]}],Ms={workflows:Ss},Ts=Ms.workflows;function Zs(){const[i,N]=l.useState({total:0,inReview:0,approved:0}),[m,S]=l.useState([]),[j,M]=l.useState(!0),[D,w]=l.useState(!1);return l.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),w(!0)),(n.metaKey||n.ctrlKey)&&n.key==="i"&&(n.preventDefault(),window.location.href="/tasks/new"),(n.metaKey||n.ctrlKey)&&n.key==="u"&&(n.preventDefault(),window.location.href="/knowledge"),(n.metaKey||n.ctrlKey)&&n.key==="e"&&(n.preventDefault(),window.location.href="/agents")};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),l.useEffect(()=>{(async()=>{try{const x=await(await fetch(`${Ge}/api/v1/tasks`)).json();if(x.success&&x.data){const y=x.data,o={total:y.length,inReview:y.filter(r=>r.status==="review").length,approved:y.filter(r=>r.status==="ready"||r.status==="done").length},I=y.sort((r,k)=>{const p=new Date(r.metadata?.updatedAt||r.metadata?.createdAt||0);return new Date(k.metadata?.updatedAt||k.metadata?.createdAt||0).getTime()-p.getTime()}).slice(0,5);N(o),S(I)}}catch(n){console.error("Failed to fetch task stats:",n)}finally{M(!1)}})()},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Home"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage change tasks and take quick actions"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(v,{to:"/tasks",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"All Tasks"}),e.jsx(W,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.total===0?"No tasks yet":`${i.total} task${i.total!==1?"s":""}`})]})]})}),e.jsx(v,{to:"/tasks?status=review",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"In Review"}),e.jsx(rs,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(v,{to:"/tasks?status=ready",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"Ready / Done"}),e.jsx(ls,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.approved}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ready to implement"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(h,{children:[e.jsxs(R,{children:[e.jsx(L,{children:"Recent Tasks"}),e.jsx(ie,{children:"Recently created or updated tasks"})]}),e.jsx(u,{children:j?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]},t))}):m.length>0?e.jsxs("div",{className:"space-y-4 overflow-hidden",children:[m.map(t=>e.jsx(v,{to:`/tasks/${t.id}`,className:"block",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 p-3 rounded-lg border hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(He,{variant:Oe(t.status),children:t.status})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium line-clamp-2 sm:truncate",children:t.title||t.intent}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[t.author.name," • ",new Date(t.metadata?.updatedAt||t.metadata?.createdAt||"").toLocaleDateString()]})]})]})},t.id)),e.jsx("div",{className:"pt-2",children:e.jsx(d,{variant:"outline",size:"sm",asChild:!0,className:"w-full",children:e.jsx(v,{to:"/tasks",children:"View All Tasks"})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(W,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),e.jsx(d,{asChild:!0,className:"mt-4",children:e.jsxs(v,{to:"/tasks/new",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})]}),e.jsxs(h,{className:"flex flex-col",children:[e.jsxs(R,{children:[e.jsx(L,{children:"Quick Actions"}),e.jsx(ie,{children:"Common tasks and operations"})]}),e.jsx(u,{className:"flex flex-col flex-1",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{variant:"default",className:"w-full justify-between",onClick:()=>window.dispatchEvent(new CustomEvent("open-assistant-expanded")),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ke,{className:"mr-2 h-4 w-4"}),"Chat with Assistant"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"L"})]})]}),e.jsxs(d,{variant:"outline",className:"w-full justify-between",onClick:()=>w(!0),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ns,{className:"mr-2 h-4 w-4"}),"Launch Wizard"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"K"})]})]}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/tasks/new",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Create a Task"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"I"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/knowledge",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"View Knowledge"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"U"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/agents",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Start an Agent"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"E"})]})]})})]})})]})]}),e.jsx(Cs,{open:D,onOpenChange:w,workflows:Ts})]})}export{Zs as default};
@@ -1,9 +1,9 @@
1
- import{c as le,A as l,bF as ws,r as n,a as vs,ad as ys,j as e,L as ee,l as $e,B as o,G as D,ab as Ns,X as Cs,I as k,n as Me,E as Be,D as se,b as te,d as ae,f as re,g as ne,bx as ks,W as Oe}from"./index-PyVlsLW8.js";import{C as ie}from"./card-xkODbJy-.js";import{L as Re}from"./label-DvPENm3h.js";import{T as Ss,a as Ps,b as Ge,c as We}from"./tabs-DAbCZiFC.js";import{C as Ts}from"./circle-check-BPkEav83.js";import{C as As}from"./circle-x-BBwi8e5G.js";import{A as Ds}from"./arrow-down-C6Flf0DF.js";import{A as Es}from"./arrow-up-DeQAxOPq.js";import{R as ze}from"./refresh-cw-B1bWW9Rg.js";import{C as ce}from"./circle-alert-lnP0-w3N.js";import{C as Ue}from"./chevron-up-BB-6OS4z.js";import{F as oe}from"./folder-git-2-Bgv7r0zC.js";/**
1
+ import{c as le,A as l,bH as ws,r as n,a as vs,ac as ys,j as e,L as ee,l as Fe,B as o,G as D,aa as Ns,X as Cs,I as k,n as Me,H as Be,D as se,b as te,d as ae,f as re,g as ne,bE as ks,Y as Oe}from"./index-UXL5-kaP.js";import{C as ie}from"./card-DPLdBoa5.js";import{L as Re}from"./label-8VKluf9w.js";import{T as Ss,a as Ps,b as Ge,c as We}from"./tabs-DkvCmQEX.js";import{C as Ts}from"./circle-check-xMiP6SLO.js";import{C as As}from"./circle-x-z3iynaE7.js";import{A as Ds}from"./arrow-down-UClxXzT-.js";import{A as Es}from"./arrow-up-fLCh7Hvh.js";import{R as ze}from"./refresh-cw-tXYl1ePu.js";import{C as ce}from"./circle-alert-Mv00T-P2.js";import{C as Ue}from"./chevron-up-DFd-7wxW.js";import{F as oe}from"./folder-git-2-BIw4zbmy.js";/**
2
2
  * @license lucide-react v0.542.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 Fs=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],$s=le("git-commit-horizontal",Fs);/**
6
+ */const $s=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Fs=le("git-commit-horizontal",$s);/**
7
7
  * @license lucide-react v0.542.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as le,A as l,bF as ws,r as n,a as vs,ad as ys,j as e,L as ee,l as $e,B
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 Bs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Le=le("git-pull-request",Bs);let S;async function Os(){if(S!==void 0)return S;try{const m=await fetch(`${l}/api/v1/config`);if(!m.ok)return S=null,null;const r=(await m.json())?.data||{},f=r?.coconut?.id||r?.cloud?.coconutId||r?.cloud?.coconut_id;return S=typeof f=="string"&&f.trim()?f.trim():null,S}catch(m){return console.error("[github-token] Failed to load Coconut ID",m),S=null,null}}async function Rs(m){const x=await fetch(`${ws}/api/v1/git/token`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconutId:m})});if(!x.ok){let P="Failed to request GitHub token from control plane";if(x.status===401||x.status===403)throw new Error("Please sign in to app.coconut.dev and then retry the action.");try{const y=await x.json();P=y?.error?.message||y?.message||P}catch{}throw new Error(P)}const r=await x.json(),f=r?.token||r?.data?.token,b=r?.expiresAt||r?.data?.expiresAt;if(!f||!b)throw new Error("Control plane response missing token or expiresAt");return{token:f,expiresAt:b}}async function Gs(m,x){const r=await fetch(`${l}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m,expiresAt:x})}),f=await r.json().catch(()=>({}));if(!r.ok||!f?.success){const b=f?.error?.message||"Failed to store GitHub token on Coconut";throw new Error(b)}}async function Ws(){const m=await Os();if(!m)throw new Error("Coconut ID not configured. Reconnect via Settings → Git.");const{token:x,expiresAt:r}=await Rs(m);return await Gs(x,r),{tokenFetched:!0,message:r}}function Qs(){const[m,x]=n.useState(!0),[r,f]=n.useState(null),[b,P]=n.useState([]),[y,_e]=n.useState([]),[E,de]=n.useState(""),[g,F]=n.useState(""),[me,Je]=n.useState("main"),[ue,c]=n.useState(null),{toast:i}=vs(),{refresh:J}=ys(),[he,xe]=n.useState(!1),[$,M]=n.useState(!1),[T,ge]=n.useState(null),[A,fe]=n.useState(null),[He,pe]=n.useState(null),[be,je]=n.useState(null),[we,ve]=n.useState(null),[qe,ye]=n.useState(null),[B,Ve]=n.useState("merge"),[H,Ke]=n.useState("merge"),[Xe,Ye]=n.useState("../worktrees"),[O,Qe]=n.useState("github"),[h,Ne]=n.useState(null),[Ze,w]=n.useState(!1),[es,R]=n.useState(!1),[G,q]=n.useState(""),[W,V]=n.useState(""),[Ce,ke]=n.useState(!1),[v,K]=n.useState(""),[z,U]=n.useState(!1),[p,N]=n.useState(new Set),[I,ss]=n.useState(!1),[L,ts]=n.useState(!1),[as,_]=n.useState(!1),[C,X]=n.useState(null),[Y,Se]=n.useState(null),Pe=n.useCallback(async()=>{if(O!=="github"||h?.provider!=="github")return!0;if(h?.authenticated&&h?.expiresAt){const t=new Date(h.expiresAt).getTime(),a=Date.now(),d=300*1e3;if(t>a+d)return!0}const s=i({title:"Fetching GitHub token",description:"Contacting control plane…"});try{const{message:t}=await Ws();return i({title:"GitHub token ready",description:t?`Valid until ${new Date(t).toLocaleString()}`:"Token fetched successfully."}),Ne(a=>({...a,authenticated:!0,error:void 0,expiresAt:t??a?.expiresAt,provider:"github"})),!0}catch(t){const a=t?.message?`${t.message} Visit Settings → Git to reconnect.`:"Visit Settings → Git to connect GitHub.";return i({title:"GitHub token unavailable",description:a,variant:"destructive"}),c(t?.message||"GitHub authorization required. Visit Settings → Git to reconnect."),!1}finally{s?.dismiss?.()}},[O,h?.provider,h?.authenticated,h?.expiresAt,i]),u=async()=>{x(!0),c(null);try{const[s,t,a,d,Z]=await Promise.all([fetch(`${l}/api/v1/git/status`).then(j=>j.json()),fetch(`${l}/api/v1/git/branches`).then(j=>j.json()),fetch(`${l}/api/v1/git/worktrees`).then(j=>j.json()),fetch(`${l}/api/v1/git/settings`).then(j=>j.json()).catch(()=>null),fetch(`${l}/api/v1/git/auth-status`).then(j=>j.json()).catch(()=>null)]);s.success&&f(s.data),t.success&&P(t.data),a.success&&_e(a.data),d&&d.success&&d.data?.defaultWorktreePath&&(Ye(d.data.defaultWorktreePath),d.data.authMode&&Qe(d.data.authMode)),Z&&Z.success&&Ne(Z.data)}catch(s){c(s.message),i({title:"Failed to refresh",description:s.message,variant:"destructive"})}finally{x(!1)}};n.useEffect(()=>{u()},[]);const Te=n.useMemo(()=>{const s=r?.branch?.toLowerCase();return s==="main"||s==="master"},[r?.branch]),Q=n.useMemo(()=>{const s=!!v.trim(),t=p.size>0;return s&&t},[v,p]),rs=s=>s==="??"||s.includes("U")?"U":s.includes("R")?"R":s.includes("C")?"C":s.includes("D")?"D":s.includes("A")?"A":s.includes("M")?"M":s||"?",ns=(s,t)=>{N(a=>{const d=new Set(a);return t?d.add(s):d.delete(s),d})},is=()=>{r?.changes&&N(new Set(r.changes.map(s=>s.path)))},cs=()=>{N(new Set)},os=()=>{r?.changes&&(r.changes.every(t=>p.has(t.path))?cs():is())},ls=n.useMemo(()=>!r?.changes||r.changes.length===0?!1:r.changes.every(s=>p.has(s.path)),[r?.changes,p]),ds=s=>{X(s),_(!0)},ms=async()=>{if(C){Se(C),c(null);try{const s=await fetch(`${l}/api/v1/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:C})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to discard file");N(t=>{const a=new Set(t);return a.delete(C),a}),i({title:"File discarded",description:C}),_(!1),X(null),await u(),await J()}catch(s){c(s.message),i({title:"Discard failed",description:s.message,variant:"destructive"})}finally{Se(null)}}},us=async()=>{if(E.trim()){xe(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:E,from:"main"})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create worktree");de(""),await u(),i({title:"Worktree created",description:s.data?.added?.branch})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}xe(!1)}},Ae=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{ge(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/push`:"/api/v1/git/push",a=await fetch(`${l}${t}`,{method:"POST"}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Push failed");i({title:"Pushed",description:s?`Worktree ${s}`:"Current branch"}),await u()}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Push failed",description:a,variant:"destructive"}),d&&w(!0)}ge(null)}},De=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{fe(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/pull`:"/api/v1/git/pull",a=await fetch(`${l}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:H})}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Pull failed");await u(),i({title:"Pulled",description:`${s?`Worktree ${s}`:"Current branch"} (${H})`})}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Pull failed",description:a,variant:"destructive"}),d&&w(!0)}fe(null)}},hs=async s=>{if(confirm(`Remove worktree ${s}?`)){c(null);try{pe(s);const t=await fetch(`${l}/api/v1/git/worktrees/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to remove worktree");await u(),i({title:"Worktree removed",description:s})}catch(t){c(t.message),i({title:"Remove failed",description:t.message,variant:"destructive"})}pe(t=>t===s?null:t)}},xs=async()=>{if(!G||!W){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}ke(!0);try{const t=await(await fetch(`${l}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:W})})).json();if(!t.success)throw new Error(t.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),w(!1),q(""),V(""),await u()}catch(s){i({title:"Error",description:s?.message||"Failed to save credentials",variant:"destructive"})}finally{ke(!1)}},gs=async()=>{if(g.trim()){M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:me})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");F(""),await u(),i({title:"Branch created",description:g})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}M(!1)}},fs=async s=>{je(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");await u(),i({title:"Switched branch",description:s})}catch(t){c(t.message),i({title:"Switch failed",description:t.message,variant:"destructive"})}je(null)},ps=async s=>{if(confirm(`Delete branch ${s}?`)){ye(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to delete branch");await u(),i({title:"Branch deleted",description:s})}catch(t){c(t.message),i({title:"Delete failed",description:t.message,variant:"destructive"})}ye(null)}},bs=async s=>{ve(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:B})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to merge branch");await u(),i({title:"Branch merged",description:`${s} (${B})`})}catch(t){c(t.message),i({title:"Merge failed",description:t.message,variant:"destructive"})}ve(null)},Ee=async()=>{if(Q){if(Te){R(!0);return}U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await J(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)}},js=async()=>{R(!1),U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await J(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)},Fe=async()=>{if(g.trim()){R(!1),M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:r?.branch})}).then(a=>a.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(g)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");F(""),await u(),i({title:"Branch created & switched",description:g})}catch(s){c(s.message),i({title:"Failed",description:s.message,variant:"destructive"})}M(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Source Control"}),h&&e.jsx(ee,{to:"/settings/git",className:"flex items-center gap-1.5 text-xs rounded-full px-2.5 py-1 border hover:bg-muted transition-colors",title:h.authenticated?"Authenticated with remote":"Authentication required - click to configure",children:h.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"h-3 w-3 text-green-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Not authenticated"}),e.jsx($e,{className:"h-3 w-3 text-muted-foreground ml-0.5"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{className:"text-sm border rounded-md px-3 py-2 bg-background h-9",value:H,onChange:s=>Ke(s.target.value),title:"Pull strategy",children:[e.jsx("option",{value:"merge",children:"Merge"}),e.jsx("option",{value:"rebase",children:"Rebase"}),e.jsx("option",{value:"ff-only",children:"FF only"})]}),e.jsxs(o,{variant:"outline",onClick:()=>De(),size:"sm",disabled:A==="",children:[e.jsx(Ds,{className:"h-4 w-4 mr-2"+(A===""?" animate-spin":"")}),A===""?"Pulling…":"Pull"]}),e.jsxs(o,{onClick:()=>Ae(),size:"sm",disabled:T==="",children:[e.jsx(Es,{className:"h-4 w-4 mr-2"+(T===""?" animate-spin":"")}),T===""?"Pushing…":"Push"]})]})]}),ue&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-900 dark:bg-red-950",children:ue}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Repository Status"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(o,{variant:"outline",size:"sm","aria-label":"Refresh status",onClick:u,disabled:m,children:[e.jsx(ze,{className:"h-4 w-4"+(m?" animate-spin":"")}),"Refresh"]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview of your current branch, sync status with the remote, and uncommitted changes."}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ze,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Branch:"}),e.jsx("span",{className:"font-mono font-semibold",children:r.branch}),Te&&e.jsxs("span",{className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-amber-500/10 text-amber-600",children:[e.jsx(ce,{className:"h-3 w-3"}),"Default branch"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-blue-600",children:"↓"}),e.jsxs("span",{className:"text-muted-foreground",children:[r.behind," behind"]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded"+(r.ahead>0?" bg-amber-500/10":""),children:[e.jsx("span",{className:"text-green-600",children:"↑"}),e.jsxs("span",{className:r.ahead>0?"text-amber-700 dark:text-amber-300 font-medium":"text-muted-foreground",children:[r.ahead," ",r.ahead>0?"unpushed":"ahead"]})]})]})]}),r.changes.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(o,{variant:"default",size:"sm",onClick:os,className:"h-7 text-xs",children:ls?"Deselect All":"Select All"}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground",children:["Uncommitted Changes (",r.changes.length,")"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 max-h-48 overflow-auto",children:e.jsx("ul",{className:"text-sm font-mono space-y-1",children:r.changes.map((s,t)=>e.jsxs("li",{className:"flex gap-2 items-center justify-between rounded px-2 py-1 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-1 min-w-0",children:[e.jsx(Ns,{checked:p.has(s.path),onCheckedChange:a=>ns(s.path,a===!0)}),e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-5 rounded bg-background text-xs font-semibold",children:rs(s.status)}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.path})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ds(s.path),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive flex-shrink-0",title:"Discard changes",children:e.jsx(Cs,{className:"h-3.5 w-3.5 opacity-50"})})]},t))})})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Commit Changes"}),p.size>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.size," of ",r.changes.length," file",r.changes.length!==1?"s":""," selected"]})]}),(r.changes?.length??0)>0?e.jsxs(e.Fragment,{children:[p.size===0&&e.jsx("div",{className:"mb-3 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900 rounded-lg p-2",children:"Select files above to commit specific changes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Describe your changes...",value:v,onChange:s=>K(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary",onKeyDown:s=>{s.key==="Enter"&&Q&&!z&&Ee()}}),e.jsxs(o,{onClick:Ee,disabled:!Q||z,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),z?"Committing…":"Commit"]})]})]}):e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground bg-muted/30 rounded-lg",children:"No uncommitted changes. Make some changes to your files to commit them."})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No status available"})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Branches"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",b.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ss(!I),"aria-label":I?"Collapse branches":"Expand branches",children:I?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground my-4",children:"Branches let you work on different features or fixes in isolation. Create a branch from any existing branch, switch between them, and merge them back when ready."}),e.jsxs("div",{className:"flex gap-2 mb-4 p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"From branch"}),e.jsx("select",{className:"text-sm border rounded-md px-3 py-2 bg-background",value:me,onChange:s=>Je(s.target.value),title:"Base branch for new branch",children:b.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-feature",value:g,onChange:s=>F(s.target.value),className:"bg-background border-2 border-primary focus-visible:border-primary"})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{onClick:gs,disabled:$||!g.trim(),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),$?"Creating…":"Create Branch"]})})]}),b.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No branches found. Create your first branch above."}):e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.current?e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-600 animate-pulse",title:"Current branch"}):e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-muted-foreground"}),e.jsx("div",{className:"font-mono text-sm font-medium",children:s.name}),s.current&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-600/10 text-green-600 font-medium",children:"ACTIVE"})]}),e.jsx("div",{className:"flex gap-1.5",children:!s.current&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>fs(s.name),disabled:be===s.name,title:"Switch to this branch",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),be===s.name?"Switching…":"Switch"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>bs(s.name),disabled:we===s.name,title:`Merge ${s.name} into ${r?.branch||"current branch"} (${B})`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),we===s.name?"Merging…":"Merge"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ps(s.name),disabled:qe===s.name,className:"text-destructive hover:text-destructive",title:"Delete this branch",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})})]},s.name))}),e.jsx("div",{className:"mt-4 pt-3 border-t flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Merge strategy:"}),e.jsxs("select",{className:"text-xs border rounded px-2 py-1 bg-background font-medium",value:B,onChange:s=>Ve(s.target.value),children:[e.jsx("option",{value:"merge",children:"Merge commit"}),e.jsx("option",{value:"squash",children:"Squash & merge"}),e.jsx("option",{value:"rebase",children:"Rebase & merge"})]})]})})]})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Worktrees"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ts(!L),"aria-label":L?"Collapse worktrees":"Expand worktrees",children:L?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Worktrees allow you to have multiple branches checked out simultaneously in different directories. Perfect for working on multiple features at once or testing changes without switching branches."}),e.jsxs("div",{className:"flex gap-2 mb-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(k,{placeholder:"feature/worktree-name",value:E,onChange:s=>de(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary"}),e.jsxs(o,{onClick:us,disabled:he||!E.trim(),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),he?"Creating…":"Create Worktree"]})]}),e.jsxs("p",{className:"mb-4 text-xs text-muted-foreground bg-muted/30 rounded-lg p-2",children:["💡 Worktrees are created in ",e.jsx("code",{className:"font-mono font-semibold",children:Xe})," relative to your project root.",e.jsx(ee,{to:"/settings/git",className:"underline underline-offset-2 ml-1 font-medium",children:"Configure location"})]}),y.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No worktrees yet. Create one to work on multiple branches simultaneously."}):e.jsx("div",{className:"space-y-2 mb-4",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3 bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",s.branch]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.path})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>De(s.name),disabled:A===s.name,title:"Pull latest changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),A===s.name?"Pulling…":"Pull"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ae(s.name),disabled:T===s.name,title:"Push changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),T===s.name?"Pushing…":"Push"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>hs(s.name),disabled:He===s.name,className:"text-destructive hover:text-destructive",title:"Remove worktree",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})]},s.name))})]})]}),e.jsx(se,{open:Ze,onOpenChange:w,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Authentication Required"}),e.jsx(ne,{children:"Configure git credentials to push or pull from the remote repository."})]}),e.jsxs(Ss,{defaultValue:h?.remote?.startsWith("https://")?"credentials":"instructions",className:"w-full",children:[e.jsxs(Ps,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"credentials",disabled:!h?.remote?.startsWith("https://"),children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]}),e.jsxs(Ge,{value:"instructions",children:[e.jsx($e,{className:"h-4 w-4 mr-2"}),"Setup Instructions"]})]}),e.jsxs(We,{value:"credentials",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-username",children:"Username"}),e.jsx(k,{id:"auth-username",placeholder:"your-username",value:G,onChange:s=>q(s.target.value),autoComplete:"username",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-password",children:"Password / Personal Access Token"}),e.jsx(k,{id:"auth-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:W,onChange:s=>V(s.target.value),autoComplete:"current-password",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We recommend using a Personal Access Token instead of your password."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1",onClick:()=>{w(!1),q(""),V("")},children:"Cancel"}),e.jsx(o,{className:"flex-1",onClick:xs,disabled:Ce||!G||!W,children:Ce?"Saving...":"Save & Test"})]})]}),e.jsxs(We,{value:"instructions",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure one of the following authentication methods:"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"SSH Keys (Recommended)"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:'ssh-keygen -t ed25519 -C "your_email@example.com"'}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Then add ~/.ssh/id_ed25519.pub to your GitHub/GitLab account"})]}),e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Git Credential Manager"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:"brew install git-credential-manager"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),className:"flex-1",children:"Close"}),e.jsx(o,{asChild:!0,className:"flex-1",children:e.jsx(ee,{to:"/settings/git",onClick:()=>w(!1),children:"Open Settings"})})]})]})]})]})}),e.jsx(se,{open:as,onOpenChange:_,children:e.jsxs(te,{className:"max-w-md",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-destructive"}),"Discard Changes?"]}),e.jsxs(ne,{children:["Are you sure you want to discard changes to ",e.jsx("code",{className:"font-mono text-sm bg-muted px-1 py-0.5 rounded",children:C}),"? This action cannot be undone."]})]}),e.jsxs(Oe,{children:[e.jsx(o,{variant:"outline",onClick:()=>{_(!1),X(null)},disabled:Y!==null,children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:ms,disabled:Y!==null,children:Y?"Discarding...":"Discard"})]})]})}),e.jsx(se,{open:es,onOpenChange:R,children:e.jsxs(te,{className:"max-w-lg",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-600"}),"Create a Branch First?"]}),e.jsxs(ne,{children:["You're about to commit directly to ",r?.branch,". It's best practice to create a feature branch first."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-blue-900 dark:text-blue-100",children:"Why create a branch?"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Keeps ",r?.branch," stable and deployable"]}),e.jsx("li",{children:"Makes it easier to review and test changes"}),e.jsx("li",{children:"Allows working on multiple features simultaneously"}),e.jsx("li",{children:"Simplifies collaboration with your team"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-awesome-feature",value:g,onChange:s=>F(s.target.value),onKeyDown:s=>{s.key==="Enter"&&g.trim()&&Fe()},className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create a new branch from ",r?.branch," and switch to it"]})]})]}),e.jsxs(Oe,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(o,{variant:"outline",onClick:js,disabled:z,className:"sm:flex-1",children:["Commit to ",r?.branch," Anyway"]}),e.jsxs(o,{onClick:Fe,disabled:!g.trim()||$,className:"sm:flex-1",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),$?"Creating...":"Create Branch & Switch"]})]})]})})]})}export{Qs as default};
16
+ */const Bs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Le=le("git-pull-request",Bs);let S;async function Os(){if(S!==void 0)return S;try{const m=await fetch(`${l}/api/v1/config`);if(!m.ok)return S=null,null;const r=(await m.json())?.data||{},f=r?.coconut?.id||r?.cloud?.coconutId||r?.cloud?.coconut_id;return S=typeof f=="string"&&f.trim()?f.trim():null,S}catch(m){return console.error("[github-token] Failed to load Coconut ID",m),S=null,null}}async function Rs(m){const x=await fetch(`${ws}/api/v1/git/token`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconutId:m})});if(!x.ok){let P="Failed to request GitHub token from control plane";if(x.status===401||x.status===403)throw new Error("Please sign in to app.coconut.dev and then retry the action.");try{const y=await x.json();P=y?.error?.message||y?.message||P}catch{}throw new Error(P)}const r=await x.json(),f=r?.token||r?.data?.token,b=r?.expiresAt||r?.data?.expiresAt;if(!f||!b)throw new Error("Control plane response missing token or expiresAt");return{token:f,expiresAt:b}}async function Gs(m,x){const r=await fetch(`${l}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m,expiresAt:x})}),f=await r.json().catch(()=>({}));if(!r.ok||!f?.success){const b=f?.error?.message||"Failed to store GitHub token on Coconut";throw new Error(b)}}async function Ws(){const m=await Os();if(!m)throw new Error("Coconut ID not configured. Reconnect via Settings → Git.");const{token:x,expiresAt:r}=await Rs(m);return await Gs(x,r),{tokenFetched:!0,message:r}}function Qs(){const[m,x]=n.useState(!0),[r,f]=n.useState(null),[b,P]=n.useState([]),[y,_e]=n.useState([]),[E,de]=n.useState(""),[g,$]=n.useState(""),[me,He]=n.useState("main"),[ue,c]=n.useState(null),{toast:i}=vs(),{refresh:H}=ys(),[he,xe]=n.useState(!1),[F,M]=n.useState(!1),[T,ge]=n.useState(null),[A,fe]=n.useState(null),[Je,pe]=n.useState(null),[be,je]=n.useState(null),[we,ve]=n.useState(null),[qe,ye]=n.useState(null),[B,Ve]=n.useState("merge"),[J,Ke]=n.useState("merge"),[Xe,Ye]=n.useState("../worktrees"),[O,Qe]=n.useState("github"),[h,Ne]=n.useState(null),[Ze,w]=n.useState(!1),[es,R]=n.useState(!1),[G,q]=n.useState(""),[W,V]=n.useState(""),[Ce,ke]=n.useState(!1),[v,K]=n.useState(""),[z,U]=n.useState(!1),[p,N]=n.useState(new Set),[I,ss]=n.useState(!1),[L,ts]=n.useState(!1),[as,_]=n.useState(!1),[C,X]=n.useState(null),[Y,Se]=n.useState(null),Pe=n.useCallback(async()=>{if(O!=="github"||h?.provider!=="github")return!0;if(h?.authenticated&&h?.expiresAt){const t=new Date(h.expiresAt).getTime(),a=Date.now(),d=300*1e3;if(t>a+d)return!0}const s=i({title:"Fetching GitHub token",description:"Contacting control plane…"});try{const{message:t}=await Ws();return i({title:"GitHub token ready",description:t?`Valid until ${new Date(t).toLocaleString()}`:"Token fetched successfully."}),Ne(a=>({...a,authenticated:!0,error:void 0,expiresAt:t??a?.expiresAt,provider:"github"})),!0}catch(t){const a=t?.message?`${t.message} Visit Settings → Git to reconnect.`:"Visit Settings → Git to connect GitHub.";return i({title:"GitHub token unavailable",description:a,variant:"destructive"}),c(t?.message||"GitHub authorization required. Visit Settings → Git to reconnect."),!1}finally{s?.dismiss?.()}},[O,h?.provider,h?.authenticated,h?.expiresAt,i]),u=async()=>{x(!0),c(null);try{const[s,t,a,d,Z]=await Promise.all([fetch(`${l}/api/v1/git/status`).then(j=>j.json()),fetch(`${l}/api/v1/git/branches`).then(j=>j.json()),fetch(`${l}/api/v1/git/worktrees`).then(j=>j.json()),fetch(`${l}/api/v1/git/settings`).then(j=>j.json()).catch(()=>null),fetch(`${l}/api/v1/git/auth-status`).then(j=>j.json()).catch(()=>null)]);s.success&&f(s.data),t.success&&P(t.data),a.success&&_e(a.data),d&&d.success&&d.data?.defaultWorktreePath&&(Ye(d.data.defaultWorktreePath),d.data.authMode&&Qe(d.data.authMode)),Z&&Z.success&&Ne(Z.data)}catch(s){c(s.message),i({title:"Failed to refresh",description:s.message,variant:"destructive"})}finally{x(!1)}};n.useEffect(()=>{u()},[]);const Te=n.useMemo(()=>{const s=r?.branch?.toLowerCase();return s==="main"||s==="master"},[r?.branch]),Q=n.useMemo(()=>{const s=!!v.trim(),t=p.size>0;return s&&t},[v,p]),rs=s=>s==="??"||s.includes("U")?"U":s.includes("R")?"R":s.includes("C")?"C":s.includes("D")?"D":s.includes("A")?"A":s.includes("M")?"M":s||"?",ns=(s,t)=>{N(a=>{const d=new Set(a);return t?d.add(s):d.delete(s),d})},is=()=>{r?.changes&&N(new Set(r.changes.map(s=>s.path)))},cs=()=>{N(new Set)},os=()=>{r?.changes&&(r.changes.every(t=>p.has(t.path))?cs():is())},ls=n.useMemo(()=>!r?.changes||r.changes.length===0?!1:r.changes.every(s=>p.has(s.path)),[r?.changes,p]),ds=s=>{X(s),_(!0)},ms=async()=>{if(C){Se(C),c(null);try{const s=await fetch(`${l}/api/v1/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:C})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to discard file");N(t=>{const a=new Set(t);return a.delete(C),a}),i({title:"File discarded",description:C}),_(!1),X(null),await u(),await H()}catch(s){c(s.message),i({title:"Discard failed",description:s.message,variant:"destructive"})}finally{Se(null)}}},us=async()=>{if(E.trim()){xe(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:E,from:"main"})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create worktree");de(""),await u(),i({title:"Worktree created",description:s.data?.added?.branch})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}xe(!1)}},Ae=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{ge(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/push`:"/api/v1/git/push",a=await fetch(`${l}${t}`,{method:"POST"}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Push failed");i({title:"Pushed",description:s?`Worktree ${s}`:"Current branch"}),await u()}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Push failed",description:a,variant:"destructive"}),d&&w(!0)}ge(null)}},De=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{fe(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/pull`:"/api/v1/git/pull",a=await fetch(`${l}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:J})}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Pull failed");await u(),i({title:"Pulled",description:`${s?`Worktree ${s}`:"Current branch"} (${J})`})}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Pull failed",description:a,variant:"destructive"}),d&&w(!0)}fe(null)}},hs=async s=>{if(confirm(`Remove worktree ${s}?`)){c(null);try{pe(s);const t=await fetch(`${l}/api/v1/git/worktrees/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to remove worktree");await u(),i({title:"Worktree removed",description:s})}catch(t){c(t.message),i({title:"Remove failed",description:t.message,variant:"destructive"})}pe(t=>t===s?null:t)}},xs=async()=>{if(!G||!W){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}ke(!0);try{const t=await(await fetch(`${l}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:W})})).json();if(!t.success)throw new Error(t.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),w(!1),q(""),V(""),await u()}catch(s){i({title:"Error",description:s?.message||"Failed to save credentials",variant:"destructive"})}finally{ke(!1)}},gs=async()=>{if(g.trim()){M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:me})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");$(""),await u(),i({title:"Branch created",description:g})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}M(!1)}},fs=async s=>{je(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");await u(),i({title:"Switched branch",description:s})}catch(t){c(t.message),i({title:"Switch failed",description:t.message,variant:"destructive"})}je(null)},ps=async s=>{if(confirm(`Delete branch ${s}?`)){ye(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to delete branch");await u(),i({title:"Branch deleted",description:s})}catch(t){c(t.message),i({title:"Delete failed",description:t.message,variant:"destructive"})}ye(null)}},bs=async s=>{ve(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:B})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to merge branch");await u(),i({title:"Branch merged",description:`${s} (${B})`})}catch(t){c(t.message),i({title:"Merge failed",description:t.message,variant:"destructive"})}ve(null)},Ee=async()=>{if(Q){if(Te){R(!0);return}U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)}},js=async()=>{R(!1),U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)},$e=async()=>{if(g.trim()){R(!1),M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:r?.branch})}).then(a=>a.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(g)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");$(""),await u(),i({title:"Branch created & switched",description:g})}catch(s){c(s.message),i({title:"Failed",description:s.message,variant:"destructive"})}M(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Source Control"}),h&&e.jsx(ee,{to:"/settings/git",className:"flex items-center gap-1.5 text-xs rounded-full px-2.5 py-1 border hover:bg-muted transition-colors",title:h.authenticated?"Authenticated with remote":"Authentication required - click to configure",children:h.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"h-3 w-3 text-green-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Not authenticated"}),e.jsx(Fe,{className:"h-3 w-3 text-muted-foreground ml-0.5"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{className:"text-sm border rounded-md px-3 py-2 bg-background h-9",value:J,onChange:s=>Ke(s.target.value),title:"Pull strategy",children:[e.jsx("option",{value:"merge",children:"Merge"}),e.jsx("option",{value:"rebase",children:"Rebase"}),e.jsx("option",{value:"ff-only",children:"FF only"})]}),e.jsxs(o,{variant:"outline",onClick:()=>De(),size:"sm",disabled:A==="",children:[e.jsx(Ds,{className:"h-4 w-4 mr-2"+(A===""?" animate-spin":"")}),A===""?"Pulling…":"Pull"]}),e.jsxs(o,{onClick:()=>Ae(),size:"sm",disabled:T==="",children:[e.jsx(Es,{className:"h-4 w-4 mr-2"+(T===""?" animate-spin":"")}),T===""?"Pushing…":"Push"]})]})]}),ue&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-900 dark:bg-red-950",children:ue}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Repository Status"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(o,{variant:"outline",size:"sm","aria-label":"Refresh status",onClick:u,disabled:m,children:[e.jsx(ze,{className:"h-4 w-4"+(m?" animate-spin":"")}),"Refresh"]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview of your current branch, sync status with the remote, and uncommitted changes."}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ze,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Branch:"}),e.jsx("span",{className:"font-mono font-semibold",children:r.branch}),Te&&e.jsxs("span",{className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-amber-500/10 text-amber-600",children:[e.jsx(ce,{className:"h-3 w-3"}),"Default branch"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-blue-600",children:"↓"}),e.jsxs("span",{className:"text-muted-foreground",children:[r.behind," behind"]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded"+(r.ahead>0?" bg-amber-500/10":""),children:[e.jsx("span",{className:"text-green-600",children:"↑"}),e.jsxs("span",{className:r.ahead>0?"text-amber-700 dark:text-amber-300 font-medium":"text-muted-foreground",children:[r.ahead," ",r.ahead>0?"unpushed":"ahead"]})]})]})]}),r.changes.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(o,{variant:"default",size:"sm",onClick:os,className:"h-7 text-xs",children:ls?"Deselect All":"Select All"}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground",children:["Uncommitted Changes (",r.changes.length,")"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 max-h-48 overflow-auto",children:e.jsx("ul",{className:"text-sm font-mono space-y-1",children:r.changes.map((s,t)=>e.jsxs("li",{className:"flex gap-2 items-center justify-between rounded px-2 py-1 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-1 min-w-0",children:[e.jsx(Ns,{checked:p.has(s.path),onCheckedChange:a=>ns(s.path,a===!0)}),e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-5 rounded bg-background text-xs font-semibold",children:rs(s.status)}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.path})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ds(s.path),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive flex-shrink-0",title:"Discard changes",children:e.jsx(Cs,{className:"h-3.5 w-3.5 opacity-50"})})]},t))})})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Commit Changes"}),p.size>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.size," of ",r.changes.length," file",r.changes.length!==1?"s":""," selected"]})]}),(r.changes?.length??0)>0?e.jsxs(e.Fragment,{children:[p.size===0&&e.jsx("div",{className:"mb-3 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900 rounded-lg p-2",children:"Select files above to commit specific changes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Describe your changes...",value:v,onChange:s=>K(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary",onKeyDown:s=>{s.key==="Enter"&&Q&&!z&&Ee()}}),e.jsxs(o,{onClick:Ee,disabled:!Q||z,children:[e.jsx(Fs,{className:"h-4 w-4 mr-2"}),z?"Committing…":"Commit"]})]})]}):e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground bg-muted/30 rounded-lg",children:"No uncommitted changes. Make some changes to your files to commit them."})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No status available"})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Branches"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",b.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ss(!I),"aria-label":I?"Collapse branches":"Expand branches",children:I?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground my-4",children:"Branches let you work on different features or fixes in isolation. Create a branch from any existing branch, switch between them, and merge them back when ready."}),e.jsxs("div",{className:"flex gap-2 mb-4 p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"From branch"}),e.jsx("select",{className:"text-sm border rounded-md px-3 py-2 bg-background",value:me,onChange:s=>He(s.target.value),title:"Base branch for new branch",children:b.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-feature",value:g,onChange:s=>$(s.target.value),className:"bg-background border-2 border-primary focus-visible:border-primary"})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{onClick:gs,disabled:F||!g.trim(),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating…":"Create Branch"]})})]}),b.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No branches found. Create your first branch above."}):e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.current?e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-600 animate-pulse",title:"Current branch"}):e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-muted-foreground"}),e.jsx("div",{className:"font-mono text-sm font-medium",children:s.name}),s.current&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-600/10 text-green-600 font-medium",children:"ACTIVE"})]}),e.jsx("div",{className:"flex gap-1.5",children:!s.current&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>fs(s.name),disabled:be===s.name,title:"Switch to this branch",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),be===s.name?"Switching…":"Switch"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>bs(s.name),disabled:we===s.name,title:`Merge ${s.name} into ${r?.branch||"current branch"} (${B})`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),we===s.name?"Merging…":"Merge"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ps(s.name),disabled:qe===s.name,className:"text-destructive hover:text-destructive",title:"Delete this branch",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})})]},s.name))}),e.jsx("div",{className:"mt-4 pt-3 border-t flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Merge strategy:"}),e.jsxs("select",{className:"text-xs border rounded px-2 py-1 bg-background font-medium",value:B,onChange:s=>Ve(s.target.value),children:[e.jsx("option",{value:"merge",children:"Merge commit"}),e.jsx("option",{value:"squash",children:"Squash & merge"}),e.jsx("option",{value:"rebase",children:"Rebase & merge"})]})]})})]})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Worktrees"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ts(!L),"aria-label":L?"Collapse worktrees":"Expand worktrees",children:L?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Worktrees allow you to have multiple branches checked out simultaneously in different directories. Perfect for working on multiple features at once or testing changes without switching branches."}),e.jsxs("div",{className:"flex gap-2 mb-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(k,{placeholder:"feature/worktree-name",value:E,onChange:s=>de(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary"}),e.jsxs(o,{onClick:us,disabled:he||!E.trim(),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),he?"Creating…":"Create Worktree"]})]}),e.jsxs("p",{className:"mb-4 text-xs text-muted-foreground bg-muted/30 rounded-lg p-2",children:["💡 Worktrees are created in ",e.jsx("code",{className:"font-mono font-semibold",children:Xe})," relative to your project root.",e.jsx(ee,{to:"/settings/git",className:"underline underline-offset-2 ml-1 font-medium",children:"Configure location"})]}),y.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No worktrees yet. Create one to work on multiple branches simultaneously."}):e.jsx("div",{className:"space-y-2 mb-4",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3 bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",s.branch]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.path})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>De(s.name),disabled:A===s.name,title:"Pull latest changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),A===s.name?"Pulling…":"Pull"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ae(s.name),disabled:T===s.name,title:"Push changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),T===s.name?"Pushing…":"Push"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>hs(s.name),disabled:Je===s.name,className:"text-destructive hover:text-destructive",title:"Remove worktree",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})]},s.name))})]})]}),e.jsx(se,{open:Ze,onOpenChange:w,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Authentication Required"}),e.jsx(ne,{children:"Configure git credentials to push or pull from the remote repository."})]}),e.jsxs(Ss,{defaultValue:h?.remote?.startsWith("https://")?"credentials":"instructions",className:"w-full",children:[e.jsxs(Ps,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"credentials",disabled:!h?.remote?.startsWith("https://"),children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]}),e.jsxs(Ge,{value:"instructions",children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Setup Instructions"]})]}),e.jsxs(We,{value:"credentials",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-username",children:"Username"}),e.jsx(k,{id:"auth-username",placeholder:"your-username",value:G,onChange:s=>q(s.target.value),autoComplete:"username",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-password",children:"Password / Personal Access Token"}),e.jsx(k,{id:"auth-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:W,onChange:s=>V(s.target.value),autoComplete:"current-password",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We recommend using a Personal Access Token instead of your password."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1",onClick:()=>{w(!1),q(""),V("")},children:"Cancel"}),e.jsx(o,{className:"flex-1",onClick:xs,disabled:Ce||!G||!W,children:Ce?"Saving...":"Save & Test"})]})]}),e.jsxs(We,{value:"instructions",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure one of the following authentication methods:"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"SSH Keys (Recommended)"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:'ssh-keygen -t ed25519 -C "your_email@example.com"'}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Then add ~/.ssh/id_ed25519.pub to your GitHub/GitLab account"})]}),e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Git Credential Manager"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:"brew install git-credential-manager"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),className:"flex-1",children:"Close"}),e.jsx(o,{asChild:!0,className:"flex-1",children:e.jsx(ee,{to:"/settings/git",onClick:()=>w(!1),children:"Open Settings"})})]})]})]})]})}),e.jsx(se,{open:as,onOpenChange:_,children:e.jsxs(te,{className:"max-w-md",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-destructive"}),"Discard Changes?"]}),e.jsxs(ne,{children:["Are you sure you want to discard changes to ",e.jsx("code",{className:"font-mono text-sm bg-muted px-1 py-0.5 rounded",children:C}),"? This action cannot be undone."]})]}),e.jsxs(Oe,{children:[e.jsx(o,{variant:"outline",onClick:()=>{_(!1),X(null)},disabled:Y!==null,children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:ms,disabled:Y!==null,children:Y?"Discarding...":"Discard"})]})]})}),e.jsx(se,{open:es,onOpenChange:R,children:e.jsxs(te,{className:"max-w-lg",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-600"}),"Create a Branch First?"]}),e.jsxs(ne,{children:["You're about to commit directly to ",r?.branch,". It's best practice to create a feature branch first."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-blue-900 dark:text-blue-100",children:"Why create a branch?"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Keeps ",r?.branch," stable and deployable"]}),e.jsx("li",{children:"Makes it easier to review and test changes"}),e.jsx("li",{children:"Allows working on multiple features simultaneously"}),e.jsx("li",{children:"Simplifies collaboration with your team"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-awesome-feature",value:g,onChange:s=>$(s.target.value),onKeyDown:s=>{s.key==="Enter"&&g.trim()&&$e()},className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create a new branch from ",r?.branch," and switch to it"]})]})]}),e.jsxs(Oe,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(o,{variant:"outline",onClick:js,disabled:z,className:"sm:flex-1",children:["Commit to ",r?.branch," Anyway"]}),e.jsxs(o,{onClick:$e,disabled:!g.trim()||F,className:"sm:flex-1",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating...":"Create Branch & Switch"]})]})]})})]})}export{Qs as default};