loki-mode 6.75.3 → 6.76.1

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 (76) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +659 -0
  4. package/autonomy/run.sh +115 -4
  5. package/dashboard/__init__.py +1 -1
  6. package/docs/INSTALLATION.md +1 -1
  7. package/mcp/__init__.py +1 -1
  8. package/mcp/magic_tools.py +471 -0
  9. package/mcp/server.py +13 -0
  10. package/package.json +1 -1
  11. package/references/magic-modules-patterns.md +634 -0
  12. package/references/magic-rarv-integration.md +87 -0
  13. package/skills/00-index.md +2 -0
  14. package/skills/magic-modules.md +205 -0
  15. package/web-app/dist/assets/{AdminPage-D4QSV6Zi.js → AdminPage-DwVUK4v9.js} +1 -1
  16. package/web-app/dist/assets/{Avatar-88MlpLO5.js → Avatar-B7gqhcg3.js} +1 -1
  17. package/web-app/dist/assets/{Badge-DbGjLr4i.js → Badge-DA3xNJAS.js} +1 -1
  18. package/web-app/dist/assets/{Button-sp_FVGZj.js → Button-BPXURLaK.js} +1 -1
  19. package/web-app/dist/assets/{ComparePage-p2ENnfa7.js → ComparePage-B0JQMhKG.js} +1 -1
  20. package/web-app/dist/assets/GitHubIssuesPanel-D38-fy29.js +12 -0
  21. package/web-app/dist/assets/{GitHubPRsPanel-Bi_yrcAE.js → GitHubPRsPanel-DLPcW3N0.js} +2 -2
  22. package/web-app/dist/assets/{HomePage-BB83YPiX.js → HomePage-CzeoS2V_.js} +3 -3
  23. package/web-app/dist/assets/{LoginPage-BXUudCJ9.js → LoginPage-DqCzxsfx.js} +1 -1
  24. package/web-app/dist/assets/MagicPage-CBLqpa55.js +31 -0
  25. package/web-app/dist/assets/{MetricsPage-CX0Ahy-_.js → MetricsPage-CPYQR0zr.js} +1 -1
  26. package/web-app/dist/assets/{NotFoundPage-C4JqatEk.js → NotFoundPage-B62u4iCs.js} +1 -1
  27. package/web-app/dist/assets/{ProjectPage-t5J2XAJT.js → ProjectPage-DNujSl6j.js} +67 -72
  28. package/web-app/dist/assets/{ProjectsPage-Bzpz1clk.js → ProjectsPage-uHG7kxB-.js} +1 -1
  29. package/web-app/dist/assets/{SettingsPage-y_yl8FvH.js → SettingsPage-BaQJbOgL.js} +1 -1
  30. package/web-app/dist/assets/{ShowcasePage-B7d6pzMq.js → ShowcasePage-DQR_e-kg.js} +1 -1
  31. package/web-app/dist/assets/{SystemSettingsPage-C4tR33KU.js → SystemSettingsPage-C_Q_1WK4.js} +1 -1
  32. package/web-app/dist/assets/{TeamsPage-DIOCfZIP.js → TeamsPage-DOFErDqX.js} +1 -1
  33. package/web-app/dist/assets/{TemplatesPage-DlKyapXX.js → TemplatesPage-Ty72hILN.js} +1 -1
  34. package/web-app/dist/assets/{TerminalOutput-Czg-ZC2k.js → TerminalOutput-DqOVnR1p.js} +7 -12
  35. package/web-app/dist/assets/{activity-h1wU9a0L.js → activity-BgBZ4s4c.js} +1 -1
  36. package/web-app/dist/assets/{bell-Bu8lsWOp.js → bell-C-UezVWi.js} +1 -1
  37. package/web-app/dist/assets/{bot-rWO7KjkQ.js → bot-D70fEnm5.js} +1 -1
  38. package/web-app/dist/assets/{check-BWp8L5Cy.js → check-CBohulxQ.js} +1 -1
  39. package/web-app/dist/assets/{chevron-left-Bw4I1yGm.js → chevron-left-C-emzUhB.js} +1 -1
  40. package/web-app/dist/assets/{circle-alert-C37PKXiC.js → circle-alert-8SRY0_GX.js} +1 -1
  41. package/web-app/dist/assets/{clock-DDScLol4.js → clock-mfq4XnPQ.js} +1 -1
  42. package/web-app/dist/assets/{cloud-DaYKPLaM.js → cloud-DpRM7T8t.js} +1 -1
  43. package/web-app/dist/assets/code-xml-1N2Ui-4c.js +6 -0
  44. package/web-app/dist/assets/{copy-DKIRv0VK.js → copy-LXquTgzI.js} +1 -1
  45. package/web-app/dist/assets/{database-CYZBHz51.js → database-S1dyXnuT.js} +1 -1
  46. package/web-app/dist/assets/{dollar-sign-CydJu0kl.js → dollar-sign-CRqk0dW5.js} +1 -1
  47. package/web-app/dist/assets/{file-code-corner-DqZ9gpdv.js → file-code-corner-B99CwY_6.js} +1 -1
  48. package/web-app/dist/assets/{file-plus-CzeFJWp3.js → file-plus-DZ5qnz5b.js} +1 -1
  49. package/web-app/dist/assets/{folder-open-4YWk08dP.js → folder-open-DBCm7yuF.js} +1 -1
  50. package/web-app/dist/assets/{git-commit-horizontal-wbqFPNID.js → git-commit-horizontal-DM1ERuNd.js} +1 -1
  51. package/web-app/dist/assets/{globe-Cby-g5Yb.js → globe-B7xEJSL_.js} +1 -1
  52. package/web-app/dist/assets/{hammer-BNScgGdp.js → hammer-Cgi3LTuS.js} +1 -1
  53. package/web-app/dist/assets/{index-6Z4B0I6r.js → index-BN52-GQT.js} +22 -17
  54. package/web-app/dist/assets/index-BfZSDej1.css +1 -0
  55. package/web-app/dist/assets/{layers-XfssQc5V.js → layers-Bi8RPIBC.js} +1 -1
  56. package/web-app/dist/assets/{lightbulb-EhnzRw7M.js → lightbulb-Doc_n8JX.js} +1 -1
  57. package/web-app/dist/assets/{loader-circle-BA0QIVGA.js → loader-circle-BB932A7A.js} +1 -1
  58. package/web-app/dist/assets/{lock-BABtHe6K.js → lock-Bt6gpMrs.js} +1 -1
  59. package/web-app/dist/assets/{mail-Dokiey5S.js → mail-BuzAu1IP.js} +1 -1
  60. package/web-app/dist/assets/{package-DbJyS1Ft.js → package-BE5FHxQ8.js} +1 -1
  61. package/web-app/dist/assets/{plus-BcAN8Kaj.js → plus-CNqABexN.js} +1 -1
  62. package/web-app/dist/assets/{refresh-cw-B3dG1-Sb.js → refresh-cw-34B13ztx.js} +1 -1
  63. package/web-app/dist/assets/{rotate-ccw-Cs1Phctm.js → rotate-ccw-CrD2QB29.js} +1 -1
  64. package/web-app/dist/assets/{save-DsrNCZrP.js → save-DsJcqdnI.js} +1 -1
  65. package/web-app/dist/assets/{server-CpN2GX4G.js → server-BcgRMArA.js} +1 -1
  66. package/web-app/dist/assets/{shield-alert-CKJ1pzCz.js → shield-alert-DLYLdVJ0.js} +1 -1
  67. package/web-app/dist/assets/{trash-2-C9vZqTqw.js → trash-2-Cc-VTvzt.js} +1 -1
  68. package/web-app/dist/assets/{trending-down-BNLTrF5P.js → trending-down-CrDpO2a_.js} +1 -1
  69. package/web-app/dist/assets/{trending-up-DmFIdVOc.js → trending-up-CNVsmM3G.js} +1 -1
  70. package/web-app/dist/assets/upload-LuDuB7Wc.js +6 -0
  71. package/web-app/dist/assets/{usePolling-vUlY-o6P.js → usePolling-C8rvc-CG.js} +1 -1
  72. package/web-app/dist/assets/{user-Dh00W8De.js → user-BT79cI-o.js} +1 -1
  73. package/web-app/dist/index.html +2 -2
  74. package/web-app/server.py +120 -0
  75. package/web-app/dist/assets/GitHubIssuesPanel-DBbBTG9w.js +0 -17
  76. package/web-app/dist/assets/index-CVM4A1Fw.css +0 -1
@@ -1,4 +1,4 @@
1
- import{c as he,j as e,P as We,r as n,a as j,C as Ue,M as fe,R as re,u as ae,b as Ve,A as Qe,S as Ye,d as Ke,U as Ze,e as Je}from"./index-6Z4B0I6r.js";import{u as R}from"./usePolling-vUlY-o6P.js";import{P as Xe,S as et,C as be,F as tt,E as F,T as st}from"./TerminalOutput-Czg-ZC2k.js";import{B as rt}from"./Badge-DbGjLr4i.js";import{P as at}from"./package-DbJyS1Ft.js";import{C as nt}from"./cloud-DaYKPLaM.js";import{H as it}from"./hammer-BNScgGdp.js";import{C as lt}from"./chevron-left-Bw4I1yGm.js";import{L as ot}from"./layers-XfssQc5V.js";import{C as ct}from"./check-BWp8L5Cy.js";import{M as dt}from"./mail-Dokiey5S.js";import{B as xt}from"./bell-Bu8lsWOp.js";import{F as mt}from"./file-code-corner-DqZ9gpdv.js";import"./lock-BABtHe6K.js";import"./clock-DDScLol4.js";import"./circle-alert-C37PKXiC.js";/**
1
+ import{c as he,j as e,P as We,r as n,a as j,C as Ue,M as fe,R as re,u as ae,b as Ve,A as Qe,S as Ye,d as Ke,U as Ze,e as Je}from"./index-BN52-GQT.js";import{u as R}from"./usePolling-C8rvc-CG.js";import{P as Xe,S as et,F as tt,E as F,T as st}from"./TerminalOutput-DqOVnR1p.js";import{B as rt}from"./Badge-DA3xNJAS.js";import{P as at}from"./package-BE5FHxQ8.js";import{C as nt}from"./cloud-DpRM7T8t.js";import{C as be}from"./code-xml-1N2Ui-4c.js";import{H as it}from"./hammer-Cgi3LTuS.js";import{C as lt}from"./chevron-left-C-emzUhB.js";import{L as ot}from"./layers-Bi8RPIBC.js";import{C as ct}from"./check-CBohulxQ.js";import{M as dt}from"./mail-BuzAu1IP.js";import{B as xt}from"./bell-C-UezVWi.js";import{F as mt}from"./file-code-corner-B99CwY_6.js";import"./lock-Bt6gpMrs.js";import"./clock-mfq4XnPQ.js";import"./circle-alert-8SRY0_GX.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -24,5 +24,5 @@ Describe your project here...
24
24
 
25
25
  - Requirement 1
26
26
  - Requirement 2
27
- `)}},[]),Q=async()=>{if(!(!l.trim()||A)){_(!0),S(null),$(!0);try{const g=await j.planSession(l,y);S(g)}catch{S({complexity:"unknown",cost_estimate:"N/A",iterations:0,phases:[],output_text:"Failed to run loki plan. The CLI may not be available.",returncode:1})}finally{_(!1)}}},G=async()=>{if(!(!l.trim()||s||E)){$(!1),z(!0);try{await t(l,y,p.trim()||void 0,I?"quick":void 0)}finally{z(!1)}}};return e.jsxs(e.Fragment,{children:[q&&e.jsx(yt,{plan:H,loading:A,onConfirm:G,onCancel:()=>$(!1)}),e.jsxs("div",{className:"card p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Product Requirements"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>k(!N),className:"text-xs font-medium px-3 py-1.5 rounded-card border border-primary/20 text-primary hover:bg-primary/5 transition-colors",children:c||"Templates"}),N&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-56 card rounded-card overflow-hidden z-20 shadow-card-hover",children:e.jsxs("div",{className:"py-1 max-h-64 overflow-y-auto terminal-scroll",children:[h&&e.jsx("div",{className:"px-3 py-2 text-xs text-warning border-b border-warning/10",children:"Could not load templates from server. Check that the backend is running."}),!h&&w.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-muted",children:"Loading..."}),w.map(g=>e.jsx("button",{onClick:()=>V(g.filename,g.name),className:"w-full text-left px-3 py-2 text-sm text-ink hover:bg-primary/5 transition-colors",children:g.name},g.filename))]})})]})})]}),e.jsx("textarea",{value:l,onChange:g=>d(g.target.value),placeholder:"Paste your PRD here, or select a template above to get started...",className:"flex-1 min-h-[280px] w-full bg-card rounded-card border border-border-light px-4 py-3 text-sm font-mono text-ink placeholder:text-primary/60 resize-none focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30 transition-all",spellCheck:!1}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-muted font-medium mb-1 uppercase tracking-wider",children:"Project Directory"}),e.jsx("input",{type:"text",value:p,onChange:g=>b(g.target.value),placeholder:"Leave blank to auto-create, or type a path (e.g. /Users/you/my-project)",className:"w-full bg-card rounded-card border border-border-light px-4 py-2 text-sm font-mono text-ink placeholder:text-primary/60/70 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30 transition-all",spellCheck:!1}),e.jsx("p",{className:"text-xs text-muted-accessible mt-1",children:"Type a path or leave blank to auto-create under ~/purple-lab-projects/"})]}),r&&e.jsx("div",{className:"mt-3 px-3 py-2 rounded-btn bg-danger/10 border border-danger/20 text-danger text-xs font-medium",children:r}),e.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[e.jsxs("button",{onClick:()=>C(!I),title:"Quick Mode: 3 iterations max, faster builds",className:`flex items-center gap-1.5 px-3 py-1.5 rounded-card text-xs font-semibold border transition-all ${I?"bg-primary/10 border-primary/30 text-primary":"border-border-light text-muted hover:text-ink hover:bg-card"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${I?"bg-primary":"bg-muted/40"}`}),"Quick"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted font-mono",children:[l.length.toLocaleString()," chars"]}),e.jsx("button",{onClick:Q,disabled:!l.trim()||s||E||A,className:`px-6 py-2.5 rounded-card text-sm font-semibold transition-all ${!l.trim()||s||E||A?"bg-primary/10 text-muted cursor-not-allowed":"bg-primary text-white hover:bg-primary/90 shadow-button"}`,children:A?"Analyzing...":E?"Starting...":s?"Building...":"Start Build"})]})]})]})}const O=[{key:"reason",label:"Reason",description:"Analyzing task, planning approach"},{key:"act",label:"Act",description:"Implementing changes, writing code"},{key:"reflect",label:"Reflect",description:"Reviewing output, self-critique"},{key:"verify",label:"Verify",description:"Testing, validation, quality gates"}];function wt(t){if(!t)return"reason";const s=t.toLowerCase();return s.includes("reason")||s.includes("plan")?"reason":s.includes("act")||s.includes("implement")||s.includes("code")?"act":s.includes("reflect")||s.includes("review")?"reflect":s.includes("verify")||s.includes("test")||s.includes("check")?"verify":"idle"}function kt({currentPhase:t,iteration:s}){const r=wt(t);return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"RARV Cycle"}),e.jsxs("span",{className:"font-mono text-xs text-muted",children:["Iteration ",s]})]}),e.jsx("div",{className:"flex items-center justify-center mb-5",children:e.jsxs("svg",{viewBox:"0 0 120 120",className:"w-28 h-28",children:[O.map((a,i)=>{const o=a.key===r,l=r!=="idle"&&O.findIndex(u=>u.key===r)>i,d=(i*90-90)*(Math.PI/180),c=60+40*Math.cos(d),m=60+40*Math.sin(d);return e.jsxs("g",{children:[i<O.length-1&&e.jsx("line",{x1:c,y1:m,x2:60+40*Math.cos(((i+1)*90-90)*(Math.PI/180)),y2:60+40*Math.sin(((i+1)*90-90)*(Math.PI/180)),stroke:l?"#553DE9":"#ECEAE3",strokeWidth:l?2:1,strokeDasharray:l?"none":"4 3"}),i===O.length-1&&e.jsx("line",{x1:c,y1:m,x2:60+40*Math.cos(-90*(Math.PI/180)),y2:60+40*Math.sin(-90*(Math.PI/180)),stroke:"#ECEAE3",strokeWidth:1,strokeDasharray:"4 3"}),e.jsx("circle",{cx:c,cy:m,r:o?14:10,fill:o||l?"#553DE9":"#E8E4FD",stroke:o?"#4432c4":l?"#553DE9":"#ECEAE3",strokeWidth:o?3:1.5,className:o?"phase-active":""}),e.jsx("text",{x:c,y:m+(i===0?-20:i===2?24:0),textAnchor:"middle",className:"text-[9px] font-semibold fill-ink",dx:i===1?22:i===3?-22:0,children:a.label[0]})]},a.key)}),e.jsx("text",{x:"60",y:"64",textAnchor:"middle",className:"text-lg font-bold font-mono fill-primary",children:s})]})}),e.jsx("div",{className:"space-y-2",children:O.map(a=>{const i=a.key===r;return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-card transition-all duration-200 ${i?"bg-primary/8 border border-primary/20":"opacity-50"}`,children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${i?"bg-primary phase-active":"bg-border"}`}),e.jsxs("div",{children:[e.jsx("span",{className:`text-sm font-semibold ${i?"text-primary":"text-muted"}`,children:a.label}),i&&e.jsx("p",{className:"text-xs text-muted mt-0.5",children:a.description})]})]},a.key)})})]})}const ee={architect:"bg-primary/10 text-primary border-primary/20",developer:"bg-primary/10 text-primary border-primary/20",tester:"bg-success/10 text-success border-success/20",reviewer:"bg-warning/10 text-warning border-warning/20",planner:"bg-primary/60/20 text-ink border-primary/60/30",default:"bg-border/30 text-muted border-border/50"};function Et(t){if(!t)return ee.default;const s=t.toLowerCase();for(const[r,a]of Object.entries(ee))if(s.includes(r))return a;return ee.default}function St({agents:t,loading:s}){const r=(t==null?void 0:t.filter(i=>i.alive))||[],a=(t==null?void 0:t.filter(i=>!i.alive))||[];return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Agents"}),e.jsxs("span",{className:"font-mono text-xs text-muted",children:[r.length," active"]})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading agents..."}),!s&&(t==null?void 0:t.length)===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No agents running"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Start a build to spawn agents"})]}),r.length>0&&e.jsx("div",{className:"space-y-2 mb-4",children:r.map(i=>e.jsx(de,{agent:i},i.id))}),a.length>0&&e.jsxs("details",{className:"mt-3",children:[e.jsxs("summary",{className:"text-xs text-muted cursor-pointer hover:text-ink transition-colors",children:[a.length," completed"]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:a.slice(0,10).map(i=>e.jsx(de,{agent:i,compact:!0},i.id))})]})]})}function de({agent:t,compact:s}){const r=Et(t.type||t.name||"");return s?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-btn bg-hover text-xs",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted/30"}),e.jsx("span",{className:"font-medium text-muted truncate",children:t.name||t.id}),e.jsx("span",{className:"text-primary/60 ml-auto",children:t.type})]}):e.jsxs("div",{className:`flex items-start gap-3 px-3 py-2.5 rounded-card border ${r}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.alive?"bg-success phase-active":"bg-muted/30"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold truncate",children:t.name||t.id}),t.type&&e.jsx("span",{className:"text-xs font-mono font-medium opacity-70",children:t.type})]}),t.task&&e.jsx("p",{className:"text-xs opacity-70 mt-0.5 truncate",children:t.task}),t.status&&t.status!=="unknown"&&e.jsx("span",{className:"inline-block text-xs font-mono mt-1 opacity-60",children:t.status})]}),t.pid&&e.jsxs("span",{className:"text-xs font-mono text-muted-accessible flex-shrink-0",children:["PID ",t.pid]})]})}function Ct({text:t,position:s="top",size:r=14}){const[a,i]=n.useState(!1),o=n.useRef(null);n.useEffect(()=>{if(!a)return;const c=m=>{o.current&&!o.current.contains(m.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[a]);const l={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},d={top:"top-full left-1/2 -translate-x-1/2 border-t-[#1A1A1E] dark:border-t-card border-l-transparent border-r-transparent border-b-transparent border-4",bottom:"bottom-full left-1/2 -translate-x-1/2 border-b-[#1A1A1E] dark:border-b-card border-l-transparent border-r-transparent border-t-transparent border-4",left:"left-full top-1/2 -translate-y-1/2 border-l-[#1A1A1E] dark:border-l-card border-t-transparent border-b-transparent border-r-transparent border-4",right:"right-full top-1/2 -translate-y-1/2 border-r-[#1A1A1E] dark:border-r-card border-t-transparent border-b-transparent border-l-transparent border-4"};return e.jsxs("div",{className:"relative inline-flex items-center",ref:o,children:[e.jsx("button",{onClick:()=>i(!a),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),className:"text-muted/50 hover:text-primary transition-colors p-0.5 rounded-full","aria-label":"Help",type:"button",children:e.jsx(Ue,{size:r})}),a&&e.jsx("div",{className:`absolute z-50 ${l[s]}`,role:"tooltip",children:e.jsxs("div",{className:"relative bg-[#1A1A1E] text-white px-3 py-2 rounded-lg shadow-lg max-w-[240px]",children:[e.jsx("p",{className:"text-[11px] leading-relaxed",children:t}),e.jsx("span",{className:`absolute ${d[s]}`})]})})]})}const At={qualityGates:"Automated checks ensuring your code meets quality standards. Includes static analysis, test coverage, and security scanning."},Dt={pass:{badge:"bg-success/10 text-success border-success/20",dot:"bg-success",label:"Pass"},fail:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Fail"},skip:{badge:"bg-muted/10 text-muted border-muted/20",dot:"bg-muted/40",label:"Skip"},pending:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Pending"}};function Pt({item:t}){const[s,r]=n.useState(!1),a=Dt[t.status];return e.jsxs("div",{className:`border rounded-card overflow-hidden ${a.badge}`,children:[e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-3 py-2.5 text-left",onClick:()=>t.details&&r(!s),children:[e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.dot}`}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:t.label}),e.jsx("span",{className:"text-xs font-mono font-semibold uppercase tracking-wider flex-shrink-0",children:a.label}),t.details&&e.jsx("span",{className:"text-xs text-muted/60 flex-shrink-0",children:s?"v":">"})]}),s&&t.details&&e.jsx("div",{className:"px-3 pb-2.5 pt-0",children:e.jsx("p",{className:"text-xs font-mono opacity-70 leading-relaxed",children:t.details})})]})}function Ft({checklist:t,loading:s}){const r=t&&t.total>0?t.passed/t.total*100:0;return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Quality Gates"}),e.jsx(Ct,{text:At.qualityGates,position:"right",size:13})]}),t&&e.jsxs("span",{className:"font-mono text-xs text-muted",children:[t.passed,"/",t.total," passed"]})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading gates..."}),!s&&!t&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No quality gate data"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Gates run during verification phase"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-3 text-xs",children:[e.jsxs("span",{className:"text-success font-medium",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-danger font-medium",children:[t.failed," failed"]}),t.skipped>0&&e.jsxs("span",{className:"text-muted",children:[t.skipped," skipped"]}),t.pending>0&&e.jsxs("span",{className:"text-warning",children:[t.pending," pending"]})]}),e.jsx("div",{className:"w-full h-2 bg-charcoal/10 rounded-full overflow-hidden mb-4",children:e.jsx("div",{className:"h-full bg-success rounded-full transition-all duration-500",style:{width:`${r}%`}})}),e.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto terminal-scroll",children:t.items.map(a=>e.jsx(Pt,{item:a},a.id))})]})]})}const Lt={".py":"bg-success",".ts":"bg-primary",".tsx":"bg-primary",".md":"bg-warning",".sh":"bg-primary"};function Tt(t){const s=t.substring(t.lastIndexOf("."));return Lt[s]||"bg-muted"}function Mt(t){return t==null?"":t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}const te=100;function ge({node:t,depth:s,onSelectFile:r,selectedPath:a}){const[i,o]=n.useState(!1),[l,d]=n.useState(te),c=t.type==="directory",m=t.path===a,u=c&&i?t.children??[]:[],v=u.length>l;return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`w-full flex items-center gap-2 px-2 py-1 rounded-btn text-left text-sm transition-colors hover:bg-hover ${m?"bg-primary/10 text-primary":"text-ink"}`,style:{paddingLeft:`${s*16+8}px`},onClick:()=>{c?(o(!i),i&&d(te)):r(t.path)},children:[c?e.jsx("span",{className:"font-mono text-xs text-muted w-3 flex-shrink-0",children:i?"v":">"}):e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Tt(t.name)}`}),e.jsx("span",{className:`truncate ${c?"font-medium":"font-mono text-xs"}`,children:t.name}),!c&&t.size!==void 0&&e.jsx("span",{className:"ml-auto text-xs font-mono text-muted-accessible flex-shrink-0",children:Mt(t.size)})]}),u.length>0&&e.jsxs("div",{children:[u.slice(0,l).map(p=>e.jsx(ge,{node:p,depth:s+1,onSelectFile:r,selectedPath:a},p.path)),v&&e.jsxs("button",{type:"button",className:"w-full text-left text-xs text-primary hover:text-primary/80 py-1 transition-colors",style:{paddingLeft:`${(s+1)*16+8}px`},onClick:()=>d(p=>p+te),children:["Show more (",u.length-l," remaining)"]})]})]})}function Rt({files:t,loading:s}){const[r,a]=n.useState(null),[i,o]=n.useState(null),[l,d]=n.useState(!1),[c,m]=n.useState(null),u=n.useCallback(async p=>{o(null),a(p),d(!0),m(null);try{const b=await j.getFileContent(p);o(b.content)}catch(b){const y=b instanceof Error?b.message:"Unknown error",N=b instanceof TypeError||y==="Request timeout",k=y.includes("404")||y.includes("not found")||y.includes("Not found");m(N?"Network error - server may be unreachable":k?"File not found - it may have been deleted or renamed":y),o(null)}finally{d(!1)}},[]),v=n.useCallback(p=>{u(p)},[u]);return e.jsxs("div",{className:"card p-6 flex flex-col",style:{minHeight:"300px"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"File Browser"}),e.jsx("span",{className:"font-mono text-xs text-muted",children:".loki/"})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading files..."}),!s&&(!t||t.length===0)&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No project files found"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Start a session to generate .loki/ state"})]}),t&&t.length>0&&e.jsxs("div",{className:"flex gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"w-1/2 overflow-y-auto terminal-scroll pr-2",children:t.map(p=>e.jsx(ge,{node:p,depth:0,onSelectFile:v,selectedPath:r},p.path))}),e.jsxs("div",{className:"w-1/2 bg-charcoal/5 rounded-card p-3 overflow-hidden flex flex-col",children:[!r&&e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Select a file to preview"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-mono text-primary mb-2 truncate",children:r}),e.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:l?e.jsx("div",{className:"text-muted text-xs",children:"Loading..."}):c?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-6",children:[e.jsx("p",{className:"text-danger text-xs font-medium",children:"Failed to load file"}),e.jsx("p",{className:"text-muted-accessible text-xs text-center max-w-[200px] break-words",children:c}),e.jsx("button",{type:"button",onClick:()=>r&&u(r),className:"mt-1 px-3 py-1 text-xs font-semibold rounded-btn border border-primary/20 text-primary hover:bg-primary/5 transition-colors",children:"Retry"})]}):e.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap break-words leading-relaxed",children:i})})]})]})]})]})}const xe=5e5;function me(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Bt(t){if(!t)return"Never";try{const s=new Date(t),a=new Date().getTime()-s.getTime(),i=Math.floor(a/(1e3*60*60));return i<1?"Just now":i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}catch{return t}}function It({memory:t,loading:s}){const r=t?[{label:"Episodic",count:t.episodic_count,color:"text-primary",bg:"bg-primary/10",border:"border-primary/20"},{label:"Semantic",count:t.semantic_count,color:"text-success",bg:"bg-success/10",border:"border-success/20"},{label:"Skills",count:t.skill_count,color:"text-warning",bg:"bg-warning/10",border:"border-warning/20"}]:[],a=t?Math.min(t.total_tokens/xe*100,100):0;return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Memory System"}),t&&e.jsx("span",{className:"font-mono text-xs text-muted",children:Bt(t.last_consolidation)})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading memory..."}),!s&&!t&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No memory data available"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Memory populates during autonomous runs"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:r.map(i=>e.jsxs("div",{className:`${i.bg} border ${i.border} rounded-card p-3 text-center`,children:[e.jsx("div",{className:`text-2xl font-bold font-mono ${i.color}`,children:i.count}),e.jsx("div",{className:"text-xs text-muted-accessible font-medium mt-1 uppercase tracking-wider",children:i.label})]},i.label))}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs text-muted font-medium",children:"Token Usage"}),e.jsxs("span",{className:"text-xs font-mono text-ink",children:[me(t.total_tokens)," / ",me(xe)]})]}),e.jsx("div",{className:"w-full h-2 bg-charcoal/10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${a>80?"bg-danger":a>50?"bg-warning":"bg-info"}`,style:{width:`${a}%`}})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted",children:"Last Consolidation"}),e.jsx("span",{className:"font-mono text-ink",children:t.last_consolidation?new Date(t.last_consolidation).toLocaleString():"Never"})]})]})]})}function _t({visible:t}){const[s,r]=n.useState("markdown"),[a,i]=n.useState(null),[o,l]=n.useState(null),[d,c]=n.useState(!1),[m,u]=n.useState(!1),[v,p]=n.useState(null),[b,y]=n.useState(!1);if(!t)return null;const N=async()=>{c(!0),p(null),i(null),l(null);try{const h=await j.generateReport(s);i(h)}catch(h){p(h instanceof Error?h.message:"Failed to generate report")}finally{c(!1)}},k=async()=>{u(!0),p(null);try{const h=await j.shareSession();l(h)}catch(h){p(h instanceof Error?h.message:"Failed to share session")}finally{u(!1)}},w=async h=>{try{await navigator.clipboard.writeText(h),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},B=()=>{if(!a)return;const h=new Blob([a.content],{type:s==="html"?"text/html":"text/markdown"}),L=URL.createObjectURL(h),E=document.createElement("a");E.href=L,E.download=`loki-report.${s==="html"?"html":"md"}`,E.click(),URL.revokeObjectURL(L)};return e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Session Report"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 card rounded-card p-1",children:["markdown","html"].map(h=>e.jsx("button",{onClick:()=>r(h),className:`px-3 py-1 text-xs font-semibold rounded-btn transition-all ${s===h?"bg-primary text-white shadow-sm":"text-muted hover:text-ink hover:bg-hover"}`,children:h.toUpperCase()},h))}),e.jsx("button",{onClick:N,disabled:d,className:"px-4 py-1.5 rounded-card text-xs font-semibold bg-primary text-white hover:bg-primary/90 disabled:opacity-50 transition-all",children:d?"Generating...":"Generate Report"})]})]}),v&&e.jsx("div",{className:"mb-3 px-3 py-2 rounded-btn bg-danger/10 border border-danger/20 text-danger text-xs",children:v}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-xs text-muted",children:["Report generated (",a.format,")"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>w(a.content),className:"px-3 py-1 text-xs font-medium text-muted hover:text-ink border border-border-light rounded-btn hover:bg-hover transition-all",children:b?"Copied":"Copy"}),e.jsx("button",{onClick:B,className:"px-3 py-1 text-xs font-medium text-muted hover:text-ink border border-border-light rounded-btn hover:bg-hover transition-all",children:"Download"}),e.jsx("button",{onClick:k,disabled:m,className:"px-3 py-1 text-xs font-medium bg-primary/10 text-primary border border-primary/20 rounded-btn hover:bg-primary/20 disabled:opacity-50 transition-all",children:m?"Sharing...":"Share as Gist"})]}),o&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-3 py-2 rounded-btn bg-success/10 border border-success/20",children:[e.jsx("span",{className:"text-xs text-success font-medium",children:"Shared:"}),o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary underline flex-1 truncate",children:o.url}):e.jsx("span",{className:"text-xs text-muted flex-1",children:"No URL returned"}),o.url&&e.jsx("button",{onClick:()=>w(o.url),className:"text-xs text-muted hover:text-ink",children:"Copy URL"})]}),e.jsx("pre",{className:"text-[11px] font-mono text-ink bg-black/5 rounded-card p-3 overflow-auto max-h-64 whitespace-pre-wrap terminal-scroll",children:a.content||"(empty report)"})]})]})}function ue({visible:t}){const s=n.useCallback(()=>j.getMetrics(),[]),{data:r,loading:a}=R(s,15e3,t);return t?e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Session Metrics"}),a&&e.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"})]}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Iterations"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:r.iterations??0})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Gate Pass Rate"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:typeof r.quality_gate_pass_rate=="number"?`${r.quality_gate_pass_rate.toFixed(0)}%`:"N/A"})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Tokens Used"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:(r.tokens_used??0).toLocaleString()})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Time Elapsed"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:r.time_elapsed||"N/A"})]})]}):e.jsx("div",{className:"text-sm text-muted py-4 text-center",children:a?"Loading metrics...":"No metrics available"})]}):null}function $t(t){switch(t){case"completed":case"complete":case"done":return"completed";case"in_progress":return"running";case"started":return"started";case"error":case"failed":return"failed";default:return"empty"}}const zt={completed:"Completed",complete:"Completed",done:"Completed",in_progress:"In Progress",started:"Started",error:"Failed",failed:"Failed",empty:"Empty"};function Ot({onLoadSession:t}){const s=n.useCallback(()=>j.getSessionsHistory(),[]),{data:r,loading:a}=R(s,6e4,!0);return a&&!r?e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider mb-3",children:"Past Builds"}),e.jsx("div",{className:"text-sm text-muted",children:"Loading..."})]}):!r||r.length===0?null:e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider mb-3",children:"Past Builds"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto terminal-scroll",children:r.map(i=>{const o=i.file_count;return e.jsxs("button",{onClick:()=>t==null?void 0:t(i),className:"text-left px-4 py-3 rounded-card card hover:bg-hover transition-all group cursor-pointer",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-mono text-muted-accessible",children:i.date}),e.jsxs("div",{className:"flex items-center gap-2",children:[o!==void 0&&o>0&&e.jsxs("span",{className:"text-xs font-mono text-muted-accessible",children:[o," files"]}),e.jsx(rt,{status:$t(i.status),children:zt[i.status]||i.status})]})]}),e.jsx("div",{className:"text-xs text-ink truncate group-hover:text-primary transition-colors",children:i.prd_snippet||i.id}),e.jsx("div",{className:"text-xs font-mono text-muted-accessible mt-0.5 truncate",children:i.path})]},i.id)})})]})}function Ht({end:t,suffix:s="",duration:r=1500}){const[a,i]=n.useState(0),o=n.useRef(null),l=n.useRef(!1);return n.useEffect(()=>{const d=new IntersectionObserver(([c])=>{if(c.isIntersecting&&!l.current){l.current=!0;const m=performance.now(),u=v=>{const p=v-m,b=Math.min(p/r,1),y=1-Math.pow(1-b,3);i(Math.floor(y*t)),b<1&&requestAnimationFrame(u)};requestAnimationFrame(u)}},{threshold:.3});return o.current&&d.observe(o.current),()=>d.disconnect()},[t,r]),e.jsxs("span",{ref:o,className:"tabular-nums",children:[a,s]})}const qt=[{icon:at,value:21,suffix:"+",label:"Templates"},{icon:nt,value:5,suffix:"",label:"AI Providers"},{icon:be,value:100,suffix:"%",label:"Open Source"}];function Gt(){return e.jsxs("section",{className:"w-full max-w-3xl mx-auto mt-16 mb-4",children:[e.jsx("p",{className:"text-center text-sm text-[#6B6960] mb-8 tracking-wide uppercase font-medium",children:"Trusted by developers building the future"}),e.jsx("div",{className:"flex items-center justify-center gap-12 sm:gap-16",children:qt.map(t=>{const s=t.icon;return e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(s,{size:20,className:"text-[#553DE9]",strokeWidth:1.5}),e.jsx("span",{className:"text-2xl font-bold text-[#36342E]",children:e.jsx(Ht,{end:t.value,suffix:t.suffix})}),e.jsx("span",{className:"text-xs text-[#6B6960] font-medium",children:t.label})]},t.label)})}),e.jsx("div",{className:"mt-12 border-t border-[#ECEAE3]"})]})}function se({icon:t,number:s,title:r,description:a,mockup:i,delay:o}){const l=n.useRef(null),[d,c]=n.useState(!1);return n.useEffect(()=>{const m=new IntersectionObserver(([u])=>{u.isIntersecting&&(setTimeout(()=>c(!0),o),m.disconnect())},{threshold:.2});return l.current&&m.observe(l.current),()=>m.disconnect()},[o]),e.jsxs("div",{ref:l,className:`flex flex-col items-center text-center max-w-xs transition-all duration-700 ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-6"}`,children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#553DE9]/10 flex items-center justify-center",children:e.jsx(t,{size:24,className:"text-[#553DE9]",strokeWidth:1.5})}),e.jsx("span",{className:"absolute -top-2 -right-2 w-6 h-6 rounded-full bg-[#553DE9] text-white text-xs font-bold flex items-center justify-center",children:s})]}),e.jsx("h3",{className:"text-lg font-bold text-[#36342E] mb-1.5",children:r}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-4 leading-relaxed",children:a}),e.jsx("div",{className:"w-full rounded-xl border border-[#ECEAE3] bg-white p-3 shadow-sm",children:i})]})}function Wt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-lg bg-[#FAF9F6] border border-[#ECEAE3] text-left",children:e.jsx("span",{className:"text-xs text-[#36342E]",children:"Build a SaaS dashboard with analytics"})}),e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#553DE9] flex items-center justify-center flex-shrink-0",children:e.jsx(re,{size:12,className:"text-white"})})]})}function Ut(){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-[#6B6960]",children:[e.jsx("span",{children:"Phase: Implementation"}),e.jsx("span",{children:"68%"})]}),e.jsx("div",{className:"w-full h-2 rounded-full bg-[#ECEAE3] overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#553DE9] to-[#1FC5A8]",style:{width:"68%"}})}),e.jsx("div",{className:"flex gap-1",children:["Planning","Scaffolding","Implementation","Testing","Deploy"].map((t,s)=>e.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded ${s<=2?"bg-[#553DE9]/10 text-[#553DE9] font-medium":"bg-[#ECEAE3]/60 text-[#6B6960]"}`,children:t},t))})]})}function Vt(){return e.jsxs("div",{className:"space-y-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-[#1FC5A8]/20 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none",children:e.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"#1FC5A8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("span",{className:"text-xs font-semibold text-[#1FC5A8]",children:"Deployed successfully"})]}),e.jsx("div",{className:"px-3 py-1.5 rounded-lg bg-[#FAF9F6] border border-[#ECEAE3]",children:e.jsx("span",{className:"text-[10px] font-mono text-[#553DE9]",children:"https://my-app.vercel.app"})})]})}function Qt(){return e.jsxs("section",{className:"w-full max-w-5xl mx-auto py-16",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] text-center mb-3",children:"How It Works"}),e.jsx("p",{className:"text-sm text-[#6B6960] text-center mb-12 max-w-lg mx-auto",children:"Three steps from idea to production. No manual coding required."}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start justify-center gap-10 md:gap-8",children:[e.jsx("div",{className:"hidden md:block absolute top-7 left-1/2 -translate-x-1/2 w-[60%] h-px border-t-2 border-dashed border-[#ECEAE3] z-0"}),e.jsx(se,{icon:fe,number:1,title:"Describe Your Idea",description:"Type a one-line description. Loki handles the rest.",mockup:e.jsx(Wt,{}),delay:0}),e.jsx(se,{icon:it,number:2,title:"Watch It Build",description:"AI writes code, runs tests, and ensures quality.",mockup:e.jsx(Ut,{}),delay:150}),e.jsx(se,{icon:re,number:3,title:"Ship It",description:"Deploy to Vercel, Netlify, or GitHub in one click.",mockup:e.jsx(Vt,{}),delay:300})]})]})}const Yt=[{name:"SaaS Dashboard",description:"Full-stack analytics dashboard with auth, billing, and user management.",tech:["React","Node.js","PostgreSQL"],gradient:"from-violet-500/20 via-purple-500/10 to-indigo-500/20"},{name:"REST API",description:"Production-ready API with authentication, rate limiting, and docs.",tech:["Python","FastAPI","Redis"],gradient:"from-emerald-500/20 via-teal-500/10 to-cyan-500/20"},{name:"E-Commerce Store",description:"Online store with Stripe payments, cart, and inventory management.",tech:["React","Node.js","MongoDB"],gradient:"from-amber-500/20 via-orange-500/10 to-yellow-500/20"},{name:"Discord Bot",description:"Feature-rich bot with slash commands, moderation, and webhooks.",tech:["TypeScript","Discord","SQLite"],gradient:"from-blue-500/20 via-sky-500/10 to-cyan-500/20"},{name:"CLI Tool",description:"Interactive command-line application with argument parsing and config.",tech:["TypeScript","CLI","Node.js"],gradient:"from-rose-500/20 via-pink-500/10 to-fuchsia-500/20"},{name:"Landing Page",description:"Responsive marketing site with pricing, testimonials, and CTAs.",tech:["React","Tailwind","Vite"],gradient:"from-slate-500/20 via-gray-500/10 to-zinc-500/20"}],Kt={React:"bg-sky-500/10 text-sky-600","Node.js":"bg-green-500/10 text-green-600",Python:"bg-yellow-500/10 text-yellow-700",TypeScript:"bg-blue-500/10 text-blue-600",PostgreSQL:"bg-indigo-500/10 text-indigo-600",MongoDB:"bg-green-600/10 text-green-700",Redis:"bg-red-500/10 text-red-600",FastAPI:"bg-teal-500/10 text-teal-600",SQLite:"bg-blue-400/10 text-blue-500",Tailwind:"bg-cyan-400/10 text-cyan-600",Discord:"bg-indigo-400/10 text-indigo-500",CLI:"bg-amber-500/10 text-amber-600",Vite:"bg-purple-400/10 text-purple-500"};function Zt(){const t=ae(),s=n.useRef(null),[r,a]=n.useState(!1),[i,o]=n.useState(!0),l=()=>{const c=s.current;c&&(a(c.scrollLeft>8),o(c.scrollLeft<c.scrollWidth-c.clientWidth-8))};n.useEffect(()=>{const c=s.current;if(c)return l(),c.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),()=>{c.removeEventListener("scroll",l),window.removeEventListener("resize",l)}},[]);const d=c=>{const m=s.current;if(!m)return;const u=320;m.scrollBy({left:c==="left"?-u:u,behavior:"smooth"})};return e.jsxs("section",{className:"w-full max-w-5xl mx-auto py-16",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E]",children:"Start from a Template"}),e.jsx("p",{className:"text-sm text-[#6B6960] mt-1",children:"Production-ready starting points for common use cases."})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d("left"),disabled:!r,className:`w-8 h-8 rounded-lg border flex items-center justify-center transition-all ${r?"border-[#ECEAE3] text-[#36342E] hover:bg-[#F8F4F0]":"border-[#ECEAE3]/50 text-[#6B6960]/30 cursor-not-allowed"}`,"aria-label":"Scroll left",children:e.jsx(lt,{size:16})}),e.jsx("button",{onClick:()=>d("right"),disabled:!i,className:`w-8 h-8 rounded-lg border flex items-center justify-center transition-all ${i?"border-[#ECEAE3] text-[#36342E] hover:bg-[#F8F4F0]":"border-[#ECEAE3]/50 text-[#6B6960]/30 cursor-not-allowed"}`,"aria-label":"Scroll right",children:e.jsx(Ve,{size:16})})]})]}),e.jsxs("div",{ref:s,className:"flex gap-4 overflow-x-auto pb-4 snap-x snap-mandatory scrollbar-hide",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[Yt.map(c=>e.jsxs("div",{className:"flex-shrink-0 w-64 rounded-xl border border-[#ECEAE3] bg-white overflow-hidden snap-start hover:shadow-lg hover:border-[#553DE9]/30 transition-all cursor-pointer group",onClick:()=>t("/templates"),children:[e.jsx("div",{className:`h-20 bg-gradient-to-br ${c.gradient} flex items-end p-3`,children:e.jsx("h3",{className:"text-sm font-bold text-[#36342E] group-hover:text-[#553DE9] transition-colors",children:c.name})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[#6B6960] mb-3 leading-relaxed line-clamp-2",children:c.description}),e.jsx("div",{className:"flex flex-wrap gap-1",children:c.tech.map(m=>e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Kt[m]||"bg-gray-100 text-gray-600"}`,children:m},m))})]})]},c.name)),e.jsxs("div",{className:"flex-shrink-0 w-48 rounded-xl border border-dashed border-[#ECEAE3] bg-[#FAF9F6] flex flex-col items-center justify-center gap-2 snap-start cursor-pointer hover:border-[#553DE9]/40 hover:bg-[#553DE9]/5 transition-all group",onClick:()=>t("/templates"),children:[e.jsx(Qe,{size:20,className:"text-[#6B6960] group-hover:text-[#553DE9] transition-colors"}),e.jsx("span",{className:"text-sm font-semibold text-[#6B6960] group-hover:text-[#553DE9] transition-colors",children:"View All Templates"})]})]})]})}function Jt({icon:t,title:s,description:r}){return e.jsxs("div",{className:"rounded-xl border border-[#ECEAE3] bg-white p-5 hover:border-[#553DE9]/40 hover:shadow-lg transition-all group",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#553DE9]/10 flex items-center justify-center mb-3 group-hover:bg-[#553DE9]/15 transition-colors",children:e.jsx(t,{size:20,className:"text-[#553DE9]",strokeWidth:1.5})}),e.jsx("h3",{className:"text-sm font-bold text-[#36342E] mb-1.5",children:s}),e.jsx("p",{className:"text-xs text-[#6B6960] leading-relaxed",children:r})]})}const Xt=[{icon:ot,title:"Multi-AI",description:"Use Claude, GPT, Gemini. Pick the best for each task."},{icon:Ye,title:"Quality First",description:"10 quality gates. 3 blind reviewers. Zero sycophancy."},{icon:pt,title:"Self-Hosted",description:"Your code stays on your machine. Full privacy."},{icon:be,title:"Open Source",description:"MIT-licensed. Fork it, extend it, own it."}];function es(){return e.jsxs("section",{className:"w-full max-w-4xl mx-auto py-16",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] text-center mb-3",children:"Why developers choose Loki Mode"}),e.jsx("p",{className:"text-sm text-[#6B6960] text-center mb-10 max-w-lg mx-auto",children:"Built by developers, for developers. Every decision optimized for shipping faster."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:Xt.map(t=>e.jsx(Jt,{...t},t.title))})]})}const ts=[{title:"Product",links:[{label:"Features",to:"/"},{label:"Templates",to:"/templates"},{label:"Pricing",href:"https://www.autonomi.dev/#pricing"},{label:"Docs",href:"https://github.com/asklokesh/loki-mode/wiki"}]},{title:"Developers",links:[{label:"Quick Start",to:"/"},{label:"API Reference",href:"https://github.com/asklokesh/loki-mode/wiki/API-Reference"},{label:"CLI Docs",href:"https://github.com/asklokesh/loki-mode/wiki/CLI-Reference"},{label:"Changelog",href:"https://github.com/asklokesh/loki-mode/blob/main/CHANGELOG.md"}]},{title:"Company",links:[{label:"About Autonomi",href:"https://www.autonomi.dev/"},{label:"Blog",href:"https://www.autonomi.dev/blog"},{label:"Careers",href:"https://www.autonomi.dev/careers"},{label:"Contact",href:"mailto:hello@autonomi.dev"}]},{title:"Community",links:[{label:"GitHub",href:"https://github.com/asklokesh/loki-mode"},{label:"Discord",href:"https://discord.gg/autonomi"},{label:"Twitter",href:"https://twitter.com/autonomidev"},{label:"Forum",href:"https://github.com/asklokesh/loki-mode/discussions"}]}];function ss(){const t=ae(),s=(r,a)=>{r.to&&(a.preventDefault(),t(r.to))};return e.jsx("footer",{className:"w-full bg-[#F0EDE8] border-t border-[#ECEAE3] mt-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-12",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-8 mb-10",children:ts.map(r=>e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-[#36342E] uppercase tracking-wider mb-4",children:r.title}),e.jsx("ul",{className:"space-y-2.5",children:r.links.map(a=>e.jsx("li",{children:e.jsx("a",{href:a.href||a.to||"#",onClick:i=>s(a,i),className:"text-sm text-[#6B6960] hover:text-[#553DE9] transition-colors",...a.href?{target:"_blank",rel:"noopener noreferrer"}:{},children:a.label})},a.label))})]},r.title))}),e.jsxs("div",{className:"border-t border-[#ECEAE3] pt-6 flex flex-col sm:flex-row items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#6B6960]",children:[e.jsx("span",{children:"Built with care by Autonomi"}),e.jsx("span",{className:"hidden sm:inline text-[#ECEAE3]",children:"|"}),e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#553DE9]/10 text-[#553DE9] font-semibold text-[10px]",children:"v6.73.0"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-[#6B6960]",children:[e.jsx("a",{href:"https://www.autonomi.dev/privacy",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#553DE9] transition-colors",children:"Privacy"}),e.jsx("a",{href:"https://www.autonomi.dev/terms",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#553DE9] transition-colors",children:"Terms"})]})]})]})})}function rs({label:t,value:s,suffix:r=""}){const[a,i]=n.useState(0),o=n.useRef(!1),l=n.useRef(null);return n.useEffect(()=>{if(o.current)return;const d=new IntersectionObserver(([c])=>{if(c.isIntersecting&&!o.current){let m=function(p){const b=p-v,y=Math.min(b/u,1),N=1-Math.pow(1-y,3);i(Math.round(s*N)),y<1&&requestAnimationFrame(m)};o.current=!0;const u=800,v=performance.now();requestAnimationFrame(m)}},{threshold:.3});return l.current&&d.observe(l.current),()=>d.disconnect()},[s]),e.jsxs("div",{ref:l,className:"text-center",children:[e.jsxs("div",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] tabular-nums",children:[a.toLocaleString(),r]}),e.jsx("div",{className:"text-xs text-[#6B6960] dark:text-[#8A8880] mt-1",children:t})]})}const W="asklokesh/loki-mode",as="loki-mode";function ns(){const[t,s]=n.useState([{label:"GitHub Stars",value:0},{label:"Forks",value:0},{label:"Contributors",value:0},{label:"npm Downloads",value:0,suffix:"+"}]);return n.useEffect(()=>{(async()=>{try{const[a,i,o]=await Promise.allSettled([fetch(`https://api.github.com/repos/${W}`),fetch(`https://api.github.com/repos/${W}/contributors?per_page=1&anon=true`,{method:"HEAD"}),fetch(`https://api.npmjs.org/downloads/point/last-month/${as}`)]);let l=0,d=0,c=0,m=0;if(a.status==="fulfilled"&&a.value.ok){const u=await a.value.json();l=u.stargazers_count||0,d=u.forks_count||0}if(i.status==="fulfilled"){const v=(i.value.headers.get("Link")||"").match(/page=(\d+)>; rel="last"/);if(v)c=parseInt(v[1],10);else{const p=await fetch(`https://api.github.com/repos/${W}/contributors?per_page=100&anon=true`);if(p.ok){const b=await p.json();c=Array.isArray(b)?b.length:0}}}o.status==="fulfilled"&&o.value.ok&&(m=(await o.value.json()).downloads||0),s([{label:"GitHub Stars",value:l},{label:"Forks",value:d},{label:"Contributors",value:c},{label:"npm Downloads",value:m,suffix:"+"}])}catch{}})()},[]),e.jsxs("div",{className:"py-8 border-t border-[#ECEAE3] dark:border-[#2A2A30]",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-6",children:[e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-[#36342E] dark:text-[#E8E6E3]",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",fill:"currentColor"})}),e.jsx("span",{className:"text-sm font-semibold text-[#36342E] dark:text-[#E8E6E3]",children:"Open Source"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-6 max-w-lg mx-auto",children:t.map(r=>e.jsx(rs,{...r},r.label))}),e.jsx("div",{className:"mt-4 text-center",children:e.jsxs("a",{href:`https://github.com/${W}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-[#553DE9] hover:text-[#4832c7] font-medium transition-colors",children:["Star us on GitHub",e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 17L17 7M17 7H7M17 7V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})}function is(){const[t,s]=n.useState(""),[r,a]=n.useState(!1),[i,o]=n.useState(""),l=d=>{d.preventDefault(),o("");const c=t.trim();if(c){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c)){o("Please enter a valid email address.");return}try{const m=JSON.parse(localStorage.getItem("pl_newsletter_emails")||"[]");m.includes(c)||(m.push(c),localStorage.setItem("pl_newsletter_emails",JSON.stringify(m)))}catch{}a(!0),s("")}};return r?e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 rounded-xl bg-[#1FC5A8]/10 border border-[#1FC5A8]/20",children:[e.jsx(ct,{size:16,className:"text-[#1FC5A8] flex-shrink-0"}),e.jsx("span",{className:"text-sm text-[#36342E] font-medium",children:"Thanks for subscribing! We will keep you posted."})]}):e.jsxs("div",{className:"py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(dt,{size:14,className:"text-[#6B6960]"}),e.jsx("span",{className:"text-sm text-[#6B6960]",children:"Get updates on new features and tips"})]}),e.jsxs("form",{onSubmit:l,className:"flex gap-2",children:[e.jsx("input",{type:"email",value:t,onChange:d=>s(d.target.value),placeholder:"you@example.com",className:"flex-1 px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] bg-white focus:outline-none focus:ring-2 focus:ring-[#553DE9]/30 focus:border-[#553DE9]/40"}),e.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-semibold rounded-lg bg-[#553DE9] text-white hover:bg-[#4832c7] transition-colors",children:"Subscribe"})]}),i&&e.jsx("p",{className:"mt-1.5 text-xs text-[#C45B5B]",children:i})]})}const ls={"build-complete":{icon:e.jsx(ft,{size:24,className:"text-teal"}),title:"Build complete!",description:"Your code is ready. Time to ship it."},"deploy-success":{icon:e.jsx(re,{size:24,className:"text-primary"}),title:"Your app is live!",description:"Successfully deployed. The world can see your work now."},"first-project":{icon:e.jsx(Ke,{size:24,className:"text-warning"}),title:"First build complete!",description:"Welcome to Purple Lab. This is just the beginning."}},pe=["#553DE9","#1FC5A8","#D63384","#2F71E3","#D4A03C","#E8E4FD"],os=40;function cs({index:t}){const s=pe[t%pe.length],r=Math.random()*100,a=Math.random()*1.5,i=2+Math.random()*1.5,o=4+Math.random()*6,l=t%3===0,d=Math.random()*360;return e.jsx("div",{className:"confetti-piece",style:{position:"absolute",left:`${r}%`,top:"-10px",width:`${o}px`,height:`${o}px`,backgroundColor:s,borderRadius:l?"50%":"1px",opacity:0,transform:`rotate(${d}deg)`,animation:`confetti-fall ${i}s ease-in ${a}s forwards`}})}function ds({type:t,onDismiss:s}){const[r,a]=n.useState(!0),i=ls[t];return n.useEffect(()=>{const o=setTimeout(()=>{a(!1),s==null||s()},3500);return()=>clearTimeout(o)},[s]),r?e.jsxs("div",{className:"fixed inset-0 z-50 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 overflow-hidden",children:Array.from({length:os},(o,l)=>e.jsx(cs,{index:l},l))}),e.jsx("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 pointer-events-auto celebration-banner-enter",children:e.jsxs("div",{className:"bg-card border border-border rounded-card shadow-lg px-6 py-4 flex items-center gap-3",children:[i.icon,e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-ink",children:i.title}),e.jsx("p",{className:"text-xs text-muted",children:i.description})]})]})})]}):null}const xs={"no-projects":{icon:e.jsx(tt,{size:32,className:"text-primary/60"}),title:"Your workspace is a blank canvas",description:"What will you create today? Describe your idea and watch it come to life.",defaultActionLabel:"Start a new project"},"no-files":{icon:e.jsx(mt,{size:32,className:"text-teal/60"}),title:"This project is brand new",description:"Let's add some code! Start building and files will appear here as they're created.",defaultActionLabel:"Open editor"},"no-chat":{icon:e.jsx(fe,{size:32,className:"text-primary/60"}),title:"Start a conversation with Loki",description:"Try something like 'Add a contact form to my app' or 'Create a dark mode toggle.'",defaultActionLabel:"Say hello"},"no-team":{icon:e.jsx(Ze,{size:32,className:"text-pink/60"}),title:"Building alone is great, but building together is better",description:"Invite teammates to collaborate on this project in real time.",defaultActionLabel:"Invite a teammate"},"no-notifications":{icon:e.jsx(xt,{size:32,className:"text-teal/60"}),title:"All clear!",description:"No notifications right now. When something needs your attention, it will show up here.",defaultActionLabel:"Dismiss"}};function ms({type:t}){const r={"no-projects":{primary:"#553DE9",secondary:"#1FC5A8"},"no-files":{primary:"#1FC5A8",secondary:"#553DE9"},"no-chat":{primary:"#553DE9",secondary:"#D63384"},"no-team":{primary:"#D63384",secondary:"#553DE9"},"no-notifications":{primary:"#1FC5A8",secondary:"#2F71E3"}}[t];return e.jsxs("svg",{width:"120",height:"80",viewBox:"0 0 120 80",fill:"none",className:"mb-4 opacity-60",children:[e.jsx("circle",{cx:"60",cy:"40",r:"28",stroke:r.primary,strokeWidth:"1.5",strokeDasharray:"4 3"}),e.jsx("circle",{cx:"30",cy:"25",r:"8",fill:r.primary,opacity:"0.1"}),e.jsx("circle",{cx:"90",cy:"55",r:"12",fill:r.secondary,opacity:"0.1"}),e.jsx("circle",{cx:"60",cy:"40",r:"4",fill:r.primary,opacity:"0.3"}),e.jsx("line",{x1:"20",y1:"60",x2:"45",y2:"45",stroke:r.secondary,strokeWidth:"1",opacity:"0.2"}),e.jsx("line",{x1:"75",y1:"35",x2:"100",y2:"20",stroke:r.primary,strokeWidth:"1",opacity:"0.2"}),e.jsx("rect",{x:"50",y:"15",width:"20",height:"3",rx:"1.5",fill:r.secondary,opacity:"0.15"}),e.jsx("rect",{x:"42",y:"62",width:"36",height:"3",rx:"1.5",fill:r.primary,opacity:"0.15"})]})}function us({type:t,action:s,actionLabel:r}){const a=xs[t];return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 text-center warm-empty-state-enter",children:[e.jsx(ms,{type:t}),e.jsx("div",{className:"mb-3",children:a.icon}),e.jsx("h3",{className:"text-sm font-semibold text-ink mb-1.5",children:a.title}),e.jsx("p",{className:"text-xs text-muted max-w-[260px] leading-relaxed",children:a.description}),s&&e.jsx("button",{onClick:s,className:"mt-4 px-4 py-2 text-xs font-semibold rounded-btn bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:r||a.defaultActionLabel})]})}const U=["Build a SaaS dashboard with user analytics...","Create a REST API with authentication...","Make a landing page with pricing tiers...","Build a chat app with real-time messaging...","Create an e-commerce store with Stripe..."];function ps(){const t=new Date().getHours();return t>=5&&t<12?"Good morning! What shall we build today?":t>=12&&t<17?"Good afternoon! Ready to create something amazing?":t>=17&&t<22?"Good evening! Let's build something cool.":"Burning the midnight oil? Let's build something cool."}function Fs(){const t=ae(),[s,r]=n.useState(null),[a,i]=n.useState(()=>sessionStorage.getItem("pl_running")==="1"),[o,l]=n.useState(!1),[d,c]=n.useState(()=>sessionStorage.getItem("pl_prd")),[m,u]=n.useState(!1),[v,p]=n.useState(!1),[b,y]=n.useState(!1),[N,k]=n.useState(()=>sessionStorage.getItem("pl_tab")||"terminal"),[w,B]=n.useState(()=>sessionStorage.getItem("pl_provider")||"claude"),[h,L]=n.useState(void 0),[E,z]=n.useState(!1),I=n.useMemo(()=>ps(),[]),[C,H]=n.useState(""),[S,A]=n.useState(!1),[_,q]=n.useState(!1),[$,V]=n.useState(0),[Q,G]=n.useState(!1),g=n.useRef(null),D=n.useRef(null);n.useEffect(()=>{const x=setInterval(()=>{G(!0),setTimeout(()=>{V(f=>(f+1)%U.length),G(!1)},300)},3e3);return()=>clearInterval(x)},[]),n.useEffect(()=>{const x=sessionStorage.getItem("pl_template");x&&(sessionStorage.removeItem("pl_template"),j.getTemplateContent(x).then(({content:f})=>{f&&(L(f),q(!0))}).catch(()=>{}))},[]);const[T,Y]=n.useState(null),[ne,K]=n.useState(null),[ie,Z]=n.useState(null),je=n.useCallback(x=>{if(!x){Y(null),K(null),Z(null);return}Y(x.status),K(x.agents),Z(x.logs),i(x.status.running??!1),l(x.status.paused??!1)},[]),{connected:J,subscribe:ve}=Je(je),ye=n.useCallback(()=>j.getStatus(),[]),{data:M}=R(ye,3e4,!J);n.useEffect(()=>{T===null&&M!==null&&(i(M.running??!1),l(M.paused??!1))},[M,T]),n.useEffect(()=>{sessionStorage.setItem("pl_running",a?"1":"0"),a&&u(!0)},[a]),n.useEffect(()=>{d?sessionStorage.setItem("pl_prd",d):sessionStorage.removeItem("pl_prd")},[d]),n.useEffect(()=>{sessionStorage.setItem("pl_provider",w)},[w]),n.useEffect(()=>{sessionStorage.setItem("pl_tab",N)},[N]);const X=n.useRef(void 0);n.useEffect(()=>{var f;const x=(f=T??M)==null?void 0:f.phase;x==="complete"&&X.current&&X.current!=="complete"&&z(!0),X.current=x},[T,M]);const Ne=n.useCallback(()=>j.getMemorySummary(),[]),we=n.useCallback(()=>j.getChecklist(),[]),ke=n.useCallback(()=>j.getFiles(),[]),Ee=n.useCallback(()=>j.getSessionsHistory(),[]),{data:Se,loading:Ce}=R(Ne,3e4,a),{data:Ae,loading:De}=R(we,3e4,a),{data:Pe,loading:Fe}=R(ke,3e4,a),{data:le}=R(Ee,6e4,!0),P=T??M,Le=ne,Te=ie,Me=ne===null,Re=ie===null,oe=n.useCallback(async()=>{const x=C.trim();if(!(!x||S)){r(null),A(!0),u(!1),p(!1),k("terminal");try{const f=await j.quickStart(x,w);f.started&&f.session_id&&(c(x),i(!0),t(`/project/${f.session_id}`))}catch(f){r(f instanceof Error?f.message:"Failed to start build")}finally{A(!1)}}},[C,S,w,t]),Be=n.useCallback(async(x,f,qe,Ge)=>{r(null),u(!1),p(!1),k("terminal");try{await j.startSession({prd:x,provider:f,projectDir:qe,mode:Ge}),c(x),i(!0)}catch(ce){r(ce instanceof Error?ce.message:"Failed to start session")}},[]),Ie=n.useCallback(async()=>{try{(await j.stopSession()).stopped&&(i(!1),l(!1),c(null),Y(null),K(null),Z(null))}catch{i(!1),l(!1),c(null)}sessionStorage.removeItem("pl_running"),sessionStorage.removeItem("pl_prd"),sessionStorage.removeItem("pl_tab")},[]),_e=n.useCallback(x=>{t(`/project/${x.id}`)},[t]),$e=n.useCallback(x=>{B(x)},[]),ze=n.useCallback(async()=>{try{await j.pauseSession(),l(!0)}catch{}},[]),Oe=n.useCallback(async()=>{try{await j.resumeSession(),l(!1)}catch{}},[]),He=d&&d.replace(/^#+\s*/gm,"").split(`
28
- `).find(x=>x.trim().length>0)||null;return e.jsxs("div",{className:"min-h-screen bg-[#FAF9F6] relative",children:[e.jsx("div",{className:"pattern-nodes"}),e.jsx("div",{className:"max-w-[1920px] mx-auto px-6 py-6 relative z-10",children:a?e.jsxs(e.Fragment,{children:[e.jsx(F,{name:"ControlBar",children:e.jsx(jt,{status:P,prdSummary:He,onStop:Ie,onPause:ze,onResume:Oe,isPaused:o})}),e.jsx("div",{className:"mt-4",children:e.jsx(F,{name:"StatusOverview",children:e.jsx(vt,{status:P})})}),e.jsxs("div",{className:"mt-4 grid grid-cols-12 gap-6",style:{height:"calc(100vh - 340px)",minHeight:"400px"},children:[e.jsx("div",{className:"col-span-3 flex flex-col gap-6",children:e.jsx(F,{name:"PhaseVisualizer",children:e.jsx(kt,{currentPhase:(P==null?void 0:P.phase)||"idle",iteration:(P==null?void 0:P.iteration)||0})})}),e.jsxs("div",{className:"col-span-5 flex flex-col gap-0 min-h-0",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>k("terminal"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${N==="terminal"?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:"Terminal"}),e.jsx("button",{onClick:()=>k("metrics"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${N==="metrics"?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:"Metrics"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(F,{name:"Terminal",children:N==="terminal"?e.jsx(st,{logs:Te,loading:Re,subscribe:ve}):e.jsx(ue,{visible:!0})})})]}),e.jsxs("div",{className:"col-span-4 flex flex-col gap-6 overflow-y-auto",children:[e.jsx(F,{name:"AgentDashboard",children:e.jsx(St,{agents:Le,loading:Me})}),e.jsx(F,{name:"QualityGates",children:e.jsx(Ft,{checklist:Ae,loading:De})})]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-12 gap-6",children:[e.jsx("div",{className:"col-span-6",children:e.jsx(F,{name:"FileBrowser",children:e.jsx(Rt,{files:Pe,loading:Fe})})}),e.jsx("div",{className:"col-span-6",children:e.jsx(F,{name:"MemoryViewer",children:e.jsx(It,{memory:Se,loading:Ce})})})]})]}):e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{ref:D,className:"text-center mt-12 mb-10",children:[e.jsx("p",{className:"text-sm font-medium text-[#553DE9] mb-2",children:I}),e.jsx("h2",{className:"font-heading text-h1 text-[#36342E]",children:"Describe it. Build it. Ship it."}),e.jsx("p",{className:"text-[#6B6960] mt-3 text-base max-w-xl mx-auto",children:"Type what you want to build. Purple Lab handles the rest -- from code to containers, autonomously."})]}),e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:g,type:"text",value:C,onChange:x=>H(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),oe())},className:"w-full text-xl px-6 py-4 rounded-2xl bg-white border border-[#ECEAE3] shadow-sm focus:outline-none focus:ring-2 focus:ring-[#553DE9]/30 focus:border-[#553DE9]/40 focus:shadow-lg transition-all placeholder:text-transparent",disabled:S,"aria-label":"Describe what you want to build"}),!C&&e.jsx("div",{className:"absolute left-6 top-1/2 -translate-y-1/2 text-xl text-[#6B6960]/50 pointer-events-none select-none","aria-hidden":"true",children:e.jsx("span",{className:Q?"quick-input-placeholder-exit":"quick-input-placeholder",children:U[$]},$)})]}),e.jsx("div",{className:"mt-4 flex items-center justify-center gap-4",children:e.jsx("button",{onClick:oe,disabled:!C.trim()||S,className:`px-8 py-3 rounded-xl text-base font-semibold transition-all ${!C.trim()||S?"bg-[#553DE9]/20 text-[#553DE9]/40 cursor-not-allowed":"bg-[#553DE9] text-white hover:bg-[#4832c7] shadow-lg shadow-[#553DE9]/25 hover:shadow-xl hover:shadow-[#553DE9]/30 active:scale-[0.98]"}`,children:S?"Starting...":"Start Building"})}),s&&e.jsx("div",{className:"mt-3 px-4 py-2.5 rounded-xl bg-[#C45B5B]/10 border border-[#C45B5B]/20 text-[#C45B5B] text-sm font-medium text-center",children:s}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("button",{onClick:()=>q(!_),className:"text-sm text-[#553DE9] hover:text-[#4832c7] font-medium transition-colors",children:_?"Hide advanced options":"Advanced (write full PRD)"})}),_&&e.jsx("div",{className:"mt-4",children:e.jsx(Nt,{onSubmit:Be,running:a,error:s,provider:w,onProviderChange:$e,initialPrd:h})})]}),m&&!a&&e.jsxs("div",{className:"w-full max-w-3xl mt-6 flex flex-col gap-4",children:[e.jsx("button",{onClick:async()=>{try{const x=await j.getSessionsHistory();x.length>0&&t(`/project/${x[0].id}`)}catch{}},className:"w-full px-6 py-4 rounded-card text-base font-bold bg-[#553DE9] text-white hover:bg-[#553DE9]/90 transition-all shadow-lg shadow-[#553DE9]/20",children:"View Project -- Browse Files and Preview"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>p(!v),className:"px-4 py-2 rounded-card text-sm font-semibold border border-[#553DE9]/30 text-[#553DE9] hover:bg-[#553DE9]/5 transition-all",children:v?"Hide Report":"Report"}),e.jsx("button",{onClick:()=>y(!b),className:"px-4 py-2 rounded-card text-sm font-semibold border border-[#ECEAE3] text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0] transition-all",children:b?"Hide Metrics":"Metrics"})]}),e.jsx(_t,{visible:v}),e.jsx(ue,{visible:b})]}),e.jsx("div",{className:"w-full max-w-3xl mt-6",children:le&&le.length===0?e.jsx(us,{type:"no-projects",action:()=>{var f;const x=U[Math.floor(Math.random()*U.length)];H(x),(f=g.current)==null||f.focus()},actionLabel:"Try an example"}):e.jsx(Ot,{onLoadSession:_e})}),e.jsxs("div",{className:"mt-6 text-xs text-[#6B6960] flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${J?"bg-[#1FC5A8]":"bg-[#C45B5B]"}`}),J?"Connected to Purple Lab backend":"Waiting for backend connection..."]}),e.jsx(Gt,{}),e.jsx(Qt,{}),e.jsx(Zt,{}),e.jsx(es,{}),e.jsx("section",{className:"w-full max-w-3xl mx-auto py-16",children:e.jsxs("div",{className:"rounded-2xl bg-gradient-to-br from-[#553DE9]/5 via-[#553DE9]/10 to-[#1FC5A8]/5 border border-[#553DE9]/15 p-10 text-center",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] mb-3",children:"Ready to build something amazing?"}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-6 max-w-md mx-auto",children:"Go from idea to deployed product in minutes, not months. Let AI handle the heavy lifting."}),e.jsxs("div",{className:"flex items-center justify-center gap-3 flex-wrap",children:[e.jsx("button",{onClick:()=>{var x;(x=D.current)==null||x.scrollIntoView({behavior:"smooth"}),setTimeout(()=>{var f;return(f=g.current)==null?void 0:f.focus()},500)},className:"px-8 py-3 rounded-xl text-base font-semibold bg-[#553DE9] text-white hover:bg-[#4832c7] shadow-lg shadow-[#553DE9]/25 hover:shadow-xl hover:shadow-[#553DE9]/30 active:scale-[0.98] transition-all",children:"Start Building"}),e.jsx("button",{onClick:()=>t("/templates"),className:"px-8 py-3 rounded-xl text-base font-semibold border border-[#553DE9]/30 text-[#553DE9] hover:bg-[#553DE9]/5 transition-all",children:"View Templates"})]})]})}),e.jsx(is,{}),e.jsx(ns,{})]})}),!a&&e.jsx(ss,{}),E&&e.jsx(ds,{type:"build-complete",onDismiss:()=>z(!1)})]})}export{Fs as default};
27
+ `)}},[]),Q=async()=>{if(!(!l.trim()||A)){_(!0),S(null),$(!0);try{const g=await j.planSession(l,y);S(g)}catch{S({complexity:"unknown",cost_estimate:"N/A",iterations:0,phases:[],output_text:"Failed to run loki plan. The CLI may not be available.",returncode:1})}finally{_(!1)}}},G=async()=>{if(!(!l.trim()||s||E)){$(!1),z(!0);try{await t(l,y,p.trim()||void 0,I?"quick":void 0)}finally{z(!1)}}};return e.jsxs(e.Fragment,{children:[q&&e.jsx(yt,{plan:H,loading:A,onConfirm:G,onCancel:()=>$(!1)}),e.jsxs("div",{className:"card p-6 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Product Requirements"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>k(!N),className:"text-xs font-medium px-3 py-1.5 rounded-card border border-primary/20 text-primary hover:bg-primary/5 transition-colors",children:c||"Templates"}),N&&e.jsx("div",{className:"absolute right-0 top-full mt-1 w-56 card rounded-card overflow-hidden z-20 shadow-card-hover",children:e.jsxs("div",{className:"py-1 max-h-64 overflow-y-auto terminal-scroll",children:[h&&e.jsx("div",{className:"px-3 py-2 text-xs text-warning border-b border-warning/10",children:"Could not load templates from server. Check that the backend is running."}),!h&&w.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-muted",children:"Loading..."}),w.map(g=>e.jsx("button",{onClick:()=>V(g.filename,g.name),className:"w-full text-left px-3 py-2 text-sm text-ink hover:bg-primary/5 transition-colors",children:g.name},g.filename))]})})]})})]}),e.jsx("textarea",{value:l,onChange:g=>d(g.target.value),placeholder:"Paste your PRD here, or select a template above to get started...",className:"flex-1 min-h-[280px] w-full bg-card rounded-card border border-border-light px-4 py-3 text-sm font-mono text-ink placeholder:text-primary/60 resize-none focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30 transition-all",spellCheck:!1}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"block text-xs text-muted font-medium mb-1 uppercase tracking-wider",children:"Project Directory"}),e.jsx("input",{type:"text",value:p,onChange:g=>b(g.target.value),placeholder:"Leave blank to auto-create, or type a path (e.g. /Users/you/my-project)",className:"w-full bg-card rounded-card border border-border-light px-4 py-2 text-sm font-mono text-ink placeholder:text-primary/60/70 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30 transition-all",spellCheck:!1}),e.jsx("p",{className:"text-xs text-muted-accessible mt-1",children:"Type a path or leave blank to auto-create under ~/purple-lab-projects/"})]}),r&&e.jsx("div",{className:"mt-3 px-3 py-2 rounded-btn bg-danger/10 border border-danger/20 text-danger text-xs font-medium",children:r}),e.jsxs("div",{className:"flex items-center gap-3 mt-4",children:[e.jsxs("button",{onClick:()=>C(!I),title:"Quick Mode: 3 iterations max, faster builds",className:`flex items-center gap-1.5 px-3 py-1.5 rounded-card text-xs font-semibold border transition-all ${I?"bg-primary/10 border-primary/30 text-primary":"border-border-light text-muted hover:text-ink hover:bg-card"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${I?"bg-primary":"bg-muted/40"}`}),"Quick"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted font-mono",children:[l.length.toLocaleString()," chars"]}),e.jsx("button",{onClick:Q,disabled:!l.trim()||s||E||A,className:`px-6 py-2.5 rounded-card text-sm font-semibold transition-all ${!l.trim()||s||E||A?"bg-primary/10 text-muted cursor-not-allowed":"bg-primary text-white hover:bg-primary/90 shadow-button"}`,children:A?"Analyzing...":E?"Starting...":s?"Building...":"Start Build"})]})]})]})}const O=[{key:"reason",label:"Reason",description:"Analyzing task, planning approach"},{key:"act",label:"Act",description:"Implementing changes, writing code"},{key:"reflect",label:"Reflect",description:"Reviewing output, self-critique"},{key:"verify",label:"Verify",description:"Testing, validation, quality gates"}];function wt(t){if(!t)return"reason";const s=t.toLowerCase();return s.includes("reason")||s.includes("plan")?"reason":s.includes("act")||s.includes("implement")||s.includes("code")?"act":s.includes("reflect")||s.includes("review")?"reflect":s.includes("verify")||s.includes("test")||s.includes("check")?"verify":"idle"}function kt({currentPhase:t,iteration:s}){const r=wt(t);return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"RARV Cycle"}),e.jsxs("span",{className:"font-mono text-xs text-muted",children:["Iteration ",s]})]}),e.jsx("div",{className:"flex items-center justify-center mb-5",children:e.jsxs("svg",{viewBox:"0 0 120 120",className:"w-28 h-28",children:[O.map((a,i)=>{const o=a.key===r,l=r!=="idle"&&O.findIndex(u=>u.key===r)>i,d=(i*90-90)*(Math.PI/180),c=60+40*Math.cos(d),m=60+40*Math.sin(d);return e.jsxs("g",{children:[i<O.length-1&&e.jsx("line",{x1:c,y1:m,x2:60+40*Math.cos(((i+1)*90-90)*(Math.PI/180)),y2:60+40*Math.sin(((i+1)*90-90)*(Math.PI/180)),stroke:l?"#553DE9":"#ECEAE3",strokeWidth:l?2:1,strokeDasharray:l?"none":"4 3"}),i===O.length-1&&e.jsx("line",{x1:c,y1:m,x2:60+40*Math.cos(-90*(Math.PI/180)),y2:60+40*Math.sin(-90*(Math.PI/180)),stroke:"#ECEAE3",strokeWidth:1,strokeDasharray:"4 3"}),e.jsx("circle",{cx:c,cy:m,r:o?14:10,fill:o||l?"#553DE9":"#E8E4FD",stroke:o?"#4432c4":l?"#553DE9":"#ECEAE3",strokeWidth:o?3:1.5,className:o?"phase-active":""}),e.jsx("text",{x:c,y:m+(i===0?-20:i===2?24:0),textAnchor:"middle",className:"text-[9px] font-semibold fill-ink",dx:i===1?22:i===3?-22:0,children:a.label[0]})]},a.key)}),e.jsx("text",{x:"60",y:"64",textAnchor:"middle",className:"text-lg font-bold font-mono fill-primary",children:s})]})}),e.jsx("div",{className:"space-y-2",children:O.map(a=>{const i=a.key===r;return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-card transition-all duration-200 ${i?"bg-primary/8 border border-primary/20":"opacity-50"}`,children:[e.jsx("div",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${i?"bg-primary phase-active":"bg-border"}`}),e.jsxs("div",{children:[e.jsx("span",{className:`text-sm font-semibold ${i?"text-primary":"text-muted"}`,children:a.label}),i&&e.jsx("p",{className:"text-xs text-muted mt-0.5",children:a.description})]})]},a.key)})})]})}const ee={architect:"bg-primary/10 text-primary border-primary/20",developer:"bg-primary/10 text-primary border-primary/20",tester:"bg-success/10 text-success border-success/20",reviewer:"bg-warning/10 text-warning border-warning/20",planner:"bg-primary/60/20 text-ink border-primary/60/30",default:"bg-border/30 text-muted border-border/50"};function Et(t){if(!t)return ee.default;const s=t.toLowerCase();for(const[r,a]of Object.entries(ee))if(s.includes(r))return a;return ee.default}function St({agents:t,loading:s}){const r=(t==null?void 0:t.filter(i=>i.alive))||[],a=(t==null?void 0:t.filter(i=>!i.alive))||[];return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Agents"}),e.jsxs("span",{className:"font-mono text-xs text-muted",children:[r.length," active"]})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading agents..."}),!s&&(t==null?void 0:t.length)===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No agents running"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Start a build to spawn agents"})]}),r.length>0&&e.jsx("div",{className:"space-y-2 mb-4",children:r.map(i=>e.jsx(de,{agent:i},i.id))}),a.length>0&&e.jsxs("details",{className:"mt-3",children:[e.jsxs("summary",{className:"text-xs text-muted cursor-pointer hover:text-ink transition-colors",children:[a.length," completed"]}),e.jsx("div",{className:"space-y-1.5 mt-2",children:a.slice(0,10).map(i=>e.jsx(de,{agent:i,compact:!0},i.id))})]})]})}function de({agent:t,compact:s}){const r=Et(t.type||t.name||"");return s?e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded-btn bg-hover text-xs",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted/30"}),e.jsx("span",{className:"font-medium text-muted truncate",children:t.name||t.id}),e.jsx("span",{className:"text-primary/60 ml-auto",children:t.type})]}):e.jsxs("div",{className:`flex items-start gap-3 px-3 py-2.5 rounded-card border ${r}`,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:e.jsx("div",{className:`w-2.5 h-2.5 rounded-full ${t.alive?"bg-success phase-active":"bg-muted/30"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold truncate",children:t.name||t.id}),t.type&&e.jsx("span",{className:"text-xs font-mono font-medium opacity-70",children:t.type})]}),t.task&&e.jsx("p",{className:"text-xs opacity-70 mt-0.5 truncate",children:t.task}),t.status&&t.status!=="unknown"&&e.jsx("span",{className:"inline-block text-xs font-mono mt-1 opacity-60",children:t.status})]}),t.pid&&e.jsxs("span",{className:"text-xs font-mono text-muted-accessible flex-shrink-0",children:["PID ",t.pid]})]})}function Ct({text:t,position:s="top",size:r=14}){const[a,i]=n.useState(!1),o=n.useRef(null);n.useEffect(()=>{if(!a)return;const c=m=>{o.current&&!o.current.contains(m.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[a]);const l={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},d={top:"top-full left-1/2 -translate-x-1/2 border-t-[#1A1A1E] dark:border-t-card border-l-transparent border-r-transparent border-b-transparent border-4",bottom:"bottom-full left-1/2 -translate-x-1/2 border-b-[#1A1A1E] dark:border-b-card border-l-transparent border-r-transparent border-t-transparent border-4",left:"left-full top-1/2 -translate-y-1/2 border-l-[#1A1A1E] dark:border-l-card border-t-transparent border-b-transparent border-r-transparent border-4",right:"right-full top-1/2 -translate-y-1/2 border-r-[#1A1A1E] dark:border-r-card border-t-transparent border-b-transparent border-l-transparent border-4"};return e.jsxs("div",{className:"relative inline-flex items-center",ref:o,children:[e.jsx("button",{onClick:()=>i(!a),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),className:"text-muted/50 hover:text-primary transition-colors p-0.5 rounded-full","aria-label":"Help",type:"button",children:e.jsx(Ue,{size:r})}),a&&e.jsx("div",{className:`absolute z-50 ${l[s]}`,role:"tooltip",children:e.jsxs("div",{className:"relative bg-[#1A1A1E] text-white px-3 py-2 rounded-lg shadow-lg max-w-[240px]",children:[e.jsx("p",{className:"text-[11px] leading-relaxed",children:t}),e.jsx("span",{className:`absolute ${d[s]}`})]})})]})}const At={qualityGates:"Automated checks ensuring your code meets quality standards. Includes static analysis, test coverage, and security scanning."},Dt={pass:{badge:"bg-success/10 text-success border-success/20",dot:"bg-success",label:"Pass"},fail:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Fail"},skip:{badge:"bg-muted/10 text-muted border-muted/20",dot:"bg-muted/40",label:"Skip"},pending:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Pending"}};function Pt({item:t}){const[s,r]=n.useState(!1),a=Dt[t.status];return e.jsxs("div",{className:`border rounded-card overflow-hidden ${a.badge}`,children:[e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-3 py-2.5 text-left",onClick:()=>t.details&&r(!s),children:[e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.dot}`}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:t.label}),e.jsx("span",{className:"text-xs font-mono font-semibold uppercase tracking-wider flex-shrink-0",children:a.label}),t.details&&e.jsx("span",{className:"text-xs text-muted/60 flex-shrink-0",children:s?"v":">"})]}),s&&t.details&&e.jsx("div",{className:"px-3 pb-2.5 pt-0",children:e.jsx("p",{className:"text-xs font-mono opacity-70 leading-relaxed",children:t.details})})]})}function Ft({checklist:t,loading:s}){const r=t&&t.total>0?t.passed/t.total*100:0;return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Quality Gates"}),e.jsx(Ct,{text:At.qualityGates,position:"right",size:13})]}),t&&e.jsxs("span",{className:"font-mono text-xs text-muted",children:[t.passed,"/",t.total," passed"]})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading gates..."}),!s&&!t&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No quality gate data"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Gates run during verification phase"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-3 text-xs",children:[e.jsxs("span",{className:"text-success font-medium",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-danger font-medium",children:[t.failed," failed"]}),t.skipped>0&&e.jsxs("span",{className:"text-muted",children:[t.skipped," skipped"]}),t.pending>0&&e.jsxs("span",{className:"text-warning",children:[t.pending," pending"]})]}),e.jsx("div",{className:"w-full h-2 bg-charcoal/10 rounded-full overflow-hidden mb-4",children:e.jsx("div",{className:"h-full bg-success rounded-full transition-all duration-500",style:{width:`${r}%`}})}),e.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto terminal-scroll",children:t.items.map(a=>e.jsx(Pt,{item:a},a.id))})]})]})}const Lt={".py":"bg-success",".ts":"bg-primary",".tsx":"bg-primary",".md":"bg-warning",".sh":"bg-primary"};function Tt(t){const s=t.substring(t.lastIndexOf("."));return Lt[s]||"bg-muted"}function Mt(t){return t==null?"":t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/(1024*1024)).toFixed(1)}MB`}const te=100;function ge({node:t,depth:s,onSelectFile:r,selectedPath:a}){const[i,o]=n.useState(!1),[l,d]=n.useState(te),c=t.type==="directory",m=t.path===a,u=c&&i?t.children??[]:[],v=u.length>l;return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`w-full flex items-center gap-2 px-2 py-1 rounded-btn text-left text-sm transition-colors hover:bg-hover ${m?"bg-primary/10 text-primary":"text-ink"}`,style:{paddingLeft:`${s*16+8}px`},onClick:()=>{c?(o(!i),i&&d(te)):r(t.path)},children:[c?e.jsx("span",{className:"font-mono text-xs text-muted w-3 flex-shrink-0",children:i?"v":">"}):e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Tt(t.name)}`}),e.jsx("span",{className:`truncate ${c?"font-medium":"font-mono text-xs"}`,children:t.name}),!c&&t.size!==void 0&&e.jsx("span",{className:"ml-auto text-xs font-mono text-muted-accessible flex-shrink-0",children:Mt(t.size)})]}),u.length>0&&e.jsxs("div",{children:[u.slice(0,l).map(p=>e.jsx(ge,{node:p,depth:s+1,onSelectFile:r,selectedPath:a},p.path)),v&&e.jsxs("button",{type:"button",className:"w-full text-left text-xs text-primary hover:text-primary/80 py-1 transition-colors",style:{paddingLeft:`${(s+1)*16+8}px`},onClick:()=>d(p=>p+te),children:["Show more (",u.length-l," remaining)"]})]})]})}function Rt({files:t,loading:s}){const[r,a]=n.useState(null),[i,o]=n.useState(null),[l,d]=n.useState(!1),[c,m]=n.useState(null),u=n.useCallback(async p=>{o(null),a(p),d(!0),m(null);try{const b=await j.getFileContent(p);o(b.content)}catch(b){const y=b instanceof Error?b.message:"Unknown error",N=b instanceof TypeError||y==="Request timeout",k=y.includes("404")||y.includes("not found")||y.includes("Not found");m(N?"Network error - server may be unreachable":k?"File not found - it may have been deleted or renamed":y),o(null)}finally{d(!1)}},[]),v=n.useCallback(p=>{u(p)},[u]);return e.jsxs("div",{className:"card p-6 flex flex-col",style:{minHeight:"300px"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"File Browser"}),e.jsx("span",{className:"font-mono text-xs text-muted",children:".loki/"})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading files..."}),!s&&(!t||t.length===0)&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No project files found"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Start a session to generate .loki/ state"})]}),t&&t.length>0&&e.jsxs("div",{className:"flex gap-4 flex-1 min-h-0",children:[e.jsx("div",{className:"w-1/2 overflow-y-auto terminal-scroll pr-2",children:t.map(p=>e.jsx(ge,{node:p,depth:0,onSelectFile:v,selectedPath:r},p.path))}),e.jsxs("div",{className:"w-1/2 bg-charcoal/5 rounded-card p-3 overflow-hidden flex flex-col",children:[!r&&e.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-xs",children:"Select a file to preview"}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-mono text-primary mb-2 truncate",children:r}),e.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:l?e.jsx("div",{className:"text-muted text-xs",children:"Loading..."}):c?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-6",children:[e.jsx("p",{className:"text-danger text-xs font-medium",children:"Failed to load file"}),e.jsx("p",{className:"text-muted-accessible text-xs text-center max-w-[200px] break-words",children:c}),e.jsx("button",{type:"button",onClick:()=>r&&u(r),className:"mt-1 px-3 py-1 text-xs font-semibold rounded-btn border border-primary/20 text-primary hover:bg-primary/5 transition-colors",children:"Retry"})]}):e.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap break-words leading-relaxed",children:i})})]})]})]})]})}const xe=5e5;function me(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Bt(t){if(!t)return"Never";try{const s=new Date(t),a=new Date().getTime()-s.getTime(),i=Math.floor(a/(1e3*60*60));return i<1?"Just now":i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}catch{return t}}function It({memory:t,loading:s}){const r=t?[{label:"Episodic",count:t.episodic_count,color:"text-primary",bg:"bg-primary/10",border:"border-primary/20"},{label:"Semantic",count:t.semantic_count,color:"text-success",bg:"bg-success/10",border:"border-success/20"},{label:"Skills",count:t.skill_count,color:"text-warning",bg:"bg-warning/10",border:"border-warning/20"}]:[],a=t?Math.min(t.total_tokens/xe*100,100):0;return e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Memory System"}),t&&e.jsx("span",{className:"font-mono text-xs text-muted",children:Bt(t.last_consolidation)})]}),s&&!t&&e.jsx("div",{className:"text-center py-8 text-muted text-sm",children:"Loading memory..."}),!s&&!t&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-muted text-sm",children:"No memory data available"}),e.jsx("p",{className:"text-primary/60 text-xs mt-1",children:"Memory populates during autonomous runs"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:r.map(i=>e.jsxs("div",{className:`${i.bg} border ${i.border} rounded-card p-3 text-center`,children:[e.jsx("div",{className:`text-2xl font-bold font-mono ${i.color}`,children:i.count}),e.jsx("div",{className:"text-xs text-muted-accessible font-medium mt-1 uppercase tracking-wider",children:i.label})]},i.label))}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs text-muted font-medium",children:"Token Usage"}),e.jsxs("span",{className:"text-xs font-mono text-ink",children:[me(t.total_tokens)," / ",me(xe)]})]}),e.jsx("div",{className:"w-full h-2 bg-charcoal/10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${a>80?"bg-danger":a>50?"bg-warning":"bg-info"}`,style:{width:`${a}%`}})})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted",children:"Last Consolidation"}),e.jsx("span",{className:"font-mono text-ink",children:t.last_consolidation?new Date(t.last_consolidation).toLocaleString():"Never"})]})]})]})}function _t({visible:t}){const[s,r]=n.useState("markdown"),[a,i]=n.useState(null),[o,l]=n.useState(null),[d,c]=n.useState(!1),[m,u]=n.useState(!1),[v,p]=n.useState(null),[b,y]=n.useState(!1);if(!t)return null;const N=async()=>{c(!0),p(null),i(null),l(null);try{const h=await j.generateReport(s);i(h)}catch(h){p(h instanceof Error?h.message:"Failed to generate report")}finally{c(!1)}},k=async()=>{u(!0),p(null);try{const h=await j.shareSession();l(h)}catch(h){p(h instanceof Error?h.message:"Failed to share session")}finally{u(!1)}},w=async h=>{try{await navigator.clipboard.writeText(h),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},B=()=>{if(!a)return;const h=new Blob([a.content],{type:s==="html"?"text/html":"text/markdown"}),L=URL.createObjectURL(h),E=document.createElement("a");E.href=L,E.download=`loki-report.${s==="html"?"html":"md"}`,E.click(),URL.revokeObjectURL(L)};return e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Session Report"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 card rounded-card p-1",children:["markdown","html"].map(h=>e.jsx("button",{onClick:()=>r(h),className:`px-3 py-1 text-xs font-semibold rounded-btn transition-all ${s===h?"bg-primary text-white shadow-sm":"text-muted hover:text-ink hover:bg-hover"}`,children:h.toUpperCase()},h))}),e.jsx("button",{onClick:N,disabled:d,className:"px-4 py-1.5 rounded-card text-xs font-semibold bg-primary text-white hover:bg-primary/90 disabled:opacity-50 transition-all",children:d?"Generating...":"Generate Report"})]})]}),v&&e.jsx("div",{className:"mb-3 px-3 py-2 rounded-btn bg-danger/10 border border-danger/20 text-danger text-xs",children:v}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-xs text-muted",children:["Report generated (",a.format,")"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>w(a.content),className:"px-3 py-1 text-xs font-medium text-muted hover:text-ink border border-border-light rounded-btn hover:bg-hover transition-all",children:b?"Copied":"Copy"}),e.jsx("button",{onClick:B,className:"px-3 py-1 text-xs font-medium text-muted hover:text-ink border border-border-light rounded-btn hover:bg-hover transition-all",children:"Download"}),e.jsx("button",{onClick:k,disabled:m,className:"px-3 py-1 text-xs font-medium bg-primary/10 text-primary border border-primary/20 rounded-btn hover:bg-primary/20 disabled:opacity-50 transition-all",children:m?"Sharing...":"Share as Gist"})]}),o&&e.jsxs("div",{className:"mb-2 flex items-center gap-2 px-3 py-2 rounded-btn bg-success/10 border border-success/20",children:[e.jsx("span",{className:"text-xs text-success font-medium",children:"Shared:"}),o.url?e.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary underline flex-1 truncate",children:o.url}):e.jsx("span",{className:"text-xs text-muted flex-1",children:"No URL returned"}),o.url&&e.jsx("button",{onClick:()=>w(o.url),className:"text-xs text-muted hover:text-ink",children:"Copy URL"})]}),e.jsx("pre",{className:"text-[11px] font-mono text-ink bg-black/5 rounded-card p-3 overflow-auto max-h-64 whitespace-pre-wrap terminal-scroll",children:a.content||"(empty report)"})]})]})}function ue({visible:t}){const s=n.useCallback(()=>j.getMetrics(),[]),{data:r,loading:a}=R(s,15e3,t);return t?e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Session Metrics"}),a&&e.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"})]}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Iterations"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:r.iterations??0})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Gate Pass Rate"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:typeof r.quality_gate_pass_rate=="number"?`${r.quality_gate_pass_rate.toFixed(0)}%`:"N/A"})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Tokens Used"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:(r.tokens_used??0).toLocaleString()})]}),e.jsxs("div",{className:"card rounded-card p-3",children:[e.jsx("div",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-1",children:"Time Elapsed"}),e.jsx("div",{className:"text-xl font-bold text-ink",children:r.time_elapsed||"N/A"})]})]}):e.jsx("div",{className:"text-sm text-muted py-4 text-center",children:a?"Loading metrics...":"No metrics available"})]}):null}function $t(t){switch(t){case"completed":case"complete":case"done":return"completed";case"in_progress":return"running";case"started":return"started";case"error":case"failed":return"failed";default:return"empty"}}const zt={completed:"Completed",complete:"Completed",done:"Completed",in_progress:"In Progress",started:"Started",error:"Failed",failed:"Failed",empty:"Empty"};function Ot({onLoadSession:t}){const s=n.useCallback(()=>j.getSessionsHistory(),[]),{data:r,loading:a}=R(s,6e4,!0);return a&&!r?e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider mb-3",children:"Past Builds"}),e.jsx("div",{className:"text-sm text-muted",children:"Loading..."})]}):!r||r.length===0?null:e.jsxs("div",{className:"card p-4 rounded-card",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider mb-3",children:"Past Builds"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto terminal-scroll",children:r.map(i=>{const o=i.file_count;return e.jsxs("button",{onClick:()=>t==null?void 0:t(i),className:"text-left px-4 py-3 rounded-card card hover:bg-hover transition-all group cursor-pointer",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-mono text-muted-accessible",children:i.date}),e.jsxs("div",{className:"flex items-center gap-2",children:[o!==void 0&&o>0&&e.jsxs("span",{className:"text-xs font-mono text-muted-accessible",children:[o," files"]}),e.jsx(rt,{status:$t(i.status),children:zt[i.status]||i.status})]})]}),e.jsx("div",{className:"text-xs text-ink truncate group-hover:text-primary transition-colors",children:i.prd_snippet||i.id}),e.jsx("div",{className:"text-xs font-mono text-muted-accessible mt-0.5 truncate",children:i.path})]},i.id)})})]})}function Ht({end:t,suffix:s="",duration:r=1500}){const[a,i]=n.useState(0),o=n.useRef(null),l=n.useRef(!1);return n.useEffect(()=>{const d=new IntersectionObserver(([c])=>{if(c.isIntersecting&&!l.current){l.current=!0;const m=performance.now(),u=v=>{const p=v-m,b=Math.min(p/r,1),y=1-Math.pow(1-b,3);i(Math.floor(y*t)),b<1&&requestAnimationFrame(u)};requestAnimationFrame(u)}},{threshold:.3});return o.current&&d.observe(o.current),()=>d.disconnect()},[t,r]),e.jsxs("span",{ref:o,className:"tabular-nums",children:[a,s]})}const qt=[{icon:at,value:21,suffix:"+",label:"Templates"},{icon:nt,value:5,suffix:"",label:"AI Providers"},{icon:be,value:100,suffix:"%",label:"Open Source"}];function Gt(){return e.jsxs("section",{className:"w-full max-w-3xl mx-auto mt-16 mb-4",children:[e.jsx("p",{className:"text-center text-sm text-[#6B6960] mb-8 tracking-wide uppercase font-medium",children:"Trusted by developers building the future"}),e.jsx("div",{className:"flex items-center justify-center gap-12 sm:gap-16",children:qt.map(t=>{const s=t.icon;return e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(s,{size:20,className:"text-[#553DE9]",strokeWidth:1.5}),e.jsx("span",{className:"text-2xl font-bold text-[#36342E]",children:e.jsx(Ht,{end:t.value,suffix:t.suffix})}),e.jsx("span",{className:"text-xs text-[#6B6960] font-medium",children:t.label})]},t.label)})}),e.jsx("div",{className:"mt-12 border-t border-[#ECEAE3]"})]})}function se({icon:t,number:s,title:r,description:a,mockup:i,delay:o}){const l=n.useRef(null),[d,c]=n.useState(!1);return n.useEffect(()=>{const m=new IntersectionObserver(([u])=>{u.isIntersecting&&(setTimeout(()=>c(!0),o),m.disconnect())},{threshold:.2});return l.current&&m.observe(l.current),()=>m.disconnect()},[o]),e.jsxs("div",{ref:l,className:`flex flex-col items-center text-center max-w-xs transition-all duration-700 ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-6"}`,children:[e.jsxs("div",{className:"relative mb-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#553DE9]/10 flex items-center justify-center",children:e.jsx(t,{size:24,className:"text-[#553DE9]",strokeWidth:1.5})}),e.jsx("span",{className:"absolute -top-2 -right-2 w-6 h-6 rounded-full bg-[#553DE9] text-white text-xs font-bold flex items-center justify-center",children:s})]}),e.jsx("h3",{className:"text-lg font-bold text-[#36342E] mb-1.5",children:r}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-4 leading-relaxed",children:a}),e.jsx("div",{className:"w-full rounded-xl border border-[#ECEAE3] bg-white p-3 shadow-sm",children:i})]})}function Wt(){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 px-3 py-2 rounded-lg bg-[#FAF9F6] border border-[#ECEAE3] text-left",children:e.jsx("span",{className:"text-xs text-[#36342E]",children:"Build a SaaS dashboard with analytics"})}),e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#553DE9] flex items-center justify-center flex-shrink-0",children:e.jsx(re,{size:12,className:"text-white"})})]})}function Ut(){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-[#6B6960]",children:[e.jsx("span",{children:"Phase: Implementation"}),e.jsx("span",{children:"68%"})]}),e.jsx("div",{className:"w-full h-2 rounded-full bg-[#ECEAE3] overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-[#553DE9] to-[#1FC5A8]",style:{width:"68%"}})}),e.jsx("div",{className:"flex gap-1",children:["Planning","Scaffolding","Implementation","Testing","Deploy"].map((t,s)=>e.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded ${s<=2?"bg-[#553DE9]/10 text-[#553DE9] font-medium":"bg-[#ECEAE3]/60 text-[#6B6960]"}`,children:t},t))})]})}function Vt(){return e.jsxs("div",{className:"space-y-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 rounded-full bg-[#1FC5A8]/20 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none",children:e.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"#1FC5A8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("span",{className:"text-xs font-semibold text-[#1FC5A8]",children:"Deployed successfully"})]}),e.jsx("div",{className:"px-3 py-1.5 rounded-lg bg-[#FAF9F6] border border-[#ECEAE3]",children:e.jsx("span",{className:"text-[10px] font-mono text-[#553DE9]",children:"https://my-app.vercel.app"})})]})}function Qt(){return e.jsxs("section",{className:"w-full max-w-5xl mx-auto py-16",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] text-center mb-3",children:"How It Works"}),e.jsx("p",{className:"text-sm text-[#6B6960] text-center mb-12 max-w-lg mx-auto",children:"Three steps from idea to production. No manual coding required."}),e.jsxs("div",{className:"relative flex flex-col md:flex-row items-start justify-center gap-10 md:gap-8",children:[e.jsx("div",{className:"hidden md:block absolute top-7 left-1/2 -translate-x-1/2 w-[60%] h-px border-t-2 border-dashed border-[#ECEAE3] z-0"}),e.jsx(se,{icon:fe,number:1,title:"Describe Your Idea",description:"Type a one-line description. Loki handles the rest.",mockup:e.jsx(Wt,{}),delay:0}),e.jsx(se,{icon:it,number:2,title:"Watch It Build",description:"AI writes code, runs tests, and ensures quality.",mockup:e.jsx(Ut,{}),delay:150}),e.jsx(se,{icon:re,number:3,title:"Ship It",description:"Deploy to Vercel, Netlify, or GitHub in one click.",mockup:e.jsx(Vt,{}),delay:300})]})]})}const Yt=[{name:"SaaS Dashboard",description:"Full-stack analytics dashboard with auth, billing, and user management.",tech:["React","Node.js","PostgreSQL"],gradient:"from-violet-500/20 via-purple-500/10 to-indigo-500/20"},{name:"REST API",description:"Production-ready API with authentication, rate limiting, and docs.",tech:["Python","FastAPI","Redis"],gradient:"from-emerald-500/20 via-teal-500/10 to-cyan-500/20"},{name:"E-Commerce Store",description:"Online store with Stripe payments, cart, and inventory management.",tech:["React","Node.js","MongoDB"],gradient:"from-amber-500/20 via-orange-500/10 to-yellow-500/20"},{name:"Discord Bot",description:"Feature-rich bot with slash commands, moderation, and webhooks.",tech:["TypeScript","Discord","SQLite"],gradient:"from-blue-500/20 via-sky-500/10 to-cyan-500/20"},{name:"CLI Tool",description:"Interactive command-line application with argument parsing and config.",tech:["TypeScript","CLI","Node.js"],gradient:"from-rose-500/20 via-pink-500/10 to-fuchsia-500/20"},{name:"Landing Page",description:"Responsive marketing site with pricing, testimonials, and CTAs.",tech:["React","Tailwind","Vite"],gradient:"from-slate-500/20 via-gray-500/10 to-zinc-500/20"}],Kt={React:"bg-sky-500/10 text-sky-600","Node.js":"bg-green-500/10 text-green-600",Python:"bg-yellow-500/10 text-yellow-700",TypeScript:"bg-blue-500/10 text-blue-600",PostgreSQL:"bg-indigo-500/10 text-indigo-600",MongoDB:"bg-green-600/10 text-green-700",Redis:"bg-red-500/10 text-red-600",FastAPI:"bg-teal-500/10 text-teal-600",SQLite:"bg-blue-400/10 text-blue-500",Tailwind:"bg-cyan-400/10 text-cyan-600",Discord:"bg-indigo-400/10 text-indigo-500",CLI:"bg-amber-500/10 text-amber-600",Vite:"bg-purple-400/10 text-purple-500"};function Zt(){const t=ae(),s=n.useRef(null),[r,a]=n.useState(!1),[i,o]=n.useState(!0),l=()=>{const c=s.current;c&&(a(c.scrollLeft>8),o(c.scrollLeft<c.scrollWidth-c.clientWidth-8))};n.useEffect(()=>{const c=s.current;if(c)return l(),c.addEventListener("scroll",l,{passive:!0}),window.addEventListener("resize",l),()=>{c.removeEventListener("scroll",l),window.removeEventListener("resize",l)}},[]);const d=c=>{const m=s.current;if(!m)return;const u=320;m.scrollBy({left:c==="left"?-u:u,behavior:"smooth"})};return e.jsxs("section",{className:"w-full max-w-5xl mx-auto py-16",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E]",children:"Start from a Template"}),e.jsx("p",{className:"text-sm text-[#6B6960] mt-1",children:"Production-ready starting points for common use cases."})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d("left"),disabled:!r,className:`w-8 h-8 rounded-lg border flex items-center justify-center transition-all ${r?"border-[#ECEAE3] text-[#36342E] hover:bg-[#F8F4F0]":"border-[#ECEAE3]/50 text-[#6B6960]/30 cursor-not-allowed"}`,"aria-label":"Scroll left",children:e.jsx(lt,{size:16})}),e.jsx("button",{onClick:()=>d("right"),disabled:!i,className:`w-8 h-8 rounded-lg border flex items-center justify-center transition-all ${i?"border-[#ECEAE3] text-[#36342E] hover:bg-[#F8F4F0]":"border-[#ECEAE3]/50 text-[#6B6960]/30 cursor-not-allowed"}`,"aria-label":"Scroll right",children:e.jsx(Ve,{size:16})})]})]}),e.jsxs("div",{ref:s,className:"flex gap-4 overflow-x-auto pb-4 snap-x snap-mandatory scrollbar-hide",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[Yt.map(c=>e.jsxs("div",{className:"flex-shrink-0 w-64 rounded-xl border border-[#ECEAE3] bg-white overflow-hidden snap-start hover:shadow-lg hover:border-[#553DE9]/30 transition-all cursor-pointer group",onClick:()=>t("/templates"),children:[e.jsx("div",{className:`h-20 bg-gradient-to-br ${c.gradient} flex items-end p-3`,children:e.jsx("h3",{className:"text-sm font-bold text-[#36342E] group-hover:text-[#553DE9] transition-colors",children:c.name})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-[#6B6960] mb-3 leading-relaxed line-clamp-2",children:c.description}),e.jsx("div",{className:"flex flex-wrap gap-1",children:c.tech.map(m=>e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Kt[m]||"bg-gray-100 text-gray-600"}`,children:m},m))})]})]},c.name)),e.jsxs("div",{className:"flex-shrink-0 w-48 rounded-xl border border-dashed border-[#ECEAE3] bg-[#FAF9F6] flex flex-col items-center justify-center gap-2 snap-start cursor-pointer hover:border-[#553DE9]/40 hover:bg-[#553DE9]/5 transition-all group",onClick:()=>t("/templates"),children:[e.jsx(Qe,{size:20,className:"text-[#6B6960] group-hover:text-[#553DE9] transition-colors"}),e.jsx("span",{className:"text-sm font-semibold text-[#6B6960] group-hover:text-[#553DE9] transition-colors",children:"View All Templates"})]})]})]})}function Jt({icon:t,title:s,description:r}){return e.jsxs("div",{className:"rounded-xl border border-[#ECEAE3] bg-white p-5 hover:border-[#553DE9]/40 hover:shadow-lg transition-all group",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#553DE9]/10 flex items-center justify-center mb-3 group-hover:bg-[#553DE9]/15 transition-colors",children:e.jsx(t,{size:20,className:"text-[#553DE9]",strokeWidth:1.5})}),e.jsx("h3",{className:"text-sm font-bold text-[#36342E] mb-1.5",children:s}),e.jsx("p",{className:"text-xs text-[#6B6960] leading-relaxed",children:r})]})}const Xt=[{icon:ot,title:"Multi-AI",description:"Use Claude, GPT, Gemini. Pick the best for each task."},{icon:Ye,title:"Quality First",description:"10 quality gates. 3 blind reviewers. Zero sycophancy."},{icon:pt,title:"Self-Hosted",description:"Your code stays on your machine. Full privacy."},{icon:be,title:"Open Source",description:"MIT-licensed. Fork it, extend it, own it."}];function es(){return e.jsxs("section",{className:"w-full max-w-4xl mx-auto py-16",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] text-center mb-3",children:"Why developers choose Loki Mode"}),e.jsx("p",{className:"text-sm text-[#6B6960] text-center mb-10 max-w-lg mx-auto",children:"Built by developers, for developers. Every decision optimized for shipping faster."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:Xt.map(t=>e.jsx(Jt,{...t},t.title))})]})}const ts=[{title:"Product",links:[{label:"Features",to:"/"},{label:"Templates",to:"/templates"},{label:"Pricing",href:"https://www.autonomi.dev/#pricing"},{label:"Docs",href:"https://github.com/asklokesh/loki-mode/wiki"}]},{title:"Developers",links:[{label:"Quick Start",to:"/"},{label:"API Reference",href:"https://github.com/asklokesh/loki-mode/wiki/API-Reference"},{label:"CLI Docs",href:"https://github.com/asklokesh/loki-mode/wiki/CLI-Reference"},{label:"Changelog",href:"https://github.com/asklokesh/loki-mode/blob/main/CHANGELOG.md"}]},{title:"Company",links:[{label:"About Autonomi",href:"https://www.autonomi.dev/"},{label:"Blog",href:"https://www.autonomi.dev/blog"},{label:"Careers",href:"https://www.autonomi.dev/careers"},{label:"Contact",href:"mailto:hello@autonomi.dev"}]},{title:"Community",links:[{label:"GitHub",href:"https://github.com/asklokesh/loki-mode"},{label:"Discord",href:"https://discord.gg/autonomi"},{label:"Twitter",href:"https://twitter.com/autonomidev"},{label:"Forum",href:"https://github.com/asklokesh/loki-mode/discussions"}]}];function ss(){const t=ae(),s=(r,a)=>{r.to&&(a.preventDefault(),t(r.to))};return e.jsx("footer",{className:"w-full bg-[#F0EDE8] border-t border-[#ECEAE3] mt-8",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-12",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-8 mb-10",children:ts.map(r=>e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-bold text-[#36342E] uppercase tracking-wider mb-4",children:r.title}),e.jsx("ul",{className:"space-y-2.5",children:r.links.map(a=>e.jsx("li",{children:e.jsx("a",{href:a.href||a.to||"#",onClick:i=>s(a,i),className:"text-sm text-[#6B6960] hover:text-[#553DE9] transition-colors",...a.href?{target:"_blank",rel:"noopener noreferrer"}:{},children:a.label})},a.label))})]},r.title))}),e.jsxs("div",{className:"border-t border-[#ECEAE3] pt-6 flex flex-col sm:flex-row items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#6B6960]",children:[e.jsx("span",{children:"Built with care by Autonomi"}),e.jsx("span",{className:"hidden sm:inline text-[#ECEAE3]",children:"|"}),e.jsx("span",{className:"px-2 py-0.5 rounded bg-[#553DE9]/10 text-[#553DE9] font-semibold text-[10px]",children:"v6.73.0"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-[#6B6960]",children:[e.jsx("a",{href:"https://www.autonomi.dev/privacy",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#553DE9] transition-colors",children:"Privacy"}),e.jsx("a",{href:"https://www.autonomi.dev/terms",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#553DE9] transition-colors",children:"Terms"})]})]})]})})}function rs({label:t,value:s,suffix:r=""}){const[a,i]=n.useState(0),o=n.useRef(!1),l=n.useRef(null);return n.useEffect(()=>{if(o.current)return;const d=new IntersectionObserver(([c])=>{if(c.isIntersecting&&!o.current){let m=function(p){const b=p-v,y=Math.min(b/u,1),N=1-Math.pow(1-y,3);i(Math.round(s*N)),y<1&&requestAnimationFrame(m)};o.current=!0;const u=800,v=performance.now();requestAnimationFrame(m)}},{threshold:.3});return l.current&&d.observe(l.current),()=>d.disconnect()},[s]),e.jsxs("div",{ref:l,className:"text-center",children:[e.jsxs("div",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] tabular-nums",children:[a.toLocaleString(),r]}),e.jsx("div",{className:"text-xs text-[#6B6960] dark:text-[#8A8880] mt-1",children:t})]})}const W="asklokesh/loki-mode",as="loki-mode";function ns(){const[t,s]=n.useState([{label:"GitHub Stars",value:0},{label:"Forks",value:0},{label:"Contributors",value:0},{label:"npm Downloads",value:0,suffix:"+"}]);return n.useEffect(()=>{(async()=>{try{const[a,i,o]=await Promise.allSettled([fetch(`https://api.github.com/repos/${W}`),fetch(`https://api.github.com/repos/${W}/contributors?per_page=1&anon=true`,{method:"HEAD"}),fetch(`https://api.npmjs.org/downloads/point/last-month/${as}`)]);let l=0,d=0,c=0,m=0;if(a.status==="fulfilled"&&a.value.ok){const u=await a.value.json();l=u.stargazers_count||0,d=u.forks_count||0}if(i.status==="fulfilled"){const v=(i.value.headers.get("Link")||"").match(/page=(\d+)>; rel="last"/);if(v)c=parseInt(v[1],10);else{const p=await fetch(`https://api.github.com/repos/${W}/contributors?per_page=100&anon=true`);if(p.ok){const b=await p.json();c=Array.isArray(b)?b.length:0}}}o.status==="fulfilled"&&o.value.ok&&(m=(await o.value.json()).downloads||0),s([{label:"GitHub Stars",value:l},{label:"Forks",value:d},{label:"Contributors",value:c},{label:"npm Downloads",value:m,suffix:"+"}])}catch{}})()},[]),e.jsxs("div",{className:"py-8 border-t border-[#ECEAE3] dark:border-[#2A2A30]",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-6",children:[e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-[#36342E] dark:text-[#E8E6E3]",children:e.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",fill:"currentColor"})}),e.jsx("span",{className:"text-sm font-semibold text-[#36342E] dark:text-[#E8E6E3]",children:"Open Source"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-6 max-w-lg mx-auto",children:t.map(r=>e.jsx(rs,{...r},r.label))}),e.jsx("div",{className:"mt-4 text-center",children:e.jsxs("a",{href:`https://github.com/${W}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-[#553DE9] hover:text-[#4832c7] font-medium transition-colors",children:["Star us on GitHub",e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 17L17 7M17 7H7M17 7V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]})}function is(){const[t,s]=n.useState(""),[r,a]=n.useState(!1),[i,o]=n.useState(""),l=d=>{d.preventDefault(),o("");const c=t.trim();if(c){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c)){o("Please enter a valid email address.");return}try{const m=JSON.parse(localStorage.getItem("pl_newsletter_emails")||"[]");m.includes(c)||(m.push(c),localStorage.setItem("pl_newsletter_emails",JSON.stringify(m)))}catch{}a(!0),s("")}};return r?e.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 rounded-xl bg-[#1FC5A8]/10 border border-[#1FC5A8]/20",children:[e.jsx(ct,{size:16,className:"text-[#1FC5A8] flex-shrink-0"}),e.jsx("span",{className:"text-sm text-[#36342E] font-medium",children:"Thanks for subscribing! We will keep you posted."})]}):e.jsxs("div",{className:"py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(dt,{size:14,className:"text-[#6B6960]"}),e.jsx("span",{className:"text-sm text-[#6B6960]",children:"Get updates on new features and tips"})]}),e.jsxs("form",{onSubmit:l,className:"flex gap-2",children:[e.jsx("input",{type:"email",value:t,onChange:d=>s(d.target.value),placeholder:"you@example.com",className:"flex-1 px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] bg-white focus:outline-none focus:ring-2 focus:ring-[#553DE9]/30 focus:border-[#553DE9]/40"}),e.jsx("button",{type:"submit",className:"px-4 py-2 text-sm font-semibold rounded-lg bg-[#553DE9] text-white hover:bg-[#4832c7] transition-colors",children:"Subscribe"})]}),i&&e.jsx("p",{className:"mt-1.5 text-xs text-[#C45B5B]",children:i})]})}const ls={"build-complete":{icon:e.jsx(ft,{size:24,className:"text-teal"}),title:"Build complete!",description:"Your code is ready. Time to ship it."},"deploy-success":{icon:e.jsx(re,{size:24,className:"text-primary"}),title:"Your app is live!",description:"Successfully deployed. The world can see your work now."},"first-project":{icon:e.jsx(Ke,{size:24,className:"text-warning"}),title:"First build complete!",description:"Welcome to Purple Lab. This is just the beginning."}},pe=["#553DE9","#1FC5A8","#D63384","#2F71E3","#D4A03C","#E8E4FD"],os=40;function cs({index:t}){const s=pe[t%pe.length],r=Math.random()*100,a=Math.random()*1.5,i=2+Math.random()*1.5,o=4+Math.random()*6,l=t%3===0,d=Math.random()*360;return e.jsx("div",{className:"confetti-piece",style:{position:"absolute",left:`${r}%`,top:"-10px",width:`${o}px`,height:`${o}px`,backgroundColor:s,borderRadius:l?"50%":"1px",opacity:0,transform:`rotate(${d}deg)`,animation:`confetti-fall ${i}s ease-in ${a}s forwards`}})}function ds({type:t,onDismiss:s}){const[r,a]=n.useState(!0),i=ls[t];return n.useEffect(()=>{const o=setTimeout(()=>{a(!1),s==null||s()},3500);return()=>clearTimeout(o)},[s]),r?e.jsxs("div",{className:"fixed inset-0 z-50 pointer-events-none",children:[e.jsx("div",{className:"absolute inset-0 overflow-hidden",children:Array.from({length:os},(o,l)=>e.jsx(cs,{index:l},l))}),e.jsx("div",{className:"absolute top-8 left-1/2 -translate-x-1/2 pointer-events-auto celebration-banner-enter",children:e.jsxs("div",{className:"bg-card border border-border rounded-card shadow-lg px-6 py-4 flex items-center gap-3",children:[i.icon,e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-ink",children:i.title}),e.jsx("p",{className:"text-xs text-muted",children:i.description})]})]})})]}):null}const xs={"no-projects":{icon:e.jsx(tt,{size:32,className:"text-primary/60"}),title:"Your workspace is a blank canvas",description:"What will you create today? Describe your idea and watch it come to life.",defaultActionLabel:"Start a new project"},"no-files":{icon:e.jsx(mt,{size:32,className:"text-teal/60"}),title:"This project is brand new",description:"Let's add some code! Start building and files will appear here as they're created.",defaultActionLabel:"Open editor"},"no-chat":{icon:e.jsx(fe,{size:32,className:"text-primary/60"}),title:"Start a conversation with Loki",description:"Try something like 'Add a contact form to my app' or 'Create a dark mode toggle.'",defaultActionLabel:"Say hello"},"no-team":{icon:e.jsx(Ze,{size:32,className:"text-pink/60"}),title:"Building alone is great, but building together is better",description:"Invite teammates to collaborate on this project in real time.",defaultActionLabel:"Invite a teammate"},"no-notifications":{icon:e.jsx(xt,{size:32,className:"text-teal/60"}),title:"All clear!",description:"No notifications right now. When something needs your attention, it will show up here.",defaultActionLabel:"Dismiss"}};function ms({type:t}){const r={"no-projects":{primary:"#553DE9",secondary:"#1FC5A8"},"no-files":{primary:"#1FC5A8",secondary:"#553DE9"},"no-chat":{primary:"#553DE9",secondary:"#D63384"},"no-team":{primary:"#D63384",secondary:"#553DE9"},"no-notifications":{primary:"#1FC5A8",secondary:"#2F71E3"}}[t];return e.jsxs("svg",{width:"120",height:"80",viewBox:"0 0 120 80",fill:"none",className:"mb-4 opacity-60",children:[e.jsx("circle",{cx:"60",cy:"40",r:"28",stroke:r.primary,strokeWidth:"1.5",strokeDasharray:"4 3"}),e.jsx("circle",{cx:"30",cy:"25",r:"8",fill:r.primary,opacity:"0.1"}),e.jsx("circle",{cx:"90",cy:"55",r:"12",fill:r.secondary,opacity:"0.1"}),e.jsx("circle",{cx:"60",cy:"40",r:"4",fill:r.primary,opacity:"0.3"}),e.jsx("line",{x1:"20",y1:"60",x2:"45",y2:"45",stroke:r.secondary,strokeWidth:"1",opacity:"0.2"}),e.jsx("line",{x1:"75",y1:"35",x2:"100",y2:"20",stroke:r.primary,strokeWidth:"1",opacity:"0.2"}),e.jsx("rect",{x:"50",y:"15",width:"20",height:"3",rx:"1.5",fill:r.secondary,opacity:"0.15"}),e.jsx("rect",{x:"42",y:"62",width:"36",height:"3",rx:"1.5",fill:r.primary,opacity:"0.15"})]})}function us({type:t,action:s,actionLabel:r}){const a=xs[t];return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-6 text-center warm-empty-state-enter",children:[e.jsx(ms,{type:t}),e.jsx("div",{className:"mb-3",children:a.icon}),e.jsx("h3",{className:"text-sm font-semibold text-ink mb-1.5",children:a.title}),e.jsx("p",{className:"text-xs text-muted max-w-[260px] leading-relaxed",children:a.description}),s&&e.jsx("button",{onClick:s,className:"mt-4 px-4 py-2 text-xs font-semibold rounded-btn bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:r||a.defaultActionLabel})]})}const U=["Build a SaaS dashboard with user analytics...","Create a REST API with authentication...","Make a landing page with pricing tiers...","Build a chat app with real-time messaging...","Create an e-commerce store with Stripe..."];function ps(){const t=new Date().getHours();return t>=5&&t<12?"Good morning! What shall we build today?":t>=12&&t<17?"Good afternoon! Ready to create something amazing?":t>=17&&t<22?"Good evening! Let's build something cool.":"Burning the midnight oil? Let's build something cool."}function Ls(){const t=ae(),[s,r]=n.useState(null),[a,i]=n.useState(()=>sessionStorage.getItem("pl_running")==="1"),[o,l]=n.useState(!1),[d,c]=n.useState(()=>sessionStorage.getItem("pl_prd")),[m,u]=n.useState(!1),[v,p]=n.useState(!1),[b,y]=n.useState(!1),[N,k]=n.useState(()=>sessionStorage.getItem("pl_tab")||"terminal"),[w,B]=n.useState(()=>sessionStorage.getItem("pl_provider")||"claude"),[h,L]=n.useState(void 0),[E,z]=n.useState(!1),I=n.useMemo(()=>ps(),[]),[C,H]=n.useState(""),[S,A]=n.useState(!1),[_,q]=n.useState(!1),[$,V]=n.useState(0),[Q,G]=n.useState(!1),g=n.useRef(null),D=n.useRef(null);n.useEffect(()=>{const x=setInterval(()=>{G(!0),setTimeout(()=>{V(f=>(f+1)%U.length),G(!1)},300)},3e3);return()=>clearInterval(x)},[]),n.useEffect(()=>{const x=sessionStorage.getItem("pl_template");x&&(sessionStorage.removeItem("pl_template"),j.getTemplateContent(x).then(({content:f})=>{f&&(L(f),q(!0))}).catch(()=>{}))},[]);const[T,Y]=n.useState(null),[ne,K]=n.useState(null),[ie,Z]=n.useState(null),je=n.useCallback(x=>{if(!x){Y(null),K(null),Z(null);return}Y(x.status),K(x.agents),Z(x.logs),i(x.status.running??!1),l(x.status.paused??!1)},[]),{connected:J,subscribe:ve}=Je(je),ye=n.useCallback(()=>j.getStatus(),[]),{data:M}=R(ye,3e4,!J);n.useEffect(()=>{T===null&&M!==null&&(i(M.running??!1),l(M.paused??!1))},[M,T]),n.useEffect(()=>{sessionStorage.setItem("pl_running",a?"1":"0"),a&&u(!0)},[a]),n.useEffect(()=>{d?sessionStorage.setItem("pl_prd",d):sessionStorage.removeItem("pl_prd")},[d]),n.useEffect(()=>{sessionStorage.setItem("pl_provider",w)},[w]),n.useEffect(()=>{sessionStorage.setItem("pl_tab",N)},[N]);const X=n.useRef(void 0);n.useEffect(()=>{var f;const x=(f=T??M)==null?void 0:f.phase;x==="complete"&&X.current&&X.current!=="complete"&&z(!0),X.current=x},[T,M]);const Ne=n.useCallback(()=>j.getMemorySummary(),[]),we=n.useCallback(()=>j.getChecklist(),[]),ke=n.useCallback(()=>j.getFiles(),[]),Ee=n.useCallback(()=>j.getSessionsHistory(),[]),{data:Se,loading:Ce}=R(Ne,3e4,a),{data:Ae,loading:De}=R(we,3e4,a),{data:Pe,loading:Fe}=R(ke,3e4,a),{data:le}=R(Ee,6e4,!0),P=T??M,Le=ne,Te=ie,Me=ne===null,Re=ie===null,oe=n.useCallback(async()=>{const x=C.trim();if(!(!x||S)){r(null),A(!0),u(!1),p(!1),k("terminal");try{const f=await j.quickStart(x,w);f.started&&f.session_id&&(c(x),i(!0),t(`/project/${f.session_id}`))}catch(f){r(f instanceof Error?f.message:"Failed to start build")}finally{A(!1)}}},[C,S,w,t]),Be=n.useCallback(async(x,f,qe,Ge)=>{r(null),u(!1),p(!1),k("terminal");try{await j.startSession({prd:x,provider:f,projectDir:qe,mode:Ge}),c(x),i(!0)}catch(ce){r(ce instanceof Error?ce.message:"Failed to start session")}},[]),Ie=n.useCallback(async()=>{try{(await j.stopSession()).stopped&&(i(!1),l(!1),c(null),Y(null),K(null),Z(null))}catch{i(!1),l(!1),c(null)}sessionStorage.removeItem("pl_running"),sessionStorage.removeItem("pl_prd"),sessionStorage.removeItem("pl_tab")},[]),_e=n.useCallback(x=>{t(`/project/${x.id}`)},[t]),$e=n.useCallback(x=>{B(x)},[]),ze=n.useCallback(async()=>{try{await j.pauseSession(),l(!0)}catch{}},[]),Oe=n.useCallback(async()=>{try{await j.resumeSession(),l(!1)}catch{}},[]),He=d&&d.replace(/^#+\s*/gm,"").split(`
28
+ `).find(x=>x.trim().length>0)||null;return e.jsxs("div",{className:"min-h-screen bg-[#FAF9F6] relative",children:[e.jsx("div",{className:"pattern-nodes"}),e.jsx("div",{className:"max-w-[1920px] mx-auto px-6 py-6 relative z-10",children:a?e.jsxs(e.Fragment,{children:[e.jsx(F,{name:"ControlBar",children:e.jsx(jt,{status:P,prdSummary:He,onStop:Ie,onPause:ze,onResume:Oe,isPaused:o})}),e.jsx("div",{className:"mt-4",children:e.jsx(F,{name:"StatusOverview",children:e.jsx(vt,{status:P})})}),e.jsxs("div",{className:"mt-4 grid grid-cols-12 gap-6",style:{height:"calc(100vh - 340px)",minHeight:"400px"},children:[e.jsx("div",{className:"col-span-3 flex flex-col gap-6",children:e.jsx(F,{name:"PhaseVisualizer",children:e.jsx(kt,{currentPhase:(P==null?void 0:P.phase)||"idle",iteration:(P==null?void 0:P.iteration)||0})})}),e.jsxs("div",{className:"col-span-5 flex flex-col gap-0 min-h-0",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>k("terminal"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${N==="terminal"?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:"Terminal"}),e.jsx("button",{onClick:()=>k("metrics"),className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${N==="metrics"?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:"Metrics"})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(F,{name:"Terminal",children:N==="terminal"?e.jsx(st,{logs:Te,loading:Re,subscribe:ve}):e.jsx(ue,{visible:!0})})})]}),e.jsxs("div",{className:"col-span-4 flex flex-col gap-6 overflow-y-auto",children:[e.jsx(F,{name:"AgentDashboard",children:e.jsx(St,{agents:Le,loading:Me})}),e.jsx(F,{name:"QualityGates",children:e.jsx(Ft,{checklist:Ae,loading:De})})]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-12 gap-6",children:[e.jsx("div",{className:"col-span-6",children:e.jsx(F,{name:"FileBrowser",children:e.jsx(Rt,{files:Pe,loading:Fe})})}),e.jsx("div",{className:"col-span-6",children:e.jsx(F,{name:"MemoryViewer",children:e.jsx(It,{memory:Se,loading:Ce})})})]})]}):e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{ref:D,className:"text-center mt-12 mb-10",children:[e.jsx("p",{className:"text-sm font-medium text-[#553DE9] mb-2",children:I}),e.jsx("h2",{className:"font-heading text-h1 text-[#36342E]",children:"Describe it. Build it. Ship it."}),e.jsx("p",{className:"text-[#6B6960] mt-3 text-base max-w-xl mx-auto",children:"Type what you want to build. Purple Lab handles the rest -- from code to containers, autonomously."})]}),e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:g,type:"text",value:C,onChange:x=>H(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),oe())},className:"w-full text-xl px-6 py-4 rounded-2xl bg-white border border-[#ECEAE3] shadow-sm focus:outline-none focus:ring-2 focus:ring-[#553DE9]/30 focus:border-[#553DE9]/40 focus:shadow-lg transition-all placeholder:text-transparent",disabled:S,"aria-label":"Describe what you want to build"}),!C&&e.jsx("div",{className:"absolute left-6 top-1/2 -translate-y-1/2 text-xl text-[#6B6960]/50 pointer-events-none select-none","aria-hidden":"true",children:e.jsx("span",{className:Q?"quick-input-placeholder-exit":"quick-input-placeholder",children:U[$]},$)})]}),e.jsx("div",{className:"mt-4 flex items-center justify-center gap-4",children:e.jsx("button",{onClick:oe,disabled:!C.trim()||S,className:`px-8 py-3 rounded-xl text-base font-semibold transition-all ${!C.trim()||S?"bg-[#553DE9]/20 text-[#553DE9]/40 cursor-not-allowed":"bg-[#553DE9] text-white hover:bg-[#4832c7] shadow-lg shadow-[#553DE9]/25 hover:shadow-xl hover:shadow-[#553DE9]/30 active:scale-[0.98]"}`,children:S?"Starting...":"Start Building"})}),s&&e.jsx("div",{className:"mt-3 px-4 py-2.5 rounded-xl bg-[#C45B5B]/10 border border-[#C45B5B]/20 text-[#C45B5B] text-sm font-medium text-center",children:s}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx("button",{onClick:()=>q(!_),className:"text-sm text-[#553DE9] hover:text-[#4832c7] font-medium transition-colors",children:_?"Hide advanced options":"Advanced (write full PRD)"})}),_&&e.jsx("div",{className:"mt-4",children:e.jsx(Nt,{onSubmit:Be,running:a,error:s,provider:w,onProviderChange:$e,initialPrd:h})})]}),m&&!a&&e.jsxs("div",{className:"w-full max-w-3xl mt-6 flex flex-col gap-4",children:[e.jsx("button",{onClick:async()=>{try{const x=await j.getSessionsHistory();x.length>0&&t(`/project/${x[0].id}`)}catch{}},className:"w-full px-6 py-4 rounded-card text-base font-bold bg-[#553DE9] text-white hover:bg-[#553DE9]/90 transition-all shadow-lg shadow-[#553DE9]/20",children:"View Project -- Browse Files and Preview"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>p(!v),className:"px-4 py-2 rounded-card text-sm font-semibold border border-[#553DE9]/30 text-[#553DE9] hover:bg-[#553DE9]/5 transition-all",children:v?"Hide Report":"Report"}),e.jsx("button",{onClick:()=>y(!b),className:"px-4 py-2 rounded-card text-sm font-semibold border border-[#ECEAE3] text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0] transition-all",children:b?"Hide Metrics":"Metrics"})]}),e.jsx(_t,{visible:v}),e.jsx(ue,{visible:b})]}),e.jsx("div",{className:"w-full max-w-3xl mt-6",children:le&&le.length===0?e.jsx(us,{type:"no-projects",action:()=>{var f;const x=U[Math.floor(Math.random()*U.length)];H(x),(f=g.current)==null||f.focus()},actionLabel:"Try an example"}):e.jsx(Ot,{onLoadSession:_e})}),e.jsxs("div",{className:"mt-6 text-xs text-[#6B6960] flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${J?"bg-[#1FC5A8]":"bg-[#C45B5B]"}`}),J?"Connected to Purple Lab backend":"Waiting for backend connection..."]}),e.jsx(Gt,{}),e.jsx(Qt,{}),e.jsx(Zt,{}),e.jsx(es,{}),e.jsx("section",{className:"w-full max-w-3xl mx-auto py-16",children:e.jsxs("div",{className:"rounded-2xl bg-gradient-to-br from-[#553DE9]/5 via-[#553DE9]/10 to-[#1FC5A8]/5 border border-[#553DE9]/15 p-10 text-center",children:[e.jsx("h2",{className:"font-heading text-h2 text-[#36342E] mb-3",children:"Ready to build something amazing?"}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-6 max-w-md mx-auto",children:"Go from idea to deployed product in minutes, not months. Let AI handle the heavy lifting."}),e.jsxs("div",{className:"flex items-center justify-center gap-3 flex-wrap",children:[e.jsx("button",{onClick:()=>{var x;(x=D.current)==null||x.scrollIntoView({behavior:"smooth"}),setTimeout(()=>{var f;return(f=g.current)==null?void 0:f.focus()},500)},className:"px-8 py-3 rounded-xl text-base font-semibold bg-[#553DE9] text-white hover:bg-[#4832c7] shadow-lg shadow-[#553DE9]/25 hover:shadow-xl hover:shadow-[#553DE9]/30 active:scale-[0.98] transition-all",children:"Start Building"}),e.jsx("button",{onClick:()=>t("/templates"),className:"px-8 py-3 rounded-xl text-base font-semibold border border-[#553DE9]/30 text-[#553DE9] hover:bg-[#553DE9]/5 transition-all",children:"View Templates"})]})]})}),e.jsx(is,{}),e.jsx(ns,{})]})}),!a&&e.jsx(ss,{}),E&&e.jsx(ds,{type:"build-complete",onDismiss:()=>z(!1)})]})}export{Ls as default};
@@ -1 +1 @@
1
- import{Q as r,u as o,r as c,j as e}from"./index-6Z4B0I6r.js";function x(){const{user:l,loading:t,login:i,isLocalMode:n}=r(),s=o();return c.useEffect(()=>{!t&&(l||n)&&s("/",{replace:!0})},[l,t,n,s]),t?e.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center text-[#6B6960] text-sm",children:"Loading..."}):e.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-sm mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"font-heading text-3xl font-bold text-[#36342E] mb-1",children:"Purple Lab"}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:"Autonomous agent workspace powered by Loki"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#ECEAE3] shadow-sm p-6 space-y-4",children:[e.jsx("h2",{className:"text-base font-medium text-[#36342E] text-center",children:"Sign in to continue"}),e.jsxs("button",{type:"button",onClick:()=>i("github"),className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-[5px] border border-[#ECEAE3] bg-[#24292f] text-white text-sm font-medium hover:bg-[#1b1f23] transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),"Sign in with GitHub"]}),e.jsxs("button",{type:"button",onClick:()=>i("google"),className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-[5px] border border-[#ECEAE3] bg-white text-[#36342E] text-sm font-medium hover:bg-[#F8F4F0] transition-colors",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Sign in with Google"]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[#ECEAE3]"})}),e.jsx("div",{className:"relative flex justify-center text-xs",children:e.jsx("span",{className:"bg-white px-2 text-[#939084]",children:"or"})})]}),e.jsx("button",{type:"button",onClick:()=>s("/"),className:"w-full text-center text-sm text-[#6B6960] hover:text-[#553DE9] transition-colors py-1",children:"Continue without account (local mode)"})]}),e.jsx("p",{className:"text-xs text-[#939084] text-center mt-4",children:"Local mode stores everything on your machine. Sign in for cloud sync and collaboration."})]})})}export{x as default};
1
+ import{Q as r,u as o,r as c,j as e}from"./index-BN52-GQT.js";function x(){const{user:l,loading:t,login:i,isLocalMode:n}=r(),s=o();return c.useEffect(()=>{!t&&(l||n)&&s("/",{replace:!0})},[l,t,n,s]),t?e.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center text-[#6B6960] text-sm",children:"Loading..."}):e.jsx("div",{className:"h-screen bg-[#FAF9F6] flex items-center justify-center",children:e.jsxs("div",{className:"w-full max-w-sm mx-auto px-6",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"font-heading text-3xl font-bold text-[#36342E] mb-1",children:"Purple Lab"}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:"Autonomous agent workspace powered by Loki"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-[#ECEAE3] shadow-sm p-6 space-y-4",children:[e.jsx("h2",{className:"text-base font-medium text-[#36342E] text-center",children:"Sign in to continue"}),e.jsxs("button",{type:"button",onClick:()=>i("github"),className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-[5px] border border-[#ECEAE3] bg-[#24292f] text-white text-sm font-medium hover:bg-[#1b1f23] transition-colors",children:[e.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),"Sign in with GitHub"]}),e.jsxs("button",{type:"button",onClick:()=>i("google"),className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-[5px] border border-[#ECEAE3] bg-white text-[#36342E] text-sm font-medium hover:bg-[#F8F4F0] transition-colors",children:[e.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),"Sign in with Google"]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-[#ECEAE3]"})}),e.jsx("div",{className:"relative flex justify-center text-xs",children:e.jsx("span",{className:"bg-white px-2 text-[#939084]",children:"or"})})]}),e.jsx("button",{type:"button",onClick:()=>s("/"),className:"w-full text-center text-sm text-[#6B6960] hover:text-[#553DE9] transition-colors py-1",children:"Continue without account (local mode)"})]}),e.jsx("p",{className:"text-xs text-[#939084] text-center mt-4",children:"Local mode stores everything on your machine. Sign in for cloud sync and collaboration."})]})})}export{x as default};
@@ -0,0 +1,31 @@
1
+ import{c as C,r as s,j as e,t as $,X as J,l as W,T as X,F as H,m as K}from"./index-BN52-GQT.js";import{U as Y}from"./upload-LuDuB7Wc.js";import{C as ee}from"./circle-alert-8SRY0_GX.js";import{L as R}from"./loader-circle-BB932A7A.js";import{C as te}from"./code-xml-1N2Ui-4c.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const se=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ae=C("archive",se);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const re=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]],ne=C("atom",re);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ie=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],le=C("boxes",ie);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const de=[["path",{d:"m14 13-8.381 8.38a1 1 0 0 1-3.001-3l8.384-8.381",key:"pgg06f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m21.5 10.5-8-8",key:"a17d9x"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m8.5 7.5 8 8",key:"1oyaui"}]],oe=C("gavel",de);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ce=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],xe=C("grid-3x3",ce);/**
27
+ * @license lucide-react v0.577.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const me=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],ue=C("list",me),he=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function pe({onGenerate:t}){const o=s.useId(),c=s.useId(),b=s.useId(),h=s.useId(),f=s.useId(),x=s.useRef(null),[m,u]=s.useState(""),[p,E]=s.useState(""),[k,d]=s.useState("both"),[g,j]=s.useState(""),[i,y]=s.useState(null),[v,r]=s.useState(null),[l,D]=s.useState(!1),[w,z]=s.useState(null),[B,M]=s.useState(null),[N,F]=s.useState({state:"idle"}),_=s.useCallback(a=>new Promise((n,S)=>{const A=new FileReader;A.onload=()=>n(typeof A.result=="string"?A.result:""),A.onerror=()=>S(A.error??new Error("File read error")),A.readAsDataURL(a)}),[]),T=s.useCallback(async a=>{if(a){if(!a.type.startsWith("image/")){F({state:"error",message:"Screenshot must be an image file."});return}try{const n=await _(a);y(n),r(a.name)}catch{F({state:"error",message:"Could not read the selected file."})}}},[_]),q=s.useCallback(async a=>{var S;a.preventDefault(),D(!1);const n=(S=a.dataTransfer.files)==null?void 0:S[0];await T(n)},[T]),L=s.useCallback(()=>{y(null),r(null),x.current&&(x.current.value="")},[]),I=s.useCallback(()=>{let a=!0;return m.trim()?he.test(m.trim())?z(null):(z("Name must start with a letter and contain only letters, numbers, hyphens, or underscores."),a=!1):(z("Name is required."),a=!1),p.trim()?p.trim().length<10?(M("Description should be at least 10 characters."),a=!1):M(null):(M("Description is required."),a=!1),a},[m,p]),U=s.useCallback(a=>a.split(",").map(n=>n.trim()).filter(n=>n.length>0),[]),Q=s.useCallback(async a=>{if(a.preventDefault(),N.state==="submitting"||!I())return;F({state:"submitting"});const n={name:m.trim(),description:p.trim(),target:k,tags:U(g),...i?{screenshot:i}:{}};await t(n)?(F({state:"success",message:`Component "${n.name}" generated successfully.`}),u(""),E(""),j(""),d("both"),L()):F({state:"error",message:"Generation failed. Please try again."})},[N.state,I,m,p,k,g,i,t,U,L]),G=N.state==="submitting";return e.jsxs("form",{onSubmit:Q,noValidate:!0,className:"rounded-xl border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] shadow-sm",children:[e.jsxs("div",{className:"px-6 py-5 border-b border-[#ECEAE3] dark:border-[#2A2A30]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"text-[#553DE9]",size:18,"aria-hidden":"true"}),e.jsx("h3",{className:"text-base font-semibold text-[#36342E] dark:text-[#E8E6E3]",children:"Generate a new component"})]}),e.jsx("p",{className:"mt-1 text-xs text-[#6B6960] dark:text-[#8A8880]",children:"Provide a short spec. Loki will create the component, run a debate, and register it."})]}),e.jsxs("div",{className:"px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:o,className:"block text-xs font-medium text-[#36342E] dark:text-[#E8E6E3] mb-1.5",children:"Name"}),e.jsx("input",{id:o,type:"text",value:m,onChange:a=>u(a.target.value),placeholder:"e.g. PricingCard","aria-invalid":w?!0:void 0,"aria-describedby":w?`${o}-error`:void 0,className:"w-full px-3 py-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-sm text-[#36342E] dark:text-[#E8E6E3] placeholder:text-[#939084] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:border-[#553DE9]"}),w?e.jsx("p",{id:`${o}-error`,className:"mt-1 text-xs text-[#C45B5B]",children:w}):e.jsx("p",{className:"mt-1 text-xs text-[#939084]",children:"Letters, numbers, hyphens, underscores. Must start with a letter."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:b,className:"block text-xs font-medium text-[#36342E] dark:text-[#E8E6E3] mb-1.5",children:"Tags"}),e.jsx("input",{id:b,type:"text",value:g,onChange:a=>j(a.target.value),placeholder:"marketing, pricing, card",className:"w-full px-3 py-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-sm text-[#36342E] dark:text-[#E8E6E3] placeholder:text-[#939084] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:border-[#553DE9]"}),e.jsx("p",{className:"mt-1 text-xs text-[#939084]",children:"Comma-separated list used for search and grouping."})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:c,className:"block text-xs font-medium text-[#36342E] dark:text-[#E8E6E3] mb-1.5",children:"Description"}),e.jsx("textarea",{id:c,value:p,onChange:a=>E(a.target.value),rows:4,placeholder:"Describe what this component should look like and how it behaves.","aria-invalid":B?!0:void 0,"aria-describedby":B?`${c}-error`:void 0,className:"w-full px-3 py-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-sm text-[#36342E] dark:text-[#E8E6E3] placeholder:text-[#939084] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:border-[#553DE9] resize-y"}),B?e.jsx("p",{id:`${c}-error`,className:"mt-1 text-xs text-[#C45B5B]",children:B}):null]}),e.jsxs("fieldset",{children:[e.jsx("legend",{id:f,className:"block text-xs font-medium text-[#36342E] dark:text-[#E8E6E3] mb-1.5",children:"Target"}),e.jsx("div",{role:"radiogroup","aria-labelledby":f,className:"flex flex-wrap gap-2",children:[{value:"react",label:"React"},{value:"webcomponent",label:"Web Component"},{value:"both",label:"Both"}].map(a=>{const n=k===a.value;return e.jsxs("label",{className:["inline-flex items-center gap-2 px-3 py-2 rounded-lg border text-sm cursor-pointer transition-colors",n?"border-[#553DE9] bg-[#553DE9]/10 text-[#553DE9]":"border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-[#36342E] dark:text-[#E8E6E3] hover:border-[#553DE9]/50"].join(" "),children:[e.jsx("input",{type:"radio",name:"magic-target",value:a.value,checked:n,onChange:()=>d(a.value),className:"sr-only"}),e.jsx("span",{"aria-hidden":"true",className:["inline-block h-3 w-3 rounded-full border",n?"border-[#553DE9] bg-[#553DE9]":"border-[#939084] bg-transparent"].join(" ")}),a.label]},a.value)})})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:h,className:"block text-xs font-medium text-[#36342E] dark:text-[#E8E6E3] mb-1.5",children:["Screenshot ",e.jsx("span",{className:"text-[#939084] font-normal",children:"(optional)"})]}),e.jsxs("div",{onDragOver:a=>{a.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:q,className:["flex items-center gap-3 rounded-lg border-2 border-dashed px-4 py-4 transition-colors",l?"border-[#553DE9] bg-[#553DE9]/5":"border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAF9F6] dark:bg-[#121215]"].join(" "),children:[i?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:i,alt:v?`Uploaded ${v}`:"Uploaded screenshot preview",className:"h-16 w-16 object-cover rounded-md border border-[#ECEAE3] dark:border-[#2A2A30]"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3] truncate",children:v??"screenshot"}),e.jsx("p",{className:"text-xs text-[#939084]",children:"Drop a new image to replace."})]}),e.jsxs("button",{type:"button",onClick:L,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs text-[#6B6960] dark:text-[#8A8880] hover:text-[#C45B5B] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40","aria-label":"Remove screenshot",children:[e.jsx(J,{size:14,"aria-hidden":"true"}),"Remove"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"text-[#553DE9]",size:20,"aria-hidden":"true"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:["Drag and drop an image, or",e.jsx("button",{type:"button",onClick:()=>{var a;return(a=x.current)==null?void 0:a.click()},className:"ml-1 underline text-[#553DE9] hover:text-[#3F2BB8] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 rounded",children:"browse"})]}),e.jsx("p",{className:"text-xs text-[#939084]",children:"PNG or JPG up to 5 MB."})]})]}),e.jsx("input",{ref:x,id:h,type:"file",accept:"image/*",onChange:a=>{var n;return void T((n=a.target.files)==null?void 0:n[0])},className:"sr-only"})]})]}),N.state==="error"?e.jsxs("div",{role:"alert",className:"flex items-start gap-2 rounded-lg border border-[#C45B5B]/30 bg-[#C45B5B]/10 px-3 py-2 text-xs text-[#C45B5B]",children:[e.jsx(ee,{size:14,"aria-hidden":"true",className:"mt-0.5"}),e.jsx("span",{children:N.message})]}):N.state==="success"?e.jsxs("div",{role:"status",className:"flex items-start gap-2 rounded-lg border border-[#1FC5A8]/30 bg-[#1FC5A8]/10 px-3 py-2 text-xs text-[#1FC5A8]",children:[e.jsx(W,{size:14,"aria-hidden":"true",className:"mt-0.5"}),e.jsx("span",{children:N.message})]}):null]}),e.jsx("div",{className:"px-6 py-4 border-t border-[#ECEAE3] dark:border-[#2A2A30] flex items-center justify-end gap-3",children:e.jsx("button",{type:"submit",disabled:G,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-[#553DE9] text-white text-sm font-medium shadow-sm hover:bg-[#3F2BB8] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-[#1A1A1E] disabled:opacity-60 disabled:cursor-not-allowed",children:G?e.jsxs(e.Fragment,{children:[e.jsx(R,{size:16,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx($,{size:16,"aria-hidden":"true"}),"Generate"]})})})]})}function P(t){if(!t)return"";const o=new Date(t);return Number.isNaN(o.getTime())?t:o.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ge(t){const o=t.includes("react")||t.includes("both"),c=t.includes("webcomponent")||t.includes("both");return{react:o,webcomponent:c}}function V({targets:t}){const{react:o,webcomponent:c}=ge(t);return e.jsxs("div",{className:"flex items-center gap-1.5","aria-label":"Supported targets",children:[o?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-sky-500/10 text-sky-600 dark:text-sky-400 px-1.5 py-0.5 text-[11px] font-medium",title:"React target",children:[e.jsx(ne,{size:11,"aria-hidden":"true"}),"React"]}):null,c?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-amber-500/10 text-amber-700 dark:text-amber-400 px-1.5 py-0.5 text-[11px] font-medium",title:"Web Component target",children:[e.jsx(le,{size:11,"aria-hidden":"true"}),"WC"]}):null]})}function Z({passed:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[#1FC5A8]/10 text-[#1FC5A8] px-1.5 py-0.5 text-[11px] font-medium",title:"Debate passed",children:[e.jsx(W,{size:11,"aria-hidden":"true"}),"Debate passed"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-[#D4A03C]/10 text-[#D4A03C] px-1.5 py-0.5 text-[11px] font-medium",title:"Debate has not passed",children:[e.jsx(X,{size:11,"aria-hidden":"true"}),"Needs debate"]})}function O({value:t}){return e.jsx("span",{className:"inline-flex items-center rounded-full bg-[#F5F4EF] dark:bg-[#23232A] text-[#6B6960] dark:text-[#8A8880] px-2 py-0.5 text-[11px]",children:t})}function be({component:t,variant:o,onRunDebate:c,onDeprecate:b}){const[h,f]=s.useState(!1),[x,m]=s.useState(!1),u=s.useCallback(async()=>{if(!(!c||h)){f(!0);try{await c(t.name)}finally{f(!1)}}},[c,h,t.name]),p=s.useCallback(async()=>{if(!(!b||x||!window.confirm(`Deprecate component "${t.name}"? This marks it as unavailable for new projects.`))){m(!0);try{await b(t.name)}finally{m(!1)}}},[b,x,t.name]),E=s.useCallback(()=>{const i=`/api/magic/components/${encodeURIComponent(t.name)}/spec`;window.open(i,"_blank","noopener,noreferrer")},[t.name]),k=s.useCallback(()=>{const i=`/api/magic/components/${encodeURIComponent(t.name)}/code`;window.open(i,"_blank","noopener,noreferrer")},[t.name]),d=t.tags.slice(0,4),g=t.tags.length-d.length,j=e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:E,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-[#36342E] dark:text-[#E8E6E3] text-xs hover:bg-[#F5F4EF] dark:hover:bg-[#23232A] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),"View spec"]}),e.jsxs("button",{type:"button",onClick:k,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-[#36342E] dark:text-[#E8E6E3] text-xs hover:bg-[#F5F4EF] dark:hover:bg-[#23232A] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:[e.jsx(te,{size:12,"aria-hidden":"true"}),"View code"]}),e.jsxs("button",{type:"button",onClick:u,disabled:h,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border border-[#553DE9]/40 bg-[#553DE9]/10 text-[#553DE9] text-xs hover:bg-[#553DE9]/20 focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 disabled:opacity-60 disabled:cursor-not-allowed",children:[h?e.jsx(R,{size:12,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):e.jsx(oe,{size:12,"aria-hidden":"true"}),"Run debate"]}),e.jsxs("button",{type:"button",onClick:p,disabled:x,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#121215] text-[#6B6960] dark:text-[#8A8880] text-xs hover:text-[#C45B5B] hover:border-[#C45B5B]/40 focus:outline-none focus:ring-2 focus:ring-[#C45B5B]/40 disabled:opacity-60 disabled:cursor-not-allowed",children:[x?e.jsx(R,{size:12,className:"animate-spin motion-reduce:animate-none","aria-hidden":"true"}):e.jsx(ae,{size:12,"aria-hidden":"true"}),"Deprecate"]})]});return o==="list"?e.jsxs("article",{className:"rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] px-4 py-3 hover:shadow-sm transition-shadow",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-[#36342E] dark:text-[#E8E6E3] truncate",children:t.name}),e.jsxs("span",{className:"inline-flex items-center rounded-md bg-[#553DE9]/10 text-[#553DE9] px-1.5 py-0.5 text-[11px] font-medium",children:["v",t.version]})]}),e.jsx("p",{className:"flex-1 text-xs text-[#6B6960] dark:text-[#8A8880] truncate",children:t.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(V,{targets:t.targets}),e.jsx(Z,{passed:t.debate_passed}),e.jsxs("span",{className:"text-[11px] text-[#939084]",children:["Updated ",P(t.updated_at)]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1",children:[d.map(i=>e.jsx(O,{value:i},i)),g>0?e.jsxs("span",{className:"text-[11px] text-[#939084]",children:["+",g," more"]}):null]}),j]})]}):e.jsxs("article",{className:"flex flex-col rounded-xl border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] shadow-sm hover:shadow-md transition-shadow overflow-hidden",children:[e.jsx("div",{className:"h-24 bg-gradient-to-br from-[#553DE9]/20 via-[#553DE9]/10 to-[#8B78F0]/10 dark:from-[#553DE9]/30 dark:via-[#553DE9]/15 dark:to-[#8B78F0]/10 border-b border-[#ECEAE3] dark:border-[#2A2A30]"}),e.jsxs("div",{className:"px-4 py-4 flex-1 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-[#36342E] dark:text-[#E8E6E3] truncate",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center rounded-md bg-[#553DE9]/10 text-[#553DE9] px-1.5 py-0.5 text-[11px] font-medium",children:["v",t.version]}),e.jsx(V,{targets:t.targets})]})]}),e.jsx(Z,{passed:t.debate_passed})]}),e.jsx("p",{className:"text-xs text-[#6B6960] dark:text-[#8A8880] line-clamp-3",children:t.description}),d.length>0?e.jsxs("div",{className:"flex flex-wrap gap-1",children:[d.map(i=>e.jsx(O,{value:i},i)),g>0?e.jsxs("span",{className:"text-[11px] text-[#939084]",children:["+",g]}):null]}):null,e.jsx("div",{className:"mt-auto pt-2 border-t border-[#ECEAE3] dark:border-[#2A2A30] flex items-center justify-between text-[11px] text-[#939084]",children:e.jsxs("span",{children:["Updated ",P(t.updated_at)]})}),j]})]})}function ve(){const[t,o]=s.useState([]),[c,b]=s.useState(!0),[h,f]=s.useState(null),[x,m]=s.useState(""),[u,p]=s.useState("grid"),[E,k]=s.useState("all"),d=s.useCallback(async()=>{try{b(!0),f(null);const r=await fetch("/api/magic/components");if(r.ok){const l=await r.json();o(Array.isArray(l==null?void 0:l.components)?l.components:[])}else f(`Failed to load components (HTTP ${r.status})`)}catch(r){console.error("Failed to load components",r),f("Failed to load components")}finally{b(!1)}},[]);s.useEffect(()=>{d()},[d]);const g=s.useCallback(async r=>{try{return(await fetch("/api/magic/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})).ok?(await d(),!0):!1}catch(l){return console.error("Failed to generate component",l),!1}},[d]),j=s.useCallback(async r=>{try{return(await fetch(`/api/magic/components/${encodeURIComponent(r)}/debate`,{method:"POST"})).ok?(await d(),!0):!1}catch(l){return console.error("Failed to run debate",l),!1}},[d]),i=s.useCallback(async r=>{try{return(await fetch(`/api/magic/components/${encodeURIComponent(r)}`,{method:"DELETE"})).ok?(await d(),!0):!1}catch(l){return console.error("Failed to deprecate component",l),!1}},[d]),y=x.trim().toLowerCase(),v=t.filter(r=>{const l=!y||r.name.toLowerCase().includes(y)||r.description.toLowerCase().includes(y)||r.tags.some(w=>w.toLowerCase().includes(y)),D=E==="all"||r.targets.includes(E)||r.targets.includes("both");return l&&D});return e.jsxs("div",{className:"min-h-screen bg-[#FAF9F6] dark:bg-[#0F0F11]",children:[e.jsx("header",{className:"border-b border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E]",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx($,{className:"text-[#553DE9]",size:28,"aria-hidden":"true"}),e.jsx("h1",{className:"text-2xl font-semibold text-[#36342E] dark:text-[#E8E6E3]",children:"Magic Modules"})]}),e.jsx("p",{className:"text-sm text-[#6B6960] dark:text-[#8A8880] max-w-3xl",children:"Describe a component. Loki generates React and Web Component variants, runs a multi-persona debate, and registers it for reuse."})]})}),e.jsxs("section",{"aria-labelledby":"magic-generator-heading",className:"max-w-6xl mx-auto px-6 py-8",children:[e.jsx("h2",{id:"magic-generator-heading",className:"sr-only",children:"Generate a new component"}),e.jsx(pe,{onGenerate:g})]}),e.jsxs("section",{"aria-labelledby":"magic-registry-heading",className:"max-w-6xl mx-auto px-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{id:"magic-registry-heading",className:"text-lg font-semibold text-[#36342E] dark:text-[#E8E6E3]",children:"Component Registry"}),e.jsx("span",{className:"text-xs text-[#6B6960] dark:text-[#8A8880]",children:c?"Loading...":`${v.length} of ${t.length} component${t.length===1?"":"s"}`})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-3 mb-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]",size:16,"aria-hidden":"true"}),e.jsx("label",{htmlFor:"magic-search",className:"sr-only",children:"Search components"}),e.jsx("input",{id:"magic-search",type:"text",placeholder:"Search components by name, description, or tag...",value:x,onChange:r=>m(r.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-sm text-[#36342E] dark:text-[#E8E6E3] placeholder:text-[#939084] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:border-[#553DE9]"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:"magic-filter-target",className:"sr-only",children:"Filter by target"}),e.jsxs("select",{id:"magic-filter-target",value:E,onChange:r=>k(r.target.value),className:"px-3 py-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-sm text-[#36342E] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40 focus:border-[#553DE9]",children:[e.jsx("option",{value:"all",children:"All targets"}),e.jsx("option",{value:"react",children:"React"}),e.jsx("option",{value:"webcomponent",children:"Web Component"})]}),e.jsx("button",{type:"button",onClick:()=>p(r=>r==="grid"?"list":"grid"),className:"p-2 rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#36342E] dark:text-[#E8E6E3] hover:bg-[#F5F4EF] dark:hover:bg-[#23232A] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",title:u==="grid"?"Switch to list view":"Switch to grid view","aria-label":u==="grid"?"Switch to list view":"Switch to grid view","aria-pressed":u==="list",children:u==="grid"?e.jsx(ue,{size:16}):e.jsx(xe,{size:16})})]})]})]}),e.jsx("section",{className:"max-w-6xl mx-auto px-6 pb-12",children:h?e.jsx("div",{role:"alert",className:"text-center py-12 text-[#C45B5B] text-sm",children:h}):c?e.jsx("div",{className:"text-center py-12 text-[#6B6960] dark:text-[#8A8880] text-sm",children:"Loading components..."}):v.length===0?e.jsx("div",{className:"text-center py-12 text-[#6B6960] dark:text-[#8A8880] text-sm",children:t.length===0?"No components yet. Describe one above to get started.":"No components match your search."}):e.jsx("div",{className:u==="grid"?"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4":"space-y-2",children:v.map(r=>e.jsx(be,{component:r,variant:u,onRunDebate:j,onDeprecate:i},r.name))})})]})}export{ve as default};
@@ -1,4 +1,4 @@
1
- import{c as X,r as v,j as e,b as Y,A as z,w as U,d as K,l as Z}from"./index-6Z4B0I6r.js";import{G as W}from"./git-commit-horizontal-wbqFPNID.js";import{C as J}from"./chevron-left-Bw4I1yGm.js";import{F as ee}from"./file-code-corner-DqZ9gpdv.js";import{P as te}from"./plus-BcAN8Kaj.js";import{M as se,T as ne}from"./trending-down-BNLTrF5P.js";import{C as B}from"./clock-DDScLol4.js";import{D as _}from"./dollar-sign-CydJu0kl.js";import{L as re}from"./layers-XfssQc5V.js";import{T as ae}from"./trending-up-DmFIdVOc.js";/**
1
+ import{c as X,r as v,j as e,b as Y,A as z,w as U,d as K,l as Z}from"./index-BN52-GQT.js";import{G as W}from"./git-commit-horizontal-DM1ERuNd.js";import{C as J}from"./chevron-left-C-emzUhB.js";import{F as ee}from"./file-code-corner-B99CwY_6.js";import{P as te}from"./plus-CNqABexN.js";import{M as se,T as ne}from"./trending-down-CrDpO2a_.js";import{C as B}from"./clock-mfq4XnPQ.js";import{D as _}from"./dollar-sign-CRqk0dW5.js";import{L as re}from"./layers-Bi8RPIBC.js";import{T as ae}from"./trending-up-CNVsmM3G.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as e,H as t,$ as s,a0 as o}from"./index-6Z4B0I6r.js";function r(){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[60vh] p-8 text-center",children:[e.jsx("div",{className:"text-6xl font-heading font-bold text-primary/20 mb-4",children:"404"}),e.jsx("h1",{className:"text-h3 font-heading font-bold text-ink mb-2",children:"Page not found"}),e.jsx("p",{className:"text-sm text-muted-accessible mb-6 max-w-xs",children:"The page you are looking for does not exist or has been moved."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>window.history.back(),className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-btn border border-border text-secondary hover:bg-hover transition-colors",children:[e.jsx(t,{size:14}),"Go Back"]}),e.jsxs(s,{to:"/",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-[#4432c4] transition-colors shadow-button",children:[e.jsx(o,{size:14}),"Home"]})]})]})}export{r as default};
1
+ import{j as e,H as t,$ as s,a0 as o}from"./index-BN52-GQT.js";function r(){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[60vh] p-8 text-center",children:[e.jsx("div",{className:"text-6xl font-heading font-bold text-primary/20 mb-4",children:"404"}),e.jsx("h1",{className:"text-h3 font-heading font-bold text-ink mb-2",children:"Page not found"}),e.jsx("p",{className:"text-sm text-muted-accessible mb-6 max-w-xs",children:"The page you are looking for does not exist or has been moved."}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>window.history.back(),className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-btn border border-border text-secondary hover:bg-hover transition-colors",children:[e.jsx(t,{size:14}),"Go Back"]}),e.jsxs(s,{to:"/",className:"inline-flex items-center gap-1.5 px-4 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-[#4432c4] transition-colors shadow-button",children:[e.jsx(o,{size:14}),"Home"]})]})]})}export{r as default};