loki-mode 6.44.1 → 6.45.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 (26) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +30 -18
  4. package/dashboard/__init__.py +1 -1
  5. package/docs/INSTALLATION.md +1 -1
  6. package/mcp/__init__.py +1 -1
  7. package/package.json +1 -1
  8. package/web-app/dist/assets/{Badge-DTFBYZoA.js → Badge-ClncXa1x.js} +1 -1
  9. package/web-app/dist/assets/Button-CUOgrX10.js +6 -0
  10. package/web-app/dist/assets/{Card-CL6xo_RX.js → Card-2UWDXe0P.js} +1 -1
  11. package/web-app/dist/assets/{HomePage-1Ccs1i0m.js → HomePage-C4WxoEKI.js} +1 -1
  12. package/web-app/dist/assets/ProjectPage-Dy7ONtf_.js +162 -0
  13. package/web-app/dist/assets/ProjectsPage-CIDkRHyZ.js +6 -0
  14. package/web-app/dist/assets/{SettingsPage-CULNMl6W.js → SettingsPage-5AxjoTTg.js} +1 -1
  15. package/web-app/dist/assets/{TemplatesPage-DdrBEy9w.js → TemplatesPage-DPlaAtAk.js} +1 -1
  16. package/web-app/dist/assets/{TerminalOutput-C3fQIXqq.js → TerminalOutput-Do2PhilR.js} +1 -1
  17. package/web-app/dist/assets/{clock-D5NTAxeP.js → clock-DpWpY1Zx.js} +1 -1
  18. package/web-app/dist/assets/{external-link-CSO4H-LC.js → external-link-KmF9dPsz.js} +1 -1
  19. package/web-app/dist/assets/{index-DvhjaUe4.js → index-ACgjqVp2.js} +17 -17
  20. package/web-app/dist/assets/index-BZpAV5M8.css +1 -0
  21. package/web-app/dist/index.html +2 -2
  22. package/web-app/server.py +353 -63
  23. package/web-app/dist/assets/Button-NSmP6YCA.js +0 -1
  24. package/web-app/dist/assets/ProjectPage-wby1itP1.js +0 -141
  25. package/web-app/dist/assets/ProjectsPage-DEP-ZiW7.js +0 -11
  26. package/web-app/dist/assets/index-BLBd5LBk.css +0 -1
package/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: loki-mode
3
3
  description: Multi-agent autonomous startup system. Triggers on "Loki Mode". Takes PRD to deployed product with minimal human intervention. Requires --dangerously-skip-permissions flag.
4
4
  ---
5
5
 
6
- # Loki Mode v6.44.1
6
+ # Loki Mode v6.45.1
7
7
 
8
8
  **You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
9
9
 
@@ -267,4 +267,4 @@ The following features are documented in skill modules but not yet fully automat
267
267
  | Quality gates 3-reviewer system | Implemented (v5.35.0) | 5 specialist reviewers in `skills/quality-gates.md`; execution in run.sh |
268
268
  | Benchmarks (HumanEval, SWE-bench) | Infrastructure only | Runner scripts and datasets exist in `benchmarks/`; no published results |
269
269
 
270
- **v6.44.1 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
270
+ **v6.45.1 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.44.1
1
+ 6.45.1
package/autonomy/loki CHANGED
@@ -3212,24 +3212,36 @@ cmd_web_stop() {
3212
3212
 
3213
3213
  rm -f "$PURPLE_LAB_PID_FILE" "${LOKI_DIR}/purple-lab/port" 2>/dev/null || true
3214
3214
 
3215
- # Kill orphaned loki-run processes and their entire process trees
3216
- # This catches claude/codex/gemini child processes that survive parent death
3217
- local orphan_pids
3218
- orphan_pids=$(pgrep -f "loki-run-" 2>/dev/null || true)
3219
- if [ -n "$orphan_pids" ]; then
3220
- echo "Cleaning up orphaned build processes..."
3221
- for opid in $orphan_pids; do
3222
- # Kill the entire process tree rooted at this PID
3223
- pkill -TERM -P "$opid" 2>/dev/null || true
3224
- kill -TERM "$opid" 2>/dev/null || true
3225
- done
3226
- sleep 2
3227
- # SIGKILL any survivors
3228
- for opid in $orphan_pids; do
3229
- pkill -9 -P "$opid" 2>/dev/null || true
3230
- kill -9 "$opid" 2>/dev/null || true
3231
- done
3232
- echo "Orphaned build processes cleaned up."
3215
+ # Kill only processes that Purple Lab started (tracked in child-pids.json)
3216
+ # External loki sessions (started via "loki start" from terminal) are NOT touched
3217
+ local pids_file="${LOKI_DIR}/purple-lab/child-pids.json"
3218
+ if [ -f "$pids_file" ]; then
3219
+ local tracked_pids
3220
+ tracked_pids=$(python3 -c "import json; [print(p) for p in json.load(open('$pids_file'))]" 2>/dev/null || true)
3221
+ if [ -n "$tracked_pids" ]; then
3222
+ echo "Cleaning up Purple Lab build processes..."
3223
+ for opid in $tracked_pids; do
3224
+ pkill -TERM -P "$opid" 2>/dev/null || true
3225
+ kill -TERM "$opid" 2>/dev/null || true
3226
+ done
3227
+ sleep 2
3228
+ for opid in $tracked_pids; do
3229
+ pkill -9 -P "$opid" 2>/dev/null || true
3230
+ kill -9 "$opid" 2>/dev/null || true
3231
+ done
3232
+ echo "Purple Lab build processes cleaned up."
3233
+ fi
3234
+ rm -f "$pids_file" 2>/dev/null || true
3235
+ fi
3236
+
3237
+ # Also stop the Loki Dashboard if it was started by a Purple Lab session
3238
+ local dash_pid
3239
+ dash_pid=$(lsof -ti:57374 -sTCP:LISTEN 2>/dev/null | head -1 || true)
3240
+ if [ -n "$dash_pid" ]; then
3241
+ kill "$dash_pid" 2>/dev/null || true
3242
+ sleep 1
3243
+ kill -0 "$dash_pid" 2>/dev/null && kill -9 "$dash_pid" 2>/dev/null || true
3244
+ echo "Loki Dashboard stopped (port 57374)"
3233
3245
  fi
3234
3246
  }
3235
3247
 
@@ -7,7 +7,7 @@ Modules:
7
7
  control: Session control API (start/stop/pause/resume)
8
8
  """
9
9
 
10
- __version__ = "6.44.1"
10
+ __version__ = "6.45.1"
11
11
 
12
12
  # Expose the control app for easy import
13
13
  try:
@@ -2,7 +2,7 @@
2
2
 
3
3
  The flagship product of [Autonomi](https://www.autonomi.dev/). Complete installation instructions for all platforms and use cases.
4
4
 
5
- **Version:** v6.44.1
5
+ **Version:** v6.45.1
6
6
 
7
7
  ---
8
8
 
package/mcp/__init__.py CHANGED
@@ -57,4 +57,4 @@ try:
57
57
  except ImportError:
58
58
  __all__ = ['mcp']
59
59
 
60
- __version__ = '6.44.1'
60
+ __version__ = '6.45.1'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "6.44.1",
3
+ "version": "6.45.1",
4
4
  "description": "Loki Mode by Autonomi - Multi-agent autonomous startup system for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "keywords": [
6
6
  "agent",
@@ -1,4 +1,4 @@
1
- import{c as m,r,j as e}from"./index-DvhjaUe4.js";import{C as g,a as p}from"./clock-D5NTAxeP.js";/**
1
+ import{c as m,r,j as e}from"./index-ACgjqVp2.js";import{C as g,a as p}from"./clock-DpWpY1Zx.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,6 @@
1
+ import{c as p,r as u,j as e}from"./index-ACgjqVp2.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 m=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],j=p("plus",m),h={primary:"bg-[#553DE9] text-white hover:bg-[#4432c4] shadow-button rounded-btn",secondary:"border border-[#553DE9] text-[#553DE9] hover:bg-[#E8E4FD] bg-transparent rounded-btn",ghost:"text-[#36342E] hover:bg-[#F8F4F0] rounded-btn",danger:"bg-[#C45B5B]/10 text-[#C45B5B] border border-[#C45B5B]/20 hover:bg-[#C45B5B]/20 rounded-btn"},b={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},y={sm:14,md:16,lg:18};function B({size:t}){return e.jsxs("svg",{className:"animate-spin",width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}const f=u.forwardRef(({variant:t="primary",size:o="md",icon:n,iconRight:a,loading:s=!1,disabled:i,className:c="",children:d,...l},x)=>{const r=y[o];return e.jsxs("button",{ref:x,disabled:i||s,className:["inline-flex items-center justify-center gap-2 font-medium transition-colors",h[t],b[o],(i||s)&&"opacity-60 cursor-not-allowed",c].filter(Boolean).join(" "),...l,children:[s?e.jsx(B,{size:r}):n?e.jsx(n,{size:r}):null,d,a&&!s&&e.jsx(a,{size:r})]})});f.displayName="Button";export{f as B,j as P};
@@ -1 +1 @@
1
- import{j as s}from"./index-DvhjaUe4.js";const n={none:"p-0",sm:"p-3",md:"p-4",lg:"p-6"};function p({hover:e=!1,padding:d="md",className:t="",children:a,onClick:r}){return s.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r,onKeyDown:r?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())}:void 0,className:["bg-white border border-[#ECEAE3] rounded-[5px] shadow-card",e&&"hover:shadow-card-hover transition-shadow duration-200",r&&"cursor-pointer",n[d],t].filter(Boolean).join(" "),children:a})}export{p as C};
1
+ import{j as s}from"./index-ACgjqVp2.js";const n={none:"p-0",sm:"p-3",md:"p-4",lg:"p-6"};function p({hover:e=!1,padding:d="md",className:t="",children:a,onClick:r}){return s.jsx("div",{role:r?"button":void 0,tabIndex:r?0:void 0,onClick:r,onKeyDown:r?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),r())}:void 0,className:["bg-white border border-[#ECEAE3] rounded-[5px] shadow-card",e&&"hover:shadow-card-hover transition-shadow duration-200",r&&"cursor-pointer",n[d],t].filter(Boolean).join(" "),children:a})}export{p as C};
@@ -1,4 +1,4 @@
1
- import{j as e,r as n,a as h,u as be,b as ge}from"./index-DvhjaUe4.js";import{u as I,B as je}from"./Badge-DTFBYZoA.js";import{P as ve,a as Ne,S as ye,E,T as we}from"./TerminalOutput-C3fQIXqq.js";import"./clock-D5NTAxeP.js";function ke(t){if(t<60)return`${Math.round(t)}s`;if(t<3600)return`${Math.floor(t/60)}m ${Math.round(t%60)}s`;const s=Math.floor(t/3600),l=Math.floor(t%3600/60);return`${s}h ${l}m`}function Se(t,s){if(!t||t<=0)return"--";const l={simple:{opus:1,haiku:1,total:3},standard:{opus:2,haiku:2,total:5},complex:{opus:3,haiku:3,total:8}},r=l[s]||l.standard;return t<=r.opus?"Opus":t>r.total-r.haiku?"Haiku":"Sonnet"}function Ce({status:t,prdSummary:s,onStop:l,onPause:r,onResume:a,isPaused:c}){const i=t?Se(t.iteration??0,t.complexity||"standard"):"--",o=c??(t==null?void 0:t.paused)??!1;return e.jsxs("div",{className:"card px-5 py-3 flex items-center gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Phase"}),e.jsx("span",{className:"font-mono font-semibold text-ink",children:(t==null?void 0:t.phase)||"idle"})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Complexity"}),e.jsx("span",{className:`font-mono font-semibold ${(t==null?void 0:t.complexity)==="complex"?"text-warning":(t==null?void 0:t.complexity)==="simple"?"text-success":"text-ink"}`,children:(t==null?void 0:t.complexity)||"standard"})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Model"}),e.jsx("span",{className:`font-mono font-semibold px-2 py-0.5 rounded-md text-xs ${i==="Opus"?"bg-primary/10 text-primary":i==="Haiku"?"bg-success/10 text-success":"bg-primary/10 text-primary"}`,children:i})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Tasks"}),e.jsx("span",{className:"font-mono text-ink",children:t!=null&&t.current_task?e.jsx("span",{className:"text-xs",children:t.current_task}):e.jsx("span",{className:"text-muted",children:"--"})}),((t==null?void 0:t.pending_tasks)??0)>0&&e.jsxs("span",{className:"text-xs text-primary font-mono",children:["+",t==null?void 0:t.pending_tasks," pending"]})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium flex-shrink-0",children:"Building"}),e.jsx("span",{className:"text-xs font-mono text-ink truncate max-w-[220px]",title:s,children:s.length>60?s.slice(0,60)+"...":s})]})]}),e.jsx("div",{className:"flex-1"}),((t==null?void 0:t.uptime)??0)>0&&e.jsx("span",{className:"font-mono text-xs text-muted",children:ke((t==null?void 0:t.uptime)??0)}),(r||a)&&e.jsxs("button",{onClick:o?a:r,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-btn text-xs font-semibold border border-warning/30 text-warning hover:bg-warning/10 transition-colors",children:[o?e.jsx(ve,{size:14}):e.jsx(Ne,{size:14}),o?"Resume":"Pause"]}),l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-btn text-xs font-semibold bg-danger/10 text-danger border border-danger/20 hover:bg-danger/20 transition-colors",children:[e.jsx(ye,{size:14}),"Stop"]})]})}function Ee({status:t}){const s=[{label:"Iteration",value:t?t.iteration.toString():"--",color:"text-primary"},{label:"Agents",value:t?t.running_agents.toString():"--",color:t&&t.running_agents>0?"text-success":"text-muted"},{label:"Pending",value:t?t.pending_tasks.toString():"--",color:t&&t.pending_tasks>0?"text-warning":"text-muted"},{label:"Provider",value:(t==null?void 0:t.provider)||"--",color:"text-primary"}];return e.jsx("div",{className:"grid grid-cols-4 gap-3",children:s.map(l=>e.jsxs("div",{className:"card p-4 text-center",children:[e.jsx("div",{className:`text-2xl font-bold font-mono ${l.color}`,children:l.value}),e.jsx("div",{className:"text-xs text-muted font-medium mt-1 uppercase tracking-wider",children:l.label})]},l.label))})}function Pe({plan:t,loading:s,onConfirm:l,onCancel:r}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",children:e.jsxs("div",{className:"card w-full max-w-lg mx-4 p-6 rounded-card shadow-card-hover",children:[e.jsx("h2",{className:"text-lg font-bold text-ink mb-4",children:"Build Estimate"}),s?e.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-muted",children:"Analyzing PRD..."}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-muted hover:text-ink transition-colors",children:"Cancel"}),e.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium text-primary hover:text-primary/80 transition-colors underline",children:"Skip analysis, build now"})]})]}):t?e.jsxs(e.Fragment,{children:[t.returncode!==0&&e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-btn bg-warning/10 border border-warning/20 text-warning text-xs",children:["loki plan exited with code ",t.returncode," - showing partial results"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",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:"Complexity"}),e.jsx("div",{className:"text-base font-bold text-ink capitalize",children:t.complexity})]}),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:"Est. Cost"}),e.jsx("div",{className:"text-base font-bold text-ink",children:t.cost_estimate})]}),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-base font-bold text-ink",children:t.iterations})]}),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:"Phases"}),e.jsx("div",{className:"text-xs text-ink capitalize",children:t.phases.join(", ")})]})]}),t.output_text&&e.jsxs("details",{className:"mb-4",children:[e.jsx("summary",{className:"text-xs text-muted cursor-pointer hover:text-ink transition-colors",children:"Raw output"}),e.jsx("pre",{className:"mt-2 text-xs font-mono text-muted-accessible bg-black/5 rounded-card p-3 overflow-auto max-h-40 whitespace-pre-wrap",children:t.output_text})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-muted hover:text-ink transition-colors",children:"Cancel"}),e.jsx("button",{onClick:l,className:"px-5 py-2 rounded-card text-sm font-semibold bg-primary text-white hover:bg-primary/90 transition-all shadow-button",children:"Start Build"})]})]}):e.jsx("div",{className:"text-sm text-muted py-4",children:"No plan data available."})]})})}function _e({onSubmit:t,running:s,error:l,provider:r,onProviderChange:a,initialPrd:c}){const[i,o]=n.useState(""),[m,b]=n.useState(""),[f,y]=n.useState("claude"),[d,g]=n.useState(""),j=r??f,[v,w]=n.useState(!1),[k,T]=n.useState([]),[x,P]=n.useState(!1),[N,M]=n.useState(!1),[_,A]=n.useState(!1),[z,F]=n.useState(null),[L,$]=n.useState(!1),[O,D]=n.useState(!1);n.useEffect(()=>{h.getTemplates().then(u=>{T(u),P(!1)}).catch(()=>{T([]),P(!0)})},[]),n.useEffect(()=>{c&&o(c)},[c]),n.useEffect(()=>{if(c)return;const u=localStorage.getItem("loki-prd-draft");u&&o(u),h.getPrdPrefill().then(({content:S})=>{S&&o(S)}).catch(()=>{})},[c]),n.useEffect(()=>{i.trim()?localStorage.setItem("loki-prd-draft",i):localStorage.removeItem("loki-prd-draft")},[i]),n.useEffect(()=>{const u=S=>{i.trim()&&S.preventDefault()};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[i]);const R=n.useCallback(async(u,S)=>{b(S),w(!1);try{const G=await h.getTemplateContent(u);o(G.content)}catch{o(`# ${S}
1
+ import{j as e,r as n,a as h,u as be,b as ge}from"./index-ACgjqVp2.js";import{u as I,B as je}from"./Badge-ClncXa1x.js";import{P as ve,a as Ne,S as ye,E,T as we}from"./TerminalOutput-Do2PhilR.js";import"./clock-DpWpY1Zx.js";function ke(t){if(t<60)return`${Math.round(t)}s`;if(t<3600)return`${Math.floor(t/60)}m ${Math.round(t%60)}s`;const s=Math.floor(t/3600),l=Math.floor(t%3600/60);return`${s}h ${l}m`}function Se(t,s){if(!t||t<=0)return"--";const l={simple:{opus:1,haiku:1,total:3},standard:{opus:2,haiku:2,total:5},complex:{opus:3,haiku:3,total:8}},r=l[s]||l.standard;return t<=r.opus?"Opus":t>r.total-r.haiku?"Haiku":"Sonnet"}function Ce({status:t,prdSummary:s,onStop:l,onPause:r,onResume:a,isPaused:c}){const i=t?Se(t.iteration??0,t.complexity||"standard"):"--",o=c??(t==null?void 0:t.paused)??!1;return e.jsxs("div",{className:"card px-5 py-3 flex items-center gap-6 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Phase"}),e.jsx("span",{className:"font-mono font-semibold text-ink",children:(t==null?void 0:t.phase)||"idle"})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Complexity"}),e.jsx("span",{className:`font-mono font-semibold ${(t==null?void 0:t.complexity)==="complex"?"text-warning":(t==null?void 0:t.complexity)==="simple"?"text-success":"text-ink"}`,children:(t==null?void 0:t.complexity)||"standard"})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Model"}),e.jsx("span",{className:`font-mono font-semibold px-2 py-0.5 rounded-md text-xs ${i==="Opus"?"bg-primary/10 text-primary":i==="Haiku"?"bg-success/10 text-success":"bg-primary/10 text-primary"}`,children:i})]}),e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium",children:"Tasks"}),e.jsx("span",{className:"font-mono text-ink",children:t!=null&&t.current_task?e.jsx("span",{className:"text-xs",children:t.current_task}):e.jsx("span",{className:"text-muted",children:"--"})}),((t==null?void 0:t.pending_tasks)??0)>0&&e.jsxs("span",{className:"text-xs text-primary font-mono",children:["+",t==null?void 0:t.pending_tasks," pending"]})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-muted uppercase tracking-wider font-medium flex-shrink-0",children:"Building"}),e.jsx("span",{className:"text-xs font-mono text-ink truncate max-w-[220px]",title:s,children:s.length>60?s.slice(0,60)+"...":s})]})]}),e.jsx("div",{className:"flex-1"}),((t==null?void 0:t.uptime)??0)>0&&e.jsx("span",{className:"font-mono text-xs text-muted",children:ke((t==null?void 0:t.uptime)??0)}),(r||a)&&e.jsxs("button",{onClick:o?a:r,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-btn text-xs font-semibold border border-warning/30 text-warning hover:bg-warning/10 transition-colors",children:[o?e.jsx(ve,{size:14}):e.jsx(Ne,{size:14}),o?"Resume":"Pause"]}),l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-btn text-xs font-semibold bg-danger/10 text-danger border border-danger/20 hover:bg-danger/20 transition-colors",children:[e.jsx(ye,{size:14}),"Stop"]})]})}function Ee({status:t}){const s=[{label:"Iteration",value:t?t.iteration.toString():"--",color:"text-primary"},{label:"Agents",value:t?t.running_agents.toString():"--",color:t&&t.running_agents>0?"text-success":"text-muted"},{label:"Pending",value:t?t.pending_tasks.toString():"--",color:t&&t.pending_tasks>0?"text-warning":"text-muted"},{label:"Provider",value:(t==null?void 0:t.provider)||"--",color:"text-primary"}];return e.jsx("div",{className:"grid grid-cols-4 gap-3",children:s.map(l=>e.jsxs("div",{className:"card p-4 text-center",children:[e.jsx("div",{className:`text-2xl font-bold font-mono ${l.color}`,children:l.value}),e.jsx("div",{className:"text-xs text-muted font-medium mt-1 uppercase tracking-wider",children:l.label})]},l.label))})}function Pe({plan:t,loading:s,onConfirm:l,onCancel:r}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 backdrop-blur-sm",children:e.jsxs("div",{className:"card w-full max-w-lg mx-4 p-6 rounded-card shadow-card-hover",children:[e.jsx("h2",{className:"text-lg font-bold text-ink mb-4",children:"Build Estimate"}),s?e.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-sm text-muted",children:"Analyzing PRD..."}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-muted hover:text-ink transition-colors",children:"Cancel"}),e.jsx("button",{onClick:l,className:"px-4 py-2 text-sm font-medium text-primary hover:text-primary/80 transition-colors underline",children:"Skip analysis, build now"})]})]}):t?e.jsxs(e.Fragment,{children:[t.returncode!==0&&e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-btn bg-warning/10 border border-warning/20 text-warning text-xs",children:["loki plan exited with code ",t.returncode," - showing partial results"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",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:"Complexity"}),e.jsx("div",{className:"text-base font-bold text-ink capitalize",children:t.complexity})]}),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:"Est. Cost"}),e.jsx("div",{className:"text-base font-bold text-ink",children:t.cost_estimate})]}),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-base font-bold text-ink",children:t.iterations})]}),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:"Phases"}),e.jsx("div",{className:"text-xs text-ink capitalize",children:t.phases.join(", ")})]})]}),t.output_text&&e.jsxs("details",{className:"mb-4",children:[e.jsx("summary",{className:"text-xs text-muted cursor-pointer hover:text-ink transition-colors",children:"Raw output"}),e.jsx("pre",{className:"mt-2 text-xs font-mono text-muted-accessible bg-black/5 rounded-card p-3 overflow-auto max-h-40 whitespace-pre-wrap",children:t.output_text})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-medium text-muted hover:text-ink transition-colors",children:"Cancel"}),e.jsx("button",{onClick:l,className:"px-5 py-2 rounded-card text-sm font-semibold bg-primary text-white hover:bg-primary/90 transition-all shadow-button",children:"Start Build"})]})]}):e.jsx("div",{className:"text-sm text-muted py-4",children:"No plan data available."})]})})}function _e({onSubmit:t,running:s,error:l,provider:r,onProviderChange:a,initialPrd:c}){const[i,o]=n.useState(""),[m,b]=n.useState(""),[f,y]=n.useState("claude"),[d,g]=n.useState(""),j=r??f,[v,w]=n.useState(!1),[k,T]=n.useState([]),[x,P]=n.useState(!1),[N,M]=n.useState(!1),[_,A]=n.useState(!1),[z,F]=n.useState(null),[L,$]=n.useState(!1),[O,D]=n.useState(!1);n.useEffect(()=>{h.getTemplates().then(u=>{T(u),P(!1)}).catch(()=>{T([]),P(!0)})},[]),n.useEffect(()=>{c&&o(c)},[c]),n.useEffect(()=>{if(c)return;const u=localStorage.getItem("loki-prd-draft");u&&o(u),h.getPrdPrefill().then(({content:S})=>{S&&o(S)}).catch(()=>{})},[c]),n.useEffect(()=>{i.trim()?localStorage.setItem("loki-prd-draft",i):localStorage.removeItem("loki-prd-draft")},[i]),n.useEffect(()=>{const u=S=>{i.trim()&&S.preventDefault()};return window.addEventListener("beforeunload",u),()=>window.removeEventListener("beforeunload",u)},[i]);const R=n.useCallback(async(u,S)=>{b(S),w(!1);try{const G=await h.getTemplateContent(u);o(G.content)}catch{o(`# ${S}
2
2
 
3
3
  ## Overview
4
4
 
@@ -0,0 +1,162 @@
1
+ var Mt=e=>{throw TypeError(e)};var Et=(e,t,n)=>t.has(e)||Mt("Cannot "+n);var Re=(e,t,n)=>(Et(e,t,"read from private field"),n?n.call(e):t.get(e)),Rt=(e,t,n)=>t.has(e)?Mt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Lt=(e,t,n,r)=>(Et(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);import{c as _,r as d,W as ke,j as a,a as U,B as Ot,S as Xn,d as Yn,u as Qn}from"./index-ACgjqVp2.js";import{T as Zn,P as Dt,a as Jn,S as er,E as tr}from"./TerminalOutput-Do2PhilR.js";import{B as Le,P as nr}from"./Button-CUOgrX10.js";import{C as rr,a as ar}from"./clock-DpWpY1Zx.js";import{E as sr}from"./external-link-KmF9dPsz.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 or=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ir=_("arrow-left",or);/**
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 lr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],cr=_("arrow-right",lr);/**
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 dr=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],ur=_("bot",dr);/**
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 fr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],pr=_("chevron-down",fr);/**
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 mr=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],hr=_("chevron-right",mr);/**
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 xr=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],gr=_("code-xml",xr);/**
32
+ * @license lucide-react v0.577.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const br=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],vr=_("eye-off",br);/**
37
+ * @license lucide-react v0.577.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const yr=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Oe=_("eye",yr);/**
42
+ * @license lucide-react v0.577.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const wr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],jr=_("file-braces",wr);/**
47
+ * @license lucide-react v0.577.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const kr=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],se=_("file-code-corner",kr);/**
52
+ * @license lucide-react v0.577.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Sr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],zr=_("file-code",Sr);/**
57
+ * @license lucide-react v0.577.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const Nr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],Cr=_("file-plus",Nr);/**
62
+ * @license lucide-react v0.577.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Pr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],an=_("file-text",Pr);/**
67
+ * @license lucide-react v0.577.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Mr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5",key:"qbrxap"}]],Er=_("file-type",Mr);/**
72
+ * @license lucide-react v0.577.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const Rr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Lr=_("file",Rr);/**
77
+ * @license lucide-react v0.577.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const Or=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],sn=_("folder-open",Or);/**
82
+ * @license lucide-react v0.577.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Dr=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],$r=_("folder-plus",Dr);/**
87
+ * @license lucide-react v0.577.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const Ir=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Tr=_("folder",Ir);/**
92
+ * @license lucide-react v0.577.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const Fr=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Ar=_("key-round",Fr);/**
97
+ * @license lucide-react v0.577.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const _r=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Vr=_("message-square",_r);/**
102
+ * @license lucide-react v0.577.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const Br=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Hr=_("package",Br);/**
107
+ * @license lucide-react v0.577.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const qr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Ur=_("rotate-cw",qr);/**
112
+ * @license lucide-react v0.577.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const Wr=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Gr=_("send",Wr);/**
117
+ * @license lucide-react v0.577.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const Kr=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Xr=_("server",Kr);/**
122
+ * @license lucide-react v0.577.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const Yr=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qr=_("shield-check",Yr);/**
127
+ * @license lucide-react v0.577.0 - ISC
128
+ *
129
+ * This source code is licensed under the ISC license.
130
+ * See the LICENSE file in the root directory of this source tree.
131
+ */const Zr=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],on=_("terminal",Zr);/**
132
+ * @license lucide-react v0.577.0 - ISC
133
+ *
134
+ * This source code is licensed under the ISC license.
135
+ * See the LICENSE file in the root directory of this source tree.
136
+ */const Jr=[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]],at=_("test-tube-diagonal",Jr);/**
137
+ * @license lucide-react v0.577.0 - ISC
138
+ *
139
+ * This source code is licensed under the ISC license.
140
+ * See the LICENSE file in the root directory of this source tree.
141
+ */const ea=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ln=_("trash-2",ea);/**
142
+ * @license lucide-react v0.577.0 - ISC
143
+ *
144
+ * This source code is licensed under the ISC license.
145
+ * See the LICENSE file in the root directory of this source tree.
146
+ */const ta=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],na=_("triangle-alert",ta);/**
147
+ * @license lucide-react v0.577.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */const ra=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qe=_("x",ra);function $t(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function aa(e){if(Array.isArray(e))return e}function sa(e,t,n){return(t=fa(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oa(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,o,f,i=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(r=o.call(n)).done)&&(i.push(r.value),i.length!==t);l=!0);}catch(p){c=!0,s=p}finally{try{if(!l&&n.return!=null&&(f=n.return(),Object(f)!==f))return}finally{if(c)throw s}}return i}}function ia(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
152
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function It(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function Tt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?It(Object(n),!0).forEach(function(r){sa(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):It(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function la(e,t){if(e==null)return{};var n,r,s=ca(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function ca(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function da(e,t){return aa(e)||oa(e,t)||pa(e,t)||ia()}function ua(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fa(e){var t=ua(e,"string");return typeof t=="symbol"?t:t+""}function pa(e,t){if(e){if(typeof e=="string")return $t(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$t(e,t):void 0}}function ma(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ft(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function At(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ft(Object(n),!0).forEach(function(r){ma(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ft(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ha(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(s,o){return o(s)},r)}}function De(e){return function t(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=e.length?e.apply(this,s):function(){for(var f=arguments.length,i=new Array(f),l=0;l<f;l++)i[l]=arguments[l];return t.apply(n,[].concat(s,i))}}}function Ze(e){return{}.toString.call(e).includes("Object")}function xa(e){return!Object.keys(e).length}function Ae(e){return typeof e=="function"}function ga(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ba(e,t){return Ze(t)||ce("changeType"),Object.keys(t).some(function(n){return!ga(e,n)})&&ce("changeField"),t}function va(e){Ae(e)||ce("selectorType")}function ya(e){Ae(e)||Ze(e)||ce("handlerType"),Ze(e)&&Object.values(e).some(function(t){return!Ae(t)})&&ce("handlersType")}function wa(e){e||ce("initialIsRequired"),Ze(e)||ce("initialType"),xa(e)&&ce("initialContent")}function ja(e,t){throw new Error(e[t]||e.default)}var ka={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},ce=De(ja)(ka),We={changes:ba,selector:va,handler:ya,initial:wa};function Sa(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};We.initial(e),We.handler(t);var n={current:e},r=De(Ca)(n,t),s=De(Na)(n),o=De(We.changes)(e),f=De(za)(n);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(p){return p};return We.selector(c),c(n.current)}function l(c){ha(r,s,o,f)(c)}return[i,l]}function za(e,t){return Ae(t)?t(e.current):t}function Na(e,t){return e.current=At(At({},e.current),t),t}function Ca(e,t,n){return Ae(t)?t(e.current):Object.keys(n).forEach(function(r){var s;return(s=t[r])===null||s===void 0?void 0:s.call(t,e.current[r])}),n}var Pa={create:Sa},Ma={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Ea(e){return function t(){for(var n=this,r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];return s.length>=e.length?e.apply(this,s):function(){for(var f=arguments.length,i=new Array(f),l=0;l<f;l++)i[l]=arguments[l];return t.apply(n,[].concat(s,i))}}}function Ra(e){return{}.toString.call(e).includes("Object")}function La(e){return e||_t("configIsRequired"),Ra(e)||_t("configType"),e.urls?(Oa(),{paths:{vs:e.urls.monacoBase}}):e}function Oa(){console.warn(cn.deprecation)}function Da(e,t){throw new Error(e[t]||e.default)}var cn={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
153
+ You are using deprecated way of configuration.
154
+
155
+ Instead of using
156
+ monaco.config({ urls: { monacoBase: '...' } })
157
+ use
158
+ monaco.config({ paths: { vs: '...' } })
159
+
160
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
161
+ `},_t=Ea(Da)(cn),$a={config:La},Ia=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(s){return n.reduceRight(function(o,f){return f(o)},s)}};function dn(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],dn(e[n],t[n]))}),Tt(Tt({},e),t)}var Ta={type:"cancelation",msg:"operation is manually canceled"};function st(e){var t=!1,n=new Promise(function(r,s){e.then(function(o){return t?s(Ta):r(o)}),e.catch(s)});return n.cancel=function(){return t=!0},n}var Fa=["monaco"],Aa=Pa.create({config:Ma,isInitialized:!1,resolve:null,reject:null,monaco:null}),un=da(Aa,2),Ve=un[0],Je=un[1];function _a(e){var t=$a.config(e),n=t.monaco,r=la(t,Fa);Je(function(s){return{config:dn(s.config,r),monaco:n}})}function Va(){var e=Ve(function(t){var n=t.monaco,r=t.isInitialized,s=t.resolve;return{monaco:n,isInitialized:r,resolve:s}});if(!e.isInitialized){if(Je({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),st(ot);if(window.monaco&&window.monaco.editor)return fn(window.monaco),e.resolve(window.monaco),st(ot);Ia(Ba,qa)(Ua)}return st(ot)}function Ba(e){return document.body.appendChild(e)}function Ha(e){var t=document.createElement("script");return e&&(t.src=e),t}function qa(e){var t=Ve(function(r){var s=r.config,o=r.reject;return{config:s,reject:o}}),n=Ha("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function Ua(){var e=Ve(function(n){var r=n.config,s=n.resolve,o=n.reject;return{config:r,resolve:s,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){var r=n.m||n;fn(r),e.resolve(r)},function(n){e.reject(n)})}function fn(e){Ve().monaco||Je({monaco:e})}function Wa(){return Ve(function(e){var t=e.monaco;return t})}var ot=new Promise(function(e,t){return Je({resolve:e,reject:t})}),pn={config:_a,init:Va,__getMonacoInstance:Wa},Ga={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},it=Ga,Ka={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Xa=Ka;function Ya({children:e}){return ke.createElement("div",{style:Xa.container},e)}var Qa=Ya,Za=Qa;function Ja({width:e,height:t,isEditorReady:n,loading:r,_ref:s,className:o,wrapperProps:f}){return ke.createElement("section",{style:{...it.wrapper,width:e,height:t},...f},!n&&ke.createElement(Za,null,r),ke.createElement("div",{ref:s,style:{...it.fullWidth,...!n&&it.hide},className:o}))}var es=Ja,mn=d.memo(es);function ts(e){d.useEffect(e,[])}var hn=ts;function ns(e,t,n=!0){let r=d.useRef(!0);d.useEffect(r.current||!n?()=>{r.current=!1}:e,t)}var Q=ns;function Te(){}function we(e,t,n,r){return rs(e,r)||as(e,t,n,r)}function rs(e,t){return e.editor.getModel(xn(e,t))}function as(e,t,n,r){return e.editor.createModel(t,n,r?xn(e,r):void 0)}function xn(e,t){return e.Uri.parse(t)}function ss({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:f,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:l=!1,theme:c="light",loading:p="Loading...",options:v={},height:h="100%",width:w="100%",className:j,wrapperProps:g={},beforeMount:y=Te,onMount:x=Te}){let[m,k]=d.useState(!1),[S,b]=d.useState(!0),P=d.useRef(null),N=d.useRef(null),I=d.useRef(null),H=d.useRef(x),L=d.useRef(y),M=d.useRef(!1);hn(()=>{let z=pn.init();return z.then(D=>(N.current=D)&&b(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>P.current?F():z.cancel()}),Q(()=>{if(P.current&&N.current){let z=P.current.getOriginalEditor(),D=we(N.current,e||"",r||n||"text",o||"");D!==z.getModel()&&z.setModel(D)}},[o],m),Q(()=>{if(P.current&&N.current){let z=P.current.getModifiedEditor(),D=we(N.current,t||"",s||n||"text",f||"");D!==z.getModel()&&z.setModel(D)}},[f],m),Q(()=>{let z=P.current.getModifiedEditor();z.getOption(N.current.editor.EditorOption.readOnly)?z.setValue(t||""):t!==z.getValue()&&(z.executeEdits("",[{range:z.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),z.pushUndoStop())},[t],m),Q(()=>{var z,D;(D=(z=P.current)==null?void 0:z.getModel())==null||D.original.setValue(e||"")},[e],m),Q(()=>{let{original:z,modified:D}=P.current.getModel();N.current.editor.setModelLanguage(z,r||n||"text"),N.current.editor.setModelLanguage(D,s||n||"text")},[n,r,s],m),Q(()=>{var z;(z=N.current)==null||z.editor.setTheme(c)},[c],m),Q(()=>{var z;(z=P.current)==null||z.updateOptions(v)},[v],m);let E=d.useCallback(()=>{var W;if(!N.current)return;L.current(N.current);let z=we(N.current,e||"",r||n||"text",o||""),D=we(N.current,t||"",s||n||"text",f||"");(W=P.current)==null||W.setModel({original:z,modified:D})},[n,t,s,e,r,o,f]),V=d.useCallback(()=>{var z;!M.current&&I.current&&(P.current=N.current.editor.createDiffEditor(I.current,{automaticLayout:!0,...v}),E(),(z=N.current)==null||z.editor.setTheme(c),k(!0),M.current=!0)},[v,c,E]);d.useEffect(()=>{m&&H.current(P.current,N.current)},[m]),d.useEffect(()=>{!S&&!m&&V()},[S,m,V]);function F(){var D,W,Z,J;let z=(D=P.current)==null?void 0:D.getModel();i||((W=z==null?void 0:z.original)==null||W.dispose()),l||((Z=z==null?void 0:z.modified)==null||Z.dispose()),(J=P.current)==null||J.dispose()}return ke.createElement(mn,{width:w,height:h,isEditorReady:m,loading:p,_ref:I,className:j,wrapperProps:g})}var os=ss;d.memo(os);function is(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var ls=is,Ge=new Map;function cs({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:s,path:o,theme:f="light",line:i,loading:l="Loading...",options:c={},overrideServices:p={},saveViewState:v=!0,keepCurrentModel:h=!1,width:w="100%",height:j="100%",className:g,wrapperProps:y={},beforeMount:x=Te,onMount:m=Te,onChange:k,onValidate:S=Te}){let[b,P]=d.useState(!1),[N,I]=d.useState(!0),H=d.useRef(null),L=d.useRef(null),M=d.useRef(null),E=d.useRef(m),V=d.useRef(x),F=d.useRef(),z=d.useRef(r),D=ls(o),W=d.useRef(!1),Z=d.useRef(!1);hn(()=>{let O=pn.init();return O.then($=>(H.current=$)&&I(!1)).catch($=>($==null?void 0:$.type)!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>L.current?te():O.cancel()}),Q(()=>{var $,R,G,ee;let O=we(H.current,e||r||"",t||s||"",o||n||"");O!==(($=L.current)==null?void 0:$.getModel())&&(v&&Ge.set(D,(R=L.current)==null?void 0:R.saveViewState()),(G=L.current)==null||G.setModel(O),v&&((ee=L.current)==null||ee.restoreViewState(Ge.get(o))))},[o],b),Q(()=>{var O;(O=L.current)==null||O.updateOptions(c)},[c],b),Q(()=>{!L.current||r===void 0||(L.current.getOption(H.current.editor.EditorOption.readOnly)?L.current.setValue(r):r!==L.current.getValue()&&(Z.current=!0,L.current.executeEdits("",[{range:L.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),L.current.pushUndoStop(),Z.current=!1))},[r],b),Q(()=>{var $,R;let O=($=L.current)==null?void 0:$.getModel();O&&s&&((R=H.current)==null||R.editor.setModelLanguage(O,s))},[s],b),Q(()=>{var O;i!==void 0&&((O=L.current)==null||O.revealLine(i))},[i],b),Q(()=>{var O;(O=H.current)==null||O.editor.setTheme(f)},[f],b);let J=d.useCallback(()=>{var O;if(!(!M.current||!H.current)&&!W.current){V.current(H.current);let $=o||n,R=we(H.current,r||e||"",t||s||"",$||"");L.current=(O=H.current)==null?void 0:O.editor.create(M.current,{model:R,automaticLayout:!0,...c},p),v&&L.current.restoreViewState(Ge.get($)),H.current.editor.setTheme(f),i!==void 0&&L.current.revealLine(i),P(!0),W.current=!0}},[e,t,n,r,s,o,c,p,v,f,i]);d.useEffect(()=>{b&&E.current(L.current,H.current)},[b]),d.useEffect(()=>{!N&&!b&&J()},[N,b,J]),z.current=r,d.useEffect(()=>{var O,$;b&&k&&((O=F.current)==null||O.dispose(),F.current=($=L.current)==null?void 0:$.onDidChangeModelContent(R=>{Z.current||k(L.current.getValue(),R)}))},[b,k]),d.useEffect(()=>{if(b){let O=H.current.editor.onDidChangeMarkers($=>{var G;let R=(G=L.current.getModel())==null?void 0:G.uri;if(R&&$.find(ee=>ee.path===R.path)){let ee=H.current.editor.getModelMarkers({resource:R});S==null||S(ee)}});return()=>{O==null||O.dispose()}}return()=>{}},[b,S]);function te(){var O,$;(O=F.current)==null||O.dispose(),h?v&&Ge.set(o,L.current.saveViewState()):($=L.current.getModel())==null||$.dispose(),L.current.dispose()}return ke.createElement(mn,{width:w,height:j,isEditorReady:b,loading:l,_ref:M,className:g,wrapperProps:y})}var ds=cs,us=d.memo(ds),fs=us;function ps(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function ms(e,t){const n=getComputedStyle(e.ownerDocument.body),r=parseFloat(n.fontSize);return t*r}function hs(e){return e/100*window.innerHeight}function xs(e){return e/100*window.innerWidth}function gs(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function $e({groupSize:e,panelElement:t,styleProp:n}){let r;const[s,o]=gs(n);switch(o){case"%":{r=s/100*e;break}case"px":{r=s;break}case"rem":{r=ms(t,s);break}case"em":{r=ps(t,s);break}case"vh":{r=hs(s);break}case"vw":{r=xs(s);break}}return r}function X(e){return parseFloat(e.toFixed(3))}function Ne({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,s)=>(r+=t==="horizontal"?s.element.offsetWidth:s.element.offsetHeight,r),0)}function ct(e){const{panels:t}=e,n=Ne({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:s,panelConstraints:o}=r;let f=0;if(o.collapsedSize!==void 0){const p=$e({groupSize:n,panelElement:s,styleProp:o.collapsedSize});f=X(p/n*100)}let i;if(o.defaultSize!==void 0){const p=$e({groupSize:n,panelElement:s,styleProp:o.defaultSize});i=X(p/n*100)}let l=0;if(o.minSize!==void 0){const p=$e({groupSize:n,panelElement:s,styleProp:o.minSize});l=X(p/n*100)}let c=100;if(o.maxSize!==void 0){const p=$e({groupSize:n,panelElement:s,styleProp:o.maxSize});c=X(p/n*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:f,collapsible:o.collapsible===!0,defaultSize:i,disabled:o.disabled,minSize:l,maxSize:c,panelId:r.id}})}function B(e,t="Assertion error"){if(!e)throw Error(t)}function dt(e,t){return Array.from(t).sort(e==="horizontal"?bs:vs)}function bs(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function vs(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function gn(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function bn(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function ys({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let s,o=Number.MAX_VALUE;for(const f of t){const{x:i,y:l}=bn(r,f),c=e==="horizontal"?i:l;c<o&&(o=c,s=f)}return B(s,"No rect found"),s}let Ke;function ws(){return Ke===void 0&&(typeof matchMedia=="function"?Ke=!!matchMedia("(pointer:coarse)").matches:Ke=!1),Ke}function vn(e){const{element:t,orientation:n,panels:r,separators:s}=e,o=dt(n,Array.from(t.children).filter(gn).map(j=>({element:j}))).map(({element:j})=>j),f=[];let i=!1,l=!1,c=-1,p=-1,v=0,h,w=[];{let j=-1;for(const g of o)g.hasAttribute("data-panel")&&(j++,g.ariaDisabled===null&&(v++,c===-1&&(c=j),p=j))}if(v>1){let j=-1;for(const g of o)if(g.hasAttribute("data-panel")){j++;const y=r.find(x=>x.element===g);if(y){if(h){const x=h.element.getBoundingClientRect(),m=g.getBoundingClientRect();let k;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),b=n==="horizontal"?new DOMRect(m.left,m.top,0,m.height):new DOMRect(m.left,m.top,m.width,0);switch(w.length){case 0:{k=[S,b];break}case 1:{const P=w[0],N=ys({orientation:n,rects:[x,m],targetRect:P.element.getBoundingClientRect()});k=[P,N===x?b:S];break}default:{k=w;break}}}else w.length?k=w:k=[n==="horizontal"?new DOMRect(x.right,m.top,m.left-x.right,m.height):new DOMRect(m.left,x.bottom,m.width,m.top-x.bottom)];for(const S of k){let b="width"in S?S:S.element.getBoundingClientRect();const P=ws()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(b.width<P){const I=P-b.width;b=new DOMRect(b.x-I/2,b.y,b.width+I,b.height)}if(b.height<P){const I=P-b.height;b=new DOMRect(b.x,b.y-I/2,b.width,b.height+I)}const N=j<=c||j>p;!i&&!N&&f.push({group:e,groupSize:Ne({group:e}),panels:[h,y],separator:"width"in S?void 0:S,rect:b}),i=!1}}l=!1,h=y,w=[]}}else if(g.hasAttribute("data-separator")){g.ariaDisabled!==null&&(i=!0);const y=s.find(x=>x.element===g);y?w.push(y):(h=void 0,w=[])}else l=!0}return f}var le;class yn{constructor(){Rt(this,le,{})}addListener(t,n){const r=Re(this,le)[t];return r===void 0?Re(this,le)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Re(this,le)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let s=!1,o=null;const f=Array.from(r);for(let i=0;i<f.length;i++){const l=f[i];try{l.call(null,n)}catch(c){o===null&&(s=!0,o=c)}}if(s)throw o}}removeAllListeners(){Lt(this,le,{})}removeListener(t,n){const r=Re(this,le)[t];if(r!==void 0){const s=r.indexOf(n);s>=0&&r.splice(s,1)}}}le=new WeakMap;let re=new Map;const wn=new yn;function js(e){re=new Map(re),re.delete(e)}function Vt(e,t){for(const[n]of re)if(n.id===e)return n}function de(e,t){for(const[n,r]of re)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function xe(){return re}function mt(e,t){return wn.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function oe(e,t){const n=re.get(e);re=new Map(re),re.set(e,t),wn.emit("groupChange",{group:e,prev:n,next:t})}function ks(e,t,n){let r,s={x:1/0,y:1/0};for(const o of t){const f=bn(n,o.rect);switch(e){case"horizontal":{f.x<=s.x&&(r=o,s=f);break}case"vertical":{f.y<=s.y&&(r=o,s=f);break}}}return r?{distance:s,hitRegion:r}:void 0}function Ss(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function zs(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:qt(e),b:qt(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();B(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:Ht(Bt(n.a)),b:Ht(Bt(n.b))};if(s.a===s.b){const o=r.childNodes,f={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const l=o[i];if(l===f.a)return 1;if(l===f.b)return-1}}return Math.sign(s.a-s.b)}const Ns=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Cs(e){const t=getComputedStyle(jn(e)??e).display;return t==="flex"||t==="inline-flex"}function Ps(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Cs(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Ns.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function Bt(e){let t=e.length;for(;t--;){const n=e[t];if(B(n,"Missing node"),Ps(n))return n}return null}function Ht(e){return e&&Number(getComputedStyle(e).zIndex)||0}function qt(e){const t=[];for(;e;)t.push(e),e=jn(e);return t}function jn(e){const{parentNode:t}=e;return Ss(t)?t.host:t}function Ms(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Es({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!gn(n)||n.contains(e)||e.contains(n))return!0;if(zs(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Ms(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function ht(e,t){const n=[];return t.forEach((r,s)=>{if(s.disabled)return;const o=vn(s),f=ks(s.orientation,o,{x:e.clientX,y:e.clientY});f&&f.distance.x<=0&&f.distance.y<=0&&Es({groupElement:s.element,hitRegion:f.hitRegion.rect,pointerEventTarget:e.target})&&n.push(f.hitRegion)}),n}function Rs(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function K(e,t,n=0){return Math.abs(X(e)-X(t))<=n}function ne(e,t){return K(e,t)?0:e>t?1:-1}function je({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:s=0,collapsible:o,disabled:f,maxSize:i=100,minSize:l=0}=t;if(f&&!e)return n;if(ne(r,l)<0)if(o){const c=(s+l)/2;ne(r,c)<0?r=s:r=l}else r=l;return r=Math.min(i,r),r=X(r),r}function _e({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:o}){if(K(e,0))return t;const f=o==="imperative-api",i=Object.values(t),l=Object.values(s),c=[...i],[p,v]=r;B(p!=null,"Invalid first pivot index"),B(v!=null,"Invalid second pivot index");let h=0;switch(o){case"keyboard":{{const g=e<0?v:p,y=n[g];B(y,`Panel constraints not found for index ${g}`);const{collapsedSize:x=0,collapsible:m,minSize:k=0}=y;if(m){const S=i[g];if(B(S!=null,`Previous layout not found for panel index ${g}`),K(S,x)){const b=k-S;ne(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const g=e<0?p:v,y=n[g];B(y,`No panel constraints found for index ${g}`);const{collapsedSize:x=0,collapsible:m,minSize:k=0}=y;if(m){const S=i[g];if(B(S!=null,`Previous layout not found for panel index ${g}`),K(S,k)){const b=S-x;ne(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}break}default:{const g=e<0?v:p,y=n[g];B(y,`Panel constraints not found for index ${g}`);const x=i[g],{collapsible:m,collapsedSize:k,minSize:S}=y;if(m&&ne(x,S)<0)if(e>0){const b=S-k,P=b/2,N=x+e;ne(N,S)<0&&(e=ne(e,P)<=0?0:b)}else{const b=S-k,P=100-b/2,N=x-e;ne(N,S)<0&&(e=ne(100+e,P)>0?0:-b)}break}}{const g=e<0?1:-1;let y=e<0?v:p,x=0;for(;;){const k=i[y];B(k!=null,`Previous layout not found for panel index ${y}`);const S=je({overrideDisabledPanels:f,panelConstraints:n[y],prevSize:k,size:100})-k;if(x+=S,y+=g,y<0||y>=n.length)break}const m=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-m:m}{let g=e<0?p:v;for(;g>=0&&g<n.length;){const y=Math.abs(e)-Math.abs(h),x=i[g];B(x!=null,`Previous layout not found for panel index ${g}`);const m=x-y,k=je({overrideDisabledPanels:f,panelConstraints:n[g],prevSize:x,size:m});if(!K(x,k)&&(h+=x-k,c[g]=k,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(Rs(l,c))return s;{const g=e<0?v:p,y=i[g];B(y!=null,`Previous layout not found for panel index ${g}`);const x=y+h,m=je({overrideDisabledPanels:f,panelConstraints:n[g],prevSize:y,size:x});if(c[g]=m,!K(m,x)){let k=x-m,S=e<0?v:p;for(;S>=0&&S<n.length;){const b=c[S];B(b!=null,`Previous layout not found for panel index ${S}`);const P=b+k,N=je({overrideDisabledPanels:f,panelConstraints:n[S],prevSize:b,size:P});if(K(b,N)||(k-=N-b,c[S]=N),K(k,0))break;e>0?S--:S++}}}const w=Object.values(c).reduce((g,y)=>y+g,0);if(!K(w,100,.1))return s;const j=Object.keys(s);return c.reduce((g,y,x)=>(g[j[x]]=y,g),{})}function pe(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||ne(e[n],t[n])!==0)return!1;return!0}function me({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],s=r.reduce((i,l)=>i+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(i=>`${i}%`).join(", ")}`);if(!K(s,100)&&r.length>0)for(let i=0;i<t.length;i++){const l=r[i];B(l!=null,`No layout data found for index ${i}`);const c=100/s*l;r[i]=c}let o=0;for(let i=0;i<t.length;i++){const l=n[i];B(l!=null,`No layout data found for index ${i}`);const c=r[i];B(c!=null,`No layout data found for index ${i}`);const p=je({overrideDisabledPanels:!0,panelConstraints:t[i],prevSize:l,size:c});c!=p&&(o+=c-p,r[i]=p)}if(!K(o,0))for(let i=0;i<t.length;i++){const l=r[i];B(l!=null,`No layout data found for index ${i}`);const c=l+o,p=je({overrideDisabledPanels:!0,panelConstraints:t[i],prevSize:l,size:c});if(l!==p&&(o-=p-l,r[i]=p,K(o,0)))break}const f=Object.keys(e);return r.reduce((i,l,c)=>(i[f[c]]=l,i),{})}function kn({groupId:e,panelId:t}){const n=()=>{const i=xe();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:p,layout:v,groupSize:h,separatorToPanels:w}]of i)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:p,group:l,groupSize:h,layout:v,separatorToPanels:w};throw Error(`Group ${e} not found`)},r=()=>{const i=n().derivedPanelConstraints.find(l=>l.panelId===t);if(i!==void 0)return i;throw Error(`Panel constraints not found for Panel ${t}`)},s=()=>{const i=n().group.panels.find(l=>l.id===t);if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const i=n().layout[t];if(i!==void 0)return i;throw Error(`Layout not found for Panel ${t}`)},f=i=>{const l=o();if(i===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:p,group:v,groupSize:h,layout:w,separatorToPanels:j}=n(),g=v.panels.findIndex(k=>k.id===t),y=g===v.panels.length-1,x=_e({delta:y?l-i:i-l,initialLayout:w,panelConstraints:p,pivotIndices:y?[g-1,g]:[g,g+1],prevLayout:w,trigger:"imperative-api"}),m=me({layout:x,panelConstraints:p});pe(w,m)||oe(v,{defaultLayoutDeferred:c,derivedPanelConstraints:p,groupSize:h,layout:m,separatorToPanels:j})};return{collapse:()=>{const{collapsible:i,collapsedSize:l}=r(),{mutableValues:c}=s(),p=o();i&&p!==l&&(c.expandToSize=p,f(l))},expand:()=>{const{collapsible:i,collapsedSize:l,minSize:c}=r(),{mutableValues:p}=s(),v=o();if(i&&v===l){let h=p.expandToSize??c;h===0&&(h=1),f(h)}},getSize:()=>{const{group:i}=n(),l=o(),{element:c}=s(),p=i.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:p}},isCollapsed:()=>{const{collapsible:i,collapsedSize:l}=r(),c=o();return i&&K(l,c)},resize:i=>{const{group:l}=n(),{element:c}=s(),p=Ne({group:l}),v=$e({groupSize:p,panelElement:c,styleProp:i}),h=X(v/p*100);f(h)}}}function Ut(e){if(e.defaultPrevented)return;const t=xe();ht(e,t).forEach(n=>{if(n.separator){const r=n.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(r){const s=r.panelConstraints.defaultSize,o=kn({groupId:n.group.id,panelId:r.id});o&&s!==void 0&&(o.resize(s),e.preventDefault())}}})}function Ye(e){const t=xe();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function Sn({groupId:e}){const t=()=>{const n=xe();for(const[r,s]of n)if(r.id===e)return{group:r,...s};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:s,group:o,groupSize:f,layout:i,separatorToPanels:l}=t(),c=me({layout:n,panelConstraints:s});return r?i:(pe(i,c)||oe(o,{defaultLayoutDeferred:r,derivedPanelConstraints:s,groupSize:f,layout:c,separatorToPanels:l}),c)}}}function fe(e,t){const n=Ye(e),r=de(n.id,!0),s=n.separators.find(p=>p.element===e);B(s,"Matching separator not found");const o=r.separatorToPanels.get(s);B(o,"Matching panels not found");const f=o.map(p=>n.panels.indexOf(p)),i=Sn({groupId:n.id}).getLayout(),l=_e({delta:t,initialLayout:i,panelConstraints:r.derivedPanelConstraints,pivotIndices:f,prevLayout:i,trigger:"keyboard"}),c=me({layout:l,panelConstraints:r.derivedPanelConstraints});pe(i,c)||oe(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels})}function Wt(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Ye(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&fe(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&fe(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&fe(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&fe(t,-5);break}case"End":{e.preventDefault(),fe(t,100);break}case"Enter":{e.preventDefault();const r=Ye(t),s=de(r.id,!0),{derivedPanelConstraints:o,layout:f,separatorToPanels:i}=s,l=r.separators.find(h=>h.element===t);B(l,"Matching separator not found");const c=i.get(l);B(c,"Matching panels not found");const p=c[0],v=o.find(h=>h.panelId===p.id);if(B(v,"Panel metadata not found"),v.collapsible){const h=f[p.id],w=v.collapsedSize===h?r.mutableState.expandedPanelSizes[p.id]??v.minSize:v.collapsedSize;fe(t,w-h)}break}case"F6":{e.preventDefault();const r=Ye(t).separators.map(f=>f.element),s=Array.from(r).findIndex(f=>f===e.currentTarget);B(s!==null,"Index not found");const o=e.shiftKey?s>0?s-1:r.length-1:s+1<r.length?s+1:0;r[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),fe(t,-100);break}}}let Se={cursorFlags:0,state:"inactive"};const xt=new yn;function he(){return Se}function Ls(e){return xt.addListener("change",e)}function Os(e){const t=Se,n={...Se};n.cursorFlags=e,Se=n,xt.emit("change",{prev:t,next:n})}function ze(e){const t=Se;Se=e,xt.emit("change",{prev:t,next:e})}function Gt(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=xe(),n=ht(e,t),r=new Map;let s=!1;n.forEach(o=>{o.separator&&(s||(s=!0,o.separator.element.focus({preventScroll:!0})));const f=t.get(o.group);f&&r.set(o.group,f.layout)}),ze({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}const Ds=e=>e,lt=()=>{},zn=1,Nn=2,Cn=4,Pn=8,Kt=3,Xt=12;let Xe;function Yt(){return Xe===void 0&&(Xe=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Xe=!0)),Xe}function $s({cursorFlags:e,groups:t,state:n}){let r=0,s=0;switch(n){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{r++;break}case"vertical":{s++;break}}})}if(!(r===0&&s===0)){switch(n){case"active":{if(e&&Yt()){const o=(e&zn)!==0,f=(e&Nn)!==0,i=(e&Cn)!==0,l=(e&Pn)!==0;if(o)return i?"se-resize":l?"ne-resize":"e-resize";if(f)return i?"sw-resize":l?"nw-resize":"w-resize";if(i)return"s-resize";if(l)return"n-resize"}break}}return Yt()?r>0&&s>0?"move":r>0?"ew-resize":"ns-resize":r>0&&s>0?"grab":r>0?"col-resize":"row-resize"}}const Qt=new WeakMap;function gt(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Qt.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(n));const r=he();switch(r.state){case"active":case"hover":{const s=$s({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(f=>f.group),state:r.state}),o=`*, *:hover {cursor: ${s} !important; }`;if(t===o)return;t=o,s?n.cssRules.length===0?n.insertRule(o):n.replaceSync(o):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Qt.set(e,{prevStyle:t,styleSheet:n})}function Mn({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:s,pointerDownAtPoint:o,prevCursorFlags:f}){let i=0;n.forEach(c=>{const{group:p,groupSize:v}=c,{orientation:h,panels:w}=p,{disableCursor:j}=p.mutableState;let g=0;o?h==="horizontal"?g=(t.clientX-o.x)/v*100:g=(t.clientY-o.y)/v*100:h==="horizontal"?g=t.clientX<0?-100:100:g=t.clientY<0?-100:100;const y=r.get(p),x=s.get(p);if(!y||!x)return;const{defaultLayoutDeferred:m,derivedPanelConstraints:k,groupSize:S,layout:b,separatorToPanels:P}=x;if(k&&b&&P){const N=_e({delta:g,initialLayout:y,panelConstraints:k,pivotIndices:c.panels.map(I=>w.indexOf(I)),prevLayout:b,trigger:"mouse-or-touch"});if(pe(N,b)){if(g!==0&&!j)switch(h){case"horizontal":{i|=g<0?zn:Nn;break}case"vertical":{i|=g<0?Cn:Pn;break}}}else oe(c.group,{defaultLayoutDeferred:m,derivedPanelConstraints:k,groupSize:S,layout:N,separatorToPanels:P})}});let l=0;t.movementX===0?l|=f&Kt:l|=i&Kt,t.movementY===0?l|=f&Xt:l|=i&Xt,Os(l),gt(e)}function Zt(e){const t=xe(),n=he();switch(n.state){case"active":Mn({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function Jt(e){if(e.defaultPrevented)return;const t=he(),n=xe();switch(t.state){case"active":{if(e.buttons===0){ze({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(r=>{const s=de(r.group.id,!0);oe(r.group,s)});return}Mn({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const r=ht(e,n);r.length===0?t.state!=="inactive"&&ze({cursorFlags:0,state:"inactive"}):ze({cursorFlags:0,hitRegions:r,state:"hover"}),gt(e.currentTarget);break}}}function en(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(he().state){case"hover":ze({cursorFlags:0,state:"inactive"})}}function tn(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=he();switch(t.state){case"active":ze({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(gt(e.currentTarget),t.hitRegions.forEach(n=>{const r=de(n.group.id,!0);oe(n.group,r)}),e.preventDefault())}}function nn(e){let t=0,n=0;const r={};for(const o of e)if(o.defaultSize!==void 0){t++;const f=X(o.defaultSize);n+=f,r[o.panelId]=f}else r[o.panelId]=void 0;const s=e.length-t;if(s!==0){const o=X((100-n)/s);for(const f of e)f.defaultSize===void 0&&(r[f.panelId]=o)}return r}function Is(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const s=Ne({group:e}),o=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,f=r.mutableValues.prevSize,i={asPercentage:X(o/s*100),inPixels:o};r.mutableValues.prevSize=i,r.onResize(i,r.id,f)}function Ts(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Fs({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let s=0,o=0,f=!1;const i=new Map,l=[];for(const v of e.panels){const h=r[v.id]??0;switch(v.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{f=!0;const w=h/100*n,j=X(w/t*100);i.set(v.id,j),s+=j;break}case"preserve-relative-size":default:{l.push(v.id),o+=h;break}}}if(!f||l.length===0)return r;const c=100-s,p={...r};if(i.forEach((v,h)=>{p[h]=v}),o>0)for(const v of l){const h=r[v]??0;p[v]=X(h/o*c)}else{const v=X(c/l.length);for(const h of l)p[h]=v}return p}function As(e,t){const n=e.map(s=>s.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n)if(!r.includes(s))return!1;return!0}const ye=new Map;function _s(e){let t=!0;B(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,s=new Set,o=new n(j=>{for(const g of j){const{borderBoxSize:y,target:x}=g;if(x===e.element){if(t){const m=Ne({group:e});if(m===0)return;const k=de(e.id);if(!k)return;const S=ct(e),b=k.defaultLayoutDeferred?nn(S):k.layout,P=Fs({group:e,nextGroupSize:m,prevGroupSize:k.groupSize,prevLayout:b}),N=me({layout:P,panelConstraints:S});if(!k.defaultLayoutDeferred&&pe(k.layout,N)&&Ts(k.derivedPanelConstraints,S)&&k.groupSize===m)return;oe(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:m,layout:N,separatorToPanels:k.separatorToPanels})}}else Is(e,x,y)}});o.observe(e.element),e.panels.forEach(j=>{B(!r.has(j.id),`Panel ids must be unique; id "${j.id}" was used more than once`),r.add(j.id),j.onResize&&o.observe(j.element)});const f=Ne({group:e}),i=ct(e),l=e.panels.map(({id:j})=>j).join(",");let c=e.mutableState.defaultLayout;c&&(As(e.panels,c)||(c=void 0));const p=e.mutableState.layouts[l]??c??nn(i),v=me({layout:p,panelConstraints:i}),h=e.element.ownerDocument;ye.set(h,(ye.get(h)??0)+1);const w=new Map;return vn(e).forEach(j=>{j.separator&&w.set(j.separator,j.panels)}),oe(e,{defaultLayoutDeferred:f===0,derivedPanelConstraints:i,groupSize:f,layout:v,separatorToPanels:w}),e.separators.forEach(j=>{B(!s.has(j.id),`Separator ids must be unique; id "${j.id}" was used more than once`),s.add(j.id),j.element.addEventListener("keydown",Wt)}),ye.get(h)===1&&(h.addEventListener("dblclick",Ut,!0),h.addEventListener("pointerdown",Gt,!0),h.addEventListener("pointerleave",Zt),h.addEventListener("pointermove",Jt),h.addEventListener("pointerout",en),h.addEventListener("pointerup",tn,!0)),function(){t=!1,ye.set(h,Math.max(0,(ye.get(h)??0)-1)),js(e),e.separators.forEach(j=>{j.element.removeEventListener("keydown",Wt)}),ye.get(h)||(h.removeEventListener("dblclick",Ut,!0),h.removeEventListener("pointerdown",Gt,!0),h.removeEventListener("pointerleave",Zt),h.removeEventListener("pointermove",Jt),h.removeEventListener("pointerout",en),h.removeEventListener("pointerup",tn,!0)),o.disconnect()}}function Vs(){const[e,t]=d.useState({}),n=d.useCallback(()=>t({}),[]);return[e,n]}function bt(e){const t=d.useId();return`${e??t}`}const ge=typeof window<"u"?d.useLayoutEffect:d.useEffect;function Fe(e){const t=d.useRef(e);return ge(()=>{t.current=e},[e]),d.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function vt(...e){return Fe(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function yt(e){const t=d.useRef({...e});return ge(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const En=d.createContext(null);function Bs(e,t){const n=d.useRef({getLayout:()=>({}),setLayout:Ds});d.useImperativeHandle(t,()=>n.current,[]),ge(()=>{Object.assign(n.current,Sn({groupId:e}))})}function ut({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:s,elementRef:o,groupRef:f,id:i,onLayoutChange:l,onLayoutChanged:c,orientation:p="horizontal",resizeTargetMinimumSize:v={coarse:20,fine:10},style:h,...w}){const j=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),g=Fe(M=>{pe(j.current.onLayoutChange,M)||(j.current.onLayoutChange=M,l==null||l(M))}),y=Fe(M=>{pe(j.current.onLayoutChanged,M)||(j.current.onLayoutChanged=M,c==null||c(M))}),x=bt(i),m=d.useRef(null),[k,S]=Vs(),b=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:v,separators:[]}),P=vt(m,o);Bs(x,f);const N=Fe((M,E)=>{const V=he(),F=Vt(M),z=de(M);if(z){let D=!1;switch(V.state){case"active":{D=V.hitRegions.some(W=>W.group===F);break}}return{flexGrow:z.layout[E]??1,pointerEvents:D?"none":void 0}}return{flexGrow:(n==null?void 0:n[E])??1}}),I=yt({defaultLayout:n,disableCursor:r}),H=d.useMemo(()=>({get disableCursor(){return!!I.disableCursor},getPanelStyles:N,id:x,orientation:p,registerPanel:M=>{const E=b.current;return E.panels=dt(p,[...E.panels,M]),S(),()=>{E.panels=E.panels.filter(V=>V!==M),S()}},registerSeparator:M=>{const E=b.current;return E.separators=dt(p,[...E.separators,M]),S(),()=>{E.separators=E.separators.filter(V=>V!==M),S()}},togglePanelDisabled:(M,E)=>{const V=b.current.panels.find(D=>D.id===M);V&&(V.panelConstraints.disabled=E);const F=Vt(x),z=de(x);F&&z&&oe(F,{...z,derivedPanelConstraints:ct(F)})},toggleSeparatorDisabled:(M,E)=>{const V=b.current.separators.find(F=>F.id===M);V&&(V.disabled=E)}}),[N,x,S,p,I]),L=d.useRef(null);return ge(()=>{const M=m.current;if(M===null)return;const E=b.current;let V;if(I.defaultLayout!==void 0&&Object.keys(I.defaultLayout).length===E.panels.length){V={};for(const te of E.panels){const O=I.defaultLayout[te.id];O!==void 0&&(V[te.id]=O)}}const F={disabled:!!s,element:M,id:x,mutableState:{defaultLayout:V,disableCursor:!!I.disableCursor,expandedPanelSizes:b.current.lastExpandedPanelSizes,layouts:b.current.layouts},orientation:p,panels:E.panels,resizeTargetMinimumSize:E.resizeTargetMinimumSize,separators:E.separators};L.current=F;const z=_s(F),{defaultLayoutDeferred:D,derivedPanelConstraints:W,layout:Z}=de(F.id,!0);!D&&W.length>0&&(g(Z),y(Z));const J=mt(x,te=>{const{defaultLayoutDeferred:O,derivedPanelConstraints:$,layout:R}=te.next;if(O||$.length===0)return;const G=F.panels.map(({id:Y})=>Y).join(",");F.mutableState.layouts[G]=R,$.forEach(Y=>{if(Y.collapsible){const{layout:Ce}=te.prev??{};if(Ce){const be=K(Y.collapsedSize,R[Y.panelId]),et=K(Y.collapsedSize,Ce[Y.panelId]);be&&!et&&(F.mutableState.expandedPanelSizes[Y.panelId]=Ce[Y.panelId])}}});const ee=he().state!=="active";g(R),ee&&y(R)});return()=>{L.current=null,z(),J()}},[s,x,y,g,p,k,I]),d.useEffect(()=>{const M=L.current;M&&(M.mutableState.defaultLayout=n,M.mutableState.disableCursor=!!r)}),a.jsx(En.Provider,{value:H,children:a.jsx("div",{...w,className:t,"data-group":!0,"data-testid":x,id:x,ref:P,style:{height:"100%",width:"100%",overflow:"hidden",...h,display:"flex",flexDirection:p==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:p==="horizontal"?"pan-y":"pan-x"},children:e})})}ut.displayName="Group";function wt(){const e=d.useContext(En);return B(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Hs(e,t){const{id:n}=wt(),r=d.useRef({collapse:lt,expand:lt,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:lt});d.useImperativeHandle(t,()=>r.current,[]),ge(()=>{Object.assign(r.current,kn({groupId:n,panelId:e}))})}function Ie({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:s,disabled:o,elementRef:f,groupResizeBehavior:i="preserve-relative-size",id:l,maxSize:c="100%",minSize:p="0%",onResize:v,panelRef:h,style:w,...j}){const g=!!l,y=bt(l),x=yt({disabled:o}),m=d.useRef(null),k=vt(m,f),{getPanelStyles:S,id:b,orientation:P,registerPanel:N,togglePanelDisabled:I}=wt(),H=v!==null,L=Fe((E,V,F)=>{v==null||v(E,l,F)});ge(()=>{const E=m.current;if(E!==null){const V={element:E,id:y,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:H?L:void 0,panelConstraints:{groupResizeBehavior:i,collapsedSize:n,collapsible:r,defaultSize:s,disabled:x.disabled,maxSize:c,minSize:p}};return N(V)}},[i,n,r,s,H,y,g,c,p,L,N,x]),d.useEffect(()=>{I(y,!!o)},[o,y,I]),Hs(y,h);const M=d.useSyncExternalStore(E=>mt(b,E),()=>JSON.stringify(S(b,y)),()=>JSON.stringify(S(b,y)));return a.jsx("div",{...j,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":y,id:y,ref:k,style:{...qs,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(M)},children:a.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...w,touchAction:P==="horizontal"?"pan-y":"pan-x"},children:e})})}Ie.displayName="Panel";const qs={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Us({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let s,o;const f=e[n],i=t.find(l=>l.panelId===n);if(i){const l=i.maxSize,c=i.collapsible?i.collapsedSize:i.minSize,p=[r,r+1];o=me({layout:_e({delta:c-f,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n],s=me({layout:_e({delta:l-f,initialLayout:e,panelConstraints:t,pivotIndices:p,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:s,valueMin:o,valueNow:f}}function ft({children:e,className:t,disabled:n,elementRef:r,id:s,style:o,...f}){const i=bt(s),l=yt({disabled:n}),[c,p]=d.useState({}),[v,h]=d.useState("inactive"),w=d.useRef(null),j=vt(w,r),{disableCursor:g,id:y,orientation:x,registerSeparator:m,toggleSeparatorDisabled:k}=wt(),S=x==="horizontal"?"vertical":"horizontal";ge(()=>{const P=w.current;if(P!==null){const N={disabled:l.disabled,element:P,id:i},I=m(N),H=Ls(M=>{h(M.next.state!=="inactive"&&M.next.hitRegions.some(E=>E.separator===N)?M.next.state:"inactive")}),L=mt(y,M=>{const{derivedPanelConstraints:E,layout:V,separatorToPanels:F}=M.next,z=F.get(N);if(z){const D=z[0],W=z.indexOf(D);p(Us({layout:V,panelConstraints:E,panelId:D.id,panelIndex:W}))}});return()=>{H(),L(),I()}}},[y,i,m,l]),d.useEffect(()=>{k(i,!!n)},[n,i,k]);let b;return n&&!g&&(b="not-allowed"),a.jsx("div",{...f,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":S,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":n?"disabled":v,"data-testid":i,id:i,ref:j,role:"separator",style:{flexBasis:"auto",cursor:b,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}ft.displayName="Separator";const Ws={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Gs={sm:"w-7 h-7",md:"w-8 h-8"},Ks={sm:14,md:16};function ie({icon:e,label:t,size:n="md",variant:r="ghost",onClick:s,className:o="",disabled:f=!1,title:i}){return a.jsx("button",{type:"button","aria-label":t,title:i??t,disabled:f,onClick:s,className:["inline-flex items-center justify-center rounded-btn transition-colors",Ws[r],Gs[n],f?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:a.jsx(e,{size:Ks[n]})})}function Xs({x:e,y:t,items:n,onClose:r}){const[s,o]=d.useState(0),f=d.useRef(null),i=d.useRef([]);d.useEffect(()=>{var c;(c=i.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=p=>{f.current&&!f.current.contains(p.target)&&r()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]);const l=d.useCallback(c=>{var p,v;switch(c.key){case"Escape":c.preventDefault(),r();break;case"ArrowDown":c.preventDefault(),o(h=>{var j;const w=(h+1)%n.length;return(j=i.current[w])==null||j.focus(),w});break;case"ArrowUp":c.preventDefault(),o(h=>{var j;const w=(h-1+n.length)%n.length;return(j=i.current[w])==null||j.focus(),w});break;case"Home":c.preventDefault(),o(0),(p=i.current[0])==null||p.focus();break;case"End":c.preventDefault(),o(n.length-1),(v=i.current[n.length-1])==null||v.focus();break}},[n.length,r]);return a.jsx("div",{ref:f,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:l,children:n.map((c,p)=>{const v=c.icon,h=c.variant==="danger";return a.jsxs("button",{ref:w=>{i.current[p]=w},role:"menuitem",tabIndex:s===p?0:-1,onClick:()=>{c.onClick(),r()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",h?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[a.jsx(v,{size:14}),c.label]},c.label)})})}function Ys({sessionId:e,defaultMode:t}){const[n,r]=d.useState([]),[s,o]=d.useState(""),[f,i]=d.useState(t||"quick"),[l,c]=d.useState(!1),p=d.useRef(null),v=d.useRef(null);d.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[n]);const h=async()=>{var g;const w=s.trim();if(!w||l)return;const j={role:"user",content:w,timestamp:new Date().toISOString()};r(y=>[...y,j]),o(""),c(!0);try{const{task_id:y}=await U.chatStart(e,w,f);let x;const m=150;let k=0;do await new Promise(b=>setTimeout(b,2e3)),x=await U.chatPoll(e,y),k++,k>=m&&(x={complete:!0,output_lines:["Build timed out after 5 minutes."],files_changed:[],returncode:1});while(!x.complete);const S={role:"system",content:x.output_lines.join(`
162
+ `)||"Done.",timestamp:new Date().toISOString(),filesChanged:x.files_changed};r(b=>[...b,S])}catch(y){const x={role:"system",content:`Error: ${y instanceof Error?y.message:"Request failed"}`,timestamp:new Date().toISOString()};r(m=>[...m,x])}finally{c(!1),(g=v.current)==null||g.focus()}};return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&a.jsx("div",{className:"text-xs text-muted text-center py-8",children:"Send a message to iterate on your project."}),n.map((w,j)=>a.jsx("div",{className:`flex ${w.role==="user"?"justify-end":"justify-start"}`,children:a.jsxs("div",{className:`max-w-[80%] rounded-lg px-3 py-2 text-xs ${w.role==="user"?"bg-primary/10 text-ink":"bg-hover text-ink"}`,children:[a.jsx("p",{className:"whitespace-pre-wrap",children:w.content}),w.filesChanged&&w.filesChanged.length>0&&a.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[a.jsx("span",{className:"text-xs text-muted font-semibold uppercase",children:"Files changed:"}),a.jsx("ul",{className:"mt-1 space-y-0.5",children:w.filesChanged.map((g,y)=>a.jsx("li",{className:"text-xs font-mono text-muted",children:g},y))})]})]})},j)),l&&a.jsx("div",{className:"flex justify-start",children:a.jsxs("div",{className:"bg-hover text-ink rounded-lg px-3 py-2 text-xs",children:["Building",a.jsx("span",{className:"animate-pulse",children:"..."})]})})]}),a.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[a.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(w=>a.jsx("button",{onClick:()=>i(w),className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${f===w?"bg-primary text-white":"text-muted hover:text-ink"}`,children:w},w))}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{ref:v,type:"text",value:s,onChange:w=>o(w.target.value),onKeyDown:w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),h())},placeholder:"Ask AI to modify your project...",className:"flex-1 px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",disabled:l}),a.jsx(Le,{size:"sm",icon:Gr,onClick:h,disabled:l||!s.trim(),"aria-label":"Send message",children:"Send"})]})]})]})}const rn=[{id:"build",label:"Build Log",icon:on},{id:"agents",label:"Agents",icon:ur},{id:"quality",label:"Quality",icon:Qr},{id:"chat",label:"AI Chat",icon:Vr}];function Qs({status:e}){switch(e){case"pass":return a.jsx(ar,{size:14,className:"text-success"});case"fail":return a.jsx(Qe,{size:14,className:"text-danger"});default:return a.jsx(rr,{size:14,className:"text-muted"})}}function Zs({agents:e}){return!e||e.length===0?a.jsx("div",{className:"p-4 text-xs text-muted",children:"No agents running."}):a.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[a.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),a.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),a.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),a.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function Js({checklist:e}){return!e||!e.items||e.items.length===0?a.jsx("div",{className:"p-4 text-xs text-muted",children:"No quality gate data available."}):a.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[a.jsx("span",{children:"Gate"}),a.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[a.jsx(Qs,{status:t.status}),a.jsx("span",{className:"text-ink",children:t.label}),t.details&&a.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function eo({logs:e,logsLoading:t,agents:n,checklist:r,sessionId:s,subscribe:o,buildMode:f}){var c;const[i,l]=d.useState("build");return a.jsxs("div",{className:"h-full flex flex-col bg-card",children:[a.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:rn.map(p=>{const v=p.icon,h=i===p.id;return a.jsxs("button",{role:"tab","aria-selected":h,onClick:()=>l(p.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${h?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[a.jsx(v,{size:14}),p.label]},p.id)})}),a.jsxs("div",{role:"tabpanel","aria-label":(c=rn.find(p=>p.id===i))==null?void 0:c.label,className:"flex-1 min-h-0 overflow-hidden",children:[i==="build"&&a.jsx(Zn,{logs:e,loading:t,subscribe:o}),i==="agents"&&a.jsx(Zs,{agents:n}),i==="quality"&&a.jsx(Js,{checklist:r}),i==="chat"&&a.jsx(Ys,{sessionId:s,defaultMode:f})]})]})}function pt(e,t,n){var o;if(t==="directory")return n?a.jsx(sn,{size:14}):a.jsx(Tr,{size:14});const r=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:a.jsx(se,{size:14,className:"text-yellow-600"}),ts:a.jsx(se,{size:14,className:"text-blue-500"}),tsx:a.jsx(se,{size:14,className:"text-blue-400"}),jsx:a.jsx(se,{size:14,className:"text-yellow-500"}),py:a.jsx(se,{size:14,className:"text-green-600"}),html:a.jsx(zr,{size:14,className:"text-orange-500"}),css:a.jsx(Er,{size:14,className:"text-purple-500"}),json:a.jsx(jr,{size:14,className:"text-green-500"}),md:a.jsx(an,{size:14,className:"text-muted"}),go:a.jsx(se,{size:14,className:"text-cyan-600"}),rs:a.jsx(se,{size:14,className:"text-orange-600"}),rb:a.jsx(se,{size:14,className:"text-red-500"}),sh:a.jsx(se,{size:14,className:"text-green-600"})}[r]||a.jsx(Lr,{size:14})}function to(e){var s;const t=((s=e.split(".").pop())==null?void 0:s.toLowerCase())||"",n={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},r=e.toLowerCase();return r==="dockerfile"?"dockerfile":r==="makefile"?"makefile":n[t]||"plaintext"}function Rn(e,t){for(const n of e){if(n.path===t)return n.size;if(n.children){const r=Rn(n.children,t);if(r!==void 0)return r}}}function Ln(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function On({nodes:e,selectedPath:t,onSelect:n,onDelete:r,onContextMenu:s,depth:o=0}){const[f,i]=d.useState(()=>{const l=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>l.add(c.path)),l});return a.jsx("div",{role:o===0?"tree":"group",children:e.map(l=>{const c=l.type==="directory",p=f.has(l.path),v=l.path===t;return a.jsxs("div",{className:"group/file",children:[a.jsxs("button",{role:"treeitem","aria-label":l.name,"aria-selected":v,...c?{"aria-expanded":p}:{},onContextMenu:h=>{h.preventDefault(),s==null||s(h,l.path,l.name,l.type)},onClick:()=>{c?i(h=>{const w=new Set(h);return w.has(l.path)?w.delete(l.path):w.add(l.path),w}):n(l.path,l.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${v?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?a.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:p?a.jsx(pr,{size:14}):a.jsx(hr,{size:14})}):a.jsx("span",{className:"w-3 flex-shrink-0"}),a.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:pt(l.name,l.type,p)}),a.jsxs("span",{className:"truncate",children:[l.name,c?"/":""]}),!c&&l.size!=null&&l.size>0&&a.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ln(l.size)}),!c&&r&&a.jsx("span",{role:"button",tabIndex:-1,onClick:h=>{h.stopPropagation(),r(l.path,l.name)},onKeyDown:h=>{h.key==="Enter"&&(h.stopPropagation(),r(l.path,l.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:a.jsx(Qe,{size:12})})]}),c&&p&&l.children&&a.jsx(On,{nodes:l.children,selectedPath:t,onSelect:n,onDelete:r,onContextMenu:s,depth:o+1})]},l.path)})})}function Dn(e,t=""){const n=[];for(const r of e)r.type==="file"&&n.push({path:r.path,name:r.name}),r.children&&n.push(...Dn(r.children,r.path+"/"));return n}function no(){const[e,t]=d.useState({}),[n,r]=d.useState(""),[s,o]=d.useState(""),[f,i]=d.useState(!0),[l,c]=d.useState(null),[p,v]=d.useState(new Set),h=d.useCallback(async()=>{try{const x=await U.getSecrets();t(x)}catch{}i(!1)},[]);d.useEffect(()=>{h()},[h]);const w=async()=>{const x=n.trim();if(x){if(!/^[A-Z_][A-Z0-9_]*$/.test(x)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await U.setSecret(x,s),r(""),o(""),await h()}catch(m){c(m instanceof Error?m.message:"Failed to set secret")}}},j=async x=>{if(window.confirm(`Delete secret "${x}"?`))try{await U.deleteSecret(x),await h()}catch(m){c(m instanceof Error?m.message:"Failed to delete secret")}},g=x=>{v(m=>{const k=new Set(m);return k.has(x)?k.delete(x):k.add(x),k})},y=Object.keys(e);return f?a.jsx("div",{className:"p-6",children:a.jsx("div",{className:"text-sm text-muted animate-pulse",children:"Loading secrets..."})}):a.jsx("div",{className:"h-full flex flex-col",children:a.jsxs("div",{className:"p-6 overflow-y-auto",children:[a.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),a.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[a.jsx(na,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),a.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),y.length>0&&a.jsx("div",{className:"card mb-6",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-border",children:[a.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),a.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),a.jsx("th",{className:"w-20 px-4 py-2"})]})}),a.jsx("tbody",{children:y.map(x=>a.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[a.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:x}),a.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("span",{children:p.has(x)?e[x]:"***"}),a.jsx("button",{onClick:()=>g(x),className:"text-muted hover:text-ink transition-colors",title:p.has(x)?"Hide value":"Show value",children:p.has(x)?a.jsx(vr,{size:14}):a.jsx(Oe,{size:14})})]})}),a.jsx("td",{className:"px-4 py-2.5 text-right",children:a.jsx("button",{onClick:()=>j(x),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:a.jsx(ln,{size:14})})})]},x))})]})}),y.length===0&&a.jsx("div",{className:"card p-4 mb-6",children:a.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),a.jsxs("div",{className:"card p-4",children:[a.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),l&&a.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:l}),a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),a.jsx("input",{type:"text",value:n,onChange:x=>r(x.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),a.jsx("input",{type:"password",value:s,onChange:x=>o(x.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),a.jsxs("button",{onClick:w,disabled:!n.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[a.jsx(nr,{size:14}),"Add"]})]})]})]})})}function ro({session:e,onClose:t}){var Pt;const[n,r]=d.useState(null),[s,o]=d.useState(""),[f,i]=d.useState(null),[l,c]=d.useState(null),[p,v]=d.useState(!1),[h,w]=d.useState("code"),[j,g]=d.useState(!1),[y,x]=d.useState(!1),[m,k]=d.useState(e),S=d.useRef(null),[b,P]=d.useState([]),[N,I]=d.useState(!1),[H,L]=d.useState(""),M=d.useRef(null),E=d.useRef(null),[V,F]=d.useState(0),[z,D]=d.useState(null),[W,Z]=d.useState("standard"),[J,te]=d.useState("claude"),[O,$]=d.useState(null),[R,G]=d.useState(null),[ee,Y]=d.useState(!1),[Ce,be]=d.useState(!1),et=d.useCallback(async()=>{try{await U.stopSession(),Y(!1),be(!1)}catch{}},[]),$n=d.useCallback(async()=>{try{await U.pauseSession(),be(!0)}catch{}},[]),In=d.useCallback(async()=>{try{await U.resumeSession(),be(!1)}catch{}},[]);d.useEffect(()=>{const u=async()=>{try{const T=await U.getStatus();Y(T.running),be(T.paused),T.provider&&te(T.provider)}catch{}};u();const C=setInterval(u,1e4);return()=>clearInterval(C)},[]),d.useEffect(()=>{if(!(R!=null&&R.loading))return;const u=setInterval(()=>{G(C=>C?{...C,elapsed:Math.floor((Date.now()-C.startTime)/1e3)}:null)},1e3);return()=>clearInterval(u)},[R==null?void 0:R.loading]);const[A,Tn]=d.useState(null);d.useEffect(()=>{U.getPreviewInfo(m.id).then(Tn).catch(()=>{})},[m.id]);const Fn=(A==null?void 0:A.preview_url)||`/api/sessions/${encodeURIComponent(m.id)}/preview/index.html`,[Be,jt]=d.useState([]),[ae,He]=d.useState(0);d.useEffect(()=>{A!=null&&A.preview_url&&(jt([A.preview_url]),He(0))},[A==null?void 0:A.preview_url]);const Pe=Be[ae]||Fn,[kt,St]=d.useState(Pe),ve=d.useCallback(async()=>{try{const u=await U.getSessionDetail(m.id);k(u)}catch{}},[m.id]),An=d.useCallback((u,C,T,q)=>{u.preventDefault(),D({x:u.clientX,y:u.clientY,path:C,name:T,type:q})},[]),_n=d.useCallback(()=>{ae>0&&(He(u=>u-1),F(u=>u+1))},[ae]),Vn=d.useCallback(()=>{ae<Be.length-1&&(He(u=>u+1),F(u=>u+1))},[ae,Be.length]),Bn=d.useCallback(u=>{jt(C=>[...C.slice(0,ae+1),u]),He(C=>C+1),F(C=>C+1)},[ae]);d.useEffect(()=>{St(Pe)},[Pe]);const qe=d.useCallback(async()=>{G({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),$(null);try{const u=await U.reviewProject(m.id);$(u.output)}catch(u){$(`Error: ${u instanceof Error?u.message:"Unknown"}`)}finally{G(null)}},[m.id]),Ue=d.useCallback(async()=>{G({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),$(null);try{const u=await U.testProject(m.id);$(u.output)}catch(u){$(`Error: ${u instanceof Error?u.message:"Unknown"}`)}finally{G(null)}},[m.id]),tt=d.useCallback(async()=>{G({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),$(null);try{const u=await U.explainProject(m.id);$(u.output)}catch(u){$(`Error: ${u instanceof Error?u.message:"Unknown"}`)}finally{G(null)}},[m.id]),nt=d.useCallback(async(u,C)=>{if(window.confirm(`Delete "${C}"?`))try{await U.deleteSessionFile(m.id,u),n===u&&(r(null),o(""),i(null),c(null),g(!1)),await ve()}catch(q){const ue=q instanceof Error?q.message:"Unknown error";window.alert(`Delete failed: ${ue}`)}},[m.id,n,ve]),Hn=d.useCallback(u=>u.type==="file"?[{label:"Review",icon:Oe,onClick:()=>{qe()}},{label:"Generate Tests",icon:at,onClick:()=>{Ue()}},{label:"Explain",icon:Ot,onClick:()=>{tt()}},{label:"Delete",icon:ln,onClick:()=>{nt(u.path,u.name)},variant:"danger"}]:[{label:"Review Project",icon:Oe,onClick:()=>{qe()}},{label:"Run Tests",icon:at,onClick:()=>{Ue()}}],[qe,Ue,tt,nt]),Me=d.useCallback(async(u,C)=>{j&&n&&l!==null&&P(q=>q.map(ue=>ue.path===n?{...ue,content:l,modified:!0}:ue));const T=b.find(q=>q.path===u);if(T){r(u),o(C),i(T.content),c(T.content),g(T.modified);return}r(u),o(C),v(!0),g(!1);try{const q=m.id?await U.getSessionFileContent(m.id,u):await U.getFileContent(u);i(q.content),c(q.content),P(ue=>[...ue,{path:u,name:C,content:q.content,modified:!1}])}catch{i("[Error loading file]"),c("[Error loading file]")}finally{v(!1)}},[m.id,j,n,l,b]),rt=d.useCallback(async()=>{var u;if(!(!n||l===null||!m.id)){x(!0);try{await U.saveSessionFile(m.id,n,l),i(l),g(!1),P(T=>T.map(q=>q.path===n?{...q,content:l,modified:!1}:q));const C=((u=n.split(".").pop())==null?void 0:u.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(C)&&F(T=>T+1)}catch(C){const T=C instanceof Error?C.message:"Unknown error";window.alert(`Save failed: ${T}`)}finally{x(!1)}}},[n,l,m.id]),zt=d.useCallback(u=>{const C=b.find(T=>T.path===u);if(!(C!=null&&C.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(P(T=>T.filter(q=>q.path!==u)),n===u)){const T=b.filter(q=>q.path!==u);if(T.length>0){const q=T[T.length-1];r(q.path),o(q.name),i(q.content),c(q.content),g(q.modified)}else r(null),o(""),i(null),c(null),g(!1)}},[b,n]);d.useEffect(()=>{const u=C=>{(C.metaKey||C.ctrlKey)&&C.key==="s"&&(C.preventDefault(),j&&n&&rt()),(C.metaKey||C.ctrlKey)&&C.key==="p"&&(C.preventDefault(),I(T=>!T),L("")),C.key==="Escape"&&N&&I(!1)};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[j,n,rt,N]),d.useEffect(()=>{N&&M.current&&M.current.focus()},[N]);const Nt=Dn(m.files),Ee=H?Nt.filter(u=>u.path.toLowerCase().includes(H.toLowerCase())):Nt;d.useEffect(()=>{const u=m.files.find(C=>C.name==="index.html"&&C.type==="file");u&&Me(u.path,u.name)},[]);const qn=d.useCallback(u=>{u!==void 0&&(c(u),g(u!==f))},[f]),Un=d.useCallback(u=>{S.current=u},[]),Wn=d.useCallback(async()=>{const u=window.prompt("New file name (e.g. src/utils.ts):");if(!(!u||!u.trim()))try{await U.createSessionFile(m.id,u.trim()),await ve()}catch(C){const T=C instanceof Error?C.message:"Unknown error";window.alert(`Create file failed: ${T}`)}},[m.id,ve]),Gn=d.useCallback(async()=>{const u=window.prompt("New folder name (e.g. src/components):");if(!(!u||!u.trim()))try{await U.createSessionDirectory(m.id,u.trim()),await ve()}catch(C){const T=C instanceof Error?C.message:"Unknown error";window.alert(`Create folder failed: ${T}`)}},[m.id,ve]),Ct=n?Rn(m.files,n):void 0,Kn=((Pt=s.split(".").pop())==null?void 0:Pt.toUpperCase())||"";return a.jsxs("div",{className:"flex flex-col h-full relative",children:[a.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[a.jsx("button",{onClick:()=>{j&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:m.id}),a.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:m.path})]}),a.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${m.status==="completed"||m.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:m.status}),!ee&&a.jsx(Le,{variant:"primary",size:"sm",icon:Dt,onClick:async()=>{try{const u=m.prd||"";if(!u.trim()){window.alert("No PRD found for this project. Go to Home to start a new build.");return}await U.startSession({prd:u,provider:J,projectDir:m.path}),Y(!0)}catch(u){window.alert(`Failed to start: ${u instanceof Error?u.message:"Unknown error"}`)}},title:"Start build for this project",children:"Build"}),ee&&a.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[Ce?a.jsx(Le,{variant:"ghost",size:"sm",icon:Dt,onClick:In,title:"Resume build",children:"Resume"}):a.jsx(Le,{variant:"ghost",size:"sm",icon:Jn,onClick:$n,title:"Pause build",children:"Pause"}),a.jsx(Le,{variant:"danger",size:"sm",icon:er,onClick:et,title:"Stop build",children:"Stop"})]}),a.jsx(ie,{icon:Oe,label:"Review project",size:"sm",onClick:qe,disabled:!!(R!=null&&R.loading)}),a.jsx(ie,{icon:at,label:"Run tests",size:"sm",onClick:Ue,disabled:!!(R!=null&&R.loading)}),a.jsx(ie,{icon:Ot,label:"Explain project",size:"sm",onClick:tt,disabled:!!(R!=null&&R.loading)})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsxs(ut,{orientation:"vertical",children:[a.jsx(Ie,{defaultSize:70,minSize:40,children:a.jsxs(ut,{orientation:"horizontal",className:"h-full",children:[a.jsx(Ie,{defaultSize:20,minSize:15,children:a.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[a.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-muted-accessible uppercase tracking-wider font-semibold flex-1",children:"Files"}),a.jsxs("button",{onClick:Wn,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[a.jsx(Cr,{size:12})," New"]}),a.jsxs("button",{onClick:Gn,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[a.jsx($r,{size:12})," New"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:m.files.length>0?a.jsx(On,{nodes:m.files,selectedPath:n,onSelect:Me,onDelete:nt,onContextMenu:An}):a.jsx("div",{className:"p-4 text-xs text-muted",children:"No files"})})]})}),a.jsx(ft,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),a.jsx(Ie,{defaultSize:80,minSize:40,children:a.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[a.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:gr},{id:"preview",label:"Preview",icon:Oe},{id:"config",label:"Config",icon:Xn},{id:"secrets",label:"Secrets",icon:Ar},{id:"prd",label:"PRD",icon:an}].map(u=>a.jsxs("button",{role:"tab","aria-selected":h===u.id,onClick:()=>w(u.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${h===u.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[a.jsx(u.icon,{size:14}),u.label]},u.id))}),a.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[h==="code"&&a.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[b.length>0&&a.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:b.map(u=>a.jsxs("button",{onClick:()=>Me(u.path,u.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${u.path===n?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[a.jsx("span",{className:"w-4 flex items-center justify-center",children:pt(u.name,"file")}),u.name,u.modified&&a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),a.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:C=>{C.stopPropagation(),zt(u.path)},onKeyDown:C=>{C.key==="Enter"&&(C.stopPropagation(),zt(u.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:a.jsx(Qe,{size:12})})]},u.path))}),n?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[a.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:n}),y&&a.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),a.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Ct!=null?Ln(Ct):""}),a.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:Kn}),j&&a.jsx("button",{onClick:rt,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:p?a.jsx("div",{className:"text-muted text-xs animate-pulse p-4",children:"Loading..."}):a.jsx(fs,{value:l??"",language:to(s),theme:"vs",onChange:qn,onMount:Un,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Select a file to view its contents"})]}),h==="preview"&&a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover",children:A!=null&&A.preview_url?a.jsxs(a.Fragment,{children:[a.jsx(ie,{icon:ir,label:"Back",size:"sm",onClick:_n,disabled:ae<=0}),a.jsx(ie,{icon:cr,label:"Forward",size:"sm",onClick:Vn,disabled:ae>=Be.length-1}),a.jsx(ie,{icon:Ur,label:"Refresh",size:"sm",onClick:()=>F(u=>u+1)}),a.jsx("input",{value:kt,onChange:u=>St(u.target.value),onKeyDown:u=>{u.key==="Enter"&&Bn(kt)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),a.jsx(ie,{icon:sr,label:"Open in new tab",size:"sm",onClick:()=>window.open(Pe,"_blank")})]}):A?a.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:a.jsx("span",{className:"font-medium text-ink",children:A.description})}):a.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),A!=null&&A.preview_url?a.jsx("div",{className:"flex-1 bg-white",children:a.jsx("iframe",{ref:E,src:Pe,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},V)}):A?a.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[a.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:A.type==="api"||A.type==="python-api"?a.jsx(Xr,{size:28,className:"text-primary"}):A.type==="library"?a.jsx(Hr,{size:28,className:"text-primary"}):A.type==="go-app"||A.type==="rust-app"?a.jsx(on,{size:28,className:"text-primary"}):a.jsx(sn,{size:28,className:"text-primary"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:A.type.replace(/-/g," ").replace(/\b\w/g,u=>u.toUpperCase())}),a.jsx("p",{className:"text-sm text-muted",children:A.description})]}),A.dev_command&&a.jsxs("div",{className:"card p-4 max-w-md w-full",children:[a.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Run locally"}),a.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn block",children:A.dev_command})]}),A.port&&a.jsxs("p",{className:"text-xs text-muted",children:["Server runs on port ",A.port]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]}),h==="config"&&a.jsx("div",{className:"h-full flex flex-col",children:a.jsxs("div",{className:"p-6 overflow-y-auto",children:[a.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"card p-4",children:[a.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),a.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",a.jsx("span",{className:"font-semibold text-ink capitalize",children:J})]}),a.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(u=>a.jsx("button",{onClick:()=>{te(u),U.setProvider(u).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${J===u?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:u},u))})]}),a.jsxs("div",{className:"card p-4",children:[a.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),a.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(u=>a.jsx("button",{onClick:()=>Z(u),className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${W===u?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:u},u))})]}),a.jsxs("div",{className:"card p-4",children:[a.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),a.jsx("input",{value:m.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),a.jsxs("div",{className:"card p-4",children:[a.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),a.jsx("input",{value:m.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),h==="secrets"&&a.jsx(no,{}),h==="prd"&&a.jsx("div",{className:"h-full flex flex-col",children:a.jsxs("div",{className:"p-6 overflow-y-auto",children:[a.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),m.prd?a.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:m.prd}):a.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No PRD found for this project."})]})})]})]})})]})}),a.jsx(ft,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),a.jsx(Ie,{defaultSize:30,minSize:15,collapsible:!0,children:a.jsx(eo,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,buildMode:W})})]})}),(R==null?void 0:R.loading)&&a.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),a.jsxs("span",{className:"text-sm font-medium text-ink",children:[R.type==="review"?"Reviewing project":R.type==="test"?"Generating tests":"Analyzing project","..."]}),a.jsxs("span",{className:"text-xs font-mono text-muted",children:[R.elapsed,"s"]})]})}),O&&a.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),a.jsx(ie,{icon:Qe,label:"Close",size:"sm",onClick:()=>$(null)})]}),a.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:O})]}),z&&a.jsx(Xs,{x:z.x,y:z.y,items:Hn(z),onClose:()=>D(null)}),N&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>I(!1),children:a.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:u=>u.stopPropagation(),children:[a.jsx("input",{ref:M,type:"text",value:H,onChange:u=>L(u.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:u=>{u.key==="Enter"&&Ee.length>0&&(Me(Ee[0].path,Ee[0].name),I(!1)),u.key==="Escape"&&I(!1)}}),a.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Ee.slice(0,20).map(u=>a.jsxs("button",{onClick:()=>{Me(u.path,u.name),I(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[a.jsx("span",{className:"w-5 flex items-center justify-center",children:pt(u.name,"file")}),a.jsx("span",{className:"text-ink",children:u.name}),a.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:u.path})]},u.path)),Ee.length===0&&a.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})})]})}function uo(){const{sessionId:e}=Yn(),t=Qn(),[n,r]=d.useState(null),[s,o]=d.useState(!0),[f,i]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),i(null),U.getSessionDetail(e).then(l=>{r(l),o(!1)}).catch(l=>{i(l instanceof Error?l.message:"Failed to load session"),o(!1)}))},[e]),s?a.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),a.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):f||!n?a.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),a.jsx("p",{className:"text-xs text-muted mt-1",children:f||`Session ${e} does not exist`}),a.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):a.jsx("div",{className:"h-screen bg-background flex flex-col",children:a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(tr,{name:"ProjectWorkspace",children:a.jsx(ro,{session:n,onClose:()=>t("/")})})})})}export{uo as default};
@@ -0,0 +1,6 @@
1
+ import{c as f,u as h,r as n,a as g,j as e}from"./index-ACgjqVp2.js";import{B as d,P as m}from"./Button-CUOgrX10.js";import{C as j}from"./Card-2UWDXe0P.js";import{u as y,B as b}from"./Badge-ClncXa1x.js";import"./clock-DpWpY1Zx.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 N=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],v=f("search",N);function C(r){const s=k(r);return s==="completed"?"completed":s==="running"?"running":s==="failed"?"failed":s==="started"?"started":"empty"}const S={completed:"Completed",complete:"Completed",done:"Completed",completion_promise_fulfilled:"Completed",running:"Running",in_progress:"Running",planning:"Planning",started:"Started",error:"Failed",failed:"Failed",empty:"Empty"};function k(r){return{completion_promise_fulfilled:"completed",complete:"completed",done:"completed",in_progress:"running",planning:"running",error:"failed"}[r]||r}const E=[{key:"all",label:"All"},{key:"running",label:"Running"},{key:"completed",label:"Completed"},{key:"failed",label:"Failed"}];function A(){const r=h(),[s,a]=n.useState(""),[l,p]=n.useState("all"),u=n.useCallback(()=>g.getSessionsHistory(),[]),{data:i}=y(u,15e3,!0),o=n.useMemo(()=>{if(!i)return[];let t=i;if(l!=="all"&&(t=t.filter(c=>c.status===l)),s.trim()){const c=s.trim().toLowerCase();t=t.filter(x=>x.prd_snippet.toLowerCase().includes(c))}return t},[i,l,s]);return e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"font-heading text-h1 text-[#36342E]",children:"Projects"}),e.jsx(d,{icon:m,onClick:()=>r("/"),children:"New Project"})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(v,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#6B6960]"}),e.jsx("input",{type:"text",placeholder:"Search projects...","aria-label":"Search projects",value:s,onChange:t=>a(t.target.value),className:"w-full pl-9 pr-3 py-2 text-sm border border-[#ECEAE3] rounded-[5px] bg-white text-[#36342E] placeholder:text-[#939084] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/20 focus:border-[#553DE9]"})]}),e.jsx("div",{className:"flex items-center gap-1",role:"tablist",children:E.map(t=>e.jsx("button",{role:"tab","aria-selected":l===t.key,onClick:()=>p(t.key),className:`px-3 py-1.5 text-xs font-semibold rounded-[3px] transition-colors ${l===t.key?"bg-[#553DE9] text-white":"text-[#6B6960] hover:text-[#36342E] hover:bg-[#F8F4F0]"}`,children:t.label},t.key))})]}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("p",{className:"text-[#6B6960] text-sm mb-4",children:"No projects yet. Start building."}),e.jsx(d,{icon:m,onClick:()=>r("/"),children:"New Project"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:o.map(t=>e.jsx(w,{session:t,onClick:()=>r(`/project/${t.id}`)},t.id))})]})}function w({session:r,onClick:s}){const a=new Date(r.date).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs(j,{hover:!0,onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-[#6B6960]",children:a}),e.jsx(b,{status:C(r.status),children:S[r.status]||r.status})]}),e.jsx("h3",{className:"text-sm font-medium text-[#36342E] line-clamp-2 mb-2",children:r.prd_snippet||"Untitled project"}),e.jsx("p",{className:"text-xs text-[#6B6960] truncate",children:r.path})]})}export{A as default};