loki-mode 9.69.0 → 9.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/completion-council.sh +23 -6
  4. package/autonomy/loki +41 -16
  5. package/autonomy/run.sh +7 -1
  6. package/dashboard/__init__.py +1 -1
  7. package/dashboard/static/index.html +2 -1
  8. package/docs/INSTALLATION.md +1 -1
  9. package/docs/v10/BOARD.md +18 -18
  10. package/docs/v10/TODO.md +18 -28
  11. package/loki-ts/dist/loki.js +2 -2
  12. package/mcp/__init__.py +1 -1
  13. package/package.json +1 -1
  14. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  15. package/web-app/dist/assets/{AdminPage-CPW7u9tJ.js → AdminPage-5-i7dYRv.js} +1 -1
  16. package/web-app/dist/assets/{Avatar-BhRtaUAf.js → Avatar-DOgXkiA5.js} +1 -1
  17. package/web-app/dist/assets/{Badge-s77pIGLL.js → Badge-BBCAEx-v.js} +1 -1
  18. package/web-app/dist/assets/{Button-8cbxl-XL.js → Button-mrjJiIzX.js} +1 -1
  19. package/web-app/dist/assets/{CockpitPage-ClXReCar.js → CockpitPage-DO1BqQtR.js} +1 -1
  20. package/web-app/dist/assets/{ComparePage-4YF0E8Y0.js → ComparePage-CttX-p4A.js} +1 -1
  21. package/web-app/dist/assets/{ErrorBoundary-Ddl2zJ-Q.js → ErrorBoundary-DrXZPl7W.js} +1 -1
  22. package/web-app/dist/assets/{EvidenceReceiptPanel-DQz-lFwc.js → EvidenceReceiptPanel-DsHfSljL.js} +1 -1
  23. package/web-app/dist/assets/{GitHubIssuesPanel-Dixk_nbH.js → GitHubIssuesPanel-DXDCz06W.js} +1 -1
  24. package/web-app/dist/assets/{GitHubPRsPanel-D-mWUpjU.js → GitHubPRsPanel-3qECbDiA.js} +1 -1
  25. package/web-app/dist/assets/{HomePage-BIP-AOaV.js → HomePage-vb55Jnnw.js} +2 -2
  26. package/web-app/dist/assets/{LoginPage-CGXcRM1H.js → LoginPage-C1wouCAg.js} +1 -1
  27. package/web-app/dist/assets/{MagicPage-w-7wL0Yx.js → MagicPage-Ccf2TzsX.js} +1 -1
  28. package/web-app/dist/assets/{MetricsPage-jK92Q32u.js → MetricsPage-DxpjKBlD.js} +1 -1
  29. package/web-app/dist/assets/{NotFoundPage-ZJwD0l5Y.js → NotFoundPage-BjesliCI.js} +1 -1
  30. package/web-app/dist/assets/{ProjectPage-DPyO5DCA.js → ProjectPage-OLJv91Fm.js} +4 -4
  31. package/web-app/dist/assets/{ProjectsPage-DPa_pwYV.js → ProjectsPage-Bd0VWUNT.js} +1 -1
  32. package/web-app/dist/assets/{SettingsPage-C2JFhnZx.js → SettingsPage-B92ofTn5.js} +1 -1
  33. package/web-app/dist/assets/ShowcasePage-Ben4Ud4y.js +1 -0
  34. package/web-app/dist/assets/SystemSettingsPage-DQ7y1jJw.js +1 -0
  35. package/web-app/dist/assets/{TeamsPage-BOdmj8Ci.js → TeamsPage-DvI2Ysar.js} +1 -1
  36. package/web-app/dist/assets/{TemplatesPage-CPBTyO3Z.js → TemplatesPage-qkFTI361.js} +1 -1
  37. package/web-app/dist/assets/{TerminalOutput-5w6qt3am.js → TerminalOutput-Bbi5Qsu1.js} +1 -1
  38. package/web-app/dist/assets/{activity-WHG7RxVL.js → activity-B6_UNFP3.js} +1 -1
  39. package/web-app/dist/assets/{bell-mrKJNTMd.js → bell-D9bRY83l.js} +1 -1
  40. package/web-app/dist/assets/{bot-BO_6hrmU.js → bot-B9XE8rVE.js} +1 -1
  41. package/web-app/dist/assets/{check-BPynHeeg.js → check-CIlNFVu7.js} +1 -1
  42. package/web-app/dist/assets/{chevron-left-Dfy86g55.js → chevron-left-sqTwkCti.js} +1 -1
  43. package/web-app/dist/assets/{circle-alert-j0J21snc.js → circle-alert-ClR-8eiz.js} +1 -1
  44. package/web-app/dist/assets/{clock-B6g4PLdQ.js → clock-DhrLudbQ.js} +1 -1
  45. package/web-app/dist/assets/{cloud-CNniMSkg.js → cloud-CbY5ijES.js} +1 -1
  46. package/web-app/dist/assets/{code-xml-DfbVZ8e6.js → code-xml-DGN0zQOT.js} +1 -1
  47. package/web-app/dist/assets/{database-D-3X-HfV.js → database-CFkV71Ae.js} +1 -1
  48. package/web-app/dist/assets/{dollar-sign-61G2HLQb.js → dollar-sign-t0__nc7_.js} +1 -1
  49. package/web-app/dist/assets/{file-code-corner-SX2tNRWt.js → file-code-corner-V4yaRoxs.js} +1 -1
  50. package/web-app/dist/assets/{file-plus-uBkhrSTF.js → file-plus-BTdcA9zR.js} +1 -1
  51. package/web-app/dist/assets/{globe-Boxp5WvY.js → globe-DJ8UlFt2.js} +1 -1
  52. package/web-app/dist/assets/{hammer-CH2dHEVO.js → hammer-DSpaXtqP.js} +1 -1
  53. package/web-app/dist/assets/{index-QkrBk17c.js → index-aYgURGFC.js} +14 -17
  54. package/web-app/dist/assets/{layers-CNEFtp9e.js → layers-cbPS7UG9.js} +1 -1
  55. package/web-app/dist/assets/{loader-circle-Bqrcv5u2.js → loader-circle-CciQSsBx.js} +1 -1
  56. package/web-app/dist/assets/{lock-B3JEFmN7.js → lock-JtWoEayV.js} +1 -1
  57. package/web-app/dist/assets/{package-CKGU_qVz.js → package-Dcv0g9iv.js} +1 -1
  58. package/web-app/dist/assets/{plus-C5JdVMit.js → plus-R_7Xr4PC.js} +1 -1
  59. package/web-app/dist/assets/{refresh-cw--TAFe9rs.js → refresh-cw-6MdZdvHz.js} +1 -1
  60. package/web-app/dist/assets/{rotate-ccw-Ctp9TQHw.js → rotate-ccw-Dcteu0jr.js} +1 -1
  61. package/web-app/dist/assets/{scroll-text-PBn0162f.js → scroll-text-Xcw2I15b.js} +1 -1
  62. package/web-app/dist/assets/{server-IDnQPQXH.js → server-BhMeLqV8.js} +1 -1
  63. package/web-app/dist/assets/{shield-alert-TIxCJQgv.js → shield-alert-Y7birYk_.js} +1 -1
  64. package/web-app/dist/assets/{thumbs-up-Cln0A7Qt.js → thumbs-up-B9I1RzAj.js} +1 -1
  65. package/web-app/dist/assets/{trash-2-CgamkKFR.js → trash-2-FrJ_zeQ_.js} +1 -1
  66. package/web-app/dist/assets/{trending-down-BPzQ_tCr.js → trending-down-DA-YY1yX.js} +1 -1
  67. package/web-app/dist/assets/{trending-up-Biap94MX.js → trending-up-CC7ghXOa.js} +1 -1
  68. package/web-app/dist/assets/{upload-D1ER7BVL.js → upload-Btyqt4Cn.js} +1 -1
  69. package/web-app/dist/assets/{usePolling-Cj1AXL0Z.js → usePolling-CTqGbMeS.js} +1 -1
  70. package/web-app/dist/assets/{user-ytdejGkb.js → user-AWsEaMJm.js} +1 -1
  71. package/web-app/dist/index.html +1 -1
  72. package/web-app/dist/assets/ShowcasePage-Dj5ZHpkm.js +0 -1
  73. package/web-app/dist/assets/SystemSettingsPage-y6nAFJoW.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-Dixk_nbH.js","assets/index-QkrBk17c.js","assets/index-BfQ0f3-S.css","assets/Button-8cbxl-XL.js","assets/thumbs-up-Cln0A7Qt.js","assets/refresh-cw--TAFe9rs.js","assets/circle-alert-j0J21snc.js","assets/user-ytdejGkb.js","assets/loader-circle-Bqrcv5u2.js","assets/rotate-ccw-Ctp9TQHw.js","assets/GitHubPRsPanel-D-mWUpjU.js","assets/chevron-left-Dfy86g55.js","assets/shield-alert-TIxCJQgv.js","assets/file-code-corner-SX2tNRWt.js","assets/clock-B6g4PLdQ.js","assets/check-BPynHeeg.js","assets/ErrorBoundary-Ddl2zJ-Q.js","assets/TerminalOutput-5w6qt3am.js","assets/lock-B3JEFmN7.js","assets/package-CKGU_qVz.js","assets/file-plus-uBkhrSTF.js","assets/activity-WHG7RxVL.js","assets/scroll-text-PBn0162f.js","assets/bot-BO_6hrmU.js","assets/hammer-CH2dHEVO.js","assets/dollar-sign-61G2HLQb.js","assets/globe-Boxp5WvY.js","assets/trash-2-CgamkKFR.js","assets/upload-D1ER7BVL.js","assets/plus-C5JdVMit.js","assets/code-xml-DfbVZ8e6.js","assets/trending-up-Biap94MX.js","assets/layers-CNEFtp9e.js","assets/trending-down-BPzQ_tCr.js","assets/server-IDnQPQXH.js"])))=>i.map(i=>d[i]);
2
- var ra=e=>{throw TypeError(e)};var na=(e,t,s)=>t.has(e)||ra("Cannot "+s);var Us=(e,t,s)=>(na(e,t,"read from private field"),s?s.call(e):t.get(e)),oa=(e,t,s)=>t.has(e)?ra("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),aa=(e,t,s,i)=>(na(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ae,r as d,W as Ms,j as r,e as sn,f as Vl,g as mr,h as ms,I as xd,T as Ut,R as Kt,i as os,M as Gl,k as sr,l as ps,S as Yl,U as vd,X as gt,m as as,Z as Ls,a as W,E as ls,G as Te,K as bd,n as yd,o as Sd,F as _i,P as rs,_ as eo,p as pr,q as Xl,s as wd,t as Cd,v as kd,A as to,L as Nd,B as Js,w as rn,x as jd,d as Ed,y as Es,z as la,D as ca,H as Dd,J as Jl,N as oi,O as Rd,u as Pd}from"./index-QkrBk17c.js";import{R as Md,S as ir,P as Zl,E as Wi}from"./ErrorBoundary-Ddl2zJ-Q.js";import{B as le}from"./Button-8cbxl-XL.js";import{T as Ld,F as Bd}from"./TerminalOutput-5w6qt3am.js";import{P as Ql}from"./package-CKGU_qVz.js";import{F as Q}from"./file-code-corner-SX2tNRWt.js";import{F as _r}from"./file-plus-uBkhrSTF.js";import{C as ut}from"./clock-B6g4PLdQ.js";import{A as Td}from"./activity-WHG7RxVL.js";import{S as zd}from"./scroll-text-PBn0162f.js";import{B as Ad}from"./bot-BO_6hrmU.js";import{C as Yt}from"./check-BPynHeeg.js";import{L as gi}from"./loader-circle-Bqrcv5u2.js";import{H as Od}from"./hammer-CH2dHEVO.js";import{D as ec}from"./dollar-sign-61G2HLQb.js";import{R as bt}from"./refresh-cw--TAFe9rs.js";import{C as _s}from"./circle-alert-j0J21snc.js";import{G as nn}from"./globe-Boxp5WvY.js";import{C as so,T as io,F as on}from"./trash-2-CgamkKFR.js";import{C as $d,G as an,a as tc,F as sc,H as rr,M as ic,T as Id}from"./thumbs-up-Cln0A7Qt.js";import{U as rc}from"./upload-D1ER7BVL.js";import{P as gr}from"./plus-C5JdVMit.js";import{R as nc,E as Fd}from"./rotate-ccw-Ctp9TQHw.js";import{C as ln}from"./code-xml-DfbVZ8e6.js";import{T as Hd}from"./trending-up-Biap94MX.js";import{L as Wd}from"./layers-CNEFtp9e.js";import{T as Ud}from"./trending-down-BPzQ_tCr.js";import{S as Kd}from"./server-IDnQPQXH.js";/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-DXDCz06W.js","assets/index-aYgURGFC.js","assets/index-BfQ0f3-S.css","assets/Button-mrjJiIzX.js","assets/thumbs-up-B9I1RzAj.js","assets/refresh-cw-6MdZdvHz.js","assets/circle-alert-ClR-8eiz.js","assets/user-AWsEaMJm.js","assets/loader-circle-CciQSsBx.js","assets/rotate-ccw-Dcteu0jr.js","assets/GitHubPRsPanel-3qECbDiA.js","assets/chevron-left-sqTwkCti.js","assets/shield-alert-Y7birYk_.js","assets/file-code-corner-V4yaRoxs.js","assets/clock-DhrLudbQ.js","assets/check-CIlNFVu7.js","assets/ErrorBoundary-DrXZPl7W.js","assets/TerminalOutput-Bbi5Qsu1.js","assets/lock-JtWoEayV.js","assets/package-Dcv0g9iv.js","assets/file-plus-BTdcA9zR.js","assets/activity-B6_UNFP3.js","assets/scroll-text-Xcw2I15b.js","assets/bot-B9XE8rVE.js","assets/hammer-DSpaXtqP.js","assets/dollar-sign-t0__nc7_.js","assets/globe-DJ8UlFt2.js","assets/trash-2-FrJ_zeQ_.js","assets/upload-Btyqt4Cn.js","assets/plus-R_7Xr4PC.js","assets/code-xml-DGN0zQOT.js","assets/trending-up-CC7ghXOa.js","assets/layers-cbPS7UG9.js","assets/trending-down-DA-YY1yX.js","assets/server-BhMeLqV8.js"])))=>i.map(i=>d[i]);
2
+ var ra=e=>{throw TypeError(e)};var na=(e,t,s)=>t.has(e)||ra("Cannot "+s);var Us=(e,t,s)=>(na(e,t,"read from private field"),s?s.call(e):t.get(e)),oa=(e,t,s)=>t.has(e)?ra("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),aa=(e,t,s,i)=>(na(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ae,r as d,W as Ms,j as r,e as sn,f as Vl,g as mr,h as ms,I as xd,T as Ut,R as Kt,i as os,M as Gl,k as sr,l as ps,S as Yl,U as vd,X as gt,m as as,Z as Ls,a as W,E as ls,G as Te,K as bd,n as yd,o as Sd,F as _i,P as rs,_ as eo,p as pr,q as Xl,s as wd,t as Cd,v as kd,A as to,L as Nd,B as Js,w as rn,x as jd,d as Ed,y as Es,z as la,D as ca,H as Dd,J as Jl,N as oi,O as Rd,u as Pd}from"./index-aYgURGFC.js";import{R as Md,S as ir,P as Zl,E as Wi}from"./ErrorBoundary-DrXZPl7W.js";import{B as le}from"./Button-mrjJiIzX.js";import{T as Ld,F as Bd}from"./TerminalOutput-Bbi5Qsu1.js";import{P as Ql}from"./package-Dcv0g9iv.js";import{F as Q}from"./file-code-corner-V4yaRoxs.js";import{F as _r}from"./file-plus-BTdcA9zR.js";import{C as ut}from"./clock-DhrLudbQ.js";import{A as Td}from"./activity-B6_UNFP3.js";import{S as zd}from"./scroll-text-Xcw2I15b.js";import{B as Ad}from"./bot-B9XE8rVE.js";import{C as Yt}from"./check-CIlNFVu7.js";import{L as gi}from"./loader-circle-CciQSsBx.js";import{H as Od}from"./hammer-DSpaXtqP.js";import{D as ec}from"./dollar-sign-t0__nc7_.js";import{R as bt}from"./refresh-cw-6MdZdvHz.js";import{C as _s}from"./circle-alert-ClR-8eiz.js";import{G as nn}from"./globe-DJ8UlFt2.js";import{C as so,T as io,F as on}from"./trash-2-FrJ_zeQ_.js";import{C as $d,G as an,a as tc,F as sc,H as rr,M as ic,T as Id}from"./thumbs-up-B9I1RzAj.js";import{U as rc}from"./upload-Btyqt4Cn.js";import{P as gr}from"./plus-R_7Xr4PC.js";import{R as nc,E as Fd}from"./rotate-ccw-Dcteu0jr.js";import{C as ln}from"./code-xml-DGN0zQOT.js";import{T as Hd}from"./trending-up-CC7ghXOa.js";import{L as Wd}from"./layers-cbPS7UG9.js";import{T as Ud}from"./trending-down-DA-YY1yX.js";import{S as Kd}from"./server-BhMeLqV8.js";/**
3
3
  * @license lucide-react v0.577.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
@@ -222,7 +222,7 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
222
222
  \x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(Zg*Math.pow(2,x),Qg);h.current=x+1,_&&_.writeln(`\r
223
223
  \x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${x+1}/${jl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&f()},y)},g.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const p=s.current;if(!p)return;const u=new Hg({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),g=new Kg,m=new Jg;u.loadAddon(g),u.loadAddon(m),u.open(p),i.current=u,n.current=g;try{g.fit()}catch{}u.onData(y=>{const v=o.current;v&&v.readyState===WebSocket.OPEN&&v.send(JSON.stringify({type:"input",data:y}))}),f();let _=null;const x=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return x.observe(p),()=>{l.current=!1,x.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),u.dispose(),i.current=null,n.current=null}},[f,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const p=setTimeout(()=>{var u;try{(u=n.current)==null||u.fit(),c()}catch{}},50);return()=>clearTimeout(p)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const El={file_created:{icon:_r,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Q,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Ql,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:ps,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Gl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:os,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ut,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:xd,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Dl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function tx({event:e,isLast:t,onFileClick:s}){const i=El[e.type]||El.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(ut,{size:10}),Dl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(ut,{size:10}),Dl(e.timestamp)]})]})})]})}const Xr=20,Rl=10;function sx({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Xr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Vl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Xr&&n,l=a?e.slice(-Rl):e,h=a?e.length-Rl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(mr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Xr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ms,{size:12}),"Collapse older events"]}),l.map((c,f)=>r.jsx(tx,{event:c,isLast:f===l.length-1,onFileClick:t},c.id))]})}const Pl=[{id:"terminal",label:"Terminal",icon:os,alwaysShow:!0},{id:"activity",label:"Activity",icon:Td,alwaysShow:!0},{id:"build",label:"Build Log",icon:zd},{id:"agents",label:"Agents",icon:Ad},{id:"quality",label:"Quality",icon:Yl}];function ix({status:e}){switch(e){case"pass":return r.jsx(Yt,{size:14,className:"text-success"});case"fail":return r.jsx(gt,{size:14,className:"text-danger"});default:return r.jsx(ut,{size:14,className:"text-muted"})}}function rx({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(vd,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function nx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Yl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ix,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function ox({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var _;const[c,f]=d.useState("terminal"),p=s&&s.length>0,u=i&&i.items&&i.items.length>0,g=e&&e.length>0,m=Pl.filter(x=>!!(x.alwaysShow||x.id==="build"&&(g||o)||x.id==="agents"&&(p||o)||x.id==="quality"&&(u||o)));return m.find(x=>x.id===c)||f("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:m.map(x=>{const y=x.icon,v=c===x.id;return r.jsxs("button",{role:"tab","aria-selected":v,onClick:()=>f(x.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${v?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),x.label,x.id==="agents"&&p&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),x.id==="quality"&&u&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},x.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=Pl.find(x=>x.id===c))==null?void 0:_.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(ex,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Ld,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(rx,{agents:s}),c==="activity"&&r.jsx(sx,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(nx,{checklist:i})]})]})}const Ml={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Working..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function ax({context:e="general",className:t=""}){const s=Ml[e]||Ml.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{if(s.length<2)return;const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(gi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Jr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:eu},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Od},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ai},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:as},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:ps}];function lx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(null),[h,c]=d.useState(e),[f,p]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){p(!0);const x=setTimeout(()=>{c(e),p(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const u=Jr.findIndex(x=>x.id===e),g=t!==null&&s?Math.min(t/s*100,100):0,m=a!==null&&t&&s?Math.ceil(a/t*Math.max(0,s-t)):null,_=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${g}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${f?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Jr.map((x,y)=>{const v=y<u,j=y===u,k=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${j?"phase-indicator-active":""} ${v?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${j?"phase-icon-active":""} ${v?"phase-icon-complete":""}`,children:v?r.jsx(ps,{size:14,className:"text-success phase-check-enter"}):j?r.jsx(k,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(k,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${j?"text-ink":v?"text-success":"text-muted/50"}`,children:x.label}),y<Jr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${v?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(ax,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ls,{size:12}),"Iter ",t??"--",s?`/${s}`:""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ut,{size:12}),a===null?"--":_(a),o&&m!==null&&m>0&&r.jsxs("span",{className:"text-muted/60",children:["(est. ",_(m)," to iteration cap)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ec,{size:12}),i!==null?`$${i.toFixed(2)}`:"not recorded"]})]})]})]})}const Zr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function cx({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(f){l(f instanceof Error?f.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
224
224
  focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
225
- placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ls,{size:10})]}),r.jsx(le,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(_s,{size:12}),a]})]})}function hx(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(os,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ls,{size:10})]})]})}function dx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async f=>{await s(f),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(le,{variant:"danger",size:"sm",icon:Iu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),n&&r.jsx(cx,{platform:e,onConnect:c})]}):r.jsx(hx,{})]})]})}function ux({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const m=await W.getDeployStatus();i(m),t==null||t(m),l(null)}catch(m){l(m instanceof Error?m.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const m=setInterval(h,3e4);return()=>clearInterval(m)},[h]);const c=d.useCallback(async m=>{const _=await W.connectVercel(m);_.success&&(i(x=>({...x,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),f=d.useCallback(async m=>{const _=await W.connectNetlify(m);_.success&&(i(x=>({...x,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),p=d.useCallback(async m=>{await W.disconnectPlatform(m),i(x=>({...x,[m]:{connected:!1}}));const _={...s,[m]:{connected:!1}};t==null||t(_)},[s,t]),u={vercel:c,netlify:f,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(gi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const g=[s.vercel,s.netlify,s.github].filter(m=>m.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[g," of ",Zr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Zr.map(m=>{const _=s[m.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${m.name}: ${_.connected?`Connected as ${_.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${_.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:m.name})]},m.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Zr.map(m=>r.jsx(dx,{platform:m,status:s[m.id],onConnect:u[m.id],onDisconnect:()=>p(m.id)},m.id))})]})}const Ll={connected:"Connected",disconnected:"Not connected",checking:"Checking...",unknown:"Status unknown"},fx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:nn,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:nn,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:Te,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function mx({platform:e,deployState:t,onDeploy:s,disabled:i,connection:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=n==="connected",f=i||!c;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n==="disconnected"?"opacity-60":"hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),n==="checking"||n==="unknown"?r.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:Ll[n]}):r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${c?"bg-green-500":"bg-gray-300"}`,title:Ll[n]})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:["Deploy to ",e.name]}),n==="disconnected"&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(nn,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ls,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:"Retry"})]})]})}function px({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(Te,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(Te,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function _x({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState(null),[o,a]=d.useState(!1);d.useEffect(()=>{W.getDeployStatus().then(n).catch(()=>a(!0))},[]);const[l,h]=d.useState(!1),c=Object.values(t).some(u=>u.status==="deploying"),f=d.useCallback(async u=>{s(g=>({...g,[u]:{status:"deploying"}}));try{const g=await W.deployProject(e,u);g.url?s(m=>({...m,[u]:{status:"success",url:g.url}})):s(m=>({...m,[u]:{status:"error",error:g.error||"Deploy failed"}}))}catch(g){s(m=>({...m,[u]:{status:"error",error:g instanceof Error?g.message:"Deploy failed"}}))}},[e]),p=u=>{var g;return i?(g=i[u.connectionKey])!=null&&g.connected?"connected":"disconnected":o?"unknown":"checking"};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx(Kt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>h(!l),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:i?["vercel","netlify","github"].map(u=>{var g,m;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(g=i[u])!=null&&g.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(m=i[u])!=null&&m.connected?"Connected":"Not connected"}`},u)}):r.jsx("span",{className:"text-[11px] text-muted",children:o?"Status unknown":"Checking..."})})]}),r.jsx("span",{className:"text-xs text-muted",children:l?"Hide":"Manage"})]}),l&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(ux,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:fx.map(u=>r.jsx(mx,{platform:u,deployState:t[u.id],onDeploy:()=>f(u.id),disabled:c,connection:p(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(px,{sessionId:e,disabled:c})]})})}const Ch=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Et=Ch?"Cmd":"Ctrl",Bl=[{keys:[`${Et}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Et}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Et}+,`],label:"Open settings",category:"navigation"},{keys:[`${Et}+S`],label:"Save file",category:"editor"},{keys:[`${Et}+Z`],label:"Undo",category:"editor"},{keys:[`${Et}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Et}+B`],label:"Start / stop build",category:"build"},{keys:[`${Et}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Et}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],gx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},xx=["navigation","editor","build","general"];function vx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,f;const a=Ch?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((f=o.target)==null?void 0:f.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(p=>!p);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(p=>!p);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function bx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Bl;const a=s.toLowerCase();return Bl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(as,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[xx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:gx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function yx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const kh="pl_recent_commands",Sx=5;function Nh(){try{const e=localStorage.getItem(kh);return e?JSON.parse(e):[]}catch{return[]}}function Qr(e){try{const t=Nh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(kh,JSON.stringify(t.slice(0,Sx)))}catch{}}function wx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Q,ts:Q,tsx:Q,jsx:Q,py:Q,go:Q,rs:Q,rb:Q,sh:Q,html:ac,css:no,json:ro,md:_i}[t]||oo}function Cx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Tl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function kx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,f]=d.useState([]),[p,u]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),_=yd(e);Sd(e,t),d.useEffect(()=>{e&&(a(""),h(0),f([]),u(!1),setTimeout(()=>{var S;return(S=g.current)==null?void 0:S.focus()},50))},[e]);const x=d.useMemo(()=>Nh().map(C=>s.find(D=>D.id===C)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(C=>({cmd:C,indices:[]}));const S=[];for(const C of s){const D=Cx(o,C.label);if(D){const L=D[0]*10+(D[D.length-1]-D[0]);S.push({cmd:C,indices:D,score:L})}}return S.sort((C,D)=>C.score-D.score),S.map(C=>({cmd:C.cmd,indices:C.indices}))},[s,o]),v=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),j=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){f([]),u(!1);return}return u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);f(S.filter(C=>C.type==="file"))}catch{f([])}u(!1)},200),()=>{m.current&&clearTimeout(m.current)}},[o,i]);const k=!o.trim()&&x.length>0,w=d.useMemo(()=>{const S=[];return k&&x.forEach((C,D)=>S.push({type:"recent",index:D})),j.forEach((C,D)=>S.push({type:"command",index:D})),v.length>0&&v.forEach((C,D)=>S.push({type:"setting",index:D})),c.forEach((C,D)=>S.push({type:"file",index:D})),S},[k,x,j,v,c]),N=w.length;d.useEffect(()=>{h(0)},[o]);const M=d.useCallback(S=>{const C=w[S];if(C){if(C.type==="recent"){const D=x[C.index];D&&(Qr(D.id),D.action(),t())}else if(C.type==="command"){const D=j[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="setting"){const D=v[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="file"){const D=c[C.index];D&&n&&(n(D.path,D.name),t())}}},[w,x,j,v,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(C=>Math.min(C+1,N-1))):S.key==="ArrowUp"?(S.preventDefault(),h(C=>Math.max(C-1,0))):S.key==="Enter"&&N>0?M(l):S.key==="Escape"&&t()},[N,l,M,t]);if(!e)return null;let Y=0;const V=()=>Y++,$=j.length>0,P=v.length>0,E=c.length>0,B=p&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:_,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(as,{size:18,className:"text-muted"}),r.jsx("input",{ref:g,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[k&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(ut,{size:10})," Recent"]}),x.map((S,C)=>{const D=V(),L=S.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),j.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Tl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),v.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Tl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,C)=>{const D=V(),L=S.type==="directory"?ao:wx(S.name);return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),B&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),N===0&&!B&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Nx=d.lazy(()=>eo(()=>import("./GitHubIssuesPanel-Dixk_nbH.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),jx=d.lazy(()=>eo(()=>import("./GitHubPRsPanel-D-mWUpjU.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,8,24,25,26,27,28,29,9,30,31,32,33,34])).then(e=>({default:e.GitHubPRsPanel}))),Ex=d.lazy(()=>eo(()=>Promise.resolve().then(()=>qx),void 0).then(e=>({default:e.CICDPanel}))),Dx=3e4,Rx={modified:r.jsx(Q,{size:13,className:"text-yellow-500"}),added:r.jsx(_r,{size:13,className:"text-green-500"}),deleted:r.jsx(io,{size:13,className:"text-red-400"}),renamed:r.jsx(Q,{size:13,className:"text-blue-400"}),untracked:r.jsx(sc,{size:13,className:"text-muted"})},Px={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Mx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(tc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(Te,{size:9}),t]},s))})]})]})})}function zl({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Rx[e.status]||r.jsx(sc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Px[e.status]||"?"})]})}function Lx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,f]=d.useState(!0),[p,u]=d.useState(null),[g,m]=d.useState(""),[_,x]=d.useState(!1),[y,v]=d.useState(null),[j,k]=d.useState(!1),[w,N]=d.useState(""),[M,U]=d.useState(!1),[Y,V]=d.useState(!1),[$,P]=d.useState(""),[E,B]=d.useState(""),[S,C]=d.useState(!1),[D,L]=d.useState(null),[Z,oe]=d.useState(!1),q=d.useCallback(async()=>{f(!0),u(null);try{const[z,xe,T]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(z),a(xe),h(T)}catch(z){u(z instanceof Error?z.message:"Failed to load git data")}f(!1)},[e]);d.useEffect(()=>{q()},[q]);const J=async()=>{if(!(!g.trim()||_)){x(!0),v(null);try{const z=await W.git.commit(e,g.trim());v(`Committed: ${z.hash}`),m(""),await q()}catch(z){v(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}x(!1)}},se=async()=>{if(!(!w.trim()||M)){U(!0);try{await W.git.createBranch(e,w.trim()),N(""),k(!1),await q()}catch(z){u(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},de=async z=>{try{await W.git.checkoutBranch(e,z),await q()}catch(xe){u(xe instanceof Error?xe.message:"Checkout failed")}},ue=async()=>{oe(!0);try{await W.git.push(e),await q()}catch(z){u(z instanceof Error?z.message:"Push failed")}oe(!1)},ce=async()=>{if(!(!$.trim()||S)){C(!0),L(null);try{const z=await W.git.pr(e,$.trim(),E.trim());L(z.url),P(""),B(""),V(!1)}catch(z){L(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}C(!1)}},ge=(i==null?void 0:i.files.filter(z=>z.staged))||[],Fe=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):p&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(_s,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:p}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(le,{size:"sm",variant:"secondary",icon:bt,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(Te,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Yt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Q,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ut},{id:"branches",label:"Branches",icon:Te,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),p&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:p}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Yt,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[ge.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",ge.length,")"]}),ge.map((z,xe)=>r.jsx(zl,{file:z},`s-${xe}`))]}),Fe.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",Fe.length,")"]}),Fe.map((z,xe)=>r.jsx(zl,{file:z},`u-${xe}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:g,onChange:z=>m(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",icon:tc,onClick:J,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(le,{size:"sm",variant:"secondary",icon:rc,onClick:ue,loading:Z,disabled:Z,children:"Push"}),r.jsx(le,{size:"sm",variant:"ghost",icon:an,onClick:()=>V(!Y),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),D&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:D.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:D}):r.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:D})})]}),Y&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:$,onChange:z=>P(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:z=>B(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(le,{size:"sm",icon:an,onClick:ce,disabled:!$.trim()||S,loading:S,children:"Create PR"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ut,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Mx,{commit:z},xe))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>k(!j),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(gr,{size:12}),"New Branch"]})}),j&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:z=>N(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&se()}}),r.jsx(le,{size:"sm",onClick:se,disabled:!w.trim()||M,loading:M,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Te,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&de(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(Te,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${xe}`)),l.filter(z=>z.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(Te,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function en(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function tn({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(cu,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(le,{size:"sm",icon:rc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Bx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({actions:0,fetchedAt:0}),c=d.useRef(!1),f=d.useCallback(async()=>{n(!0);try{const _=await W.git.branches(e);a({has_remote:_.some(x=>x.remote)})}catch{a(null)}n(!1)},[e]);d.useEffect(()=>{f()},[f]);const p=d.useCallback(async()=>{if(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Dx||c.current)return;c.current=!0;const x=await W.getWorkflowRuns(e,5).catch(()=>null);h({actions:x?x.filter(y=>y.status==="in_progress").length:0,fetchedAt:Date.now()}),c.current=!1},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&p()},[o==null?void 0:o.has_remote,p]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&p()},[t,o==null?void 0:o.has_remote,p]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const u=(o==null?void 0:o.has_remote)??!0,g=[{id:"changes",label:"Changes",icon:Q,requiresRemote:!1},{id:"issues",label:"Issues",icon:$d,requiresRemote:!0},{id:"prs",label:"PRs",icon:an,requiresRemote:!0},{id:"actions",label:"Actions",icon:rs,count:l.actions,requiresRemote:!0}],m=g;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[m.map(_=>{const x=_.requiresRemote&&!u;return r.jsxs("button",{onClick:()=>s(_.id),disabled:x,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===_.id?"bg-primary/10 text-primary":x?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:x?"Connect to GitHub to access this tab":void 0,children:[r.jsx(_.icon,{size:12}),_.label,_.count!==void 0&&_.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:_.count})]},_.id)}),u&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(lc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Lx,{sessionId:e}),t==="issues"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(Nx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="prs"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(jx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="actions"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ex,{sessionId:e})})}):r.jsx(tn,{sessionId:e,onPushed:f}))]})]})}function Tx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(null),u=d.useCallback(async()=>{try{const _=await W.getCheckpoints(e);i(_),p(null)}catch{p("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{u();const _=setInterval(u,15e3);return()=>clearInterval(_)},[u]);const g=d.useCallback(async _=>{if(a)return;const x=s.find(v=>v.id===_);if(!(!x||!window.confirm(`Restore to checkpoint "${x.description}"?
225
+ placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ls,{size:10})]}),r.jsx(le,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(_s,{size:12}),a]})]})}function hx(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(os,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ls,{size:10})]})]})}function dx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async f=>{await s(f),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(le,{variant:"danger",size:"sm",icon:Iu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),n&&r.jsx(cx,{platform:e,onConnect:c})]}):r.jsx(hx,{})]})]})}function ux({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const m=await W.getDeployStatus();i(m),t==null||t(m),l(null)}catch(m){l(m instanceof Error?m.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const m=setInterval(h,3e4);return()=>clearInterval(m)},[h]);const c=d.useCallback(async m=>{const _=await W.connectVercel(m);_.success&&(i(x=>({...x,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),f=d.useCallback(async m=>{const _=await W.connectNetlify(m);_.success&&(i(x=>({...x,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),p=d.useCallback(async m=>{await W.disconnectPlatform(m),i(x=>({...x,[m]:{connected:!1}}));const _={...s,[m]:{connected:!1}};t==null||t(_)},[s,t]),u={vercel:c,netlify:f,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(gi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const g=[s.vercel,s.netlify,s.github].filter(m=>m.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[g," of ",Zr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Zr.map(m=>{const _=s[m.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${m.name}: ${_.connected?`Connected as ${_.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${_.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:m.name})]},m.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Zr.map(m=>r.jsx(dx,{platform:m,status:s[m.id],onConnect:u[m.id],onDisconnect:()=>p(m.id)},m.id))})]})}const Ll={connected:"Connected",disconnected:"Not connected",checking:"Checking...",unknown:"Status unknown"},fx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:nn,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:nn,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:Te,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function mx({platform:e,deployState:t,onDeploy:s,disabled:i,connection:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=n==="connected",f=i||!c;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n==="disconnected"?"opacity-60":"hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),n==="checking"||n==="unknown"?r.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:Ll[n]}):r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${c?"bg-green-500":"bg-gray-300"}`,title:Ll[n]})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:["Deploy to ",e.name]}),n==="disconnected"&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(nn,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ls,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:"Retry"})]})]})}function px({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(Te,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(Te,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function _x({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState(null),[o,a]=d.useState(!1);d.useEffect(()=>{W.getDeployStatus().then(n).catch(()=>a(!0))},[]);const[l,h]=d.useState(!1),c=Object.values(t).some(u=>u.status==="deploying"),f=d.useCallback(async u=>{s(g=>({...g,[u]:{status:"deploying"}}));try{const g=await W.deployProject(e,u);g.url?s(m=>({...m,[u]:{status:"success",url:g.url}})):s(m=>({...m,[u]:{status:"error",error:g.error||"Deploy failed"}}))}catch(g){s(m=>({...m,[u]:{status:"error",error:g instanceof Error?g.message:"Deploy failed"}}))}},[e]),p=u=>{var g;return i?(g=i[u.connectionKey])!=null&&g.connected?"connected":"disconnected":o?"unknown":"checking"};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx(Kt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>h(!l),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:i?["vercel","netlify","github"].map(u=>{var g,m;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(g=i[u])!=null&&g.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(m=i[u])!=null&&m.connected?"Connected":"Not connected"}`},u)}):r.jsx("span",{className:"text-[11px] text-muted",children:o?"Status unknown":"Checking..."})})]}),r.jsx("span",{className:"text-xs text-muted",children:l?"Hide":"Manage"})]}),l&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(ux,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:fx.map(u=>r.jsx(mx,{platform:u,deployState:t[u.id],onDeploy:()=>f(u.id),disabled:c,connection:p(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(px,{sessionId:e,disabled:c})]})})}const Ch=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Et=Ch?"Cmd":"Ctrl",Bl=[{keys:[`${Et}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Et}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Et}+,`],label:"Open settings",category:"navigation"},{keys:[`${Et}+S`],label:"Save file",category:"editor"},{keys:[`${Et}+Z`],label:"Undo",category:"editor"},{keys:[`${Et}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Et}+B`],label:"Start / stop build",category:"build"},{keys:[`${Et}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Et}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],gx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},xx=["navigation","editor","build","general"];function vx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,f;const a=Ch?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((f=o.target)==null?void 0:f.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(p=>!p);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(p=>!p);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function bx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Bl;const a=s.toLowerCase();return Bl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(as,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[xx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:gx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function yx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const kh="pl_recent_commands",Sx=5;function Nh(){try{const e=localStorage.getItem(kh);return e?JSON.parse(e):[]}catch{return[]}}function Qr(e){try{const t=Nh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(kh,JSON.stringify(t.slice(0,Sx)))}catch{}}function wx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Q,ts:Q,tsx:Q,jsx:Q,py:Q,go:Q,rs:Q,rb:Q,sh:Q,html:ac,css:no,json:ro,md:_i}[t]||oo}function Cx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Tl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function kx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,f]=d.useState([]),[p,u]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),_=yd(e);Sd(e,t),d.useEffect(()=>{e&&(a(""),h(0),f([]),u(!1),setTimeout(()=>{var S;return(S=g.current)==null?void 0:S.focus()},50))},[e]);const x=d.useMemo(()=>Nh().map(C=>s.find(D=>D.id===C)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(C=>({cmd:C,indices:[]}));const S=[];for(const C of s){const D=Cx(o,C.label);if(D){const L=D[0]*10+(D[D.length-1]-D[0]);S.push({cmd:C,indices:D,score:L})}}return S.sort((C,D)=>C.score-D.score),S.map(C=>({cmd:C.cmd,indices:C.indices}))},[s,o]),v=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),j=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){f([]),u(!1);return}return u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);f(S.filter(C=>C.type==="file"))}catch{f([])}u(!1)},200),()=>{m.current&&clearTimeout(m.current)}},[o,i]);const k=!o.trim()&&x.length>0,w=d.useMemo(()=>{const S=[];return k&&x.forEach((C,D)=>S.push({type:"recent",index:D})),j.forEach((C,D)=>S.push({type:"command",index:D})),v.length>0&&v.forEach((C,D)=>S.push({type:"setting",index:D})),c.forEach((C,D)=>S.push({type:"file",index:D})),S},[k,x,j,v,c]),N=w.length;d.useEffect(()=>{h(0)},[o]);const M=d.useCallback(S=>{const C=w[S];if(C){if(C.type==="recent"){const D=x[C.index];D&&(Qr(D.id),D.action(),t())}else if(C.type==="command"){const D=j[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="setting"){const D=v[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="file"){const D=c[C.index];D&&n&&(n(D.path,D.name),t())}}},[w,x,j,v,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(C=>Math.min(C+1,N-1))):S.key==="ArrowUp"?(S.preventDefault(),h(C=>Math.max(C-1,0))):S.key==="Enter"&&N>0?M(l):S.key==="Escape"&&t()},[N,l,M,t]);if(!e)return null;let Y=0;const V=()=>Y++,$=j.length>0,P=v.length>0,E=c.length>0,B=p&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:_,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(as,{size:18,className:"text-muted"}),r.jsx("input",{ref:g,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[k&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(ut,{size:10})," Recent"]}),x.map((S,C)=>{const D=V(),L=S.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),j.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Tl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),v.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Tl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,C)=>{const D=V(),L=S.type==="directory"?ao:wx(S.name);return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),B&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),N===0&&!B&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Nx=d.lazy(()=>eo(()=>import("./GitHubIssuesPanel-DXDCz06W.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),jx=d.lazy(()=>eo(()=>import("./GitHubPRsPanel-3qECbDiA.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,8,24,25,26,27,28,29,9,30,31,32,33,34])).then(e=>({default:e.GitHubPRsPanel}))),Ex=d.lazy(()=>eo(()=>Promise.resolve().then(()=>qx),void 0).then(e=>({default:e.CICDPanel}))),Dx=3e4,Rx={modified:r.jsx(Q,{size:13,className:"text-yellow-500"}),added:r.jsx(_r,{size:13,className:"text-green-500"}),deleted:r.jsx(io,{size:13,className:"text-red-400"}),renamed:r.jsx(Q,{size:13,className:"text-blue-400"}),untracked:r.jsx(sc,{size:13,className:"text-muted"})},Px={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Mx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(tc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(Te,{size:9}),t]},s))})]})]})})}function zl({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Rx[e.status]||r.jsx(sc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Px[e.status]||"?"})]})}function Lx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,f]=d.useState(!0),[p,u]=d.useState(null),[g,m]=d.useState(""),[_,x]=d.useState(!1),[y,v]=d.useState(null),[j,k]=d.useState(!1),[w,N]=d.useState(""),[M,U]=d.useState(!1),[Y,V]=d.useState(!1),[$,P]=d.useState(""),[E,B]=d.useState(""),[S,C]=d.useState(!1),[D,L]=d.useState(null),[Z,oe]=d.useState(!1),q=d.useCallback(async()=>{f(!0),u(null);try{const[z,xe,T]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(z),a(xe),h(T)}catch(z){u(z instanceof Error?z.message:"Failed to load git data")}f(!1)},[e]);d.useEffect(()=>{q()},[q]);const J=async()=>{if(!(!g.trim()||_)){x(!0),v(null);try{const z=await W.git.commit(e,g.trim());v(`Committed: ${z.hash}`),m(""),await q()}catch(z){v(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}x(!1)}},se=async()=>{if(!(!w.trim()||M)){U(!0);try{await W.git.createBranch(e,w.trim()),N(""),k(!1),await q()}catch(z){u(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},de=async z=>{try{await W.git.checkoutBranch(e,z),await q()}catch(xe){u(xe instanceof Error?xe.message:"Checkout failed")}},ue=async()=>{oe(!0);try{await W.git.push(e),await q()}catch(z){u(z instanceof Error?z.message:"Push failed")}oe(!1)},ce=async()=>{if(!(!$.trim()||S)){C(!0),L(null);try{const z=await W.git.pr(e,$.trim(),E.trim());L(z.url),P(""),B(""),V(!1)}catch(z){L(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}C(!1)}},ge=(i==null?void 0:i.files.filter(z=>z.staged))||[],Fe=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):p&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(_s,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:p}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(le,{size:"sm",variant:"secondary",icon:bt,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(Te,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Yt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Q,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ut},{id:"branches",label:"Branches",icon:Te,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),p&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:p}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Yt,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[ge.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",ge.length,")"]}),ge.map((z,xe)=>r.jsx(zl,{file:z},`s-${xe}`))]}),Fe.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",Fe.length,")"]}),Fe.map((z,xe)=>r.jsx(zl,{file:z},`u-${xe}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:g,onChange:z=>m(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",icon:tc,onClick:J,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(le,{size:"sm",variant:"secondary",icon:rc,onClick:ue,loading:Z,disabled:Z,children:"Push"}),r.jsx(le,{size:"sm",variant:"ghost",icon:an,onClick:()=>V(!Y),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),D&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:D.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:D}):r.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:D})})]}),Y&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:$,onChange:z=>P(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:z=>B(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(le,{size:"sm",icon:an,onClick:ce,disabled:!$.trim()||S,loading:S,children:"Create PR"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ut,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Mx,{commit:z},xe))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>k(!j),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(gr,{size:12}),"New Branch"]})}),j&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:z=>N(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&se()}}),r.jsx(le,{size:"sm",onClick:se,disabled:!w.trim()||M,loading:M,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Te,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&de(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(Te,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${xe}`)),l.filter(z=>z.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(Te,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function en(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function tn({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(cu,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(le,{size:"sm",icon:rc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Bx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({actions:0,fetchedAt:0}),c=d.useRef(!1),f=d.useCallback(async()=>{n(!0);try{const _=await W.git.branches(e);a({has_remote:_.some(x=>x.remote)})}catch{a(null)}n(!1)},[e]);d.useEffect(()=>{f()},[f]);const p=d.useCallback(async()=>{if(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Dx||c.current)return;c.current=!0;const x=await W.getWorkflowRuns(e,5).catch(()=>null);h({actions:x?x.filter(y=>y.status==="in_progress").length:0,fetchedAt:Date.now()}),c.current=!1},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&p()},[o==null?void 0:o.has_remote,p]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&p()},[t,o==null?void 0:o.has_remote,p]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const u=(o==null?void 0:o.has_remote)??!0,g=[{id:"changes",label:"Changes",icon:Q,requiresRemote:!1},{id:"issues",label:"Issues",icon:$d,requiresRemote:!0},{id:"prs",label:"PRs",icon:an,requiresRemote:!0},{id:"actions",label:"Actions",icon:rs,count:l.actions,requiresRemote:!0}],m=g;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[m.map(_=>{const x=_.requiresRemote&&!u;return r.jsxs("button",{onClick:()=>s(_.id),disabled:x,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===_.id?"bg-primary/10 text-primary":x?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:x?"Connect to GitHub to access this tab":void 0,children:[r.jsx(_.icon,{size:12}),_.label,_.count!==void 0&&_.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:_.count})]},_.id)}),u&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(lc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Lx,{sessionId:e}),t==="issues"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(Nx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="prs"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(jx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="actions"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ex,{sessionId:e})})}):r.jsx(tn,{sessionId:e,onPushed:f}))]})]})}function Tx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(null),u=d.useCallback(async()=>{try{const _=await W.getCheckpoints(e);i(_),p(null)}catch{p("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{u();const _=setInterval(u,15e3);return()=>clearInterval(_)},[u]);const g=d.useCallback(async _=>{if(a)return;const x=s.find(v=>v.id===_);if(!(!x||!window.confirm(`Restore to checkpoint "${x.description}"?
226
226
 
227
227
  This will revert files to this checkpoint state.`))){l(_);try{await W.restoreCheckpoint(e,_),await u(),t==null||t()}catch{p("Failed to restore checkpoint")}l(null)}},[e,s,a,u,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(rr,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(f&&s.length===0||s.length===0)return null;const m=_=>{if(!_)return"";try{return new Date(_).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(rr,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((_,x)=>r.jsxs("div",{className:"flex items-center gap-1",children:[x>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>g(_.id),onMouseEnter:()=>c(_.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${_.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===_.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==_.id?"opacity-50":""}`,title:`${_.description} -- Click to restore`}),h===_.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:_.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[_.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ut,{size:10}),m(_.timestamp)]}),(_.files_changed??0)>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Q,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),(_.iteration??0)>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",_.iteration]})]}),!_.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(nc,{size:10}),"Click to restore"]}),_.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},_.id))}),f&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:f})]})}function zx({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Ax({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(_r,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(nu,{size:14,className:"text-danger"}):r.jsx(Q,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(pr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(gr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(ic,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,f)=>r.jsx(zx,{line:c},`${h}-${f}`))]},h))})]})}function Ox({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(u=>u.path))),[l,h]=d.useState(0),c=d.useCallback(u=>{a(g=>{const m=new Set(g);return m.has(u)?m.delete(u):m.add(u),m})},[]),f=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(u=>u.path)))},[o.size,e.files]),p=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:u=>u.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:u=>u.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Q,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(gr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(ic,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:f,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((u,g)=>{const m=u.action==="add"?"text-success":u.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${g===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(u.path),onChange:()=>c(u.path),onClick:_=>_.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:u.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${m}`,children:u.action==="add"?"+":u.action==="delete"?"-":"M"})]},u.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Ax,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(oc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:p,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Yt,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Zd,{size:14}),"Accept All"]})]})]})]})}function Zi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function $x(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Ix(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const jo={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ut,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:xr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Xl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:sr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:oc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:wd,label:"Skipped"}};function jh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Eh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function Eo({status:e}){const t=jo[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Fx({step:e}){const t=Ix(e),s=jo[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Eh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:t})]})}function Hx({job:e}){const[t,s]=d.useState(!1),i=$x(e),n=jo[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ms,{size:14,className:"text-[#939084]"}):r.jsx(pr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Eh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Fx,{step:o},o.number))})]})}function Wx({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(xr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Ux({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[f,p]=d.useState(!1),u=Zi(e),g=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const _=await W.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){c(_ instanceof Error?_.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),m=()=>{const _=!s;i(_),_&&g()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:m,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ms,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(pr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(Eo,{status:u})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(Te,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:jh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ls,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(xr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ut,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(_=>r.jsx(Hx,{job:_},_.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>p(!f),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(os,{size:12}),f?"Hide full logs":"View full logs"]}),f&&r.jsx("div",{className:"mt-2",children:r.jsx(Wx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Kx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var g;const[n,o]=d.useState(((g=t[0])==null?void 0:g.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[f,p]=d.useState(null),u=async()=>{if(n){c(!0),p(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(m){p(m instanceof Error?m.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:m=>o(m.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(m=>r.jsxs("option",{value:m.name,children:[m.name," (",m.name,")"]},m.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:m=>l(m.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),f&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ut,{size:12}),r.jsx("span",{className:"text-xs",children:f})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(le,{size:"sm",icon:rs,onClick:u,loading:h,children:"Dispatch"})]})]})}function Dh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,f]=d.useState(null),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useRef(null),x=t.some(N=>N.status==="in_progress"||N.status==="queued"||N.status==="waiting"||N.status==="requested"||N.status==="pending"),y=d.useCallback(async(N=!1)=>{if(e){N&&h(!0),f(null);try{const M=await W.getWorkflowRuns(e);s(M),a(""),m(new Date)}catch(M){const U=M instanceof Error?M.message:String(M);U.includes("gh CLI not found")?f({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?f({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?f({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):f({type:"generic",message:U})}finally{h(!1)}}},[e]),v=d.useCallback(async()=>{if(e)try{const N=await W.getWorkflows(e);n(N.filter(M=>M.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),v()},[y,v]),d.useEffect(()=>(x&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[x,e,y]);const j=t.filter(N=>Zi(N)==="success").length,k=t.filter(N=>Zi(N)==="failed").length,w=t.filter(N=>{const M=Zi(N);return M==="running"||M==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Te,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[g&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(dc,{size:10}),jh(g.toISOString())]}),r.jsx(le,{size:"sm",variant:"ghost",icon:bt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(le,{size:"sm",icon:rs,onClick:()=>u(!p),children:"Run Workflow"})]})]}),p&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Kx,{sessionId:e,workflows:i,onClose:()=>u(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ut,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ls,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ut,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Te,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ut,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Xl,{size:12}),j," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(sr,{size:12}),k," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(xr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),x&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(N=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},N))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(N=>r.jsx(Ux,{run:N,sessionId:e},N.databaseId))})]})}const qx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Dh},Symbol.toStringTag,{value:"Module"}));function Vx({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const f=Math.floor(c/60),p=c%60;return`${f}m ${p}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(ps,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Gx({tokenHistory:e,className:t=""}){const s=e.slice(-10);if(s.length<2)return null;const i=64,n=20,o=2,a=Math.max(...s,1),l=Math.min(...s,0),h=a-l||1,c=s.map((u,g)=>({x:o+g/(s.length-1)*(i-o*2),y:o+(1-(u-l)/h)*(n-o*2)})),f=c.map((u,g)=>`${g===0?"M":"L"} ${u.x.toFixed(1)} ${u.y.toFixed(1)}`).join(" "),p=`${f} L ${c[c.length-1].x.toFixed(1)} ${n-o} L ${c[0].x.toFixed(1)} ${n-o} Z`;return r.jsxs("svg",{width:i,height:n,viewBox:`0 0 ${i} ${n}`,className:`inline-block align-middle text-muted ${t}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:p,fill:"currentColor",fillOpacity:.15}),r.jsx("path",{d:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:c[c.length-1].x,cy:c[c.length-1].y,r:"2",fill:"currentColor"})]})}function Yx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Xx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Q,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Q,color:"text-yellow-500",label:"JSX"},ts:{icon:Q,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Q,color:"text-blue-400",label:"TSX"},py:{icon:Q,color:"text-green-600",label:"Python"},html:{icon:Q,color:"text-orange-500",label:"HTML"},css:{icon:no,color:"text-purple-500",label:"CSS"},json:{icon:ro,color:"text-green-500",label:"JSON"},md:{icon:_i,color:"text-muted",label:"Markdown"},go:{icon:Q,color:"text-cyan-600",label:"Go"},rs:{icon:Q,color:"text-orange-600",label:"Rust"}}[t]||{icon:oo,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Jx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Al(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Zx({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:f}){const[p,u]=d.useState(""),[g,m]=d.useState(!1);d.useEffect(()=>{if(!n)return;const v=()=>u(Jx(n));v();const j=setInterval(v,5e3);return()=>clearInterval(j)},[n]);const _=d.useCallback(async()=>{const v=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Al(h)}`:"",f?`
228
228
  Project: ${f.substring(0,100)}${f.length>100?"...":""}`:"",`
@@ -251,6 +251,6 @@ https://autonomi.dev`].filter(Boolean).join(`
251
251
  text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:v,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(gt,{size:14})})]})]}),!p&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:Rv.map(w=>r.jsx("button",{onClick:()=>j(w),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
252
252
  px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(gi,{size:14,className:"animate-spin"}),"Searching..."]}),p&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,N)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
253
253
  hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
254
- group cursor-pointer`,children:[r.jsx(Q,{size:14,className:k(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(du,{size:10}),w.lineNumber]}),r.jsx(to,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${N}`))]})})]})}const ur={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},fr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Mv(e,t,s){const i=ur[t]||ur.claude,n=fr[e]||fr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(m=>{const _=Math.round(h*m.pct),x=_*.4,y=_*.6,v=(x*i.input+y*i.output)/1e3;return{phase:m.phase,label:m.label,estimatedCost:v,estimatedTokens:_}}),f=c.reduce((m,_)=>m+_.estimatedCost,0),u=o*(e==="complex"?40:e==="simple"?15:25),g=u<60?`${u}s`:u<3600?`${Math.round(u/60)}min`:`${(u/3600).toFixed(1)}hr`;return{total:{low:f*.7,high:f*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Hl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Lv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Mv(e,t,i),f=ur[t]||ur.claude,p=fr[e]||fr.standard,u=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ec,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Hl(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(ut,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||p.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:f.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:p.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Ud,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(mr,{size:12}):r.jsx(ms,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(g=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:g.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Hl(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),u&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ut,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(le,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,icon:Ls,children:"Start Build"})]})]})}function Bv({sessionId:e}){return r.jsx(Dh,{sessionId:e})}function Qn(e,t,s){var o;if(t==="directory")return s?r.jsx(on,{size:14}):r.jsx(ao,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Q,{size:14,className:"text-yellow-600"}),ts:r.jsx(Q,{size:14,className:"text-blue-500"}),tsx:r.jsx(Q,{size:14,className:"text-blue-400"}),jsx:r.jsx(Q,{size:14,className:"text-yellow-500"}),py:r.jsx(Q,{size:14,className:"text-green-600"}),html:r.jsx(ac,{size:14,className:"text-orange-500"}),css:r.jsx(no,{size:14,className:"text-purple-500"}),json:r.jsx(ro,{size:14,className:"text-green-500"}),md:r.jsx(_i,{size:14,className:"text-muted"}),go:r.jsx(Q,{size:14,className:"text-cyan-600"}),rs:r.jsx(Q,{size:14,className:"text-orange-600"}),rb:r.jsx(Q,{size:14,className:"text-red-500"}),sh:r.jsx(Q,{size:14,className:"text-green-600"})}[i]||r.jsx(oo,{size:14})}function Tv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Rh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Rh(s.children,t);if(i!==void 0)return i}}}function Ph(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",f=a.has(h.path),p=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":p,...c?{"aria-expanded":f}:{},onContextMenu:u=>{u.preventDefault(),n==null||n(u,h.path,h.name,h.type)},onClick:()=>{c?l(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${p?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:f?r.jsx(ms,{size:14}):r.jsx(pr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Qn(h.name,h.type,f)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ph(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(gt,{size:12})})]}),c&&f&&h.children&&r.jsx(Mh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Lh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Lh(i.children,i.path+"/"));return s}function zv(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[f,p]=d.useState(new Set),u=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{u()},[u]);const g=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await u()}catch(v){c(v instanceof Error?v.message:"Failed to set secret")}}},m=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await u()}catch(v){c(v instanceof Error?v.message:"Failed to delete secret")}},_=y=>{p(v=>{const j=new Set(v);return j.has(y)?j.delete(y):j.add(y),j})},x=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"}),r.jsx(oi,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ut,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),x.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:x.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:f.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>_(y),className:"text-muted hover:text-ink transition-colors",title:f.has(y)?"Hide value":"Show value",children:f.has(y)?r.jsx(Fd,{size:14}):r.jsx(Es,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>m(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(io,{size:14})})})]},y))})]})}),x.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(gr,{size:14}),"Add"]})]})]})]})})}function Av({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,f]=d.useState(!0),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useCallback(async()=>{try{const v=await W.getDocsStatus(e);if(s(v),v.has_docs){const j=await W.getDocFiles(e);n(j.files)}}catch{}f(!1)},[e]);d.useEffect(()=>{_()},[_]);const x=async()=>{u(!0),m(null);try{await W.generateDocs(e);const v=setInterval(async()=>{try{const j=await W.getDocsStatus(e);if(j.has_docs){s(j);const k=await W.getDocFiles(e);n(k.files),u(!1),clearInterval(v)}}catch{}},3e3);setTimeout(()=>{clearInterval(v),u(!1)},3e5)}catch(v){m(v instanceof Error?v.message:"Failed to start doc generation"),u(!1)}},y=async v=>{try{const j=await W.getDocFileContent(e,v);a(v),h(j)}catch(j){m(j instanceof Error?j.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Jl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),g&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:g})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(le,{onClick:x,disabled:p,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:p?"animate-spin":""}),p?"Updating...":"Update Docs"]}):r.jsx(le,{onClick:x,disabled:p,size:"sm",children:p?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(v=>r.jsxs("button",{onClick:()=>y(v.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(_i,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:v.name}),r.jsx("span",{className:"text-xs text-muted",children:v.size<1024?`${v.size} B`:`${(v.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},v.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function Ov({session:e,onClose:t}){var sa;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(!1),[u,g]=d.useState("code"),[m,_]=d.useState(!1),[x,y]=d.useState(!1),[v,j]=d.useState(e),k=d.useRef(null),[w,N]=d.useState([]),[M,U]=d.useState(!1),[Y,V]=d.useState(""),$=d.useRef(null),P=d.useRef(null),[E,B]=d.useState(0),[S,C]=d.useState(null),[D,L]=d.useState(!0),[Z,oe]=d.useState(!0),[q,J]=d.useState(!1),[se,de]=d.useState("overview"),ue=57374,[ce,ge]=d.useState(null),Fe=d.useCallback(()=>{J(b=>{const A=!b;return L(!A),oe(!A),A})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${v.id}`)||"standard"),[T,G]=d.useState(()=>sessionStorage.getItem(`pl_provider_${v.id}`)||"claude"),[K,ne]=d.useState(null),[He,be]=d.useState(null),[he,Ae]=d.useState(null),[pe,wt]=d.useState(!1),[We,Xt]=d.useState(!1),[Ue,bs]=d.useState({phase:"idle",iteration:null,maxIterations:null,cost:null,startTime:0}),[Ct,Xe]=d.useState(!1),[Ke,Je]=d.useState(null),kt=d.useRef(null),[Bh,Do]=d.useState(!1),[Th,Ro]=d.useState([]),[Po,Is]=d.useState(null),[zh,Cr]=d.useState(!1),[Ah,wi]=d.useState(!1),[Oh,Fs]=d.useState(!1),[Ci,Mo]=d.useState("files"),{history:Lo,recordTokens:Bo}=Yx(),[$h,Ih]=d.useState(null),[To,Fh]=d.useState({line:1,column:1}),[Hh,zo]=d.useState(0),{device:Wh,setDevice:Uh,frameClass:Ao}=ev(),[kr,Kh]=d.useState(100),[Oo,qh]=d.useState(!1),[ki,Nr]=d.useState(!1),[$o,Iv]=d.useState([]),ys=d.useRef(null),[Vh,Io]=d.useState(0),{subscribe:Fo}=Ed(),tt=d.useCallback(async()=>{try{const b=await W.getSessionDetail(v.id);j(b)}catch{}},[v.id]),Ho=d.useCallback(async()=>{try{await W.stopSession(),wt(!1),Xt(!1)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.pauseSession(),Xt(!0)}catch{}},[]),Yh=d.useCallback(async()=>{try{await W.resumeSession(),Xt(!1)}catch{}},[]),Wo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();wt(F.running),Xt(F.paused),F.provider&&G(F.provider);const te=F.phase||"idle";if(te!==Wo.current&&te!=="idle"){const ot=new Date().toISOString(),Tt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},zt={id:`phase-${Date.now()}`,type:"phase_change",message:Tt[te]||`Phase: ${te}`,timestamp:ot};Ro(Mi=>[...Mi,zt]),Wo.current=te}bs({phase:te,iteration:typeof F.iteration=="number"?F.iteration:null,maxIterations:typeof F.max_iterations=="number"&&F.max_iterations>0?F.max_iterations:null,cost:typeof F.cost=="number"?F.cost:null,startTime:F.start_time?F.start_time*1e3:0});const Ze=F.tokens_used;Ze!=null&&Bo(Ze)}catch{}};b();const A=setInterval(b,pe?3e3:1e4);return()=>clearInterval(A)},[pe,Bo]),d.useEffect(()=>{if(!(he!=null&&he.loading))return;const b=setInterval(()=>{Ae(A=>A?{...A,elapsed:Math.floor((Date.now()-A.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[he==null?void 0:he.loading]);const[ee,Xh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(v.id).then(Xh).catch(()=>{})},[v.id]);const[I,Ni]=d.useState(null),[Hs,Uo]=d.useState(!1),[Ko,qo]=d.useState(!1),[Vo,ji]=d.useState(null),[Jt,Jh]=d.useState("");d.useEffect(()=>{const b=Fo("file_changed",A=>{const F=A;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ze=F.paths.map((ot,Tt)=>{var ia;const zt=(ia=F.event_types)==null?void 0:ia[Tt],Mi=zt==="created"||zt==="IN_CREATE";return{id:`file-${Date.now()}-${Tt}`,type:Mi?"file_created":"file_modified",message:Mi?`Created ${ot.split("/").pop()}`:`Modified ${ot.split("/").pop()}`,timestamp:te,filePath:ot}});if(Ro(ot=>[...ot,...Ze]),Xe(!0),kt.current&&clearTimeout(kt.current),kt.current=setTimeout(()=>Xe(!1),2e3),tt(),s&&F.paths.some(Tt=>Tt===s||s.endsWith(Tt))&&Je(s),u==="preview"){const ot=["react","vite","next","nuxt","svelte","remix"];(I==null?void 0:I.running)&&(I==null?void 0:I.framework)&&ot.some(zt=>I.framework.toLowerCase().includes(zt))||B(zt=>zt+1)}});return()=>{b(),kt.current&&clearTimeout(kt.current)}},[Fo,s,u,I==null?void 0:I.running,tt]);const Zh=d.useCallback(async()=>{if(!(!Ke||!v.id)){try{const b=await W.getSessionFileContent(v.id,Ke);l(b.content),c(b.content),_(!1),N(A=>A.map(F=>F.path===Ke?{...F,content:b.content,modified:!1}:F))}catch{}Je(null)}},[Ke,v.id]);d.useEffect(()=>{if(u!=="preview")return;let b=!1;const A=async()=>{try{const te=await W.devserver.status(v.id);b||Ni(te)}catch{}};A();const F=setInterval(A,3e3);return()=>{b=!0,clearInterval(F)}},[u,v.id]),d.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(b=>ge(b.ok)).catch(()=>ge(!1))},[u]);const Ss=d.useCallback(async b=>{Uo(!0),ji(null);try{const A=await W.devserver.start(v.id,b);if(A.status==="error")ji(A.message||"Failed to start dev server");else{const F=await W.devserver.status(v.id);Ni(F)}}catch(A){ji(A instanceof Error?A.message:"Failed to start dev server")}Uo(!1)},[v.id]),Go=d.useRef(!1);d.useEffect(()=>{Go.current||ee!=null&&ee.dev_command&&(I!=null&&I.running||(I==null?void 0:I.status)==="starting"||Hs||(Go.current=!0,Ss(ee.dev_command)))},[ee==null?void 0:ee.dev_command,I==null?void 0:I.running,I==null?void 0:I.status,Hs,Ss]);const Qh=d.useCallback(async()=>{try{await W.devserver.stop(v.id);const b=await W.devserver.status(v.id);Ni(b)}catch{}},[v.id]),ed=d.useCallback(async()=>{qo(!0);try{const b=await W.fixProject(v.id);if(b.task_id){let F=0,te;do await new Promise(ot=>setTimeout(ot,2e3)),te=await W.chatPoll(v.id,b.task_id),F++;while(!te.complete&&F<150);const Ze=await W.devserver.status(v.id);Ni(Ze)}}catch(b){ji(b instanceof Error?b.message:"Fix failed")}qo(!1)},[v.id]),ws=I!=null&&I.running&&(I!=null&&I.port)?I.framework==="expo"?`${sn}/api/sessions/${encodeURIComponent(v.id)}/expo-qr`:I.portless_url||`http://localhost:${I.port}/`:null,td=(ee==null?void 0:ee.preview_url)||`${sn}/api/sessions/${encodeURIComponent(v.id)}/preview/index.html`,sd=ws||td,[Ei,Yo]=d.useState([]),[Nt,Di]=d.useState(0);d.useEffect(()=>{const b=ws||(ee==null?void 0:ee.preview_url);b&&(Yo([b]),Di(0))},[ws,ee==null?void 0:ee.preview_url]);const Lt=Ei[Nt]||sd,[Xo,jr]=d.useState(Lt),id=d.useCallback((b,A,F,te)=>{b.preventDefault(),C({x:b.clientX,y:b.clientY,path:A,name:F,type:te})},[]),rd=d.useCallback(()=>{Nt>0&&(Di(b=>b-1),B(b=>b+1))},[Nt]),nd=d.useCallback(()=>{Nt<Ei.length-1&&(Di(b=>b+1),B(b=>b+1))},[Nt,Ei.length]),od=d.useCallback(b=>{let A=b;if(b.startsWith("/")&&ws)try{A=`${new URL(ws).origin}${b}`}catch{const F=I==null?void 0:I.port;F&&(A=`http://localhost:${F}${b}`)}Yo(F=>[...F.slice(0,Nt+1),A]),Di(F=>F+1),B(F=>F+1)},[Nt,ws,I==null?void 0:I.port]);d.useEffect(()=>{try{const b=new URL(Lt,window.location.origin);jr(b.pathname+b.search+b.hash||"/")}catch{jr(Lt)}},[Lt]);const Ri=d.useCallback(async()=>{Ae({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.reviewProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Pi=d.useCallback(async()=>{Ae({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.testProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Er=d.useCallback(async()=>{Ae({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.explainProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Dr=d.useCallback(async(b,A)=>{if(window.confirm(`Delete "${A}"?`))try{await W.deleteSessionFile(v.id,b),s===b&&(i(null),o(""),l(null),c(null),_(!1)),await tt()}catch(te){const Ze=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ze}`)}},[v.id,s,tt]),ad=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:Es,onClick:()=>{Ri()}},{label:"Generate Tests",icon:ai,onClick:()=>{Pi()}},{label:"Explain",icon:Js,onClick:()=>{Er()}},{label:"Delete",icon:io,onClick:()=>{Dr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:Es,onClick:()=>{Ri()}},{label:"Run Tests",icon:ai,onClick:()=>{Pi()}}],[Ri,Pi,Er,Dr]),Bt=d.useCallback(async(b,A)=>{Je(null),m&&s&&h!==null&&N(te=>te.map(Ze=>Ze.path===s?{...Ze,content:h,modified:!0}:Ze));const F=w.find(te=>te.path===b);if(F){i(b),o(A),l(F.content),c(F.content),_(F.modified);return}i(b),o(A),p(!0),_(!1);try{const te=v.id?await W.getSessionFileContent(v.id,b):await W.getFileContent(b);l(te.content),c(te.content),N(Ze=>[...Ze,{path:b,name:A,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{p(!1)}},[v.id,m,s,h,w]),Rr=d.useCallback(async()=>{var b;if(!(!s||h===null||!v.id)){y(!0);try{await W.saveSessionFile(v.id,s,h),l(h),_(!1),Ih(Date.now()),N(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const A=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(A)&&B(F=>F+1)}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,v.id]),Jo=d.useCallback(b=>{const A=w.find(F=>F.path===b);if(!(A!=null&&A.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(N(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),_(te.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const b=A=>{(A.metaKey||A.ctrlKey)&&A.key==="s"&&(A.preventDefault(),m&&s&&Rr()),(A.metaKey||A.ctrlKey)&&A.key==="p"&&(A.preventDefault(),U(F=>!F),V("")),(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),Do(F=>!F)),A.key==="Escape"&&M&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[m,s,Rr,M]),d.useEffect(()=>{M&&$.current&&$.current.focus()},[M]);const Zo=Lh(v.files),Ws=Y?Zo.filter(b=>b.path.toLowerCase().includes(Y.toLowerCase())):Zo;d.useEffect(()=>{const b=v.files.find(A=>A.name==="index.html"&&A.type==="file");b&&Bt(b.path,b.name)},[]);const ld=d.useCallback(b=>{b!==void 0&&(c(b),_(b!==a),zo(b.split(`
254
+ group cursor-pointer`,children:[r.jsx(Q,{size:14,className:k(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(du,{size:10}),w.lineNumber]}),r.jsx(to,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${N}`))]})})]})}const ur={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"}},fr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Mv(e,t,s){const i=ur[t]||ur.claude,n=fr[e]||fr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(m=>{const _=Math.round(h*m.pct),x=_*.4,y=_*.6,v=(x*i.input+y*i.output)/1e3;return{phase:m.phase,label:m.label,estimatedCost:v,estimatedTokens:_}}),f=c.reduce((m,_)=>m+_.estimatedCost,0),u=o*(e==="complex"?40:e==="simple"?15:25),g=u<60?`${u}s`:u<3600?`${Math.round(u/60)}min`:`${(u/3600).toFixed(1)}hr`;return{total:{low:f*.7,high:f*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Hl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Lv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Mv(e,t,i),f=ur[t]||ur.claude,p=fr[e]||fr.standard,u=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ec,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Hl(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(ut,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||p.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:f.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:p.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Ud,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(mr,{size:12}):r.jsx(ms,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(g=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:g.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Hl(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),u&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ut,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(le,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,icon:Ls,children:"Start Build"})]})]})}function Bv({sessionId:e}){return r.jsx(Dh,{sessionId:e})}function Qn(e,t,s){var o;if(t==="directory")return s?r.jsx(on,{size:14}):r.jsx(ao,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Q,{size:14,className:"text-yellow-600"}),ts:r.jsx(Q,{size:14,className:"text-blue-500"}),tsx:r.jsx(Q,{size:14,className:"text-blue-400"}),jsx:r.jsx(Q,{size:14,className:"text-yellow-500"}),py:r.jsx(Q,{size:14,className:"text-green-600"}),html:r.jsx(ac,{size:14,className:"text-orange-500"}),css:r.jsx(no,{size:14,className:"text-purple-500"}),json:r.jsx(ro,{size:14,className:"text-green-500"}),md:r.jsx(_i,{size:14,className:"text-muted"}),go:r.jsx(Q,{size:14,className:"text-cyan-600"}),rs:r.jsx(Q,{size:14,className:"text-orange-600"}),rb:r.jsx(Q,{size:14,className:"text-red-500"}),sh:r.jsx(Q,{size:14,className:"text-green-600"})}[i]||r.jsx(oo,{size:14})}function Tv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Rh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Rh(s.children,t);if(i!==void 0)return i}}}function Ph(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",f=a.has(h.path),p=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":p,...c?{"aria-expanded":f}:{},onContextMenu:u=>{u.preventDefault(),n==null||n(u,h.path,h.name,h.type)},onClick:()=>{c?l(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${p?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:f?r.jsx(ms,{size:14}):r.jsx(pr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Qn(h.name,h.type,f)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ph(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(gt,{size:12})})]}),c&&f&&h.children&&r.jsx(Mh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Lh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Lh(i.children,i.path+"/"));return s}function zv(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[f,p]=d.useState(new Set),u=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{u()},[u]);const g=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await u()}catch(v){c(v instanceof Error?v.message:"Failed to set secret")}}},m=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await u()}catch(v){c(v instanceof Error?v.message:"Failed to delete secret")}},_=y=>{p(v=>{const j=new Set(v);return j.has(y)?j.delete(y):j.add(y),j})},x=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"}),r.jsx(oi,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ut,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),x.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:x.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:f.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>_(y),className:"text-muted hover:text-ink transition-colors",title:f.has(y)?"Hide value":"Show value",children:f.has(y)?r.jsx(Fd,{size:14}):r.jsx(Es,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>m(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(io,{size:14})})})]},y))})]})}),x.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(gr,{size:14}),"Add"]})]})]})]})})}function Av({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,f]=d.useState(!0),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useCallback(async()=>{try{const v=await W.getDocsStatus(e);if(s(v),v.has_docs){const j=await W.getDocFiles(e);n(j.files)}}catch{}f(!1)},[e]);d.useEffect(()=>{_()},[_]);const x=async()=>{u(!0),m(null);try{await W.generateDocs(e);const v=setInterval(async()=>{try{const j=await W.getDocsStatus(e);if(j.has_docs){s(j);const k=await W.getDocFiles(e);n(k.files),u(!1),clearInterval(v)}}catch{}},3e3);setTimeout(()=>{clearInterval(v),u(!1)},3e5)}catch(v){m(v instanceof Error?v.message:"Failed to start doc generation"),u(!1)}},y=async v=>{try{const j=await W.getDocFileContent(e,v);a(v),h(j)}catch(j){m(j instanceof Error?j.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Jl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),g&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:g})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(le,{onClick:x,disabled:p,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:p?"animate-spin":""}),p?"Updating...":"Update Docs"]}):r.jsx(le,{onClick:x,disabled:p,size:"sm",children:p?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(v=>r.jsxs("button",{onClick:()=>y(v.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(_i,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:v.name}),r.jsx("span",{className:"text-xs text-muted",children:v.size<1024?`${v.size} B`:`${(v.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},v.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function Ov({session:e,onClose:t}){var sa;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(!1),[u,g]=d.useState("code"),[m,_]=d.useState(!1),[x,y]=d.useState(!1),[v,j]=d.useState(e),k=d.useRef(null),[w,N]=d.useState([]),[M,U]=d.useState(!1),[Y,V]=d.useState(""),$=d.useRef(null),P=d.useRef(null),[E,B]=d.useState(0),[S,C]=d.useState(null),[D,L]=d.useState(!0),[Z,oe]=d.useState(!0),[q,J]=d.useState(!1),[se,de]=d.useState("overview"),ue=57374,[ce,ge]=d.useState(null),Fe=d.useCallback(()=>{J(b=>{const A=!b;return L(!A),oe(!A),A})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${v.id}`)||"standard"),[T,G]=d.useState(()=>sessionStorage.getItem(`pl_provider_${v.id}`)||"claude"),[K,ne]=d.useState(null),[He,be]=d.useState(null),[he,Ae]=d.useState(null),[pe,wt]=d.useState(!1),[We,Xt]=d.useState(!1),[Ue,bs]=d.useState({phase:"idle",iteration:null,maxIterations:null,cost:null,startTime:0}),[Ct,Xe]=d.useState(!1),[Ke,Je]=d.useState(null),kt=d.useRef(null),[Bh,Do]=d.useState(!1),[Th,Ro]=d.useState([]),[Po,Is]=d.useState(null),[zh,Cr]=d.useState(!1),[Ah,wi]=d.useState(!1),[Oh,Fs]=d.useState(!1),[Ci,Mo]=d.useState("files"),{history:Lo,recordTokens:Bo}=Yx(),[$h,Ih]=d.useState(null),[To,Fh]=d.useState({line:1,column:1}),[Hh,zo]=d.useState(0),{device:Wh,setDevice:Uh,frameClass:Ao}=ev(),[kr,Kh]=d.useState(100),[Oo,qh]=d.useState(!1),[ki,Nr]=d.useState(!1),[$o,Iv]=d.useState([]),ys=d.useRef(null),[Vh,Io]=d.useState(0),{subscribe:Fo}=Ed(),tt=d.useCallback(async()=>{try{const b=await W.getSessionDetail(v.id);j(b)}catch{}},[v.id]),Ho=d.useCallback(async()=>{try{await W.stopSession(),wt(!1),Xt(!1)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.pauseSession(),Xt(!0)}catch{}},[]),Yh=d.useCallback(async()=>{try{await W.resumeSession(),Xt(!1)}catch{}},[]),Wo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();wt(F.running),Xt(F.paused),F.provider&&G(F.provider);const te=F.phase||"idle";if(te!==Wo.current&&te!=="idle"){const ot=new Date().toISOString(),Tt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},zt={id:`phase-${Date.now()}`,type:"phase_change",message:Tt[te]||`Phase: ${te}`,timestamp:ot};Ro(Mi=>[...Mi,zt]),Wo.current=te}bs({phase:te,iteration:typeof F.iteration=="number"?F.iteration:null,maxIterations:typeof F.max_iterations=="number"&&F.max_iterations>0?F.max_iterations:null,cost:typeof F.cost=="number"?F.cost:null,startTime:F.start_time?F.start_time*1e3:0});const Ze=F.tokens_used;Ze!=null&&Bo(Ze)}catch{}};b();const A=setInterval(b,pe?3e3:1e4);return()=>clearInterval(A)},[pe,Bo]),d.useEffect(()=>{if(!(he!=null&&he.loading))return;const b=setInterval(()=>{Ae(A=>A?{...A,elapsed:Math.floor((Date.now()-A.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[he==null?void 0:he.loading]);const[ee,Xh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(v.id).then(Xh).catch(()=>{})},[v.id]);const[I,Ni]=d.useState(null),[Hs,Uo]=d.useState(!1),[Ko,qo]=d.useState(!1),[Vo,ji]=d.useState(null),[Jt,Jh]=d.useState("");d.useEffect(()=>{const b=Fo("file_changed",A=>{const F=A;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ze=F.paths.map((ot,Tt)=>{var ia;const zt=(ia=F.event_types)==null?void 0:ia[Tt],Mi=zt==="created"||zt==="IN_CREATE";return{id:`file-${Date.now()}-${Tt}`,type:Mi?"file_created":"file_modified",message:Mi?`Created ${ot.split("/").pop()}`:`Modified ${ot.split("/").pop()}`,timestamp:te,filePath:ot}});if(Ro(ot=>[...ot,...Ze]),Xe(!0),kt.current&&clearTimeout(kt.current),kt.current=setTimeout(()=>Xe(!1),2e3),tt(),s&&F.paths.some(Tt=>Tt===s||s.endsWith(Tt))&&Je(s),u==="preview"){const ot=["react","vite","next","nuxt","svelte","remix"];(I==null?void 0:I.running)&&(I==null?void 0:I.framework)&&ot.some(zt=>I.framework.toLowerCase().includes(zt))||B(zt=>zt+1)}});return()=>{b(),kt.current&&clearTimeout(kt.current)}},[Fo,s,u,I==null?void 0:I.running,tt]);const Zh=d.useCallback(async()=>{if(!(!Ke||!v.id)){try{const b=await W.getSessionFileContent(v.id,Ke);l(b.content),c(b.content),_(!1),N(A=>A.map(F=>F.path===Ke?{...F,content:b.content,modified:!1}:F))}catch{}Je(null)}},[Ke,v.id]);d.useEffect(()=>{if(u!=="preview")return;let b=!1;const A=async()=>{try{const te=await W.devserver.status(v.id);b||Ni(te)}catch{}};A();const F=setInterval(A,3e3);return()=>{b=!0,clearInterval(F)}},[u,v.id]),d.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(b=>ge(b.ok)).catch(()=>ge(!1))},[u]);const Ss=d.useCallback(async b=>{Uo(!0),ji(null);try{const A=await W.devserver.start(v.id,b);if(A.status==="error")ji(A.message||"Failed to start dev server");else{const F=await W.devserver.status(v.id);Ni(F)}}catch(A){ji(A instanceof Error?A.message:"Failed to start dev server")}Uo(!1)},[v.id]),Go=d.useRef(!1);d.useEffect(()=>{Go.current||ee!=null&&ee.dev_command&&(I!=null&&I.running||(I==null?void 0:I.status)==="starting"||Hs||(Go.current=!0,Ss(ee.dev_command)))},[ee==null?void 0:ee.dev_command,I==null?void 0:I.running,I==null?void 0:I.status,Hs,Ss]);const Qh=d.useCallback(async()=>{try{await W.devserver.stop(v.id);const b=await W.devserver.status(v.id);Ni(b)}catch{}},[v.id]),ed=d.useCallback(async()=>{qo(!0);try{const b=await W.fixProject(v.id);if(b.task_id){let F=0,te;do await new Promise(ot=>setTimeout(ot,2e3)),te=await W.chatPoll(v.id,b.task_id),F++;while(!te.complete&&F<150);const Ze=await W.devserver.status(v.id);Ni(Ze)}}catch(b){ji(b instanceof Error?b.message:"Fix failed")}qo(!1)},[v.id]),ws=I!=null&&I.running&&(I!=null&&I.port)?I.framework==="expo"?`${sn}/api/sessions/${encodeURIComponent(v.id)}/expo-qr`:I.portless_url||`http://localhost:${I.port}/`:null,td=(ee==null?void 0:ee.preview_url)||`${sn}/api/sessions/${encodeURIComponent(v.id)}/preview/index.html`,sd=ws||td,[Ei,Yo]=d.useState([]),[Nt,Di]=d.useState(0);d.useEffect(()=>{const b=ws||(ee==null?void 0:ee.preview_url);b&&(Yo([b]),Di(0))},[ws,ee==null?void 0:ee.preview_url]);const Lt=Ei[Nt]||sd,[Xo,jr]=d.useState(Lt),id=d.useCallback((b,A,F,te)=>{b.preventDefault(),C({x:b.clientX,y:b.clientY,path:A,name:F,type:te})},[]),rd=d.useCallback(()=>{Nt>0&&(Di(b=>b-1),B(b=>b+1))},[Nt]),nd=d.useCallback(()=>{Nt<Ei.length-1&&(Di(b=>b+1),B(b=>b+1))},[Nt,Ei.length]),od=d.useCallback(b=>{let A=b;if(b.startsWith("/")&&ws)try{A=`${new URL(ws).origin}${b}`}catch{const F=I==null?void 0:I.port;F&&(A=`http://localhost:${F}${b}`)}Yo(F=>[...F.slice(0,Nt+1),A]),Di(F=>F+1),B(F=>F+1)},[Nt,ws,I==null?void 0:I.port]);d.useEffect(()=>{try{const b=new URL(Lt,window.location.origin);jr(b.pathname+b.search+b.hash||"/")}catch{jr(Lt)}},[Lt]);const Ri=d.useCallback(async()=>{Ae({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.reviewProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Pi=d.useCallback(async()=>{Ae({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.testProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Er=d.useCallback(async()=>{Ae({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.explainProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Dr=d.useCallback(async(b,A)=>{if(window.confirm(`Delete "${A}"?`))try{await W.deleteSessionFile(v.id,b),s===b&&(i(null),o(""),l(null),c(null),_(!1)),await tt()}catch(te){const Ze=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ze}`)}},[v.id,s,tt]),ad=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:Es,onClick:()=>{Ri()}},{label:"Generate Tests",icon:ai,onClick:()=>{Pi()}},{label:"Explain",icon:Js,onClick:()=>{Er()}},{label:"Delete",icon:io,onClick:()=>{Dr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:Es,onClick:()=>{Ri()}},{label:"Run Tests",icon:ai,onClick:()=>{Pi()}}],[Ri,Pi,Er,Dr]),Bt=d.useCallback(async(b,A)=>{Je(null),m&&s&&h!==null&&N(te=>te.map(Ze=>Ze.path===s?{...Ze,content:h,modified:!0}:Ze));const F=w.find(te=>te.path===b);if(F){i(b),o(A),l(F.content),c(F.content),_(F.modified);return}i(b),o(A),p(!0),_(!1);try{const te=v.id?await W.getSessionFileContent(v.id,b):await W.getFileContent(b);l(te.content),c(te.content),N(Ze=>[...Ze,{path:b,name:A,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{p(!1)}},[v.id,m,s,h,w]),Rr=d.useCallback(async()=>{var b;if(!(!s||h===null||!v.id)){y(!0);try{await W.saveSessionFile(v.id,s,h),l(h),_(!1),Ih(Date.now()),N(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const A=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(A)&&B(F=>F+1)}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,v.id]),Jo=d.useCallback(b=>{const A=w.find(F=>F.path===b);if(!(A!=null&&A.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(N(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),_(te.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const b=A=>{(A.metaKey||A.ctrlKey)&&A.key==="s"&&(A.preventDefault(),m&&s&&Rr()),(A.metaKey||A.ctrlKey)&&A.key==="p"&&(A.preventDefault(),U(F=>!F),V("")),(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),Do(F=>!F)),A.key==="Escape"&&M&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[m,s,Rr,M]),d.useEffect(()=>{M&&$.current&&$.current.focus()},[M]);const Zo=Lh(v.files),Ws=Y?Zo.filter(b=>b.path.toLowerCase().includes(Y.toLowerCase())):Zo;d.useEffect(()=>{const b=v.files.find(A=>A.name==="index.html"&&A.type==="file");b&&Bt(b.path,b.name)},[]);const ld=d.useCallback(b=>{b!==void 0&&(c(b),_(b!==a),zo(b.split(`
255
255
  `).length))},[a]),cd=d.useCallback(b=>{k.current=b;const A=b;if(A!=null&&A.onDidChangeCursorPosition&&A.onDidChangeCursorPosition(F=>{Fh({line:F.position.lineNumber,column:F.position.column})}),A!=null&&A.getModel){const F=A.getModel();F!=null&&F.getLineCount&&zo(F.getLineCount())}},[]),hd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(v.id,b.trim()),await tt()}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[v.id,tt]),dd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(v.id,b.trim()),await tt()}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[v.id,tt]),Qo=d.useCallback(async()=>{try{const b=await W.previewChanges(v.id,"preview current changes");Is(b)}catch{}},[v.id]),ud=d.useCallback(()=>{Is(null),tt()},[tt]),fd=d.useCallback(b=>{Is(null),tt()},[tt]),md=d.useCallback(()=>{Is(null)},[]),ea=s?Rh(v.files,s):void 0,pd=((sa=n.split(".").pop())==null?void 0:sa.toUpperCase())||"",{showHelp:_d,setShowHelp:ta}=vx({onToggleBuild:()=>{pe&&Ho()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:Es,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:ln,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:os,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Mr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Kt,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:Te,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:la,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Q,action:()=>{U(!0),V("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:cn,action:()=>Fe()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:ca,action:()=>L(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:Te,action:()=>Qo()},{id:"insights",label:"Build Insights",category:"command",icon:rn,action:()=>g("insights")},{id:"docs",label:"Documentation",category:"command",icon:Js,action:()=>g("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:as,action:()=>Fs(!0)}],[g,Fe,Qo]),Pr=d.useMemo(()=>{if(!pe)return"idle";const b=(Ue.phase||v.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[pe,Ue.phase,v.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{m&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:v.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:v.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${v.status==="completed"||v.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:v.status}),Lo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Gx,{tokenHistory:Lo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>L(b=>!b),title:D?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:D?r.jsx(ca,{size:16}):r.jsx(ku,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:Z?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:Z?r.jsx(yu,{size:16}):r.jsx(wu,{size:16})}),r.jsx("button",{onClick:Fe,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(cc,{size:16}):r.jsx(cn,{size:16})})]}),!pe&&r.jsx(le,{variant:"primary",size:"sm",icon:rs,onClick:()=>{if(!(v.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}wi(!0)},title:"Start build for this project",children:"Build"}),!pe&&Pr==="complete"&&r.jsx(le,{variant:"ghost",size:"sm",icon:rr,onClick:()=>Cr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(At,{icon:as,label:"Natural language search",size:"sm",onClick:()=>Fs(!0)}),pe&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[We?r.jsx(le,{variant:"ghost",size:"sm",icon:rs,onClick:Yh,title:"Resume build",children:"Resume"}):r.jsx(le,{variant:"ghost",size:"sm",icon:Zl,onClick:Gh,title:"Pause build",children:"Pause"}),r.jsx(le,{variant:"danger",size:"sm",icon:ir,onClick:Ho,title:"Stop build",children:"Stop"})]}),r.jsx(At,{icon:Es,label:"Review project",size:"sm",onClick:Ri,disabled:!!(he!=null&&he.loading)}),r.jsx(At,{icon:ai,label:"Run tests",size:"sm",onClick:Pi,disabled:!!(he!=null&&he.loading)}),r.jsx(At,{icon:Js,label:"Explain project",size:"sm",onClick:Er,disabled:!!(he!=null&&he.loading)}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(yx,{onClick:()=>ta(!0)})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("div",{className:"flex-1",children:r.jsx(lx,{phase:Pr,iteration:Ue.iteration,maxIterations:Ue.maxIterations,cost:Ue.cost,startTime:Ue.startTime,isRunning:pe})})}),r.jsx(Tx,{sessionId:v.id,onRestore:tt}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(un,{orientation:"vertical",children:[r.jsx(ei,{defaultSize:70,minSize:40,children:r.jsxs(un,{orientation:"horizontal",className:"h-full",children:[D&&r.jsx(ei,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Mo("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ao,{size:14}),"Files",Ct&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Mo("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Gl,{size:14}),"Chat"]}),Ci==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:hd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(_r,{size:12})," New"]}),r.jsxs("button",{onClick:dd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Bd,{size:12})," New"]})]})]}),Ci==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:v.files.length>0?r.jsx(Mh,{nodes:v.files,selectedPath:s,onSelect:Bt,onDelete:Dr,onContextMenu:id}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(on,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(bv,{sessionId:v.id,defaultMode:z})})})]})}),D&&r.jsx(fn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(ei,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:ln},{id:"preview",label:"Preview",icon:Es},{id:"deploy",label:"Deploy",icon:Kt},{id:"config",label:"Config",icon:la},{id:"secrets",label:"Secrets",icon:mu},{id:"prd",label:"Spec",icon:_i},{id:"dashboard",label:"Dashboard",icon:Mr},{id:"git",label:"Git",icon:Te},{id:"cicd",label:"CI/CD",icon:Te},{id:"insights",label:"Insights",icon:rn},{id:"docs",label:"Docs",icon:Js}].map(b=>r.jsxs("button",{role:"tab","aria-selected":u===b.id,onClick:()=>g(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${u===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[u==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Bt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Qn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:A=>{A.stopPropagation(),Jo(b.path)},onKeyDown:A=>{A.key==="Enter"&&(A.stopPropagation(),Jo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(gt,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),x&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:ea!=null?Ph(ea):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:pd}),m&&r.jsx("button",{onClick:Rr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Ke===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(bt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Zh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>Je(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:f?r.jsx(Dd,{}):r.jsx(Wi,{name:"Editor",children:r.jsx(Xf,{value:h??"",language:Tv(n),theme:"vs",onChange:ld,onMount:cd,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(Zx,{selectedFile:s,fileName:n,isModified:m,isSaving:x,lastSavedAt:$h,lineCount:Hh,cursorLine:To.line,cursorColumn:To.column,sessionId:v.id,prd:v.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Q,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),u==="preview"&&r.jsx(Wi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${Oo?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:I!=null&&I.running||ee!=null&&ee.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(At,{icon:Jl,label:"Back",size:"sm",onClick:rd,disabled:Nt<=0}),r.jsx(At,{icon:to,label:"Forward",size:"sm",onClick:nd,disabled:Nt>=Ei.length-1}),r.jsx(ov,{onClick:()=>{Nr(!0),B(b=>b+1)}}),r.jsx("input",{value:Xo,onChange:b=>jr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&od(Xo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(Qx,{selectedDevice:Wh,onDeviceChange:Uh,containerWidth:Vh}),r.jsx(sv,{zoom:kr,onZoomChange:Kh}),r.jsx(rv,{url:Lt}),r.jsx(iv,{}),r.jsx(At,{icon:ls,label:"Open in new tab",size:"sm",onClick:()=>window.open(Lt,"_blank")}),r.jsx(nv,{isFullscreen:Oo,onToggle:()=>qh(b=>!b)}),(I==null?void 0:I.running)&&r.jsxs("button",{onClick:Qh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(ir,{size:12}),"Stop"]})]}):ee?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:ee.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),I&&I.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${I.running?"bg-green-50 border-green-200 text-green-700":I.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":I.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${I.running?"bg-green-500":I.status==="starting"?"bg-yellow-500 animate-pulse":I.status==="error"?"bg-red-500":"bg-gray-400"}`}),I.running&&I.portless_url&&r.jsxs("span",{children:["Running at ",I.portless_url]}),I.running&&I.port&&!I.portless_url&&r.jsxs("span",{children:["Running on port ",I.port]}),I.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),I.status==="error"&&!I.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),I.status==="error"&&I.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",I.auto_fix_status]}),I.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:I.command})]}),I!=null&&I.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx($l,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Ao} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:P,src:Lt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Io(ys.current.clientWidth)}},E)})}),r.jsx(Ol,{messages:$o})]}):ee!=null&&ee.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx($l,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Ao} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:P,src:Lt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Io(ys.current.clientWidth)}},E)})}),r.jsx(Ol,{messages:$o})]}):ee?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:ee.type==="api"||ee.type==="python-api"?r.jsx(Kd,{size:28,className:"text-primary"}):ee.type==="library"?r.jsx(Ql,{size:28,className:"text-primary"}):ee.type==="go-app"||ee.type==="rust-app"?r.jsx(os,{size:28,className:"text-primary"}):r.jsx(on,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:ee.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:ee.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[ee.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:ee.dev_command}),r.jsxs("button",{onClick:()=>Ss(ee.dev_command||void 0),disabled:Hs,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(rs,{size:12}),Hs?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:ee.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:ee.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Jt,onChange:b=>Jh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Jt.trim()&&Ss(Jt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Jt.trim()&&Ss(Jt.trim()),disabled:Hs||!Jt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),Vo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Vo})]}),(I==null?void 0:I.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:ed,disabled:Ko,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Ko?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>Ss(ee.dev_command||Jt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),I.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",I.auto_fix_status]}),I.auto_fix_attempts!==void 0&&I.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",I.auto_fix_attempts,"/3"]})]}),I.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:I.output.slice(-10).join(`
256
256
  `)})]}),ee.port&&!(I!=null&&I.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",ee.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),u==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Provider for the next build: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:T})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{disabled:pe,title:pe?"Stop the build to change the provider":void 0,onClick:()=>{W.setProvider(b).then(()=>{G(b),sessionStorage.setItem(`pl_provider_${v.id}`,b),ne(null)}).catch(A=>ne(`Could not set provider: ${A instanceof Error?A.message:"unknown error"}`))},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize disabled:opacity-50 disabled:cursor-not-allowed ${T===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))}),K&&r.jsx("p",{className:"text-xs text-danger mt-2",children:K})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("p",{className:"text-xs text-muted mb-2",children:"Used by chat and the cost estimate in this browser tab. Not sent to the build."}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{xe(b),sessionStorage.setItem(`pl_buildmode_${v.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:v.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:v.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),u==="secrets"&&r.jsx(zv,{}),u==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),v.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:v.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),u==="deploy"&&r.jsx(_x,{sessionId:v.id}),u==="dashboard"&&(ce===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Mr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{ge(null);try{const b=await fetch(`http://127.0.0.1:${ue}/health`);ge(b.ok)}catch{ge(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>de(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${se===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${ue}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ls,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${ue}/#${se}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),u==="git"&&r.jsx(Bx,{sessionId:v.id}),u==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Bv,{sessionId:e.id})}),u==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Av,{sessionId:v.id})}),u==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Cv,{filesCreated:null,filesModified:null,linesGenerated:null,testsGenerated:null,testPassRate:null,totalTokens:null,phaseBreakdown:[],totalTimeSecs:pe&&Ue.startTime?Math.floor((Date.now()-Ue.startTime)/1e3):null,qualityScore:null,totalCost:Ue.cost,iterations:Ue.iteration,provider:T})})]})]})})]})}),Z&&r.jsx(fn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),Z&&r.jsx(ei,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Wi,{name:"ActivityPanel",children:r.jsx(ox,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:v.status==="running"||v.status==="in_progress",buildMode:z,buildEvents:Th,onFileClick:b=>Bt(b,b.split("/").pop()||b)})})})]})}),(he==null?void 0:he.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[he.type==="review"?"Reviewing project":he.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[he.elapsed,"s"]})]})}),He&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(At,{icon:gt,label:"Close",size:"sm",onClick:()=>be(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:He})]}),S&&r.jsx(Lm,{x:S.x,y:S.y,items:ad(S),onClose:()=>C(null)}),M&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:$,type:"text",value:Y,onChange:b=>V(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&Ws.length>0&&(Bt(Ws[0].path,Ws[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Ws.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Bt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Qn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),Ws.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(bx,{open:_d,onClose:()=>ta(!1)}),r.jsx(kx,{isOpen:Bh,onClose:()=>Do(!1),commands:gd,sessionId:v.id,onFileSelect:Bt}),Po&&r.jsx(Ox,{data:Po,onAcceptAll:ud,onAcceptSelected:fd,onReject:md,onClose:()=>Is(null)}),r.jsx(Vx,{phase:Pr,buildTime:Ue.startTime?Math.floor((Date.now()-Ue.startTime)/1e3):void 0}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Cr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>Cr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(jv,{sessionId:v.id})})]})}),Oh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Fs(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>Fs(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx(Pv,{sessionId:v.id,onOpenFile:(b,A)=>{Bt(b,b.split("/").pop()||b),Fs(!1)},className:"p-4"})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>wi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Lv,{complexity:z==="quick"?"simple":z==="max"?"complex":"standard",provider:T,estimatedIterations:Ue.maxIterations??0,onConfirm:async()=>{wi(!1);try{const b=v.prd||"";await W.startSession({prd:b,provider:T,projectDir:v.path}),wt(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>wi(!1)})})})]})}function $v(){const{sessionId:e}=Rd(),t=Pd(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Wi,{name:"ProjectWorkspace",children:r.jsx(Ov,{session:s,onClose:()=>t("/")})})})})}const bb=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"}));export{xr as L,bb as P,Du as S};