@jonit-dev/night-watch-cli 1.7.17 → 1.7.18
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.
package/package.json
CHANGED
|
@@ -387,7 +387,7 @@ Please change the parent <Route path="${L}"> to <Route path="${L==="/"?"*":`${L}
|
|
|
387
387
|
*
|
|
388
388
|
* This source code is licensed under the ISC license.
|
|
389
389
|
* See the LICENSE file in the root directory of this source tree.
|
|
390
|
-
*/const Xb=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Zb=le("zap",Xb),u0=c=>{let o;const d=new Set,r=(p,N)=>{const w=typeof p=="function"?p(o):p;if(!Object.is(w,o)){const D=o;o=N??(typeof w!="object"||w===null)?w:Object.assign({},o,w),d.forEach(z=>z(o,D))}},m=()=>o,v={setState:r,getState:m,getInitialState:()=>g,subscribe:p=>(d.add(p),()=>d.delete(p))},g=o=c(r,m,v);return v},$b=c=>c?u0(c):u0,Kb=c=>c;function Jb(c,o=Kb){const d=Qe.useSyncExternalStore(c.subscribe,()=>o(c.getState()),()=>o(c.getInitialState()));return Qe.useDebugValue(d),d}const o0=c=>{const o=$b(c),d=r=>Jb(o,r);return Object.assign(d,o),d},Fb=c=>c?o0(c):o0,Wb="";let $0=!1,gu=null;function Pb(c){$0=c}function Ib(c){gu=c}function ey(c){return encodeURIComponent(c.replace(/\//g,"~"))}function Te(c){return $0&&gu?c.replace("/api/",`/api/projects/${ey(gu)}/`):c}function ty(){return Re("/api/projects")}async function Re(c,o){const d=`${Wb}${c}`,r=await fetch(d,{headers:{"Content-Type":"application/json",...o==null?void 0:o.headers},...o});if(!r.ok){const m=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(m.error||`HTTP ${r.status}: ${r.statusText}`)}if(r.status!==204)return r.json()}function K0(){return Re(Te("/api/status"))}function ly(){return Re(Te("/api/prds"))}function ay(){return Re(Te("/api/prs"))}function ny(c,o){const d=`?lines=${encodeURIComponent(o)}`;return Re(Te(`/api/logs/${encodeURIComponent(c)}${d}`))}function zu(){return Re(Te("/api/config"))}function Du(c){return Re(Te("/api/config"),{method:"PUT",body:JSON.stringify(c)})}function sy(){return Re(Te("/api/doctor"))}function J0(){return Re(Te("/api/schedule-info"))}function iy(c){return Re(Te("/api/actions/run"),{method:"POST",headers:c?{"Content-Type":"application/json"}:void 0,body:c?JSON.stringify({prdName:c}):void 0})}function cy(){return Re(Te("/api/actions/review"),{method:"POST"})}function d0(){return Re(Te("/api/actions/install-cron"),{method:"POST"})}function ry(){return Re(Te("/api/actions/uninstall-cron"),{method:"POST"})}function uy(c="all"){return Re(Te("/api/actions/cancel"),{method:"POST",body:JSON.stringify({type:c})})}function oy(c){return Re(Te("/api/actions/retry"),{method:"POST",body:JSON.stringify({prdName:c})})}function dy(){return Re(Te("/api/actions/clear-lock"),{method:"POST"})}const Xl=["Draft","Ready","In Progress","Review","Done"];function Ou(){return Re(Te("/api/board/status"))}function fy(c){return Re(Te("/api/board/issues"),{method:"POST",body:JSON.stringify(c)})}function F0(c,o){return Re(Te(`/api/board/issues/${c}/move`),{method:"PATCH",body:JSON.stringify({column:o})})}function my(c){return Re(Te(`/api/board/issues/${c}`),{method:"DELETE"})}function hy(){return Re(Te("/api/roadmap"))}function xy(){return Re(Te("/api/roadmap/scan"),{method:"POST"})}function W0(c){return Re(Te("/api/roadmap/toggle"),{method:"PUT",body:JSON.stringify({enabled:c})})}function py(c,o){return Re(Te("/api/slack/channels/create"),{method:"POST",body:JSON.stringify({botToken:c,name:o})})}function gy(c){return Re(Te("/api/slack/channels"),{method:"POST",body:JSON.stringify({botToken:c})})}function vy(){return Re(Te("/api/agents"))}function by(c){return Re(Te(`/api/agents/${c}/prompt`))}function yy(c){return Re(Te("/api/agents"),{method:"POST",body:JSON.stringify(c)})}function f0(c,o){return Re(Te(`/api/agents/${c}`),{method:"PUT",body:JSON.stringify(o)})}function jy(c){return Re(Te(`/api/agents/${c}`),{method:"DELETE"})}function Ny(){return Re(Te("/api/agents/seed-defaults"),{method:"POST"})}function ct(c,o=[],d){const r=(d==null?void 0:d.enabled)??!0,[m,f]=y.useState(null),[h,v]=y.useState(!0),[g,p]=y.useState(null),N=y.useRef(c);N.current=c;const w=y.useRef(()=>{(async()=>{p(null);try{const z=await N.current();f(z)}catch(z){p(z instanceof Error?z:new Error("Unknown error"))}})()});return w.current=w.current.bind(w),y.useEffect(()=>{if(!r)return;let D=!1;return v(!0),p(null),(async()=>{try{const U=await N.current();D||f(U)}catch(U){D||p(U instanceof Error?U:new Error("Unknown error"))}finally{D||v(!1)}})(),()=>{D=!0}},[...o,r]),{data:m,loading:h,error:g,refetch:w.current}}function P0(c,o=[]){y.useEffect(()=>{const
|
|
390
|
+
*/const Xb=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Zb=le("zap",Xb),u0=c=>{let o;const d=new Set,r=(p,N)=>{const w=typeof p=="function"?p(o):p;if(!Object.is(w,o)){const D=o;o=N??(typeof w!="object"||w===null)?w:Object.assign({},o,w),d.forEach(z=>z(o,D))}},m=()=>o,v={setState:r,getState:m,getInitialState:()=>g,subscribe:p=>(d.add(p),()=>d.delete(p))},g=o=c(r,m,v);return v},$b=c=>c?u0(c):u0,Kb=c=>c;function Jb(c,o=Kb){const d=Qe.useSyncExternalStore(c.subscribe,()=>o(c.getState()),()=>o(c.getInitialState()));return Qe.useDebugValue(d),d}const o0=c=>{const o=$b(c),d=r=>Jb(o,r);return Object.assign(d,o),d},Fb=c=>c?o0(c):o0,Wb="";let $0=!1,gu=null;function Pb(c){$0=c}function Ib(c){gu=c}function ey(c){return encodeURIComponent(c.replace(/\//g,"~"))}function Te(c){return $0&&gu?c.replace("/api/",`/api/projects/${ey(gu)}/`):c}function ty(){return Re("/api/projects")}async function Re(c,o){const d=`${Wb}${c}`,r=await fetch(d,{headers:{"Content-Type":"application/json",...o==null?void 0:o.headers},...o});if(!r.ok){const m=await r.json().catch(()=>({error:"Unknown error"}));throw new Error(m.error||`HTTP ${r.status}: ${r.statusText}`)}if(r.status!==204)return r.json()}function K0(){return Re(Te("/api/status"))}function ly(){return Re(Te("/api/prds"))}function ay(){return Re(Te("/api/prs"))}function ny(c,o){const d=`?lines=${encodeURIComponent(o)}`;return Re(Te(`/api/logs/${encodeURIComponent(c)}${d}`))}function zu(){return Re(Te("/api/config"))}function Du(c){return Re(Te("/api/config"),{method:"PUT",body:JSON.stringify(c)})}function sy(){return Re(Te("/api/doctor"))}function J0(){return Re(Te("/api/schedule-info"))}function iy(c){return Re(Te("/api/actions/run"),{method:"POST",headers:c?{"Content-Type":"application/json"}:void 0,body:c?JSON.stringify({prdName:c}):void 0})}function cy(){return Re(Te("/api/actions/review"),{method:"POST"})}function d0(){return Re(Te("/api/actions/install-cron"),{method:"POST"})}function ry(){return Re(Te("/api/actions/uninstall-cron"),{method:"POST"})}function uy(c="all"){return Re(Te("/api/actions/cancel"),{method:"POST",body:JSON.stringify({type:c})})}function oy(c){return Re(Te("/api/actions/retry"),{method:"POST",body:JSON.stringify({prdName:c})})}function dy(){return Re(Te("/api/actions/clear-lock"),{method:"POST"})}const Xl=["Draft","Ready","In Progress","Review","Done"];function Ou(){return Re(Te("/api/board/status"))}function fy(c){return Re(Te("/api/board/issues"),{method:"POST",body:JSON.stringify(c)})}function F0(c,o){return Re(Te(`/api/board/issues/${c}/move`),{method:"PATCH",body:JSON.stringify({column:o})})}function my(c){return Re(Te(`/api/board/issues/${c}`),{method:"DELETE"})}function hy(){return Re(Te("/api/roadmap"))}function xy(){return Re(Te("/api/roadmap/scan"),{method:"POST"})}function W0(c){return Re(Te("/api/roadmap/toggle"),{method:"PUT",body:JSON.stringify({enabled:c})})}function py(c,o){return Re(Te("/api/slack/channels/create"),{method:"POST",body:JSON.stringify({botToken:c,name:o})})}function gy(c){return Re(Te("/api/slack/channels"),{method:"POST",body:JSON.stringify({botToken:c})})}function vy(){return Re(Te("/api/agents"))}function by(c){return Re(Te(`/api/agents/${c}/prompt`))}function yy(c){return Re(Te("/api/agents"),{method:"POST",body:JSON.stringify(c)})}function f0(c,o){return Re(Te(`/api/agents/${c}`),{method:"PUT",body:JSON.stringify(o)})}function jy(c){return Re(Te(`/api/agents/${c}`),{method:"DELETE"})}function Ny(){return Re(Te("/api/agents/seed-defaults"),{method:"POST"})}function ct(c,o=[],d){const r=(d==null?void 0:d.enabled)??!0,[m,f]=y.useState(null),[h,v]=y.useState(!0),[g,p]=y.useState(null),N=y.useRef(c);N.current=c;const w=y.useRef(()=>{(async()=>{p(null);try{const z=await N.current();f(z)}catch(z){p(z instanceof Error?z:new Error("Unknown error"))}})()});return w.current=w.current.bind(w),y.useEffect(()=>{if(!r)return;let D=!1;return v(!0),p(null),(async()=>{try{const U=await N.current();D||f(U)}catch(U){D||p(U instanceof Error?U:new Error("Unknown error"))}finally{D||v(!1)}})(),()=>{D=!0}},[...o,r]),{data:m,loading:h,error:g,refetch:w.current}}function P0(c,o=[],d){y.useEffect(()=>{if((d==null?void 0:d.enabled)===!1)return;const r=Te("/api/status/events"),m=new EventSource(r);return m.addEventListener("status_changed",f=>{try{const h=JSON.parse(f.data);c(h)}catch{}}),m.addEventListener("executor_started",f=>{try{const h=JSON.parse(f.data);console.log("Executor started with PID:",h.pid)}catch{}}),m.onerror=()=>{},()=>{m.close()}},o)}const Sy=typeof localStorage<"u"?localStorage.getItem("nw-selected-project"):null,rt=Fb(c=>({projectName:"Night Watch",setProjectName:o=>c({projectName:o}),toasts:[],addToast:o=>{const d=Math.random().toString(36).substring(7);c(r=>({toasts:[...r.toasts,{...o,id:d}]})),setTimeout(()=>{c(r=>({toasts:r.toasts.filter(m=>m.id!==d)}))},5e3)},removeToast:o=>c(d=>({toasts:d.toasts.filter(r=>r.id!==o)})),globalModeLoading:!0,setGlobalModeLoading:o=>c({globalModeLoading:o}),isGlobalMode:!1,setGlobalMode:o=>{Pb(o),c({isGlobalMode:o})},projects:[],setProjects:o=>c({projects:o}),selectedProjectId:Sy,selectProject:o=>{Ib(o),o?localStorage.setItem("nw-selected-project",o):localStorage.removeItem("nw-selected-project"),c(d=>{const r=d.projects.find(m=>m.name===o);return{selectedProjectId:o,...r?{projectName:r.name}:{}}})}})),wy=()=>{const[c,o]=y.useState(!1),{projectName:d,isGlobalMode:r,projects:m,selectedProjectId:f,selectProject:h}=rt(),v=[{icon:cb,label:"Dashboard",path:"/"},{icon:db,label:"Board",path:"/board"},{icon:nb,label:"Pull Requests",path:"/prs",badge:1},{icon:Q0,label:"Roadmap",path:"/roadmap"},{icon:Ri,label:"Scheduling",path:"/scheduling"},{icon:Db,label:"Logs",path:"/logs"},{icon:Rv,label:"Integrations",path:"/integrations"},{icon:pu,label:"Agents",path:"/agents"},{icon:X0,label:"Settings",path:"/settings"}];return n.jsxs("aside",{className:`
|
|
391
391
|
relative flex flex-col transition-all duration-300 ease-[cubic-bezier(0.25,0.1,0.25,1)]
|
|
392
392
|
${c?"w-20":"w-72"} h-screen flex-shrink-0 z-50
|
|
393
393
|
bg-[#030712]/80 backdrop-blur-xl border-r border-white/5
|
|
@@ -407,7 +407,7 @@ Please change the parent <Route path="${L}"> to <Route path="${L==="/"?"*":`${L}
|
|
|
407
407
|
transition-all duration-300
|
|
408
408
|
${d?"cursor-pointer hover:border-indigo-500/30 hover:shadow-indigo-500/5 group":""}
|
|
409
409
|
${o}
|
|
410
|
-
`,onClick:d,children:[d&&n.jsx("div",{className:"absolute inset-0 bg-indigo-500/0 group-hover:bg-indigo-500/[0.02] transition-colors rounded-xl pointer-events-none"}),n.jsx("div",{className:"relative z-10",children:c})]}),re=({children:c,variant:o="primary",size:d="md",loading:r=!1,className:m="",disabled:f,...h})=>{const v="inline-flex items-center justify-center rounded-lg font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-offset-[#030712] disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98]",g={primary:"bg-indigo-600 text-white hover:bg-indigo-500 focus:ring-indigo-500 shadow-[0_0_15px_-3px_rgba(79,70,229,0.4)] border border-indigo-500/50 hover:shadow-[0_0_20px_-3px_rgba(79,70,229,0.5)]",secondary:"bg-[#1f2937] text-slate-200 hover:bg-[#374151] focus:ring-slate-500 border border-white/5",danger:"bg-red-600/10 text-red-400 hover:bg-red-600/20 focus:ring-red-500 border border-red-900/50 hover:border-red-500/50",ghost:"bg-transparent text-slate-400 hover:bg-white/5 hover:text-slate-200 focus:ring-slate-400",outline:"border border-slate-700/50 bg-transparent text-slate-300 hover:bg-white/5 hover:border-slate-500 focus:ring-slate-400"},p={sm:"h-8 px-3 text-xs tracking-wide",md:"h-10 px-4 py-2 text-sm",lg:"h-12 px-6 text-base",icon:"h-9 w-9"};return n.jsxs("button",{className:`${v} ${g[o]} ${p[d]} ${m}`,disabled:f||r,...h,children:[r&&n.jsx(G0,{className:"mr-2 h-4 w-4 animate-spin"}),c]})},ha=({children:c,variant:o="default",className:d=""})=>{const r={default:"bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20",success:"bg-emerald-500/10 text-emerald-400 ring-1 ring-inset ring-emerald-500/20",warning:"bg-amber-500/10 text-amber-400 ring-1 ring-inset ring-amber-500/20",error:"bg-red-500/10 text-red-400 ring-1 ring-inset ring-red-500/20",neutral:"bg-slate-500/10 text-slate-400 ring-1 ring-inset ring-slate-500/20",info:"bg-blue-500/10 text-blue-400 ring-1 ring-inset ring-blue-500/20"};return n.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[11px] font-medium tracking-wide ${r[o]} ${d}`,children:c})},Uu={Draft:{dot:"bg-slate-500",badge:"neutral"},Ready:{dot:"bg-green-500",badge:"success"},"In Progress":{dot:"bg-blue-500",badge:"info"},Review:{dot:"bg-amber-500",badge:"warning"},Done:{dot:"bg-slate-600",badge:"neutral"}},By=({defaultColumn:c,onClose:o,onCreated:d})=>{const[r,m]=y.useState(""),[f,h]=y.useState(""),[v,g]=y.useState(c),[p,N]=y.useState(!1),[w,D]=y.useState(null),{addToast:z}=rt(),U=async A=>{if(A.preventDefault(),!!r.trim()){N(!0),D(null);try{await fy({title:r.trim(),body:f,column:v}),z({title:"Issue created",message:`"${r.trim()}" added to ${v}`,type:"success"}),d(),o()}catch(R){D(R instanceof Error?R.message:"Failed to create issue")}finally{N(!1)}}};return n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:o}),n.jsxs("div",{className:"relative bg-[#0f172a] border border-white/10 rounded-2xl shadow-2xl w-full max-w-lg",children:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/5",children:[n.jsx("h2",{className:"text-lg font-semibold text-slate-100",children:"New Board Issue"}),n.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-white/5 text-slate-500 hover:text-slate-300 transition-colors",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsxs("form",{onSubmit:U,className:"p-6 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Title"}),n.jsx("input",{type:"text",value:r,onChange:A=>m(A.target.value),placeholder:"Issue title...",required:!0,className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm placeholder-slate-600 focus:outline-none focus:border-indigo-500/50 focus:ring-1 focus:ring-indigo-500/20"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Column"}),n.jsx("select",{value:v,onChange:A=>g(A.target.value),className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:border-indigo-500/50 appearance-none cursor-pointer",children:Xl.map(A=>n.jsx("option",{value:A,children:A},A))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Body (optional)"}),n.jsx("textarea",{value:f,onChange:A=>h(A.target.value),placeholder:"Issue description...",rows:5,className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm placeholder-slate-600 focus:outline-none focus:border-indigo-500/50 focus:ring-1 focus:ring-indigo-500/20 resize-none font-mono"})]}),w&&n.jsx("p",{className:"text-sm text-red-400",children:w}),n.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[n.jsx(re,{variant:"ghost",type:"button",onClick:o,children:"Cancel"}),n.jsx(re,{type:"submit",disabled:p||!r.trim(),children:p?"Creating...":"Create Issue"})]})]})]})]})},Ly=({issue:c,onClose:o,onMoved:d,onClosed:r})=>{const[m,f]=y.useState(!1),[h,v]=y.useState(!1),{addToast:g}=rt(),p=async D=>{if(D!==c.column){f(!0);try{await F0(c.number,D),g({title:"Issue moved",message:`#${c.number} moved to ${D}`,type:"success"}),d(),o()}catch(z){g({title:"Move failed",message:z instanceof Error?z.message:"Failed to move issue",type:"error"})}finally{f(!1)}}},N=async()=>{if(confirm(`Close issue #${c.number}: "${c.title}"?`)){v(!0);try{await my(c.number),g({title:"Issue closed",message:`#${c.number} closed on GitHub`,type:"success"}),r(),o()}catch(D){g({title:"Close failed",message:D instanceof Error?D.message:"Failed to close issue",type:"error"})}finally{v(!1)}}},w=c.column??"Draft";return n.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[n.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:o}),n.jsxs("div",{className:"relative bg-[#0a0f1e] border-l border-white/10 w-full max-w-xl flex flex-col shadow-2xl overflow-hidden",children:[n.jsxs("div",{className:"flex items-start justify-between p-6 border-b border-white/5 flex-shrink-0",children:[n.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[n.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[n.jsxs("span",{className:"text-slate-500 text-sm font-mono",children:["#",c.number]}),n.jsx(ha,{variant:Uu[w].badge,children:w})]}),n.jsx("h2",{className:"text-lg font-semibold text-slate-100 leading-snug",children:c.title}),c.assignees.length>0&&n.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Assigned to: ",c.assignees.join(", ")]})]}),n.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-white/5 text-slate-500 hover:text-slate-300 transition-colors flex-shrink-0",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsxs("div",{className:"flex items-center space-x-3 px-6 py-3 border-b border-white/5 flex-shrink-0 flex-wrap gap-y-2",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"text-xs text-slate-500",children:"Move to:"}),Xl.filter(D=>D!==c.column).map(D=>n.jsx("button",{onClick:()=>p(D),disabled:m,className:"text-xs px-2.5 py-1 rounded-md bg-slate-800 text-slate-300 hover:bg-slate-700 hover:text-slate-100 border border-slate-700 transition-colors disabled:opacity-50",children:D},D))]}),n.jsxs("div",{className:"flex items-center space-x-2 ml-auto",children:[n.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-1 text-xs text-indigo-400 hover:text-indigo-300 transition-colors",children:[n.jsx(Tu,{className:"h-3.5 w-3.5"}),n.jsx("span",{children:"GitHub"})]}),n.jsx("button",{onClick:N,disabled:h,className:"text-xs px-2.5 py-1 rounded-md bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20 transition-colors disabled:opacity-50",children:h?"Closing...":"Close Issue"})]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:c.body?n.jsx("pre",{className:"text-sm text-slate-300 whitespace-pre-wrap font-mono leading-relaxed break-words",children:c.body}):n.jsx("p",{className:"text-slate-500 text-sm italic",children:"No description provided."})})]})]})},qy=({issue:c,onClick:o,onMoveRequest:d})=>{const[r,m]=y.useState(!1),f=c.column??"Draft";return n.jsxs("div",{className:"relative group",children:[n.jsx(be,{className:"p-3 cursor-pointer hover:border-indigo-500/30 transition-all active:scale-[0.99] select-none",onClick:o,children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("span",{className:"text-[10px] font-mono text-slate-600",children:["#",c.number]}),n.jsx("p",{className:"text-xs font-medium text-slate-200 line-clamp-2 mt-0.5 leading-snug",children:c.title}),c.assignees.length>0&&n.jsx("p",{className:"text-[10px] text-slate-500 mt-1.5 truncate",children:c.assignees.join(", ")})]}),n.jsx("button",{onClick:h=>{h.stopPropagation(),m(v=>!v)},className:"ml-2 p-1 rounded hover:bg-white/10 text-slate-500 hover:text-slate-300 transition-colors flex-shrink-0",title:"Move issue",children:n.jsx(Y0,{className:"h-3.5 w-3.5"})})]})}),r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>m(!1)}),n.jsx("div",{className:"absolute right-0 top-full mt-1 z-40 bg-[#0f172a] border border-white/10 rounded-xl shadow-2xl py-1 min-w-[140px]",children:Xl.filter(h=>h!==f).map(h=>n.jsxs("button",{onClick:()=>{d(c,h),m(!1)},className:"w-full text-left text-xs px-4 py-2 text-slate-300 hover:bg-white/5 hover:text-slate-100 transition-colors flex items-center space-x-2",children:[n.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Uu[h].dot}`}),n.jsx("span",{children:h})]},h))})]})]})},Yy=({name:c,issues:o,onIssueClick:d,onNewIssue:r,onMoveIssue:m})=>{const f=Uu[c];return n.jsxs("div",{className:"flex flex-col min-w-[220px] max-w-[220px] h-full",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${f.dot}`}),n.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:c}),n.jsx("span",{className:"text-[10px] font-bold text-slate-600 bg-slate-800 rounded-full px-1.5 py-0.5",children:o.length})]}),n.jsx("button",{onClick:()=>r(c),className:"p-1 rounded-md hover:bg-white/5 text-slate-600 hover:text-slate-400 transition-colors",title:`Add issue to ${c}`,children:n.jsx(gl,{className:"h-3.5 w-3.5"})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 pr-1 scrollbar-hide min-h-0",children:o.length===0?n.jsx("div",{className:"border-2 border-dashed border-slate-800 rounded-xl h-24 flex items-center justify-center",children:n.jsx("span",{className:"text-xs text-slate-700",children:"No issues"})}):o.map(h=>n.jsx(qy,{issue:h,onClick:()=>d(h),onMoveRequest:m},h.id))})]})},Gy=()=>{const[c,o]=y.useState(null),[d,r]=y.useState(null),{addToast:m,selectedProjectId:f,globalModeLoading:h}=rt(),{data:v,loading:g,error:p,refetch:N}=ct(Ou,[f],{enabled:!h});y.useEffect(()=>{const z=setInterval(()=>N(),3e4);return()=>clearInterval(z)},[N]);const w=y.useCallback(async(z,U)=>{try{await F0(z.number,U),m({title:"Issue moved",message:`#${z.number} moved to ${U}`,type:"success"}),N()}catch(A){m({title:"Move failed",message:A instanceof Error?A.message:"Failed to move issue",type:"error"})}},[m,N]);if(h||g)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading board..."})});if(p&&p.message.includes("Board not configured"))return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx("div",{className:"text-4xl",children:"📋"}),n.jsx("h2",{className:"text-xl font-semibold text-slate-200",children:"Board not configured"}),n.jsxs("p",{className:"text-slate-500 text-sm max-w-sm text-center",children:["Run ",n.jsx("code",{className:"font-mono bg-slate-800 px-2 py-0.5 rounded text-indigo-300",children:"night-watch board setup"})," in your project to create a GitHub Projects board."]})]});if(p)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx("div",{className:"text-slate-300",children:"Failed to load board"}),n.jsx("div",{className:"text-sm text-slate-500",children:p.message}),n.jsx(re,{onClick:()=>N(),children:"Retry"})]});if(!v)return null;const D=v.columns;return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6 flex-shrink-0",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold text-slate-100",children:"Board"}),n.jsxs("p",{className:"text-sm text-slate-500 mt-1",children:[Xl.reduce((z,U)=>{var A;return z+(((A=D[U])==null?void 0:A.length)??0)},0)," issues across ",Xl.length," columns"]})]}),n.jsxs(re,{onClick:()=>r("Ready"),children:[n.jsx(gl,{className:"h-4 w-4 mr-2"}),"New Issue"]})]}),n.jsx("div",{className:"flex-1 overflow-x-auto overflow-y-hidden",children:n.jsx("div",{className:"flex space-x-4 h-full pb-4",style:{minWidth:`${Xl.length*236}px`},children:Xl.map(z=>n.jsx(Yy,{name:z,issues:D[z]??[],onIssueClick:o,onNewIssue:r,onMoveIssue:w},z))})}),c&&n.jsx(Ly,{issue:c,onClose:()=>o(null),onMoved:()=>N(),onClosed:()=>N()}),d&&n.jsx(By,{defaultColumn:d,onClose:()=>r(null),onCreated:()=>N()})]})},Qy={Draft:"text-slate-400 bg-slate-500/10 ring-slate-500/20",Ready:"text-green-400 bg-green-500/10 ring-green-500/20","In Progress":"text-blue-400 bg-blue-500/10 ring-blue-500/20",Review:"text-amber-400 bg-amber-500/10 ring-amber-500/20",Done:"text-slate-500 bg-slate-600/10 ring-slate-600/20"},Vy=()=>{var $,ie,we;const c=Su(),[o,d]=y.useState(null),[r,m]=y.useState(!1),[f,h]=y.useState(null),{setProjectName:v,addToast:g,selectedProjectId:p,globalModeLoading:N}=rt(),{data:w,loading:D,error:z,refetch:U}=ct(K0,[p],{enabled:!N}),{data:A}=ct(J0,[p],{enabled:!N}),{data:R}=ct(()=>Ou().catch(()=>null),[p],{enabled:!N});P0(se=>{h(se)},[p]);const Q=f||w;if(Qe.useEffect(()=>{Q!=null&&Q.projectName&&v(Q.projectName)},[Q,v]),y.useEffect(()=>{const se=setInterval(()=>{U()},3e4);return()=>clearInterval(se)},[U]),y.useEffect(()=>{const se=()=>U();return window.addEventListener("focus",se),()=>window.removeEventListener("focus",se)},[U]),N||D)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading..."})});if(z)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load dashboard data"}),n.jsx("div",{className:"text-sm text-slate-500",children:z.message}),n.jsx(re,{onClick:()=>U(),children:"Retry"})]});if(!Q)return null;const q=Q.prds.filter(se=>se.status==="ready").length,L=Q.prds.filter(se=>se.status==="in-progress"),J=Q.prs.length,B=Q.prs.filter(se=>se.reviewScore!==null&&se.reviewScore<70).length,C=Q.processes.find(se=>se.name==="executor"),V=Q.processes.find(se=>se.name==="reviewer"),Z=Q.processes.find(se=>se.name==="qa"),P=async se=>{d(se);try{const k=await uy(se),F=k.results.every(ae=>ae.success);g({title:F?"Process Cancelled":"Cancel Failed",message:k.results.map(ae=>ae.message).join("; "),type:F?"success":"error"})}catch(k){g({title:"Cancel Failed",message:k instanceof Error?k.message:"Failed to cancel process",type:"error"})}finally{d(null),U()}},ue=async()=>{m(!0);try{await dy(),g({title:"Lock Cleared",message:"Stale executor state removed",type:"success"}),U()}catch(se){g({title:"Clear Failed",message:se instanceof Error?se.message:"Failed to clear lock",type:"error"})}finally{m(!1)}},xe=se=>{if(!se)return"Not scheduled";try{const k=new Date(se),F=new Date,ae=k.getTime()-F.getTime(),pe=Math.floor(ae/6e4);return pe<0?"Running now...":pe<60?`In ${pe} min`:pe<1440?`In ${Math.floor(pe/60)} hr${pe>=120?"s":""}`:`In ${Math.floor(pe/1440)} day${pe>=2880?"s":""}`}catch{return"Unknown"}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsxs(be,{className:"p-5",onClick:()=>c("/prds"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"PRDs Ready"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:q})]}),n.jsx("div",{className:"p-2 bg-green-500/10 rounded-lg text-green-400",children:n.jsx(ns,{className:"h-5 w-5"})})]}),n.jsxs("p",{className:"text-xs text-slate-500 mt-4",children:["of ",Q.prds.length," total"]})]}),n.jsxs(be,{className:"p-5",onClick:()=>c("/prds"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"In Progress"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:L.length})]}),n.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg text-blue-400",children:n.jsx(q0,{className:"h-5 w-5"})})]}),n.jsx("p",{className:"text-xs text-slate-500 mt-4 truncate",children:L.length===1?L[0].name:`${L.length} active`})]}),n.jsxs(be,{className:"p-5",onClick:()=>c("/prs"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Open PRs"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:J})]}),n.jsx("div",{className:"p-2 bg-purple-500/10 rounded-lg text-purple-400",children:n.jsx(Mi,{className:"h-5 w-5"})})]}),n.jsx("p",{className:`text-xs mt-4 ${B>0?"text-red-400 font-medium":"text-slate-500"}`,children:B>0?`${B} need work`:"All passing"})]}),n.jsxs(be,{className:"p-5",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Cron Status"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:Q.crontab.installed?"Active":"Inactive"})]}),n.jsx("div",{className:`p-2 rounded-lg ${Q.crontab.installed?"bg-indigo-500/10 text-indigo-400":"bg-slate-700/50 text-slate-500"}`,children:n.jsx(Ri,{className:"h-5 w-5"})})]}),n.jsx("p",{className:"text-xs text-slate-500 mt-4",children:Q.crontab.installed?`${Q.crontab.entries.length} entr${Q.crontab.entries.length===1?"y":"ies"} installed`:"No crontab entries"})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsx("h2",{className:"text-base font-semibold text-slate-200 mb-4",children:"System Status"}),n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Project"}),n.jsx("p",{className:"text-sm text-slate-200",children:Q.projectName})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Provider"}),n.jsx("p",{className:"text-sm text-slate-200 capitalize",children:Q.config.provider})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"PRD Directory"}),n.jsx("p",{className:"text-sm text-slate-200",children:Q.config.prdDir})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Last Updated"}),n.jsx("p",{className:"text-sm text-slate-200",children:new Date(Q.timestamp).toLocaleString()})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-base font-semibold text-slate-200 mb-4",children:"Process Status"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${C!=null&&C.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${C!=null&&C.running?"text-slate-200":"text-slate-400"}`,children:"Executor"}),n.jsx("div",{className:"text-xs text-slate-500",children:C!=null&&C.running?`PID: ${C.pid} • ${Q.activePrd??"Running"}`:"Idle"})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[(C==null?void 0:C.running)&&n.jsxs(re,{size:"sm",variant:"ghost",className:"text-red-400 hover:text-red-300",onClick:()=>P("run"),disabled:o==="run",children:[n.jsx(hu,{className:"h-4 w-4 mr-1"}),o==="run"?"Stopping...":"Stop"]}),!(C!=null&&C.running)&&L.length>0&&n.jsx(re,{size:"sm",variant:"ghost",className:"text-amber-400 hover:text-amber-300",onClick:ue,disabled:r,children:r?"Clearing...":"Force Clear"}),n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),children:"View Log"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${V!=null&&V.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${V!=null&&V.running?"text-slate-200":"text-slate-400"}`,children:"Reviewer"}),n.jsx("div",{className:"text-xs text-slate-500",children:V!=null&&V.running?`PID: ${V.pid} • Running`:"Idle"})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[(V==null?void 0:V.running)&&n.jsxs(re,{size:"sm",variant:"ghost",className:"text-red-400 hover:text-red-300",onClick:()=>P("review"),disabled:o==="review",children:[n.jsx(hu,{className:"h-4 w-4 mr-1"}),o==="review"?"Stopping...":"Stop"]}),n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),disabled:!(V!=null&&V.running),children:"View Log"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${Z!=null&&Z.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${Z!=null&&Z.running?"text-slate-200":"text-slate-400"}`,children:"QA"}),n.jsx("div",{className:"text-xs text-slate-500",children:Z!=null&&Z.running?`PID: ${Z.pid} • Running`:"Idle"})]})]}),n.jsx("div",{className:"flex items-center space-x-2",children:n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),children:"View Log"})})]})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-base font-semibold text-slate-200",children:"Scheduling"}),n.jsxs("button",{onClick:()=>c("/scheduling"),className:"text-sm text-indigo-400 hover:text-indigo-300 flex items-center transition-colors",children:["Manage Schedules ",n.jsx(n0,{className:"ml-1 h-3 w-3"})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${A!=null&&A.executor.installed?"bg-indigo-500/10 text-indigo-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(Ri,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${A!=null&&A.executor.installed?"text-slate-200":"text-slate-500"}`,children:"Executor"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe(A==null?void 0:A.executor.nextRun)})]})]})}),n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${A!=null&&A.reviewer.installed?"bg-purple-500/10 text-purple-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(Mi,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${A!=null&&A.reviewer.installed?"text-slate-200":"text-slate-500"}`,children:"Reviewer"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe(A==null?void 0:A.reviewer.nextRun)})]})]})}),n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${($=A==null?void 0:A.qa)!=null&&$.installed?"bg-green-500/10 text-green-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(kb,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${(ie=A==null?void 0:A.qa)!=null&&ie.installed?"text-slate-200":"text-slate-500"}`,children:"QA"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe((we=A==null?void 0:A.qa)==null?void 0:we.nextRun)})]})]})})]})]})]}),n.jsxs("div",{className:"mt-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h2",{className:"text-lg font-semibold text-slate-200",children:"GitHub Board"}),n.jsxs("button",{onClick:()=>c("/board"),className:"text-sm text-indigo-400 hover:text-indigo-300 flex items-center transition-colors",children:["View board ",n.jsx(n0,{className:"ml-1 h-3 w-3"})]})]}),n.jsx(be,{className:"p-4",children:R?n.jsx("div",{className:"flex flex-wrap gap-3",children:Xl.map(se=>{var F;const k=((F=R.columns[se])==null?void 0:F.length)??0;return n.jsxs("button",{onClick:()=>c("/board"),className:`inline-flex items-center space-x-2 px-3 py-2 rounded-lg ring-1 ring-inset transition-colors hover:opacity-80 ${Qy[se]}`,children:[n.jsx("span",{className:"text-xs font-medium",children:se}),n.jsx("span",{className:"text-xs font-bold",children:k})]},se)})}):n.jsxs("p",{className:"text-sm text-slate-500 italic",children:["Board not configured — run ",n.jsx("code",{className:"font-mono bg-slate-800 px-1.5 py-0.5 rounded text-indigo-300 text-xs",children:"night-watch board setup"})," to enable."]})})]})]})},Me=Qe.forwardRef(({className:c="",label:o,error:d,helperText:r,rightIcon:m,...f},h)=>n.jsxs("div",{className:"w-full",children:[o&&n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1.5",children:o}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{ref:h,className:`
|
|
410
|
+
`,onClick:d,children:[d&&n.jsx("div",{className:"absolute inset-0 bg-indigo-500/0 group-hover:bg-indigo-500/[0.02] transition-colors rounded-xl pointer-events-none"}),n.jsx("div",{className:"relative z-10",children:c})]}),re=({children:c,variant:o="primary",size:d="md",loading:r=!1,className:m="",disabled:f,...h})=>{const v="inline-flex items-center justify-center rounded-lg font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-offset-[#030712] disabled:opacity-50 disabled:pointer-events-none active:scale-[0.98]",g={primary:"bg-indigo-600 text-white hover:bg-indigo-500 focus:ring-indigo-500 shadow-[0_0_15px_-3px_rgba(79,70,229,0.4)] border border-indigo-500/50 hover:shadow-[0_0_20px_-3px_rgba(79,70,229,0.5)]",secondary:"bg-[#1f2937] text-slate-200 hover:bg-[#374151] focus:ring-slate-500 border border-white/5",danger:"bg-red-600/10 text-red-400 hover:bg-red-600/20 focus:ring-red-500 border border-red-900/50 hover:border-red-500/50",ghost:"bg-transparent text-slate-400 hover:bg-white/5 hover:text-slate-200 focus:ring-slate-400",outline:"border border-slate-700/50 bg-transparent text-slate-300 hover:bg-white/5 hover:border-slate-500 focus:ring-slate-400"},p={sm:"h-8 px-3 text-xs tracking-wide",md:"h-10 px-4 py-2 text-sm",lg:"h-12 px-6 text-base",icon:"h-9 w-9"};return n.jsxs("button",{className:`${v} ${g[o]} ${p[d]} ${m}`,disabled:f||r,...h,children:[r&&n.jsx(G0,{className:"mr-2 h-4 w-4 animate-spin"}),c]})},ha=({children:c,variant:o="default",className:d=""})=>{const r={default:"bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20",success:"bg-emerald-500/10 text-emerald-400 ring-1 ring-inset ring-emerald-500/20",warning:"bg-amber-500/10 text-amber-400 ring-1 ring-inset ring-amber-500/20",error:"bg-red-500/10 text-red-400 ring-1 ring-inset ring-red-500/20",neutral:"bg-slate-500/10 text-slate-400 ring-1 ring-inset ring-slate-500/20",info:"bg-blue-500/10 text-blue-400 ring-1 ring-inset ring-blue-500/20"};return n.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[11px] font-medium tracking-wide ${r[o]} ${d}`,children:c})},Uu={Draft:{dot:"bg-slate-500",badge:"neutral"},Ready:{dot:"bg-green-500",badge:"success"},"In Progress":{dot:"bg-blue-500",badge:"info"},Review:{dot:"bg-amber-500",badge:"warning"},Done:{dot:"bg-slate-600",badge:"neutral"}},By=({defaultColumn:c,onClose:o,onCreated:d})=>{const[r,m]=y.useState(""),[f,h]=y.useState(""),[v,g]=y.useState(c),[p,N]=y.useState(!1),[w,D]=y.useState(null),{addToast:z}=rt(),U=async A=>{if(A.preventDefault(),!!r.trim()){N(!0),D(null);try{await fy({title:r.trim(),body:f,column:v}),z({title:"Issue created",message:`"${r.trim()}" added to ${v}`,type:"success"}),d(),o()}catch(R){D(R instanceof Error?R.message:"Failed to create issue")}finally{N(!1)}}};return n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[n.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:o}),n.jsxs("div",{className:"relative bg-[#0f172a] border border-white/10 rounded-2xl shadow-2xl w-full max-w-lg",children:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-white/5",children:[n.jsx("h2",{className:"text-lg font-semibold text-slate-100",children:"New Board Issue"}),n.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-white/5 text-slate-500 hover:text-slate-300 transition-colors",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsxs("form",{onSubmit:U,className:"p-6 space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Title"}),n.jsx("input",{type:"text",value:r,onChange:A=>m(A.target.value),placeholder:"Issue title...",required:!0,className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm placeholder-slate-600 focus:outline-none focus:border-indigo-500/50 focus:ring-1 focus:ring-indigo-500/20"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Column"}),n.jsx("select",{value:v,onChange:A=>g(A.target.value),className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm focus:outline-none focus:border-indigo-500/50 appearance-none cursor-pointer",children:Xl.map(A=>n.jsx("option",{value:A,children:A},A))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium text-slate-400 uppercase tracking-wide block mb-1.5",children:"Body (optional)"}),n.jsx("textarea",{value:f,onChange:A=>h(A.target.value),placeholder:"Issue description...",rows:5,className:"w-full bg-slate-950/50 border border-white/10 text-slate-200 rounded-lg px-3 py-2.5 text-sm placeholder-slate-600 focus:outline-none focus:border-indigo-500/50 focus:ring-1 focus:ring-indigo-500/20 resize-none font-mono"})]}),w&&n.jsx("p",{className:"text-sm text-red-400",children:w}),n.jsxs("div",{className:"flex justify-end space-x-3 pt-2",children:[n.jsx(re,{variant:"ghost",type:"button",onClick:o,children:"Cancel"}),n.jsx(re,{type:"submit",disabled:p||!r.trim(),children:p?"Creating...":"Create Issue"})]})]})]})]})},Ly=({issue:c,onClose:o,onMoved:d,onClosed:r})=>{const[m,f]=y.useState(!1),[h,v]=y.useState(!1),{addToast:g}=rt(),p=async D=>{if(D!==c.column){f(!0);try{await F0(c.number,D),g({title:"Issue moved",message:`#${c.number} moved to ${D}`,type:"success"}),d(),o()}catch(z){g({title:"Move failed",message:z instanceof Error?z.message:"Failed to move issue",type:"error"})}finally{f(!1)}}},N=async()=>{if(confirm(`Close issue #${c.number}: "${c.title}"?`)){v(!0);try{await my(c.number),g({title:"Issue closed",message:`#${c.number} closed on GitHub`,type:"success"}),r(),o()}catch(D){g({title:"Close failed",message:D instanceof Error?D.message:"Failed to close issue",type:"error"})}finally{v(!1)}}},w=c.column??"Draft";return n.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[n.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:o}),n.jsxs("div",{className:"relative bg-[#0a0f1e] border-l border-white/10 w-full max-w-xl flex flex-col shadow-2xl overflow-hidden",children:[n.jsxs("div",{className:"flex items-start justify-between p-6 border-b border-white/5 flex-shrink-0",children:[n.jsxs("div",{className:"flex-1 min-w-0 pr-4",children:[n.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[n.jsxs("span",{className:"text-slate-500 text-sm font-mono",children:["#",c.number]}),n.jsx(ha,{variant:Uu[w].badge,children:w})]}),n.jsx("h2",{className:"text-lg font-semibold text-slate-100 leading-snug",children:c.title}),c.assignees.length>0&&n.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Assigned to: ",c.assignees.join(", ")]})]}),n.jsx("button",{onClick:o,className:"p-1.5 rounded-lg hover:bg-white/5 text-slate-500 hover:text-slate-300 transition-colors flex-shrink-0",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsxs("div",{className:"flex items-center space-x-3 px-6 py-3 border-b border-white/5 flex-shrink-0 flex-wrap gap-y-2",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:"text-xs text-slate-500",children:"Move to:"}),Xl.filter(D=>D!==c.column).map(D=>n.jsx("button",{onClick:()=>p(D),disabled:m,className:"text-xs px-2.5 py-1 rounded-md bg-slate-800 text-slate-300 hover:bg-slate-700 hover:text-slate-100 border border-slate-700 transition-colors disabled:opacity-50",children:D},D))]}),n.jsxs("div",{className:"flex items-center space-x-2 ml-auto",children:[n.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-1 text-xs text-indigo-400 hover:text-indigo-300 transition-colors",children:[n.jsx(Tu,{className:"h-3.5 w-3.5"}),n.jsx("span",{children:"GitHub"})]}),n.jsx("button",{onClick:N,disabled:h,className:"text-xs px-2.5 py-1 rounded-md bg-red-500/10 text-red-400 hover:bg-red-500/20 border border-red-500/20 transition-colors disabled:opacity-50",children:h?"Closing...":"Close Issue"})]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:c.body?n.jsx("pre",{className:"text-sm text-slate-300 whitespace-pre-wrap font-mono leading-relaxed break-words",children:c.body}):n.jsx("p",{className:"text-slate-500 text-sm italic",children:"No description provided."})})]})]})},qy=({issue:c,onClick:o,onMoveRequest:d})=>{const[r,m]=y.useState(!1),f=c.column??"Draft";return n.jsxs("div",{className:"relative group",children:[n.jsx(be,{className:"p-3 cursor-pointer hover:border-indigo-500/30 transition-all active:scale-[0.99] select-none",onClick:o,children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("span",{className:"text-[10px] font-mono text-slate-600",children:["#",c.number]}),n.jsx("p",{className:"text-xs font-medium text-slate-200 line-clamp-2 mt-0.5 leading-snug",children:c.title}),c.assignees.length>0&&n.jsx("p",{className:"text-[10px] text-slate-500 mt-1.5 truncate",children:c.assignees.join(", ")})]}),n.jsx("button",{onClick:h=>{h.stopPropagation(),m(v=>!v)},className:"ml-2 p-1 rounded hover:bg-white/10 text-slate-500 hover:text-slate-300 transition-colors flex-shrink-0",title:"Move issue",children:n.jsx(Y0,{className:"h-3.5 w-3.5"})})]})}),r&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>m(!1)}),n.jsx("div",{className:"absolute right-0 top-full mt-1 z-40 bg-[#0f172a] border border-white/10 rounded-xl shadow-2xl py-1 min-w-[140px]",children:Xl.filter(h=>h!==f).map(h=>n.jsxs("button",{onClick:()=>{d(c,h),m(!1)},className:"w-full text-left text-xs px-4 py-2 text-slate-300 hover:bg-white/5 hover:text-slate-100 transition-colors flex items-center space-x-2",children:[n.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Uu[h].dot}`}),n.jsx("span",{children:h})]},h))})]})]})},Yy=({name:c,issues:o,onIssueClick:d,onNewIssue:r,onMoveIssue:m})=>{const f=Uu[c];return n.jsxs("div",{className:"flex flex-col min-w-[220px] max-w-[220px] h-full",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${f.dot}`}),n.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wider",children:c}),n.jsx("span",{className:"text-[10px] font-bold text-slate-600 bg-slate-800 rounded-full px-1.5 py-0.5",children:o.length})]}),n.jsx("button",{onClick:()=>r(c),className:"p-1 rounded-md hover:bg-white/5 text-slate-600 hover:text-slate-400 transition-colors",title:`Add issue to ${c}`,children:n.jsx(gl,{className:"h-3.5 w-3.5"})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 pr-1 scrollbar-hide min-h-0",children:o.length===0?n.jsx("div",{className:"border-2 border-dashed border-slate-800 rounded-xl h-24 flex items-center justify-center",children:n.jsx("span",{className:"text-xs text-slate-700",children:"No issues"})}):o.map(h=>n.jsx(qy,{issue:h,onClick:()=>d(h),onMoveRequest:m},h.id))})]})},Gy=()=>{const[c,o]=y.useState(null),[d,r]=y.useState(null),{addToast:m,selectedProjectId:f,globalModeLoading:h}=rt(),{data:v,loading:g,error:p,refetch:N}=ct(Ou,[f],{enabled:!h});y.useEffect(()=>{const z=setInterval(()=>N(),3e4);return()=>clearInterval(z)},[N]);const w=y.useCallback(async(z,U)=>{try{await F0(z.number,U),m({title:"Issue moved",message:`#${z.number} moved to ${U}`,type:"success"}),N()}catch(A){m({title:"Move failed",message:A instanceof Error?A.message:"Failed to move issue",type:"error"})}},[m,N]);if(h||g)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading board..."})});if(p&&p.message.includes("Board not configured"))return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx("div",{className:"text-4xl",children:"📋"}),n.jsx("h2",{className:"text-xl font-semibold text-slate-200",children:"Board not configured"}),n.jsxs("p",{className:"text-slate-500 text-sm max-w-sm text-center",children:["Run ",n.jsx("code",{className:"font-mono bg-slate-800 px-2 py-0.5 rounded text-indigo-300",children:"night-watch board setup"})," in your project to create a GitHub Projects board."]})]});if(p)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx("div",{className:"text-slate-300",children:"Failed to load board"}),n.jsx("div",{className:"text-sm text-slate-500",children:p.message}),n.jsx(re,{onClick:()=>N(),children:"Retry"})]});if(!v)return null;const D=v.columns;return n.jsxs("div",{className:"flex flex-col h-full",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6 flex-shrink-0",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold text-slate-100",children:"Board"}),n.jsxs("p",{className:"text-sm text-slate-500 mt-1",children:[Xl.reduce((z,U)=>{var A;return z+(((A=D[U])==null?void 0:A.length)??0)},0)," issues across ",Xl.length," columns"]})]}),n.jsxs(re,{onClick:()=>r("Ready"),children:[n.jsx(gl,{className:"h-4 w-4 mr-2"}),"New Issue"]})]}),n.jsx("div",{className:"flex-1 overflow-x-auto overflow-y-hidden",children:n.jsx("div",{className:"flex space-x-4 h-full pb-4",style:{minWidth:`${Xl.length*236}px`},children:Xl.map(z=>n.jsx(Yy,{name:z,issues:D[z]??[],onIssueClick:o,onNewIssue:r,onMoveIssue:w},z))})}),c&&n.jsx(Ly,{issue:c,onClose:()=>o(null),onMoved:()=>N(),onClosed:()=>N()}),d&&n.jsx(By,{defaultColumn:d,onClose:()=>r(null),onCreated:()=>N()})]})},Qy={Draft:"text-slate-400 bg-slate-500/10 ring-slate-500/20",Ready:"text-green-400 bg-green-500/10 ring-green-500/20","In Progress":"text-blue-400 bg-blue-500/10 ring-blue-500/20",Review:"text-amber-400 bg-amber-500/10 ring-amber-500/20",Done:"text-slate-500 bg-slate-600/10 ring-slate-600/20"},Vy=()=>{var $,ie,we;const c=Su(),[o,d]=y.useState(null),[r,m]=y.useState(!1),[f,h]=y.useState(null),{setProjectName:v,addToast:g,selectedProjectId:p,globalModeLoading:N}=rt(),{data:w,loading:D,error:z,refetch:U}=ct(K0,[p],{enabled:!N}),{data:A}=ct(J0,[p],{enabled:!N}),{data:R}=ct(()=>Ou().catch(()=>null),[p],{enabled:!N});P0(se=>{h(se)},[p,N],{enabled:!N});const Q=f||w;if(Qe.useEffect(()=>{Q!=null&&Q.projectName&&v(Q.projectName)},[Q,v]),y.useEffect(()=>{const se=setInterval(()=>{U()},3e4);return()=>clearInterval(se)},[U]),y.useEffect(()=>{const se=()=>U();return window.addEventListener("focus",se),()=>window.removeEventListener("focus",se)},[U]),N||D)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading..."})});if(z)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load dashboard data"}),n.jsx("div",{className:"text-sm text-slate-500",children:z.message}),n.jsx(re,{onClick:()=>U(),children:"Retry"})]});if(!Q)return null;const q=Q.prds.filter(se=>se.status==="ready").length,L=Q.prds.filter(se=>se.status==="in-progress"),J=Q.prs.length,B=Q.prs.filter(se=>se.reviewScore!==null&&se.reviewScore<70).length,C=Q.processes.find(se=>se.name==="executor"),V=Q.processes.find(se=>se.name==="reviewer"),Z=Q.processes.find(se=>se.name==="qa"),P=async se=>{d(se);try{const k=await uy(se),F=k.results.every(ae=>ae.success);g({title:F?"Process Cancelled":"Cancel Failed",message:k.results.map(ae=>ae.message).join("; "),type:F?"success":"error"})}catch(k){g({title:"Cancel Failed",message:k instanceof Error?k.message:"Failed to cancel process",type:"error"})}finally{d(null),U()}},ue=async()=>{m(!0);try{await dy(),g({title:"Lock Cleared",message:"Stale executor state removed",type:"success"}),U()}catch(se){g({title:"Clear Failed",message:se instanceof Error?se.message:"Failed to clear lock",type:"error"})}finally{m(!1)}},xe=se=>{if(!se)return"Not scheduled";try{const k=new Date(se),F=new Date,ae=k.getTime()-F.getTime(),pe=Math.floor(ae/6e4);return pe<0?"Running now...":pe<60?`In ${pe} min`:pe<1440?`In ${Math.floor(pe/60)} hr${pe>=120?"s":""}`:`In ${Math.floor(pe/1440)} day${pe>=2880?"s":""}`}catch{return"Unknown"}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsxs(be,{className:"p-5",onClick:()=>c("/prds"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"PRDs Ready"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:q})]}),n.jsx("div",{className:"p-2 bg-green-500/10 rounded-lg text-green-400",children:n.jsx(ns,{className:"h-5 w-5"})})]}),n.jsxs("p",{className:"text-xs text-slate-500 mt-4",children:["of ",Q.prds.length," total"]})]}),n.jsxs(be,{className:"p-5",onClick:()=>c("/prds"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"In Progress"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:L.length})]}),n.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg text-blue-400",children:n.jsx(q0,{className:"h-5 w-5"})})]}),n.jsx("p",{className:"text-xs text-slate-500 mt-4 truncate",children:L.length===1?L[0].name:`${L.length} active`})]}),n.jsxs(be,{className:"p-5",onClick:()=>c("/prs"),children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Open PRs"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:J})]}),n.jsx("div",{className:"p-2 bg-purple-500/10 rounded-lg text-purple-400",children:n.jsx(Mi,{className:"h-5 w-5"})})]}),n.jsx("p",{className:`text-xs mt-4 ${B>0?"text-red-400 font-medium":"text-slate-500"}`,children:B>0?`${B} need work`:"All passing"})]}),n.jsxs(be,{className:"p-5",children:[n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Cron Status"}),n.jsx("h3",{className:"text-3xl font-bold text-slate-100 mt-1",children:Q.crontab.installed?"Active":"Inactive"})]}),n.jsx("div",{className:`p-2 rounded-lg ${Q.crontab.installed?"bg-indigo-500/10 text-indigo-400":"bg-slate-700/50 text-slate-500"}`,children:n.jsx(Ri,{className:"h-5 w-5"})})]}),n.jsx("p",{className:"text-xs text-slate-500 mt-4",children:Q.crontab.installed?`${Q.crontab.entries.length} entr${Q.crontab.entries.length===1?"y":"ies"} installed`:"No crontab entries"})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsx("h2",{className:"text-base font-semibold text-slate-200 mb-4",children:"System Status"}),n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Project"}),n.jsx("p",{className:"text-sm text-slate-200",children:Q.projectName})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Provider"}),n.jsx("p",{className:"text-sm text-slate-200 capitalize",children:Q.config.provider})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"PRD Directory"}),n.jsx("p",{className:"text-sm text-slate-200",children:Q.config.prdDir})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase mb-1",children:"Last Updated"}),n.jsx("p",{className:"text-sm text-slate-200",children:new Date(Q.timestamp).toLocaleString()})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-base font-semibold text-slate-200 mb-4",children:"Process Status"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${C!=null&&C.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${C!=null&&C.running?"text-slate-200":"text-slate-400"}`,children:"Executor"}),n.jsx("div",{className:"text-xs text-slate-500",children:C!=null&&C.running?`PID: ${C.pid} • ${Q.activePrd??"Running"}`:"Idle"})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[(C==null?void 0:C.running)&&n.jsxs(re,{size:"sm",variant:"ghost",className:"text-red-400 hover:text-red-300",onClick:()=>P("run"),disabled:o==="run",children:[n.jsx(hu,{className:"h-4 w-4 mr-1"}),o==="run"?"Stopping...":"Stop"]}),!(C!=null&&C.running)&&L.length>0&&n.jsx(re,{size:"sm",variant:"ghost",className:"text-amber-400 hover:text-amber-300",onClick:ue,disabled:r,children:r?"Clearing...":"Force Clear"}),n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),children:"View Log"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${V!=null&&V.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${V!=null&&V.running?"text-slate-200":"text-slate-400"}`,children:"Reviewer"}),n.jsx("div",{className:"text-xs text-slate-500",children:V!=null&&V.running?`PID: ${V.pid} • Running`:"Idle"})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[(V==null?void 0:V.running)&&n.jsxs(re,{size:"sm",variant:"ghost",className:"text-red-400 hover:text-red-300",onClick:()=>P("review"),disabled:o==="review",children:[n.jsx(hu,{className:"h-4 w-4 mr-1"}),o==="review"?"Stopping...":"Stop"]}),n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),disabled:!(V!=null&&V.running),children:"View Log"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${Z!=null&&Z.running?"bg-green-500 animate-pulse shadow-[0_0_8px_rgba(34,197,94,0.5)]":"bg-slate-700"}`}),n.jsxs("div",{children:[n.jsx("div",{className:`font-medium ${Z!=null&&Z.running?"text-slate-200":"text-slate-400"}`,children:"QA"}),n.jsx("div",{className:"text-xs text-slate-500",children:Z!=null&&Z.running?`PID: ${Z.pid} • Running`:"Idle"})]})]}),n.jsx("div",{className:"flex items-center space-x-2",children:n.jsx(re,{size:"sm",variant:"ghost",onClick:()=>c("/logs"),children:"View Log"})})]})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-base font-semibold text-slate-200",children:"Scheduling"}),n.jsxs("button",{onClick:()=>c("/scheduling"),className:"text-sm text-indigo-400 hover:text-indigo-300 flex items-center transition-colors",children:["Manage Schedules ",n.jsx(n0,{className:"ml-1 h-3 w-3"})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${A!=null&&A.executor.installed?"bg-indigo-500/10 text-indigo-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(Ri,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${A!=null&&A.executor.installed?"text-slate-200":"text-slate-500"}`,children:"Executor"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe(A==null?void 0:A.executor.nextRun)})]})]})}),n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${A!=null&&A.reviewer.installed?"bg-purple-500/10 text-purple-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(Mi,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${A!=null&&A.reviewer.installed?"text-slate-200":"text-slate-500"}`,children:"Reviewer"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe(A==null?void 0:A.reviewer.nextRun)})]})]})}),n.jsx("div",{className:"flex items-center justify-between p-3 bg-slate-950/50 rounded-lg border border-slate-800",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`p-1.5 rounded-md ${($=A==null?void 0:A.qa)!=null&&$.installed?"bg-green-500/10 text-green-400":"bg-slate-800 text-slate-500"}`,children:n.jsx(kb,{className:"h-4 w-4"})}),n.jsxs("div",{children:[n.jsx("div",{className:`text-sm font-medium ${(ie=A==null?void 0:A.qa)!=null&&ie.installed?"text-slate-200":"text-slate-500"}`,children:"QA"}),n.jsx("div",{className:"text-xs text-slate-500",children:A!=null&&A.paused?"Paused":xe((we=A==null?void 0:A.qa)==null?void 0:we.nextRun)})]})]})})]})]})]}),n.jsxs("div",{className:"mt-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h2",{className:"text-lg font-semibold text-slate-200",children:"GitHub Board"}),n.jsxs("button",{onClick:()=>c("/board"),className:"text-sm text-indigo-400 hover:text-indigo-300 flex items-center transition-colors",children:["View board ",n.jsx(n0,{className:"ml-1 h-3 w-3"})]})]}),n.jsx(be,{className:"p-4",children:R?n.jsx("div",{className:"flex flex-wrap gap-3",children:Xl.map(se=>{var F;const k=((F=R.columns[se])==null?void 0:F.length)??0;return n.jsxs("button",{onClick:()=>c("/board"),className:`inline-flex items-center space-x-2 px-3 py-2 rounded-lg ring-1 ring-inset transition-colors hover:opacity-80 ${Qy[se]}`,children:[n.jsx("span",{className:"text-xs font-medium",children:se}),n.jsx("span",{className:"text-xs font-bold",children:k})]},se)})}):n.jsxs("p",{className:"text-sm text-slate-500 italic",children:["Board not configured — run ",n.jsx("code",{className:"font-mono bg-slate-800 px-1.5 py-0.5 rounded text-indigo-300 text-xs",children:"night-watch board setup"})," to enable."]})})]})]})},Me=Qe.forwardRef(({className:c="",label:o,error:d,helperText:r,rightIcon:m,...f},h)=>n.jsxs("div",{className:"w-full",children:[o&&n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1.5",children:o}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{ref:h,className:`
|
|
411
411
|
w-full rounded-lg bg-slate-950 border border-slate-800
|
|
412
412
|
px-3 py-2 text-sm text-slate-200
|
|
413
413
|
placeholder:text-slate-600
|
|
@@ -467,7 +467,7 @@ Please change the parent <Route path="${L}"> to <Route path="${L==="/"?"*":`${L}
|
|
|
467
467
|
} `;if(!c)return n.jsx("div",{className:"animate-pulse flex space-x-4",children:"Loading..."});const se=((ae=c.slack)==null?void 0:ae.enabled)&&((pe=c.slack)==null?void 0:pe.botToken),k=()=>n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h2",{className:"text-xl font-bold flex items-center gap-3",children:[n.jsx(r0,{className:"w-6 h-6 text-indigo-400"}),"Slack Bot Configuration"]}),n.jsx("p",{className:"text-slate-400 mt-1",children:"Manage your connected Slack workspace."})]}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-400 bg-green-400/10 px-3 py-1.5 rounded-full border border-green-500/20",children:[n.jsx(tn,{className:"w-4 h-4"})," Connected"]})]}),n.jsxs(be,{className:"p-6 space-y-4",children:[n.jsx("h3",{className:"font-medium text-slate-200 border-b border-white/10 pb-2 mb-4",children:"API Token"}),n.jsx("div",{className:"flex gap-4",children:n.jsx(Me,{label:"Bot User OAuth Token",type:v?"text":"password",value:z,onChange:K=>U(K.target.value),className:"flex-1",rightIcon:n.jsx("button",{type:"button",onClick:()=>g(!v),className:"hover:text-slate-300 pointer-events-auto transition-colors",children:v?n.jsx(xu,{className:"w-4 h-4"}):n.jsx(zi,{className:"w-4 h-4"})})})}),n.jsxs("div",{className:"mt-4",children:[n.jsx(Me,{label:"App-Level Token (Socket Mode)",type:v?"text":"password",value:A,onChange:K=>R(K.target.value),placeholder:"xapp-..."}),n.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Required for real-time agent mentions like ",n.jsx("code",{children:"@maya"}),"."]})]}),n.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-2 mb-4 mt-8",children:[n.jsx("h3",{className:"font-medium text-slate-200",children:"Channels"}),n.jsx("span",{className:"text-[10px] uppercase tracking-wider text-slate-500 font-bold",children:"Public & Visible"})]}),n.jsx("div",{className:"grid grid-cols-2 gap-6",children:[{label:"eng",id:Q},{label:"prs",id:L},{label:"incidents",id:B},{label:"releases",id:V}].map(K=>n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("label",{className:"text-xs font-medium text-slate-400 capitalize",children:["#",K.label," Channel"]}),K.id&&n.jsxs("button",{onClick:()=>window.open(`https://slack.com/app_redirect?channel=${K.id}`,"_blank"),className:"text-[10px] text-indigo-400 hover:text-indigo-300 flex items-center gap-1 transition-colors",children:["Open ",n.jsx(Tu,{className:"w-2.5 h-2.5"})]})]}),n.jsx(Me,{value:K.id,onChange:j=>{K.label==="eng"&&q(j.target.value),K.label==="prs"&&J(j.target.value),K.label==="incidents"&&C(j.target.value),K.label==="releases"&&Z(j.target.value)},placeholder:"C1234567890"})]},K.label))}),n.jsx("div",{className:"mt-6 p-3 bg-indigo-500/5 border border-indigo-500/10 rounded-lg",children:n.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:[n.jsx("strong",{className:"text-indigo-300",children:"Pro Tip:"})," Channels are created as ",n.jsx("strong",{children:"Public"}),". If you don't see them in your sidebar, click ",n.jsx("b",{children:'"Add Channels" > "Browse all channels"'})," in Slack to join them for the first time."]})}),n.jsxs("div",{className:"mt-4 flex items-center justify-between rounded-lg border border-white/10 bg-white/[0.02] p-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-200",children:"Enable Agent Discussions"}),n.jsx("p",{className:"text-xs text-slate-400",children:"Allows mention routing and threaded agent deliberation."})]}),n.jsxs("label",{className:"inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",className:"sr-only peer",checked:P,onChange:K=>ue(K.target.checked)}),n.jsx("span",{className:"w-11 h-6 bg-slate-700 rounded-full peer peer-checked:bg-indigo-500 transition-colors relative",children:n.jsx("span",{className:`absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white transition-transform ${P?"translate-x-5":"translate-x-0"}`})})]})]}),n.jsx("div",{className:"pt-6 border-t border-white/10 flex justify-end",children:n.jsx(re,{onClick:()=>xe(!0),loading:f,children:"Save Changes"})})]})]}),F=[{number:1,title:"Create App",icon:Mv},{number:2,title:"Tokens & Scopes",icon:Z0},{number:3,title:"Channels",icon:xl}];return n.jsxs("div",{className:"max-w-4xl mx-auto space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500",children:[n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("h1",{className:"text-3xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-indigo-400 to-cyan-400 tracking-tight",children:"Integrations"}),n.jsx("p",{className:"text-slate-400",children:"Connect Night Watch to your tools for a seamless agentic workflow."})]}),se&&r===1?k():n.jsxs(be,{className:"p-8",children:[n.jsxs("div",{className:"mb-8",children:[n.jsxs("h2",{className:"text-2xl font-bold flex items-center gap-3",children:[n.jsx(r0,{className:"w-7 h-7 text-indigo-400"}),"Connect Slack"]}),n.jsx("p",{className:"text-slate-400 mt-2",children:"Night Watch operates natively in Slack, allowing agents to discuss PRs, triage errors, and collaborate."})]}),n.jsxs("div",{className:"flex items-center justify-between mb-8 relative",children:[n.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-slate-800 z-0"}),n.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 h-0.5 bg-indigo-500 z-0 transition-all duration-300",style:{width:`${(r-1)/(F.length-1)*100}%`}}),F.map(K=>n.jsxs("div",{className:`relative z-10 flex flex-col items-center gap-2 ${r>=K.number?"text-indigo-400":"text-slate-500"}`,children:[n.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center font-bold text-lg border-2 transition-all duration-300 bg-[#0b101b]
|
|
468
468
|
${r>=K.number?"border-indigo-500 glow-indigo":"border-slate-800"}
|
|
469
469
|
${r===K.number?"ring-4 ring-indigo-500/20":""}
|
|
470
|
-
`,children:r>K.number?n.jsx(tn,{className:"w-6 h-6"}):n.jsx(K.icon,{className:"w-5 h-5"})}),n.jsx("span",{className:"text-xs font-medium tracking-wide",children:K.title})]},K.number))]}),n.jsxs("div",{className:"min-h-[300px]",children:[r===1&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"1. Create a Slack App via Manifest"}),n.jsx("p",{className:"text-sm text-slate-400",children:"We've made it easy. Copy the JSON manifest below and paste it into the Slack API dashboard to create your app instantly with the correct scopes."}),n.jsxs("div",{className:"bg-[#1e293b] rounded-lg p-4 border border-white/5 relative group",children:[n.jsx("pre",{className:"text-xs text-slate-300 overflow-x-auto",children:n.jsx("code",{children:we})}),n.jsx(re,{size:"sm",className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{navigator.clipboard.writeText(we),d({title:"Copied",message:"Manifest copied to clipboard",type:"info"})},children:"Copy JSON"})]})]}),n.jsxs("div",{className:"flex justify-between items-center pt-4",children:[n.jsx(re,{variant:"outline",onClick:()=>window.open(ie,"_blank"),children:"Open Slack API Console"}),n.jsxs(re,{onClick:()=>m(2),children:["Next Step ",n.jsx(_i,{className:"w-4 h-4 ml-1"})]})]})]}),r===2&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"2. Install App & Get Token"}),n.jsxs("p",{className:"text-sm text-slate-400",children:["After creating the app, navigate to ",n.jsx("strong",{children:"Features > OAuth & Permissions"})," in the left sidebar of the Slack API dashboard. Click ",n.jsx("strong",{children:"Install to Workspace"}),". Once installed, copy the ",n.jsx("strong",{children:"Bot User OAuth Token"})," (starts with ",n.jsx("code",{children:"xoxb-"}),") and paste it below. Then create an ",n.jsx("strong",{children:"App-Level Token"})," with ",n.jsx("code",{children:"connections:write"})," (starts with ",n.jsx("code",{children:"xapp-"}),") and paste it as well. Ignore the Client ID and secrets on the Basic Information page."]}),n.jsxs("div",{className:"max-w-md mt-6",children:[n.jsx(Me,{label:"Slack Bot Token",placeholder:"xoxb-...",value:z,onChange:K=>U(K.target.value),type:v?"text":"password",rightIcon:n.jsx("button",{type:"button",onClick:()=>g(!v),className:"hover:text-slate-300 pointer-events-auto transition-colors",children:v?n.jsx(xu,{className:"w-4 h-4"}):n.jsx(zi,{className:"w-4 h-4"})})}),n.jsxs("div",{className:"mt-4",children:[n.jsx(Me,{label:"Slack App Token (Socket Mode)",placeholder:"xapp-...",value:A,onChange:K=>R(K.target.value),type:v?"text":"password"}),n.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Needed for real-time ",n.jsx("code",{children:"@agent"})," replies (Socket Mode + ",n.jsx("code",{children:"connections:write"}),")."]})]})]})]}),n.jsxs("div",{className:"flex justify-between pt-8",children:[n.jsx(re,{variant:"ghost",onClick:()=>m(1),children:"Back"}),n.jsxs(re,{onClick:$,disabled:!z.startsWith("xoxb-")||w,children:["Next Step ",n.jsx(_i,{className:"w-4 h-4 ml-1"})]})]})]}),r===3&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"3. Map Channels"}),n.jsx("p",{className:"text-sm text-slate-400",children:`Provide the Slack channel IDs where the agents should operate. You can find the Channel ID at the bottom of the channel's "About" modal in Slack.`}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-8",children:p.length>0?n.jsxs(n.Fragment,{children:[n.jsxs(be,{className:"p-4 border border-indigo-500/20 bg-indigo-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-indigo-300",children:[n.jsx(xl,{className:"w-4 h-4"})," eng"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"General engineering chat and agent banter."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:Q,onChange:q})]}),n.jsxs(be,{className:"p-4 border border-blue-500/20 bg-blue-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-blue-300",children:[n.jsx(xl,{className:"w-4 h-4"})," prs"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Pull Request reviews and agent deliberation."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:L,onChange:J})]}),n.jsxs(be,{className:"p-4 border border-red-500/20 bg-red-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-red-300",children:[n.jsx(xl,{className:"w-4 h-4"})," incidents"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"CI/CD failures and production alerts."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:B,onChange:C})]}),n.jsxs(be,{className:"p-4 border border-emerald-500/20 bg-emerald-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-emerald-300",children:[n.jsx(xl,{className:"w-4 h-4"})," releases"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Ship announcements and merged PRs."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:V,onChange:Z})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs(be,{className:"p-4 border border-indigo-500/20 bg-indigo-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-indigo-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," eng"]}),n.jsx(Me,{placeholder:"C1234567890",value:Q,onChange:K=>q(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-blue-500/20 bg-blue-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-blue-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," prs"]}),n.jsx(Me,{placeholder:"C1234567890",value:L,onChange:K=>J(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-red-500/20 bg-red-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-red-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," incidents"]}),n.jsx(Me,{placeholder:"C1234567890",value:B,onChange:K=>C(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-emerald-500/20 bg-emerald-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-emerald-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," releases"]}),n.jsx(Me,{placeholder:"C1234567890",value:V,onChange:K=>Z(K.target.value)})]})]})}),n.jsxs("div",{className:"mt-6 flex items-center justify-between rounded-lg border border-white/10 bg-white/[0.02] p-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-200",children:"Enable Agent Discussions"}),n.jsx("p",{className:"text-xs text-slate-400",children:"Threaded agent collaboration and targeted @persona responses."})]}),n.jsxs("label",{className:"inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",className:"sr-only peer",checked:P,onChange:K=>ue(K.target.checked)}),n.jsx("span",{className:"w-11 h-6 bg-slate-700 rounded-full peer peer-checked:bg-indigo-500 transition-colors relative",children:n.jsx("span",{className:`absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white transition-transform ${P?"translate-x-5":"translate-x-0"}`})})]})]})]}),n.jsxs("div",{className:"flex justify-between pt-8",children:[n.jsx(re,{variant:"ghost",onClick:()=>m(2),children:"Back"}),n.jsx(re,{onClick:()=>xe(!0),loading:f,disabled:!Q||!L||!B,children:"Complete Setup"})]})]})]})]})]})}const Zy=()=>{const[c,o]=y.useState(!0),[d,r]=y.useState(""),[m,f]=y.useState("executor"),h=y.useRef(null),{selectedProjectId:v,globalModeLoading:g}=rt(),{data:p,loading:N,error:w,refetch:D}=ct(()=>ny(m,500),[m,v],{enabled:!g}),{data:z}=ct(K0,[v],{enabled:!g}),U=(p==null?void 0:p.lines)||[];y.useEffect(()=>{c&&h.current&&(h.current.scrollTop=h.current.scrollHeight)},[U,c]),y.useEffect(()=>{if(!c)return;const q=window.setInterval(()=>{D()},3e3);return()=>window.clearInterval(q)},[c,m,D]);const A=U.filter(q=>q.toLowerCase().includes(d.toLowerCase())),R=q=>{f(q),r("")},Q=q=>{if(!(z!=null&&z.processes))return!1;const L=z.processes.find(J=>J.name===q);return(L==null?void 0:L.running)??!1};return w?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load logs"}),n.jsx("div",{className:"text-sm text-slate-500",children:w.message}),n.jsx(re,{onClick:()=>D(),children:"Retry"})]}):n.jsxs("div",{className:"flex flex-col h-[calc(100vh-8rem)]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4 bg-slate-900 p-2 rounded-lg border border-slate-800 shadow-sm",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("input",{type:"text",placeholder:"Filter logs...",className:"pl-9 pr-4 py-1.5 rounded-md border border-slate-700 bg-slate-950 text-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent w-64 placeholder:text-slate-600",value:d,onChange:q=>r(q.target.value)}),n.jsx(_u,{className:"absolute left-2.5 top-2 h-4 w-4 text-slate-500 group-focus-within:text-indigo-400"})]}),n.jsx("div",{className:"h-6 w-px bg-slate-700 mx-2"}),n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("button",{onClick:()=>R("executor"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="executor"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"Executor"}),Q("executor")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})}),n.jsx("button",{onClick:()=>R("reviewer"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="reviewer"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"Reviewer"}),Q("reviewer")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})}),n.jsx("button",{onClick:()=>R("qa"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="qa"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"QA"}),Q("qa")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs(re,{size:"sm",variant:"ghost",onClick:()=>D(),children:[n.jsx(i0,{className:"h-4 w-4 mr-2"}),"Refresh"]}),n.jsxs(re,{size:"sm",variant:"ghost",onClick:()=>o(!c),children:[c?n.jsx(V0,{className:"h-4 w-4 mr-2"}):n.jsx(ss,{className:"h-4 w-4 mr-2"}),c?"Pause":"Resume"]})]})]}),n.jsxs("div",{className:"flex-1 bg-slate-900 rounded-xl overflow-hidden shadow-inner border border-slate-800 flex flex-col relative",children:[n.jsxs("div",{className:"bg-slate-950/50 backdrop-blur text-xs text-slate-500 px-4 py-1.5 flex justify-between border-b border-slate-800",children:[n.jsxs("span",{children:["File: ",m,".log"]}),n.jsxs("span",{children:[A.length," lines"]})]}),n.jsxs("div",{ref:h,className:"flex-1 overflow-y-auto p-4 font-mono text-sm terminal-scroll bg-slate-900",children:[N?n.jsx("div",{className:"flex items-center justify-center h-full text-slate-500",children:"Loading logs..."}):A.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-slate-500",children:d?"No logs match your filter":"No logs yet — logs will appear after the first run"}):A.map((q,L)=>{const J=q.includes("[ERROR]"),B=q.includes("[WARN]");return n.jsxs("div",{className:`leading-6 hover:bg-slate-800/50 px-2 rounded -mx-2 ${J?"text-red-400":B?"text-amber-400":"text-slate-300"}`,children:[n.jsx("span",{className:"text-slate-600 select-none w-10 inline-block text-right mr-4 text-xs opacity-50",children:L+1}),q]},L)}),c&&n.jsx("div",{className:"h-4"})," "]}),!c&&n.jsxs("div",{className:"absolute bottom-4 right-4 bg-indigo-600 text-white px-3 py-1.5 rounded-full shadow-lg shadow-indigo-900/40 text-xs font-medium flex items-center cursor-pointer hover:bg-indigo-500 transition-colors",onClick:()=>o(!0),children:[n.jsx(i0,{className:"h-4 w-4 mr-2"}),"Scroll to bottom"]})]})]})},$y=({isOpen:c,onClose:o,title:d,children:r})=>(y.useEffect(()=>{const m=f=>{f.key==="Escape"&&o()};return c&&(document.addEventListener("keydown",m),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",m),document.body.style.overflow="unset"}},[c,o]),c?ov.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6",children:[n.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:o,"aria-hidden":"true"}),n.jsxs("div",{className:"relative w-full max-w-2xl transform rounded-xl bg-slate-900 border border-slate-800 shadow-2xl transition-all flex flex-col max-h-[90vh]",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 px-6 py-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-100",children:d}),n.jsx("button",{onClick:o,className:"rounded-full p-1 text-slate-400 hover:bg-slate-800 hover:text-slate-300 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6 text-slate-300",children:r})]})]}),document.body):null),uu={ready:"Ready","in-progress":"In Progress",blocked:"Blocked","pending-review":"Pending Review",done:"Done"},ou={ready:"success","in-progress":"info",blocked:"error","pending-review":"warning",done:"neutral"},Ky=()=>{const[c,o]=y.useState("list"),[d,r]=y.useState(!1),[m,f]=y.useState(null),[h,v]=y.useState(!1),[g,p]=y.useState(!1),[N,w]=y.useState({}),{addToast:D,selectedProjectId:z,globalModeLoading:U}=rt(),{data:A,loading:R,error:Q,refetch:q}=ct(ly,[z],{enabled:!U}),L=A??[],{data:J}=ct(()=>Ou().catch(()=>null),[z],{enabled:!U}),B=Qe.useMemo(()=>{const $=new Map;if(!J)return $;for(const ie of Object.values(J.columns))for(const we of ie)$.set(we.title.toLowerCase().trim(),we);return $},[J]),C=$=>{if(!$.content)return $.name;const ie=$.content.match(/^#\s+(.+)$/m);return ie?ie[1].trim():$.name},V=$=>{const ie=C($).toLowerCase().trim();return B.get(ie)??null},Z=L.map($=>N[$.name]?{...$,status:N[$.name]}:$);y.useEffect(()=>{if(Object.keys(N).length>0){const $=Object.keys(N).filter(ie=>L.some(we=>we.name===ie&&we.status!=="ready"));$.length>0&&w(ie=>{const we={...ie};for(const se of $)delete we[se];return we})}},[L,N]),P0(()=>{q()},[z]);const P=async()=>{if(m){p(!0);try{const $=await oy(m.name);D({title:"PRD Queued",message:$.message,type:"success"}),f(null),q()}catch($){D({title:"Retry Failed",message:$ instanceof Error?$.message:"Failed to retry PRD",type:"error"})}finally{p(!1)}}},ue=$=>{$.preventDefault(),r(!1)},xe=async()=>{if(m){v(!0),w($=>({...$,[m.name]:"in-progress"}));try{const $=await iy(m.name);D({title:"Executor Started",message:$.pid?`Started with PID ${$.pid}`:"Executor started",type:"success"}),q()}catch($){w(ie=>{const we={...ie};return delete we[m.name],we}),D({title:"Executor Failed",message:$ instanceof Error?$.message:"Failed to start executor",type:"error"})}finally{v(!1)}}};return y.useEffect(()=>{const $=setInterval(()=>q(),3e4);return()=>clearInterval($)},[q]),y.useEffect(()=>{const $=()=>q();return window.addEventListener("focus",$),()=>window.removeEventListener("focus",$)},[q]),y.useEffect(()=>{if(m){const $=Z.find(ie=>ie.name===m.name);$&&f($)}},[Z,m]),R?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading PRDs..."})}):Q?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load PRDs"}),n.jsx("div",{className:"text-sm text-slate-500",children:Q.message}),n.jsx(re,{onClick:()=>q(),children:"Retry"})]}):n.jsxs("div",{className:"space-y-6 h-[calc(100vh-8rem)] flex flex-col",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(re,{variant:c==="list"?"secondary":"ghost",size:"icon",onClick:()=>o("list"),children:n.jsx(c0,{className:"h-4 w-4"})}),n.jsx(re,{variant:c==="card"?"secondary":"ghost",size:"icon",onClick:()=>o("card"),children:n.jsx(mb,{className:"h-4 w-4"})}),n.jsx("div",{className:"h-6 w-px bg-slate-800 mx-2"}),n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("span",{className:"px-3 py-1 bg-slate-800 text-slate-200 rounded-full text-xs font-medium cursor-pointer border border-slate-700",children:"All"}),n.jsx("span",{className:"px-3 py-1 text-slate-500 hover:bg-slate-800 hover:text-slate-300 rounded-full text-xs font-medium cursor-pointer transition-colors",children:"Ready"}),n.jsx("span",{className:"px-3 py-1 text-slate-500 hover:bg-slate-800 hover:text-slate-300 rounded-full text-xs font-medium cursor-pointer transition-colors",children:"In Progress"})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(re,{variant:"outline",size:"sm",children:[n.jsx(Sv,{className:"h-4 w-4 mr-2"}),"Sort"]}),n.jsxs(re,{onClick:()=>r(!0),size:"sm",children:[n.jsx(gl,{className:"h-4 w-4 mr-2"}),"New PRD"]})]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto pr-1 pb-10",children:c==="list"?n.jsx("div",{className:"bg-slate-900 rounded-lg shadow-sm border border-slate-800 overflow-hidden",children:n.jsxs("table",{className:"min-w-full divide-y divide-slate-800",children:[n.jsx("thead",{className:"bg-slate-950/50",children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Name"}),n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Status"}),n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Dependencies"}),n.jsx("th",{scope:"col",className:"relative px-6 py-3",children:n.jsx("span",{className:"sr-only",children:"Actions"})})]})}),n.jsxs("tbody",{className:"divide-y divide-slate-800",children:[Z.map($=>n.jsxs("tr",{className:"hover:bg-slate-800/50 group cursor-pointer transition-colors",onClick:()=>f($),children:[n.jsxs("td",{className:"px-6 py-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("div",{className:"text-sm font-medium text-slate-200",children:$.name}),(()=>{const ie=V($);return ie?n.jsxs("a",{href:ie.url,target:"_blank",rel:"noopener noreferrer",onClick:we=>we.stopPropagation(),className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20 hover:bg-indigo-500/20 transition-colors",title:`Board: #${ie.number} — ${ie.column}`,children:["#",ie.number," · ",ie.column]}):null})()]}),$.unmetDependencies.length>0&&n.jsxs("div",{className:"text-xs text-amber-400 mt-1",children:["Blocked by: ",$.unmetDependencies.join(", ")]})]}),n.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:n.jsx(ha,{variant:ou[$.status],children:uu[$.status]})}),n.jsx("td",{className:"px-6 py-4",children:$.dependencies.length>0?n.jsx("div",{className:"flex flex-wrap gap-1",children:$.dependencies.map(ie=>n.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-400 text-xs rounded border border-slate-700",children:ie},ie))}):n.jsx("span",{className:"text-sm text-slate-600",children:"None"})}),n.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:n.jsx("button",{className:"text-slate-500 hover:text-slate-300 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Wv,{className:"h-4 w-4"})})})]},$.name)),Z.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-slate-500",children:"No PRDs found. Create your first PRD to get started."})})]})]})}):n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[Z.map($=>n.jsxs(be,{className:"p-5 flex flex-col h-full hover:border-indigo-500/50 transition-colors",onClick:()=>f($),children:[n.jsxs("div",{className:"flex justify-between items-start mb-4",children:[n.jsx(ha,{variant:ou[$.status],children:uu[$.status]}),$.status==="in-progress"&&n.jsx("div",{className:"h-2 w-2 bg-blue-500 rounded-full animate-pulse"}),$.status==="pending-review"&&n.jsx("div",{className:"h-2 w-2 bg-yellow-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:$.name}),(()=>{const ie=V($);return ie?n.jsxs("a",{href:ie.url,target:"_blank",rel:"noopener noreferrer",onClick:we=>we.stopPropagation(),className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20 hover:bg-indigo-500/20 transition-colors flex-shrink-0",children:["#",ie.number," · ",ie.column]}):null})()]}),$.content&&n.jsx("p",{className:"text-sm text-slate-400 flex-1 line-clamp-3",children:$.content.replace(/^#.*\n/,"")}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-800",children:[$.dependencies.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.dependencies.map(ie=>n.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-400 text-xs rounded border border-slate-700",children:ie},ie))}),$.unmetDependencies.length>0&&n.jsxs("div",{className:"text-xs text-amber-400",children:["Blocked by: ",$.unmetDependencies.join(", ")]})]})]},$.name)),Z.length===0&&n.jsx("div",{className:"col-span-full text-center py-12 text-slate-500",children:"No PRDs found. Create your first PRD to get started."})]})}),n.jsx($y,{isOpen:d,onClose:()=>r(!1),title:"Create New PRD",children:n.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Name"}),n.jsx("input",{type:"text",className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 placeholder:text-slate-600",placeholder:"e.g. User Authentication"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Complexity"}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("input",{type:"range",min:"1",max:"10",className:"w-full h-2 bg-slate-800 rounded-lg appearance-none cursor-pointer accent-indigo-500"}),n.jsx("span",{className:"text-sm font-bold text-slate-300 w-16 text-center",children:"MED"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Phases"}),n.jsx("input",{type:"number",defaultValue:3,min:1,max:10,className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Template"}),n.jsxs("select",{className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[n.jsx("option",{children:"Default"}),n.jsx("option",{children:"Feature"}),n.jsx("option",{children:"Bugfix"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Dependencies"}),n.jsxs("div",{className:"bg-slate-950/30 p-3 rounded-md border border-slate-800 max-h-32 overflow-y-auto space-y-2",children:[Z.map($=>n.jsxs("label",{className:"flex items-center space-x-2 text-sm text-slate-300 cursor-pointer",children:[n.jsx("input",{type:"checkbox",className:"rounded border-slate-600 bg-slate-800 text-indigo-500 focus:ring-indigo-500/50 focus:ring-offset-slate-900"}),n.jsx("span",{children:$.name})]},$.name)),Z.length===0&&n.jsx("p",{className:"text-sm text-slate-600 italic",children:"No existing PRDs"})]})]}),n.jsxs("div",{className:"flex justify-end pt-4 space-x-3",children:[n.jsx(re,{type:"button",variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),n.jsx(re,{type:"submit",children:"Create PRD"})]})]})}),m&&n.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[n.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:()=>f(null)}),n.jsxs("div",{className:"relative w-full max-w-xl bg-slate-900 h-full shadow-2xl flex flex-col transform transition-transform animate-in slide-in-from-right duration-300 border-l border-slate-800",children:[n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-800",children:[n.jsx("h2",{className:"text-lg font-bold text-slate-100 line-clamp-1",children:m.name}),n.jsx("button",{onClick:()=>f(null),className:"p-2 hover:bg-slate-800 rounded-full",children:n.jsx(c0,{className:"h-5 w-5 text-slate-500"})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-6 space-y-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(ha,{variant:ou[m.status],className:"text-sm px-3 py-1",children:uu[m.status]})}),m.content&&n.jsxs("div",{className:"prose prose-sm prose-invert max-w-none",children:[n.jsx("h3",{className:"uppercase text-xs font-bold text-slate-500 tracking-wider mb-2",children:"Description"}),n.jsx("div",{className:"whitespace-pre-wrap text-slate-300 bg-slate-950/50 p-4 rounded-lg border border-slate-800 font-mono text-sm",children:m.content})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"uppercase text-xs font-bold text-slate-500 tracking-wider",children:"Dependencies"}),m.dependencies.length?n.jsx("div",{className:"flex flex-wrap gap-2",children:m.dependencies.map($=>n.jsx("span",{className:"px-2 py-1 bg-slate-800 text-slate-300 text-xs rounded border border-slate-700",children:$},$))}):n.jsx("p",{className:"text-sm text-slate-500 italic",children:"No dependencies."}),m.unmetDependencies.length>0&&n.jsx("div",{className:"mt-2",children:n.jsxs("p",{className:"text-sm text-amber-400",children:["Unmet dependencies: ",m.unmetDependencies.join(", ")]})})]})]}),n.jsx("div",{className:"p-4 border-t border-slate-800 bg-slate-900 flex space-x-3",children:m.status==="done"?n.jsxs(re,{className:"flex-1",onClick:P,disabled:g,children:[n.jsx(Di,{className:"h-4 w-4 mr-2"}),g?"Moving...":"Retry"]}):n.jsxs(re,{className:"flex-1",onClick:xe,disabled:h||m.status==="in-progress",children:[n.jsx(ss,{className:"h-4 w-4 mr-2"}),h?"Executing...":"Execute Now"]})})]})]})]})},x0=c=>{switch(c){case"pass":return"All CI checks passed";case"fail":return"One or more CI checks failed";case"pending":return"CI checks are still running";default:return"No CI data available or CI not configured"}},Ci=c=>c===null?"No review yet or review not required":c===100?"PR has been approved":c===0?"Changes have been requested":`Review score: ${c}`,Jy=()=>{const[c,o]=y.useState(null),[d,r]=y.useState(!1),[m,f]=y.useState("all"),[h,v]=y.useState("number"),[g,p]=y.useState("desc"),{addToast:N,selectedProjectId:w,globalModeLoading:D}=rt(),{data:z,loading:U,error:A,refetch:R}=ct(ay,[w],{enabled:!D}),Q=z??[],q=Z=>{switch(Z){case"pass":return n.jsx(ns,{className:"h-4 w-4 text-green-500"});case"fail":return n.jsx(hu,{className:"h-4 w-4 text-red-500"});case"pending":return n.jsx(G0,{className:"h-4 w-4 text-amber-500 animate-spin"});default:return n.jsx(Xv,{className:"h-4 w-4 text-slate-500"})}},L=y.useMemo(()=>Q.filter(Z=>{switch(m){case"needs-work":return Z.ciStatus==="fail"||Z.reviewScore===0;case"pending":return Z.ciStatus==="pending"||Z.ciStatus==="unknown"||Z.reviewScore===null;case"passed":return Z.ciStatus==="pass"&&Z.reviewScore===100;case"all":default:return!0}}),[Q,m]),J=y.useMemo(()=>[...L].sort((P,ue)=>{let xe=0;switch(h){case"number":xe=P.number-ue.number;break;case"title":xe=P.title.localeCompare(ue.title);break;case"branch":xe=P.branch.localeCompare(ue.branch);break;case"ciStatus":{const $={fail:0,pending:1,unknown:2,pass:3};xe=($[P.ciStatus]??2)-($[ue.ciStatus]??2);break}case"reviewScore":{const $=P.reviewScore??-1,ie=ue.reviewScore??-1;xe=$-ie;break}}return g==="asc"?xe:-xe}),[L,h,g]),B=Z=>{h===Z?p(g==="asc"?"desc":"asc"):(v(Z),p("desc"))},C=Z=>h!==Z?n.jsx(jv,{className:"h-3 w-3 text-slate-600"}):g==="asc"?n.jsx(Cv,{className:"h-3 w-3 text-indigo-400"}):n.jsx(vv,{className:"h-3 w-3 text-indigo-400"});if(U)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading PRs..."})});if(A)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load PRs"}),n.jsx("div",{className:"text-sm text-slate-500",children:A.message}),n.jsx(re,{onClick:()=>R(),children:"Retry"})]});const V=async()=>{r(!0);try{const Z=await cy();N({title:"Reviewer Started",message:Z.pid?`Started with PID ${Z.pid}`:"Reviewer started",type:"success"})}catch(Z){N({title:"Reviewer Failed",message:Z instanceof Error?Z.message:"Failed to start reviewer",type:"error"})}finally{r(!1)}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("button",{onClick:()=>f("all"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="all"?"bg-slate-800 text-slate-200 border-slate-700":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"All"}),n.jsx("button",{onClick:()=>f("needs-work"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="needs-work"?"bg-red-900/50 text-red-300 border-red-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Needs Work"}),n.jsx("button",{onClick:()=>f("pending"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="pending"?"bg-amber-900/50 text-amber-300 border-amber-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Pending"}),n.jsx("button",{onClick:()=>f("passed"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="passed"?"bg-green-900/50 text-green-300 border-green-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Passed"})]}),n.jsxs(re,{size:"sm",onClick:V,disabled:d,children:[n.jsx(_u,{className:"h-4 w-4 mr-2"}),d?"Starting...":"Run Reviewer Now"]})]}),n.jsx("div",{className:"bg-slate-900 rounded-lg shadow-sm border border-slate-800 overflow-hidden",children:n.jsxs("table",{className:"min-w-full divide-y divide-slate-800",children:[n.jsx("thead",{className:"bg-slate-950/50",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("number"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Title"}),C("number")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("branch"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Branch"}),C("branch")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("ciStatus"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"CI Status"}),C("ciStatus")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("reviewScore"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Review Score"}),C("reviewScore")]})}),n.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Actions"})]})}),n.jsxs("tbody",{className:"divide-y divide-slate-800",children:[J.map(Z=>n.jsxs("tr",{className:"hover:bg-slate-800/50 cursor-pointer transition-colors",onClick:()=>o(c===Z.number?null:Z.number),children:[n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs("span",{className:"text-slate-500 font-mono mr-2",children:["#",Z.number]}),n.jsx("span",{className:"font-medium text-slate-200",children:Z.title})]})}),n.jsx("td",{className:"px-6 py-4",children:n.jsx("span",{className:"px-2 py-1 bg-slate-800 text-slate-400 border border-slate-700 rounded text-xs font-mono",children:Z.branch})}),n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex items-center space-x-2",title:x0(Z.ciStatus),children:[q(Z.ciStatus),n.jsx("span",{className:"text-sm capitalize text-slate-400",children:Z.ciStatus})]})}),n.jsx("td",{className:"px-6 py-4",children:Z.reviewScore!==null?n.jsxs("div",{className:"flex items-center space-x-2",title:Ci(Z.reviewScore),children:[n.jsx("div",{className:"w-24 h-2 bg-slate-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${Z.reviewScore>=70?"bg-green-500":"bg-red-500"}`,style:{width:`${Z.reviewScore}%`}})}),n.jsx("span",{className:`text-sm font-bold ${Z.reviewScore>=70?"text-green-500":"text-red-500"}`,children:Z.reviewScore})]}):n.jsx("span",{className:"text-slate-600 text-sm",title:Ci(null),children:"—"})}),n.jsx("td",{className:"px-6 py-4 text-right",children:n.jsx("a",{href:Z.url,target:"_blank",rel:"noopener noreferrer",className:"text-slate-500 hover:text-indigo-400",onClick:P=>P.stopPropagation(),children:n.jsx(Tu,{className:"h-4 w-4"})})})]},Z.number)),J.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-6 py-12 text-center text-slate-500",children:Q.length===0?"No open PRs found.":`No PRs match the "${m}" filter.`})})]})]})}),c&&n.jsx(be,{className:"p-6 bg-slate-900 border-indigo-900/50 animate-in fade-in slide-in-from-top-4 duration-300",children:(()=>{const Z=Q.find(P=>P.number===c);return Z?n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"font-bold text-slate-200",children:Z.title}),n.jsxs("p",{className:"text-sm text-slate-400 mt-1",children:["Branch: ",n.jsx("span",{className:"font-mono",children:Z.branch})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"text-center",title:x0(Z.ciStatus),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"CI Status"}),n.jsxs("div",{className:"flex items-center space-x-1 mt-1",children:[q(Z.ciStatus),n.jsx("span",{className:"text-sm capitalize text-slate-300",children:Z.ciStatus})]})]}),Z.reviewScore!==null?n.jsxs("div",{className:"text-center",title:Ci(Z.reviewScore),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"Review Score"}),n.jsx("div",{className:`text-xl font-bold mt-1 ${Z.reviewScore>=70?"text-green-500":"text-red-500"}`,children:Z.reviewScore})]}):n.jsxs("div",{className:"text-center",title:Ci(null),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"Review Score"}),n.jsx("div",{className:"text-xl font-bold mt-1 text-slate-500",children:"—"})]})]})]}):null})()})]})},ma=Qe.forwardRef(({className:c="",label:o,checked:d,onChange:r,...m},f)=>{const h=v=>{r&&r(v.target.checked)};return n.jsxs("label",{className:`inline-flex items-center cursor-pointer ${c}`,children:[n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:"checkbox",className:"sr-only peer",ref:f,checked:d,onChange:h,...m}),n.jsx("div",{className:"w-11 h-6 bg-slate-800 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-indigo-500/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-slate-400 after:border-slate-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600 peer-checked:after:bg-white peer-disabled:opacity-50 peer-disabled:cursor-not-allowed"})]}),o&&n.jsx("span",{className:"ml-3 text-sm font-medium text-slate-300 select-none",children:o})]})});ma.displayName="Switch";const Fy=()=>{const{addToast:c,selectedProjectId:o,globalModeLoading:d}=rt(),[r,m]=y.useState(!1),[f,h]=y.useState(!1),{data:v,loading:g,error:p,refetch:N}=ct(hy,[o],{enabled:!d});y.useEffect(()=>{if(!(v!=null&&v.enabled))return;const q=setInterval(()=>{N()},1e4);return()=>clearInterval(q)},[v==null?void 0:v.enabled,N]);const w=async q=>{h(!0);try{await W0(q),c({title:q?"Scanner Enabled":"Scanner Disabled",message:q?"Roadmap scanner is now active.":"Roadmap scanner has been paused.",type:q?"success":"info"}),N()}catch(L){c({title:"Toggle Failed",message:L instanceof Error?L.message:"Failed to toggle scanner",type:"error"})}finally{h(!1)}},D=async()=>{m(!0);try{const q=await xy();q.created.length>0?c({title:"Scan Complete",message:`Created ${q.created.length} PRD(s): ${q.created.join(", ")}`,type:"success"}):c({title:"Scan Complete",message:"No new PRDs to create.",type:"info"}),q.errors.length>0&&c({title:"Scan Errors",message:q.errors.join("; "),type:"warning"}),N()}catch(q){c({title:"Scan Failed",message:q instanceof Error?q.message:"Failed to scan roadmap",type:"error"})}finally{m(!1)}};if(g)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading roadmap scanner..."})});if(p)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load roadmap data"}),n.jsx("div",{className:"text-sm text-slate-500",children:p.message}),n.jsx(re,{onClick:()=>N(),children:"Retry"})]});if(!v)return null;if(v.status==="no-roadmap")return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Roadmap Scanner"})}),n.jsx(be,{className:"p-12",children:n.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[n.jsx("div",{className:"p-4 bg-slate-800 rounded-full",children:n.jsx(Q0,{className:"h-10 w-10 text-slate-500"})}),n.jsx("h2",{className:"text-xl font-semibold text-slate-200",children:"No ROADMAP.md Found"}),n.jsxs("p",{className:"text-slate-400 max-w-md",children:["Create a ",n.jsx("code",{className:"text-indigo-400 bg-indigo-500/10 px-1.5 py-0.5 rounded text-sm",children:"ROADMAP.md"})," in your project root with checklist items (",n.jsx("code",{className:"text-slate-300 text-sm",children:"- [ ] Feature"}),") or heading-based items (",n.jsx("code",{className:"text-slate-300 text-sm",children:"### Feature"}),") to get started."]})]})})]});const z=v.totalItems>0?Math.round(v.processedItems/v.totalItems*100):0,U=Py(v.status),A=Iy(v.items),R=v.lastScan?e1(v.lastScan):"Never",Q=v.autoScanInterval?Math.round(v.autoScanInterval/60):5;return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Roadmap Scanner"}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(ma,{label:v.enabled?"Enabled":"Disabled",checked:v.enabled,onChange:w,disabled:f}),n.jsxs(re,{onClick:D,loading:r,disabled:!v.enabled||v.status==="complete",children:[n.jsx(ss,{className:"h-4 w-4 mr-2"}),"Scan Now"]})]})]}),n.jsx(be,{className:`p-6 border-2 ${U.borderColor}`,children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(U.icon,{className:`h-8 w-8 ${U.textColor}`}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400",children:"Scanner Status"}),n.jsx("div",{className:`text-2xl font-bold ${U.textColor}`,children:U.label})]})]}),n.jsxs("div",{className:"text-right text-sm text-slate-400 space-y-1",children:[n.jsxs("div",{children:["Last scan: ",n.jsx("span",{className:"text-slate-300",children:R})]}),v.enabled&&v.status!=="complete"&&n.jsxs("div",{children:["Auto-scan: ",n.jsxs("span",{className:"text-slate-300",children:["every ",Q," min"]})]}),v.enabled&&v.status==="complete"&&n.jsx("div",{className:"text-emerald-400",children:"Auto-scan paused - all items sliced"})]})]})}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Progress"}),n.jsxs("span",{className:"text-sm text-slate-400",children:[v.processedItems," / ",v.totalItems," items (",z,"%)"]})]}),n.jsx("div",{className:"w-full h-3 bg-slate-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${z===100?"bg-gradient-to-r from-emerald-500 to-emerald-400":"bg-gradient-to-r from-indigo-600 to-indigo-400"}`,style:{width:`${z}%`}})})]}),Object.entries(A).map(([q,L])=>n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200 mb-4",children:q}),n.jsx("div",{className:"space-y-2",children:L.map(J=>n.jsx(Wy,{item:J},J.hash))})]},q))]})};function Wy({item:c}){const o=c.checked,d=c.processed;return n.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${o?"bg-slate-950/30 border-slate-800/50":d?"bg-emerald-500/5 border-emerald-500/10":"bg-slate-950/50 border-slate-800"}`,children:[n.jsxs("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[o?n.jsx(vb,{className:"h-4 w-4 text-slate-600 flex-shrink-0"}):d?n.jsx(ns,{className:"h-4 w-4 text-emerald-400 flex-shrink-0"}):n.jsx(lb,{className:"h-4 w-4 text-slate-500 flex-shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:`text-sm font-medium truncate ${o?"line-through text-slate-600":"text-slate-200"}`,children:c.title}),c.description&&n.jsx("div",{className:"text-xs text-slate-500 truncate mt-0.5",children:c.description})]})]}),n.jsx("div",{className:"flex-shrink-0 ml-3",children:o?n.jsx(ha,{variant:"neutral",children:"Skipped"}):d?n.jsx(ha,{variant:"success",children:c.prdFile||"Processed"}):n.jsx(ha,{variant:"warning",children:"Pending"})})]})}function Py(c){switch(c){case"complete":return{label:"Complete",icon:ns,textColor:"text-emerald-400",borderColor:"border-emerald-500/20 bg-emerald-500/5"};case"idle":return{label:"Idle",icon:Mi,textColor:"text-blue-400",borderColor:"border-blue-500/20 bg-blue-500/5"};case"scanning":return{label:"Scanning",icon:ss,textColor:"text-indigo-400",borderColor:"border-indigo-500/20 bg-indigo-500/5"};case"disabled":return{label:"Disabled",icon:Kt,textColor:"text-slate-400",borderColor:"border-slate-500/20 bg-slate-500/5"};default:return{label:"No Roadmap",icon:Kt,textColor:"text-slate-500",borderColor:"border-slate-500/20"}}}function Iy(c){const o={};for(const d of c){const r=d.section||"General";o[r]||(o[r]=[]),o[r].push(d)}return o}function e1(c){try{const o=new Date(c),r=new Date().getTime()-o.getTime(),m=Math.floor(r/6e4);if(m<1)return"Just now";if(m<60)return`${m} min ago`;const f=Math.floor(m/60);return f<24?`${f} hr ago`:`${Math.floor(f/24)} day(s) ago`}catch{return"Unknown"}}const Hu=[{label:"Every 30 minutes",value:"*/30 * * * *"},{label:"Every hour",value:"0 * * * *"},{label:"Every 3 hours",value:"0 */3 * * *"},{label:"Every 6 hours",value:"0 */6 * * *"},{label:"Every 12 hours",value:"0 */12 * * *"},{label:"Daily at midnight",value:"0 0 * * *"},{label:"Daily at 9 AM",value:"0 9 * * *"},{label:"Weekdays at 9 AM",value:"0 9 * * 1-5"},{label:"Custom",value:"__custom__"}];function du(c){const o=c.trim().split(/\s+/);if(o.length!==5)return c;const[d,r,m,f,h]=o,v=Hu.find(g=>g.value===c);return v?v.label:d==="*/30"&&r==="*"?"Every 30 minutes":d==="0"&&r==="*"?"Every hour":d.startsWith("*/")?`Every ${parseInt(d.replace("*/",""),10)} minutes`:d==="0"&&r.startsWith("*/")?`Every ${parseInt(r.replace("*/",""),10)} hours`:d==="0"&&r!=="*"&&m==="*"&&f==="*"&&h==="*"?`Daily at ${p0(r)}`:d==="0"&&r!=="*"&&m==="*"&&f==="*"&&h==="1-5"?`Weekdays at ${p0(r)}`:c}function p0(c){const o=parseInt(c,10);return o===0?"12 AM":o<12?`${o} AM`:o===12?"12 PM":`${o-12} PM`}function t1(c){const o=Hu.find(d=>d.value===c);return(o==null?void 0:o.value)??"__custom__"}function l1(c){const o=new Date,d=c.getTime()-o.getTime(),r=Math.floor(d/6e4),m=Math.floor(r/60),f=Math.floor(m/24);return r<1?"less than a minute":r<60?`in ${r} minute${r>1?"s":""}`:m<24?`in ${m} hour${m>1?"s":""}`:`in ${f} day${f>1?"s":""}`}function a1(c){const o={weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};return c.toLocaleDateString("en-US",o)}function n1(c){const o=new Date,d=c.getTime()-o.getTime(),r=Math.floor(d/6e4);return r>=0&&r<30}const s1=()=>{const{addToast:c,selectedProjectId:o,globalModeLoading:d}=rt(),[r,m]=y.useState(!1),[f,h]=y.useState(!1),[v,g]=y.useState({executorSchedule:"",reviewerSchedule:"",isEditing:!1}),{data:p,loading:N,error:w,refetch:D}=ct(J0,[o],{enabled:!d}),{data:z,loading:U,refetch:A}=ct(zu,[o],{enabled:!d});y.useEffect(()=>{const P=setInterval(()=>{D()},3e4);return()=>clearInterval(P)},[D]),y.useEffect(()=>{z&&!v.isEditing&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!1})},[z,v.isEditing]);const R=async()=>{if(p){m(!0);try{p.paused?(await d0(),c({title:"Schedule Resumed",message:"Cron schedules have been reactivated.",type:"success"})):(await ry(),c({title:"Schedule Paused",message:"Cron schedules have been deactivated.",type:"info"})),D()}catch(P){c({title:"Action Failed",message:P instanceof Error?P.message:"Failed to toggle schedule state",type:"error"})}finally{m(!1)}}},Q=()=>{z&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!0})},q=()=>{z&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!1})},L=async()=>{if(z){h(!0);try{await Du({cronSchedule:v.executorSchedule,reviewerSchedule:v.reviewerSchedule}),await d0(),c({title:"Schedule Updated",message:"Cron schedules have been saved and installed.",type:"success"}),g(P=>({...P,isEditing:!1})),A(),D()}catch(P){c({title:"Save Failed",message:P instanceof Error?P.message:"Failed to save schedules",type:"error"})}finally{h(!1)}}},J=(P,ue)=>{if(!P)return n.jsx("span",{className:"text-slate-500",children:"Not scheduled"});const xe=new Date(P),$=n1(xe);return n.jsxs("div",{className:"flex items-center space-x-2",children:[$&&n.jsxs("span",{className:"relative flex h-3 w-3",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-green-500"})]}),n.jsxs("div",{className:"text-sm",children:[n.jsx("span",{className:"text-slate-200 font-medium",children:l1(xe)}),n.jsxs("span",{className:"text-slate-500 ml-2",children:["(",a1(xe),")"]})]})]})},B=(P,ue,xe,$)=>{const ie=t1(ue),we=ie==="__custom__";return n.jsxs("div",{className:`space-y-3 ${$?"opacity-50 pointer-events-none":""}`,children:[n.jsx("div",{className:"flex items-center space-x-3",children:n.jsx(Zl,{label:`${P} Preset`,options:Hu,value:ie,onChange:se=>{se!=="__custom__"&&xe(se)},className:"flex-1"})}),we&&n.jsx(Me,{label:"Custom Cron Expression",value:ue,onChange:se=>xe(se.target.value),placeholder:"* * * * *",helperText:"Format: minute hour day month weekday (e.g., 0 */2 * * * for every 2 hours)"}),n.jsxs("div",{className:"text-sm text-slate-400",children:["Human-readable: ",n.jsx("span",{className:"text-slate-200",children:du(ue)})]})]})};if(N||U)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading scheduling information..."})});if(w||!p||!z)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load schedule information"}),n.jsx("div",{className:"text-sm text-slate-500",children:(w==null?void 0:w.message)||"Unknown error"}),n.jsx(re,{onClick:()=>{D(),A()},children:"Retry"})]});const C=p.paused,V=C?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-green-500/10 text-green-400 border-green-500/20",Z=C?"Paused":"Active";return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Scheduling"})}),n.jsx(be,{className:`p-6 border-2 ${V}`,children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(Mi,{className:"h-8 w-8"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400",children:"Cron Status"}),n.jsx("div",{className:"text-2xl font-bold",children:Z})]})]}),n.jsx(re,{variant:C?"primary":"outline",size:"lg",onClick:R,loading:r,children:C?n.jsxs(n.Fragment,{children:[n.jsx(ss,{className:"h-5 w-5 mr-2"}),"Resume"]}):n.jsxs(n.Fragment,{children:[n.jsx(V0,{className:"h-5 w-5 mr-2"}),"Pause"]})})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Executor Schedule"}),!v.isEditing&&n.jsxs(re,{variant:"ghost",size:"sm",onClick:Q,children:[n.jsx(Mb,{className:"h-4 w-4 mr-1"}),"Edit"]})]}),v.isEditing?B("Executor",v.executorSchedule,P=>g(ue=>({...ue,executorSchedule:P}))):n.jsx(n.Fragment,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Schedule"}),n.jsx("div",{className:"text-lg text-slate-200 font-medium",children:du(z.cronSchedule)}),n.jsx("div",{className:"text-xs text-slate-500 font-mono mt-1",children:z.cronSchedule})]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Next Run"}),J(p.executor.nextRun,z.cronSchedule)]}),n.jsxs("div",{className:`flex items-center space-x-2 text-sm ${p.executor.installed?"text-green-400":"text-amber-400"}`,children:[n.jsx(tn,{className:"h-4 w-4"}),n.jsx("span",{children:p.executor.installed?"Installed":"Not installed"})]})]})})]}),n.jsxs(be,{className:`p-6 ${z.reviewerEnabled?"":"opacity-50"}`,children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Reviewer Schedule"}),!z.reviewerEnabled&&n.jsx("span",{className:"text-xs text-slate-500 bg-slate-800 px-2 py-1 rounded",children:"Disabled"})]}),v.isEditing?B("Reviewer",v.reviewerSchedule,P=>g(ue=>({...ue,reviewerSchedule:P})),!z.reviewerEnabled):n.jsx(n.Fragment,{children:n.jsx("div",{className:"space-y-4",children:z.reviewerEnabled?n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Schedule"}),n.jsx("div",{className:"text-lg text-slate-200 font-medium",children:du(z.reviewerSchedule)}),n.jsx("div",{className:"text-xs text-slate-500 font-mono mt-1",children:z.reviewerSchedule})]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Next Run"}),J(p.reviewer.nextRun,z.reviewerSchedule)]}),n.jsxs("div",{className:`flex items-center space-x-2 text-sm ${p.reviewer.installed?"text-green-400":"text-amber-400"}`,children:[n.jsx(tn,{className:"h-4 w-4"}),n.jsx("span",{children:p.reviewer.installed?"Installed":"Not installed"})]})]}):n.jsx("div",{className:"text-slate-500 text-sm",children:"Automated reviews are disabled. Enable them in Settings to configure the reviewer schedule."})})})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[n.jsx(Ri,{className:"h-5 w-5 text-slate-400"}),n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Active Crontab Entries"})]}),p.entries.length===0?n.jsx("div",{className:"text-slate-500 text-sm",children:"No crontab entries found."}):n.jsx("div",{className:"space-y-2",children:p.entries.map((P,ue)=>n.jsx("div",{className:"bg-slate-950/50 rounded-lg p-3 font-mono text-sm text-slate-300 border border-slate-800",children:P},ue))})]}),v.isEditing&&n.jsxs("div",{className:"flex items-center justify-end space-x-4 pt-4 border-t border-slate-800",children:[n.jsx(re,{variant:"ghost",onClick:q,children:"Cancel"}),n.jsxs(re,{onClick:L,loading:f,children:[n.jsx(tn,{className:"h-4 w-4 mr-2"}),"Save & Install"]})]})]})},i1=({tabs:c,activeTab:o,onChange:d,className:r=""})=>{var g,p;const[m,f]=Qe.useState((g=c[0])==null?void 0:g.id),h=o||m,v=N=>{d?d(N):f(N)};return n.jsxs("div",{className:`flex flex-col ${r}`,children:[n.jsx("div",{className:"border-b border-slate-800 mb-6",children:n.jsx("nav",{className:"-mb-px flex space-x-8 overflow-x-auto scrollbar-hide",children:c.map(N=>n.jsx("button",{onClick:()=>v(N.id),className:`
|
|
470
|
+
`,children:r>K.number?n.jsx(tn,{className:"w-6 h-6"}):n.jsx(K.icon,{className:"w-5 h-5"})}),n.jsx("span",{className:"text-xs font-medium tracking-wide",children:K.title})]},K.number))]}),n.jsxs("div",{className:"min-h-[300px]",children:[r===1&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"1. Create a Slack App via Manifest"}),n.jsx("p",{className:"text-sm text-slate-400",children:"We've made it easy. Copy the JSON manifest below and paste it into the Slack API dashboard to create your app instantly with the correct scopes."}),n.jsxs("div",{className:"bg-[#1e293b] rounded-lg p-4 border border-white/5 relative group",children:[n.jsx("pre",{className:"text-xs text-slate-300 overflow-x-auto",children:n.jsx("code",{children:we})}),n.jsx(re,{size:"sm",className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{navigator.clipboard.writeText(we),d({title:"Copied",message:"Manifest copied to clipboard",type:"info"})},children:"Copy JSON"})]})]}),n.jsxs("div",{className:"flex justify-between items-center pt-4",children:[n.jsx(re,{variant:"outline",onClick:()=>window.open(ie,"_blank"),children:"Open Slack API Console"}),n.jsxs(re,{onClick:()=>m(2),children:["Next Step ",n.jsx(_i,{className:"w-4 h-4 ml-1"})]})]})]}),r===2&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"2. Install App & Get Token"}),n.jsxs("p",{className:"text-sm text-slate-400",children:["After creating the app, navigate to ",n.jsx("strong",{children:"Features > OAuth & Permissions"})," in the left sidebar of the Slack API dashboard. Click ",n.jsx("strong",{children:"Install to Workspace"}),". Once installed, copy the ",n.jsx("strong",{children:"Bot User OAuth Token"})," (starts with ",n.jsx("code",{children:"xoxb-"}),") and paste it below. Then create an ",n.jsx("strong",{children:"App-Level Token"})," with ",n.jsx("code",{children:"connections:write"})," (starts with ",n.jsx("code",{children:"xapp-"}),") and paste it as well. Ignore the Client ID and secrets on the Basic Information page."]}),n.jsxs("div",{className:"max-w-md mt-6",children:[n.jsx(Me,{label:"Slack Bot Token",placeholder:"xoxb-...",value:z,onChange:K=>U(K.target.value),type:v?"text":"password",rightIcon:n.jsx("button",{type:"button",onClick:()=>g(!v),className:"hover:text-slate-300 pointer-events-auto transition-colors",children:v?n.jsx(xu,{className:"w-4 h-4"}):n.jsx(zi,{className:"w-4 h-4"})})}),n.jsxs("div",{className:"mt-4",children:[n.jsx(Me,{label:"Slack App Token (Socket Mode)",placeholder:"xapp-...",value:A,onChange:K=>R(K.target.value),type:v?"text":"password"}),n.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Needed for real-time ",n.jsx("code",{children:"@agent"})," replies (Socket Mode + ",n.jsx("code",{children:"connections:write"}),")."]})]})]})]}),n.jsxs("div",{className:"flex justify-between pt-8",children:[n.jsx(re,{variant:"ghost",onClick:()=>m(1),children:"Back"}),n.jsxs(re,{onClick:$,disabled:!z.startsWith("xoxb-")||w,children:["Next Step ",n.jsx(_i,{className:"w-4 h-4 ml-1"})]})]})]}),r===3&&n.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-right-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"3. Map Channels"}),n.jsx("p",{className:"text-sm text-slate-400",children:`Provide the Slack channel IDs where the agents should operate. You can find the Channel ID at the bottom of the channel's "About" modal in Slack.`}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mt-8",children:p.length>0?n.jsxs(n.Fragment,{children:[n.jsxs(be,{className:"p-4 border border-indigo-500/20 bg-indigo-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-indigo-300",children:[n.jsx(xl,{className:"w-4 h-4"})," eng"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"General engineering chat and agent banter."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:Q,onChange:q})]}),n.jsxs(be,{className:"p-4 border border-blue-500/20 bg-blue-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-blue-300",children:[n.jsx(xl,{className:"w-4 h-4"})," prs"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Pull Request reviews and agent deliberation."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:L,onChange:J})]}),n.jsxs(be,{className:"p-4 border border-red-500/20 bg-red-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-red-300",children:[n.jsx(xl,{className:"w-4 h-4"})," incidents"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"CI/CD failures and production alerts."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:B,onChange:C})]}),n.jsxs(be,{className:"p-4 border border-emerald-500/20 bg-emerald-500/5",children:[n.jsxs("div",{className:"mb-3",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-emerald-300",children:[n.jsx(xl,{className:"w-4 h-4"})," releases"]}),n.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"Ship announcements and merged PRs."})]}),n.jsx(Zl,{options:[{label:"Select a channel...",value:""},...p.map(K=>({label:"#"+K.name,value:K.id}))],value:V,onChange:Z})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs(be,{className:"p-4 border border-indigo-500/20 bg-indigo-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-indigo-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," eng"]}),n.jsx(Me,{placeholder:"C1234567890",value:Q,onChange:K=>q(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-blue-500/20 bg-blue-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-blue-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," prs"]}),n.jsx(Me,{placeholder:"C1234567890",value:L,onChange:K=>J(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-red-500/20 bg-red-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-red-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," incidents"]}),n.jsx(Me,{placeholder:"C1234567890",value:B,onChange:K=>C(K.target.value)})]}),n.jsxs(be,{className:"p-4 border border-emerald-500/20 bg-emerald-500/5",children:[n.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-emerald-300 mb-2",children:[n.jsx(xl,{className:"w-4 h-4"})," releases"]}),n.jsx(Me,{placeholder:"C1234567890",value:V,onChange:K=>Z(K.target.value)})]})]})}),n.jsxs("div",{className:"mt-6 flex items-center justify-between rounded-lg border border-white/10 bg-white/[0.02] p-3",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-200",children:"Enable Agent Discussions"}),n.jsx("p",{className:"text-xs text-slate-400",children:"Threaded agent collaboration and targeted @persona responses."})]}),n.jsxs("label",{className:"inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",className:"sr-only peer",checked:P,onChange:K=>ue(K.target.checked)}),n.jsx("span",{className:"w-11 h-6 bg-slate-700 rounded-full peer peer-checked:bg-indigo-500 transition-colors relative",children:n.jsx("span",{className:`absolute top-0.5 left-0.5 h-5 w-5 rounded-full bg-white transition-transform ${P?"translate-x-5":"translate-x-0"}`})})]})]})]}),n.jsxs("div",{className:"flex justify-between pt-8",children:[n.jsx(re,{variant:"ghost",onClick:()=>m(2),children:"Back"}),n.jsx(re,{onClick:()=>xe(!0),loading:f,disabled:!Q||!L||!B,children:"Complete Setup"})]})]})]})]})]})}const Zy=()=>{const[c,o]=y.useState(!0),[d,r]=y.useState(""),[m,f]=y.useState("executor"),h=y.useRef(null),{selectedProjectId:v,globalModeLoading:g}=rt(),{data:p,loading:N,error:w,refetch:D}=ct(()=>ny(m,500),[m,v],{enabled:!g}),{data:z}=ct(K0,[v],{enabled:!g}),U=(p==null?void 0:p.lines)||[];y.useEffect(()=>{c&&h.current&&(h.current.scrollTop=h.current.scrollHeight)},[U,c]),y.useEffect(()=>{if(!c)return;const q=window.setInterval(()=>{D()},3e3);return()=>window.clearInterval(q)},[c,m,D]);const A=U.filter(q=>q.toLowerCase().includes(d.toLowerCase())),R=q=>{f(q),r("")},Q=q=>{if(!(z!=null&&z.processes))return!1;const L=z.processes.find(J=>J.name===q);return(L==null?void 0:L.running)??!1};return w?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load logs"}),n.jsx("div",{className:"text-sm text-slate-500",children:w.message}),n.jsx(re,{onClick:()=>D(),children:"Retry"})]}):n.jsxs("div",{className:"flex flex-col h-[calc(100vh-8rem)]",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4 bg-slate-900 p-2 rounded-lg border border-slate-800 shadow-sm",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("div",{className:"relative group",children:[n.jsx("input",{type:"text",placeholder:"Filter logs...",className:"pl-9 pr-4 py-1.5 rounded-md border border-slate-700 bg-slate-950 text-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent w-64 placeholder:text-slate-600",value:d,onChange:q=>r(q.target.value)}),n.jsx(_u,{className:"absolute left-2.5 top-2 h-4 w-4 text-slate-500 group-focus-within:text-indigo-400"})]}),n.jsx("div",{className:"h-6 w-px bg-slate-700 mx-2"}),n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("button",{onClick:()=>R("executor"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="executor"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"Executor"}),Q("executor")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})}),n.jsx("button",{onClick:()=>R("reviewer"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="reviewer"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"Reviewer"}),Q("reviewer")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})}),n.jsx("button",{onClick:()=>R("qa"),className:`px-3 py-1.5 rounded text-sm font-medium transition-colors ${m==="qa"?"bg-slate-800 text-slate-200 shadow-sm border border-slate-700":"text-slate-400 hover:bg-slate-800 hover:text-slate-200"}`,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:"QA"}),Q("qa")&&n.jsx("div",{className:"h-2 w-2 bg-green-500 rounded-full animate-pulse"})]})})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs(re,{size:"sm",variant:"ghost",onClick:()=>D(),children:[n.jsx(i0,{className:"h-4 w-4 mr-2"}),"Refresh"]}),n.jsxs(re,{size:"sm",variant:"ghost",onClick:()=>o(!c),children:[c?n.jsx(V0,{className:"h-4 w-4 mr-2"}):n.jsx(ss,{className:"h-4 w-4 mr-2"}),c?"Pause":"Resume"]})]})]}),n.jsxs("div",{className:"flex-1 bg-slate-900 rounded-xl overflow-hidden shadow-inner border border-slate-800 flex flex-col relative",children:[n.jsxs("div",{className:"bg-slate-950/50 backdrop-blur text-xs text-slate-500 px-4 py-1.5 flex justify-between border-b border-slate-800",children:[n.jsxs("span",{children:["File: ",m,".log"]}),n.jsxs("span",{children:[A.length," lines"]})]}),n.jsxs("div",{ref:h,className:"flex-1 overflow-y-auto p-4 font-mono text-sm terminal-scroll bg-slate-900",children:[N?n.jsx("div",{className:"flex items-center justify-center h-full text-slate-500",children:"Loading logs..."}):A.length===0?n.jsx("div",{className:"flex items-center justify-center h-full text-slate-500",children:d?"No logs match your filter":"No logs yet — logs will appear after the first run"}):A.map((q,L)=>{const J=q.includes("[ERROR]"),B=q.includes("[WARN]");return n.jsxs("div",{className:`leading-6 hover:bg-slate-800/50 px-2 rounded -mx-2 ${J?"text-red-400":B?"text-amber-400":"text-slate-300"}`,children:[n.jsx("span",{className:"text-slate-600 select-none w-10 inline-block text-right mr-4 text-xs opacity-50",children:L+1}),q]},L)}),c&&n.jsx("div",{className:"h-4"})," "]}),!c&&n.jsxs("div",{className:"absolute bottom-4 right-4 bg-indigo-600 text-white px-3 py-1.5 rounded-full shadow-lg shadow-indigo-900/40 text-xs font-medium flex items-center cursor-pointer hover:bg-indigo-500 transition-colors",onClick:()=>o(!0),children:[n.jsx(i0,{className:"h-4 w-4 mr-2"}),"Scroll to bottom"]})]})]})},$y=({isOpen:c,onClose:o,title:d,children:r})=>(y.useEffect(()=>{const m=f=>{f.key==="Escape"&&o()};return c&&(document.addEventListener("keydown",m),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",m),document.body.style.overflow="unset"}},[c,o]),c?ov.createPortal(n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6",children:[n.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:o,"aria-hidden":"true"}),n.jsxs("div",{className:"relative w-full max-w-2xl transform rounded-xl bg-slate-900 border border-slate-800 shadow-2xl transition-all flex flex-col max-h-[90vh]",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 px-6 py-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-100",children:d}),n.jsx("button",{onClick:o,className:"rounded-full p-1 text-slate-400 hover:bg-slate-800 hover:text-slate-300 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:n.jsx(Ft,{className:"h-5 w-5"})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6 text-slate-300",children:r})]})]}),document.body):null),uu={ready:"Ready","in-progress":"In Progress",blocked:"Blocked","pending-review":"Pending Review",done:"Done"},ou={ready:"success","in-progress":"info",blocked:"error","pending-review":"warning",done:"neutral"},Ky=()=>{const[c,o]=y.useState("list"),[d,r]=y.useState(!1),[m,f]=y.useState(null),[h,v]=y.useState(!1),[g,p]=y.useState(!1),[N,w]=y.useState({}),{addToast:D,selectedProjectId:z,globalModeLoading:U}=rt(),{data:A,loading:R,error:Q,refetch:q}=ct(ly,[z],{enabled:!U}),L=A??[],{data:J}=ct(()=>Ou().catch(()=>null),[z],{enabled:!U}),B=Qe.useMemo(()=>{const $=new Map;if(!J)return $;for(const ie of Object.values(J.columns))for(const we of ie)$.set(we.title.toLowerCase().trim(),we);return $},[J]),C=$=>{if(!$.content)return $.name;const ie=$.content.match(/^#\s+(.+)$/m);return ie?ie[1].trim():$.name},V=$=>{const ie=C($).toLowerCase().trim();return B.get(ie)??null},Z=L.map($=>N[$.name]?{...$,status:N[$.name]}:$);y.useEffect(()=>{if(Object.keys(N).length>0){const $=Object.keys(N).filter(ie=>L.some(we=>we.name===ie&&we.status!=="ready"));$.length>0&&w(ie=>{const we={...ie};for(const se of $)delete we[se];return we})}},[L,N]),P0(()=>{q()},[z,U],{enabled:!U});const P=async()=>{if(m){p(!0);try{const $=await oy(m.name);D({title:"PRD Queued",message:$.message,type:"success"}),f(null),q()}catch($){D({title:"Retry Failed",message:$ instanceof Error?$.message:"Failed to retry PRD",type:"error"})}finally{p(!1)}}},ue=$=>{$.preventDefault(),r(!1)},xe=async()=>{if(m){v(!0),w($=>({...$,[m.name]:"in-progress"}));try{const $=await iy(m.name);D({title:"Executor Started",message:$.pid?`Started with PID ${$.pid}`:"Executor started",type:"success"}),q()}catch($){w(ie=>{const we={...ie};return delete we[m.name],we}),D({title:"Executor Failed",message:$ instanceof Error?$.message:"Failed to start executor",type:"error"})}finally{v(!1)}}};return y.useEffect(()=>{const $=setInterval(()=>q(),3e4);return()=>clearInterval($)},[q]),y.useEffect(()=>{const $=()=>q();return window.addEventListener("focus",$),()=>window.removeEventListener("focus",$)},[q]),y.useEffect(()=>{if(m){const $=Z.find(ie=>ie.name===m.name);$&&f($)}},[Z,m]),R?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading PRDs..."})}):Q?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load PRDs"}),n.jsx("div",{className:"text-sm text-slate-500",children:Q.message}),n.jsx(re,{onClick:()=>q(),children:"Retry"})]}):n.jsxs("div",{className:"space-y-6 h-[calc(100vh-8rem)] flex flex-col",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(re,{variant:c==="list"?"secondary":"ghost",size:"icon",onClick:()=>o("list"),children:n.jsx(c0,{className:"h-4 w-4"})}),n.jsx(re,{variant:c==="card"?"secondary":"ghost",size:"icon",onClick:()=>o("card"),children:n.jsx(mb,{className:"h-4 w-4"})}),n.jsx("div",{className:"h-6 w-px bg-slate-800 mx-2"}),n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("span",{className:"px-3 py-1 bg-slate-800 text-slate-200 rounded-full text-xs font-medium cursor-pointer border border-slate-700",children:"All"}),n.jsx("span",{className:"px-3 py-1 text-slate-500 hover:bg-slate-800 hover:text-slate-300 rounded-full text-xs font-medium cursor-pointer transition-colors",children:"Ready"}),n.jsx("span",{className:"px-3 py-1 text-slate-500 hover:bg-slate-800 hover:text-slate-300 rounded-full text-xs font-medium cursor-pointer transition-colors",children:"In Progress"})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(re,{variant:"outline",size:"sm",children:[n.jsx(Sv,{className:"h-4 w-4 mr-2"}),"Sort"]}),n.jsxs(re,{onClick:()=>r(!0),size:"sm",children:[n.jsx(gl,{className:"h-4 w-4 mr-2"}),"New PRD"]})]})]}),n.jsx("div",{className:"flex-1 overflow-y-auto pr-1 pb-10",children:c==="list"?n.jsx("div",{className:"bg-slate-900 rounded-lg shadow-sm border border-slate-800 overflow-hidden",children:n.jsxs("table",{className:"min-w-full divide-y divide-slate-800",children:[n.jsx("thead",{className:"bg-slate-950/50",children:n.jsxs("tr",{children:[n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Name"}),n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Status"}),n.jsx("th",{scope:"col",className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Dependencies"}),n.jsx("th",{scope:"col",className:"relative px-6 py-3",children:n.jsx("span",{className:"sr-only",children:"Actions"})})]})}),n.jsxs("tbody",{className:"divide-y divide-slate-800",children:[Z.map($=>n.jsxs("tr",{className:"hover:bg-slate-800/50 group cursor-pointer transition-colors",onClick:()=>f($),children:[n.jsxs("td",{className:"px-6 py-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("div",{className:"text-sm font-medium text-slate-200",children:$.name}),(()=>{const ie=V($);return ie?n.jsxs("a",{href:ie.url,target:"_blank",rel:"noopener noreferrer",onClick:we=>we.stopPropagation(),className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20 hover:bg-indigo-500/20 transition-colors",title:`Board: #${ie.number} — ${ie.column}`,children:["#",ie.number," · ",ie.column]}):null})()]}),$.unmetDependencies.length>0&&n.jsxs("div",{className:"text-xs text-amber-400 mt-1",children:["Blocked by: ",$.unmetDependencies.join(", ")]})]}),n.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:n.jsx(ha,{variant:ou[$.status],children:uu[$.status]})}),n.jsx("td",{className:"px-6 py-4",children:$.dependencies.length>0?n.jsx("div",{className:"flex flex-wrap gap-1",children:$.dependencies.map(ie=>n.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-400 text-xs rounded border border-slate-700",children:ie},ie))}):n.jsx("span",{className:"text-sm text-slate-600",children:"None"})}),n.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:n.jsx("button",{className:"text-slate-500 hover:text-slate-300 opacity-0 group-hover:opacity-100 transition-opacity",children:n.jsx(Wv,{className:"h-4 w-4"})})})]},$.name)),Z.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-slate-500",children:"No PRDs found. Create your first PRD to get started."})})]})]})}):n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[Z.map($=>n.jsxs(be,{className:"p-5 flex flex-col h-full hover:border-indigo-500/50 transition-colors",onClick:()=>f($),children:[n.jsxs("div",{className:"flex justify-between items-start mb-4",children:[n.jsx(ha,{variant:ou[$.status],children:uu[$.status]}),$.status==="in-progress"&&n.jsx("div",{className:"h-2 w-2 bg-blue-500 rounded-full animate-pulse"}),$.status==="pending-review"&&n.jsx("div",{className:"h-2 w-2 bg-yellow-500 rounded-full animate-pulse"})]}),n.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:$.name}),(()=>{const ie=V($);return ie?n.jsxs("a",{href:ie.url,target:"_blank",rel:"noopener noreferrer",onClick:we=>we.stopPropagation(),className:"inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium bg-indigo-500/10 text-indigo-400 ring-1 ring-inset ring-indigo-500/20 hover:bg-indigo-500/20 transition-colors flex-shrink-0",children:["#",ie.number," · ",ie.column]}):null})()]}),$.content&&n.jsx("p",{className:"text-sm text-slate-400 flex-1 line-clamp-3",children:$.content.replace(/^#.*\n/,"")}),n.jsxs("div",{className:"mt-4 pt-4 border-t border-slate-800",children:[$.dependencies.length>0&&n.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:$.dependencies.map(ie=>n.jsx("span",{className:"px-2 py-0.5 bg-slate-800 text-slate-400 text-xs rounded border border-slate-700",children:ie},ie))}),$.unmetDependencies.length>0&&n.jsxs("div",{className:"text-xs text-amber-400",children:["Blocked by: ",$.unmetDependencies.join(", ")]})]})]},$.name)),Z.length===0&&n.jsx("div",{className:"col-span-full text-center py-12 text-slate-500",children:"No PRDs found. Create your first PRD to get started."})]})}),n.jsx($y,{isOpen:d,onClose:()=>r(!1),title:"Create New PRD",children:n.jsxs("form",{onSubmit:ue,className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Name"}),n.jsx("input",{type:"text",className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 placeholder:text-slate-600",placeholder:"e.g. User Authentication"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Complexity"}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("input",{type:"range",min:"1",max:"10",className:"w-full h-2 bg-slate-800 rounded-lg appearance-none cursor-pointer accent-indigo-500"}),n.jsx("span",{className:"text-sm font-bold text-slate-300 w-16 text-center",children:"MED"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Phases"}),n.jsx("input",{type:"number",defaultValue:3,min:1,max:10,className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Template"}),n.jsxs("select",{className:"w-full rounded-md bg-slate-800 border border-slate-700 px-3 py-2 text-sm text-slate-200 focus:outline-none focus:ring-2 focus:ring-indigo-500",children:[n.jsx("option",{children:"Default"}),n.jsx("option",{children:"Feature"}),n.jsx("option",{children:"Bugfix"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-1",children:"Dependencies"}),n.jsxs("div",{className:"bg-slate-950/30 p-3 rounded-md border border-slate-800 max-h-32 overflow-y-auto space-y-2",children:[Z.map($=>n.jsxs("label",{className:"flex items-center space-x-2 text-sm text-slate-300 cursor-pointer",children:[n.jsx("input",{type:"checkbox",className:"rounded border-slate-600 bg-slate-800 text-indigo-500 focus:ring-indigo-500/50 focus:ring-offset-slate-900"}),n.jsx("span",{children:$.name})]},$.name)),Z.length===0&&n.jsx("p",{className:"text-sm text-slate-600 italic",children:"No existing PRDs"})]})]}),n.jsxs("div",{className:"flex justify-end pt-4 space-x-3",children:[n.jsx(re,{type:"button",variant:"ghost",onClick:()=>r(!1),children:"Cancel"}),n.jsx(re,{type:"submit",children:"Create PRD"})]})]})}),m&&n.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[n.jsx("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm transition-opacity",onClick:()=>f(null)}),n.jsxs("div",{className:"relative w-full max-w-xl bg-slate-900 h-full shadow-2xl flex flex-col transform transition-transform animate-in slide-in-from-right duration-300 border-l border-slate-800",children:[n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-800",children:[n.jsx("h2",{className:"text-lg font-bold text-slate-100 line-clamp-1",children:m.name}),n.jsx("button",{onClick:()=>f(null),className:"p-2 hover:bg-slate-800 rounded-full",children:n.jsx(c0,{className:"h-5 w-5 text-slate-500"})})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-6 space-y-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(ha,{variant:ou[m.status],className:"text-sm px-3 py-1",children:uu[m.status]})}),m.content&&n.jsxs("div",{className:"prose prose-sm prose-invert max-w-none",children:[n.jsx("h3",{className:"uppercase text-xs font-bold text-slate-500 tracking-wider mb-2",children:"Description"}),n.jsx("div",{className:"whitespace-pre-wrap text-slate-300 bg-slate-950/50 p-4 rounded-lg border border-slate-800 font-mono text-sm",children:m.content})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h3",{className:"uppercase text-xs font-bold text-slate-500 tracking-wider",children:"Dependencies"}),m.dependencies.length?n.jsx("div",{className:"flex flex-wrap gap-2",children:m.dependencies.map($=>n.jsx("span",{className:"px-2 py-1 bg-slate-800 text-slate-300 text-xs rounded border border-slate-700",children:$},$))}):n.jsx("p",{className:"text-sm text-slate-500 italic",children:"No dependencies."}),m.unmetDependencies.length>0&&n.jsx("div",{className:"mt-2",children:n.jsxs("p",{className:"text-sm text-amber-400",children:["Unmet dependencies: ",m.unmetDependencies.join(", ")]})})]})]}),n.jsx("div",{className:"p-4 border-t border-slate-800 bg-slate-900 flex space-x-3",children:m.status==="done"?n.jsxs(re,{className:"flex-1",onClick:P,disabled:g,children:[n.jsx(Di,{className:"h-4 w-4 mr-2"}),g?"Moving...":"Retry"]}):n.jsxs(re,{className:"flex-1",onClick:xe,disabled:h||m.status==="in-progress",children:[n.jsx(ss,{className:"h-4 w-4 mr-2"}),h?"Executing...":"Execute Now"]})})]})]})]})},x0=c=>{switch(c){case"pass":return"All CI checks passed";case"fail":return"One or more CI checks failed";case"pending":return"CI checks are still running";default:return"No CI data available or CI not configured"}},Ci=c=>c===null?"No review yet or review not required":c===100?"PR has been approved":c===0?"Changes have been requested":`Review score: ${c}`,Jy=()=>{const[c,o]=y.useState(null),[d,r]=y.useState(!1),[m,f]=y.useState("all"),[h,v]=y.useState("number"),[g,p]=y.useState("desc"),{addToast:N,selectedProjectId:w,globalModeLoading:D}=rt(),{data:z,loading:U,error:A,refetch:R}=ct(ay,[w],{enabled:!D}),Q=z??[],q=Z=>{switch(Z){case"pass":return n.jsx(ns,{className:"h-4 w-4 text-green-500"});case"fail":return n.jsx(hu,{className:"h-4 w-4 text-red-500"});case"pending":return n.jsx(G0,{className:"h-4 w-4 text-amber-500 animate-spin"});default:return n.jsx(Xv,{className:"h-4 w-4 text-slate-500"})}},L=y.useMemo(()=>Q.filter(Z=>{switch(m){case"needs-work":return Z.ciStatus==="fail"||Z.reviewScore===0;case"pending":return Z.ciStatus==="pending"||Z.ciStatus==="unknown"||Z.reviewScore===null;case"passed":return Z.ciStatus==="pass"&&Z.reviewScore===100;case"all":default:return!0}}),[Q,m]),J=y.useMemo(()=>[...L].sort((P,ue)=>{let xe=0;switch(h){case"number":xe=P.number-ue.number;break;case"title":xe=P.title.localeCompare(ue.title);break;case"branch":xe=P.branch.localeCompare(ue.branch);break;case"ciStatus":{const $={fail:0,pending:1,unknown:2,pass:3};xe=($[P.ciStatus]??2)-($[ue.ciStatus]??2);break}case"reviewScore":{const $=P.reviewScore??-1,ie=ue.reviewScore??-1;xe=$-ie;break}}return g==="asc"?xe:-xe}),[L,h,g]),B=Z=>{h===Z?p(g==="asc"?"desc":"asc"):(v(Z),p("desc"))},C=Z=>h!==Z?n.jsx(jv,{className:"h-3 w-3 text-slate-600"}):g==="asc"?n.jsx(Cv,{className:"h-3 w-3 text-indigo-400"}):n.jsx(vv,{className:"h-3 w-3 text-indigo-400"});if(U)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading PRs..."})});if(A)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load PRs"}),n.jsx("div",{className:"text-sm text-slate-500",children:A.message}),n.jsx(re,{onClick:()=>R(),children:"Retry"})]});const V=async()=>{r(!0);try{const Z=await cy();N({title:"Reviewer Started",message:Z.pid?`Started with PID ${Z.pid}`:"Reviewer started",type:"success"})}catch(Z){N({title:"Reviewer Failed",message:Z instanceof Error?Z.message:"Failed to start reviewer",type:"error"})}finally{r(!1)}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex space-x-1",children:[n.jsx("button",{onClick:()=>f("all"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="all"?"bg-slate-800 text-slate-200 border-slate-700":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"All"}),n.jsx("button",{onClick:()=>f("needs-work"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="needs-work"?"bg-red-900/50 text-red-300 border-red-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Needs Work"}),n.jsx("button",{onClick:()=>f("pending"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="pending"?"bg-amber-900/50 text-amber-300 border-amber-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Pending"}),n.jsx("button",{onClick:()=>f("passed"),className:`px-3 py-1 rounded-full text-xs font-medium cursor-pointer border transition-colors ${m==="passed"?"bg-green-900/50 text-green-300 border-green-800":"text-slate-500 hover:bg-slate-800 hover:text-slate-300 border-transparent"}`,children:"Passed"})]}),n.jsxs(re,{size:"sm",onClick:V,disabled:d,children:[n.jsx(_u,{className:"h-4 w-4 mr-2"}),d?"Starting...":"Run Reviewer Now"]})]}),n.jsx("div",{className:"bg-slate-900 rounded-lg shadow-sm border border-slate-800 overflow-hidden",children:n.jsxs("table",{className:"min-w-full divide-y divide-slate-800",children:[n.jsx("thead",{className:"bg-slate-950/50",children:n.jsxs("tr",{children:[n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("number"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Title"}),C("number")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("branch"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Branch"}),C("branch")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("ciStatus"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"CI Status"}),C("ciStatus")]})}),n.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider cursor-pointer hover:text-slate-300",onClick:()=>B("reviewScore"),children:n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{children:"Review Score"}),C("reviewScore")]})}),n.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Actions"})]})}),n.jsxs("tbody",{className:"divide-y divide-slate-800",children:[J.map(Z=>n.jsxs("tr",{className:"hover:bg-slate-800/50 cursor-pointer transition-colors",onClick:()=>o(c===Z.number?null:Z.number),children:[n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex items-center",children:[n.jsxs("span",{className:"text-slate-500 font-mono mr-2",children:["#",Z.number]}),n.jsx("span",{className:"font-medium text-slate-200",children:Z.title})]})}),n.jsx("td",{className:"px-6 py-4",children:n.jsx("span",{className:"px-2 py-1 bg-slate-800 text-slate-400 border border-slate-700 rounded text-xs font-mono",children:Z.branch})}),n.jsx("td",{className:"px-6 py-4",children:n.jsxs("div",{className:"flex items-center space-x-2",title:x0(Z.ciStatus),children:[q(Z.ciStatus),n.jsx("span",{className:"text-sm capitalize text-slate-400",children:Z.ciStatus})]})}),n.jsx("td",{className:"px-6 py-4",children:Z.reviewScore!==null?n.jsxs("div",{className:"flex items-center space-x-2",title:Ci(Z.reviewScore),children:[n.jsx("div",{className:"w-24 h-2 bg-slate-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full ${Z.reviewScore>=70?"bg-green-500":"bg-red-500"}`,style:{width:`${Z.reviewScore}%`}})}),n.jsx("span",{className:`text-sm font-bold ${Z.reviewScore>=70?"text-green-500":"text-red-500"}`,children:Z.reviewScore})]}):n.jsx("span",{className:"text-slate-600 text-sm",title:Ci(null),children:"—"})}),n.jsx("td",{className:"px-6 py-4 text-right",children:n.jsx("a",{href:Z.url,target:"_blank",rel:"noopener noreferrer",className:"text-slate-500 hover:text-indigo-400",onClick:P=>P.stopPropagation(),children:n.jsx(Tu,{className:"h-4 w-4"})})})]},Z.number)),J.length===0&&n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"px-6 py-12 text-center text-slate-500",children:Q.length===0?"No open PRs found.":`No PRs match the "${m}" filter.`})})]})]})}),c&&n.jsx(be,{className:"p-6 bg-slate-900 border-indigo-900/50 animate-in fade-in slide-in-from-top-4 duration-300",children:(()=>{const Z=Q.find(P=>P.number===c);return Z?n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"font-bold text-slate-200",children:Z.title}),n.jsxs("p",{className:"text-sm text-slate-400 mt-1",children:["Branch: ",n.jsx("span",{className:"font-mono",children:Z.branch})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"text-center",title:x0(Z.ciStatus),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"CI Status"}),n.jsxs("div",{className:"flex items-center space-x-1 mt-1",children:[q(Z.ciStatus),n.jsx("span",{className:"text-sm capitalize text-slate-300",children:Z.ciStatus})]})]}),Z.reviewScore!==null?n.jsxs("div",{className:"text-center",title:Ci(Z.reviewScore),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"Review Score"}),n.jsx("div",{className:`text-xl font-bold mt-1 ${Z.reviewScore>=70?"text-green-500":"text-red-500"}`,children:Z.reviewScore})]}):n.jsxs("div",{className:"text-center",title:Ci(null),children:[n.jsx("div",{className:"text-xs text-slate-500",children:"Review Score"}),n.jsx("div",{className:"text-xl font-bold mt-1 text-slate-500",children:"—"})]})]})]}):null})()})]})},ma=Qe.forwardRef(({className:c="",label:o,checked:d,onChange:r,...m},f)=>{const h=v=>{r&&r(v.target.checked)};return n.jsxs("label",{className:`inline-flex items-center cursor-pointer ${c}`,children:[n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:"checkbox",className:"sr-only peer",ref:f,checked:d,onChange:h,...m}),n.jsx("div",{className:"w-11 h-6 bg-slate-800 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-indigo-500/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-slate-400 after:border-slate-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600 peer-checked:after:bg-white peer-disabled:opacity-50 peer-disabled:cursor-not-allowed"})]}),o&&n.jsx("span",{className:"ml-3 text-sm font-medium text-slate-300 select-none",children:o})]})});ma.displayName="Switch";const Fy=()=>{const{addToast:c,selectedProjectId:o,globalModeLoading:d}=rt(),[r,m]=y.useState(!1),[f,h]=y.useState(!1),{data:v,loading:g,error:p,refetch:N}=ct(hy,[o],{enabled:!d});y.useEffect(()=>{if(!(v!=null&&v.enabled))return;const q=setInterval(()=>{N()},1e4);return()=>clearInterval(q)},[v==null?void 0:v.enabled,N]);const w=async q=>{h(!0);try{await W0(q),c({title:q?"Scanner Enabled":"Scanner Disabled",message:q?"Roadmap scanner is now active.":"Roadmap scanner has been paused.",type:q?"success":"info"}),N()}catch(L){c({title:"Toggle Failed",message:L instanceof Error?L.message:"Failed to toggle scanner",type:"error"})}finally{h(!1)}},D=async()=>{m(!0);try{const q=await xy();q.created.length>0?c({title:"Scan Complete",message:`Created ${q.created.length} PRD(s): ${q.created.join(", ")}`,type:"success"}):c({title:"Scan Complete",message:"No new PRDs to create.",type:"info"}),q.errors.length>0&&c({title:"Scan Errors",message:q.errors.join("; "),type:"warning"}),N()}catch(q){c({title:"Scan Failed",message:q instanceof Error?q.message:"Failed to scan roadmap",type:"error"})}finally{m(!1)}};if(g)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading roadmap scanner..."})});if(p)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load roadmap data"}),n.jsx("div",{className:"text-sm text-slate-500",children:p.message}),n.jsx(re,{onClick:()=>N(),children:"Retry"})]});if(!v)return null;if(v.status==="no-roadmap")return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Roadmap Scanner"})}),n.jsx(be,{className:"p-12",children:n.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[n.jsx("div",{className:"p-4 bg-slate-800 rounded-full",children:n.jsx(Q0,{className:"h-10 w-10 text-slate-500"})}),n.jsx("h2",{className:"text-xl font-semibold text-slate-200",children:"No ROADMAP.md Found"}),n.jsxs("p",{className:"text-slate-400 max-w-md",children:["Create a ",n.jsx("code",{className:"text-indigo-400 bg-indigo-500/10 px-1.5 py-0.5 rounded text-sm",children:"ROADMAP.md"})," in your project root with checklist items (",n.jsx("code",{className:"text-slate-300 text-sm",children:"- [ ] Feature"}),") or heading-based items (",n.jsx("code",{className:"text-slate-300 text-sm",children:"### Feature"}),") to get started."]})]})})]});const z=v.totalItems>0?Math.round(v.processedItems/v.totalItems*100):0,U=Py(v.status),A=Iy(v.items),R=v.lastScan?e1(v.lastScan):"Never",Q=v.autoScanInterval?Math.round(v.autoScanInterval/60):5;return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Roadmap Scanner"}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(ma,{label:v.enabled?"Enabled":"Disabled",checked:v.enabled,onChange:w,disabled:f}),n.jsxs(re,{onClick:D,loading:r,disabled:!v.enabled||v.status==="complete",children:[n.jsx(ss,{className:"h-4 w-4 mr-2"}),"Scan Now"]})]})]}),n.jsx(be,{className:`p-6 border-2 ${U.borderColor}`,children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(U.icon,{className:`h-8 w-8 ${U.textColor}`}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400",children:"Scanner Status"}),n.jsx("div",{className:`text-2xl font-bold ${U.textColor}`,children:U.label})]})]}),n.jsxs("div",{className:"text-right text-sm text-slate-400 space-y-1",children:[n.jsxs("div",{children:["Last scan: ",n.jsx("span",{className:"text-slate-300",children:R})]}),v.enabled&&v.status!=="complete"&&n.jsxs("div",{children:["Auto-scan: ",n.jsxs("span",{className:"text-slate-300",children:["every ",Q," min"]})]}),v.enabled&&v.status==="complete"&&n.jsx("div",{className:"text-emerald-400",children:"Auto-scan paused - all items sliced"})]})]})}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("h3",{className:"text-sm font-medium text-slate-300",children:"Progress"}),n.jsxs("span",{className:"text-sm text-slate-400",children:[v.processedItems," / ",v.totalItems," items (",z,"%)"]})]}),n.jsx("div",{className:"w-full h-3 bg-slate-800 rounded-full overflow-hidden",children:n.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${z===100?"bg-gradient-to-r from-emerald-500 to-emerald-400":"bg-gradient-to-r from-indigo-600 to-indigo-400"}`,style:{width:`${z}%`}})})]}),Object.entries(A).map(([q,L])=>n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200 mb-4",children:q}),n.jsx("div",{className:"space-y-2",children:L.map(J=>n.jsx(Wy,{item:J},J.hash))})]},q))]})};function Wy({item:c}){const o=c.checked,d=c.processed;return n.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${o?"bg-slate-950/30 border-slate-800/50":d?"bg-emerald-500/5 border-emerald-500/10":"bg-slate-950/50 border-slate-800"}`,children:[n.jsxs("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[o?n.jsx(vb,{className:"h-4 w-4 text-slate-600 flex-shrink-0"}):d?n.jsx(ns,{className:"h-4 w-4 text-emerald-400 flex-shrink-0"}):n.jsx(lb,{className:"h-4 w-4 text-slate-500 flex-shrink-0"}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("div",{className:`text-sm font-medium truncate ${o?"line-through text-slate-600":"text-slate-200"}`,children:c.title}),c.description&&n.jsx("div",{className:"text-xs text-slate-500 truncate mt-0.5",children:c.description})]})]}),n.jsx("div",{className:"flex-shrink-0 ml-3",children:o?n.jsx(ha,{variant:"neutral",children:"Skipped"}):d?n.jsx(ha,{variant:"success",children:c.prdFile||"Processed"}):n.jsx(ha,{variant:"warning",children:"Pending"})})]})}function Py(c){switch(c){case"complete":return{label:"Complete",icon:ns,textColor:"text-emerald-400",borderColor:"border-emerald-500/20 bg-emerald-500/5"};case"idle":return{label:"Idle",icon:Mi,textColor:"text-blue-400",borderColor:"border-blue-500/20 bg-blue-500/5"};case"scanning":return{label:"Scanning",icon:ss,textColor:"text-indigo-400",borderColor:"border-indigo-500/20 bg-indigo-500/5"};case"disabled":return{label:"Disabled",icon:Kt,textColor:"text-slate-400",borderColor:"border-slate-500/20 bg-slate-500/5"};default:return{label:"No Roadmap",icon:Kt,textColor:"text-slate-500",borderColor:"border-slate-500/20"}}}function Iy(c){const o={};for(const d of c){const r=d.section||"General";o[r]||(o[r]=[]),o[r].push(d)}return o}function e1(c){try{const o=new Date(c),r=new Date().getTime()-o.getTime(),m=Math.floor(r/6e4);if(m<1)return"Just now";if(m<60)return`${m} min ago`;const f=Math.floor(m/60);return f<24?`${f} hr ago`:`${Math.floor(f/24)} day(s) ago`}catch{return"Unknown"}}const Hu=[{label:"Every 30 minutes",value:"*/30 * * * *"},{label:"Every hour",value:"0 * * * *"},{label:"Every 3 hours",value:"0 */3 * * *"},{label:"Every 6 hours",value:"0 */6 * * *"},{label:"Every 12 hours",value:"0 */12 * * *"},{label:"Daily at midnight",value:"0 0 * * *"},{label:"Daily at 9 AM",value:"0 9 * * *"},{label:"Weekdays at 9 AM",value:"0 9 * * 1-5"},{label:"Custom",value:"__custom__"}];function du(c){const o=c.trim().split(/\s+/);if(o.length!==5)return c;const[d,r,m,f,h]=o,v=Hu.find(g=>g.value===c);return v?v.label:d==="*/30"&&r==="*"?"Every 30 minutes":d==="0"&&r==="*"?"Every hour":d.startsWith("*/")?`Every ${parseInt(d.replace("*/",""),10)} minutes`:d==="0"&&r.startsWith("*/")?`Every ${parseInt(r.replace("*/",""),10)} hours`:d==="0"&&r!=="*"&&m==="*"&&f==="*"&&h==="*"?`Daily at ${p0(r)}`:d==="0"&&r!=="*"&&m==="*"&&f==="*"&&h==="1-5"?`Weekdays at ${p0(r)}`:c}function p0(c){const o=parseInt(c,10);return o===0?"12 AM":o<12?`${o} AM`:o===12?"12 PM":`${o-12} PM`}function t1(c){const o=Hu.find(d=>d.value===c);return(o==null?void 0:o.value)??"__custom__"}function l1(c){const o=new Date,d=c.getTime()-o.getTime(),r=Math.floor(d/6e4),m=Math.floor(r/60),f=Math.floor(m/24);return r<1?"less than a minute":r<60?`in ${r} minute${r>1?"s":""}`:m<24?`in ${m} hour${m>1?"s":""}`:`in ${f} day${f>1?"s":""}`}function a1(c){const o={weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};return c.toLocaleDateString("en-US",o)}function n1(c){const o=new Date,d=c.getTime()-o.getTime(),r=Math.floor(d/6e4);return r>=0&&r<30}const s1=()=>{const{addToast:c,selectedProjectId:o,globalModeLoading:d}=rt(),[r,m]=y.useState(!1),[f,h]=y.useState(!1),[v,g]=y.useState({executorSchedule:"",reviewerSchedule:"",isEditing:!1}),{data:p,loading:N,error:w,refetch:D}=ct(J0,[o],{enabled:!d}),{data:z,loading:U,refetch:A}=ct(zu,[o],{enabled:!d});y.useEffect(()=>{const P=setInterval(()=>{D()},3e4);return()=>clearInterval(P)},[D]),y.useEffect(()=>{z&&!v.isEditing&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!1})},[z,v.isEditing]);const R=async()=>{if(p){m(!0);try{p.paused?(await d0(),c({title:"Schedule Resumed",message:"Cron schedules have been reactivated.",type:"success"})):(await ry(),c({title:"Schedule Paused",message:"Cron schedules have been deactivated.",type:"info"})),D()}catch(P){c({title:"Action Failed",message:P instanceof Error?P.message:"Failed to toggle schedule state",type:"error"})}finally{m(!1)}}},Q=()=>{z&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!0})},q=()=>{z&&g({executorSchedule:z.cronSchedule,reviewerSchedule:z.reviewerSchedule,isEditing:!1})},L=async()=>{if(z){h(!0);try{await Du({cronSchedule:v.executorSchedule,reviewerSchedule:v.reviewerSchedule}),await d0(),c({title:"Schedule Updated",message:"Cron schedules have been saved and installed.",type:"success"}),g(P=>({...P,isEditing:!1})),A(),D()}catch(P){c({title:"Save Failed",message:P instanceof Error?P.message:"Failed to save schedules",type:"error"})}finally{h(!1)}}},J=(P,ue)=>{if(!P)return n.jsx("span",{className:"text-slate-500",children:"Not scheduled"});const xe=new Date(P),$=n1(xe);return n.jsxs("div",{className:"flex items-center space-x-2",children:[$&&n.jsxs("span",{className:"relative flex h-3 w-3",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-green-500"})]}),n.jsxs("div",{className:"text-sm",children:[n.jsx("span",{className:"text-slate-200 font-medium",children:l1(xe)}),n.jsxs("span",{className:"text-slate-500 ml-2",children:["(",a1(xe),")"]})]})]})},B=(P,ue,xe,$)=>{const ie=t1(ue),we=ie==="__custom__";return n.jsxs("div",{className:`space-y-3 ${$?"opacity-50 pointer-events-none":""}`,children:[n.jsx("div",{className:"flex items-center space-x-3",children:n.jsx(Zl,{label:`${P} Preset`,options:Hu,value:ie,onChange:se=>{se!=="__custom__"&&xe(se)},className:"flex-1"})}),we&&n.jsx(Me,{label:"Custom Cron Expression",value:ue,onChange:se=>xe(se.target.value),placeholder:"* * * * *",helperText:"Format: minute hour day month weekday (e.g., 0 */2 * * * for every 2 hours)"}),n.jsxs("div",{className:"text-sm text-slate-400",children:["Human-readable: ",n.jsx("span",{className:"text-slate-200",children:du(ue)})]})]})};if(N||U)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading scheduling information..."})});if(w||!p||!z)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load schedule information"}),n.jsx("div",{className:"text-sm text-slate-500",children:(w==null?void 0:w.message)||"Unknown error"}),n.jsx(re,{onClick:()=>{D(),A()},children:"Retry"})]});const C=p.paused,V=C?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-green-500/10 text-green-400 border-green-500/20",Z=C?"Paused":"Active";return n.jsxs("div",{className:"space-y-6 max-w-6xl mx-auto",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("h1",{className:"text-3xl font-bold text-slate-100",children:"Scheduling"})}),n.jsx(be,{className:`p-6 border-2 ${V}`,children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(Mi,{className:"h-8 w-8"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400",children:"Cron Status"}),n.jsx("div",{className:"text-2xl font-bold",children:Z})]})]}),n.jsx(re,{variant:C?"primary":"outline",size:"lg",onClick:R,loading:r,children:C?n.jsxs(n.Fragment,{children:[n.jsx(ss,{className:"h-5 w-5 mr-2"}),"Resume"]}):n.jsxs(n.Fragment,{children:[n.jsx(V0,{className:"h-5 w-5 mr-2"}),"Pause"]})})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Executor Schedule"}),!v.isEditing&&n.jsxs(re,{variant:"ghost",size:"sm",onClick:Q,children:[n.jsx(Mb,{className:"h-4 w-4 mr-1"}),"Edit"]})]}),v.isEditing?B("Executor",v.executorSchedule,P=>g(ue=>({...ue,executorSchedule:P}))):n.jsx(n.Fragment,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Schedule"}),n.jsx("div",{className:"text-lg text-slate-200 font-medium",children:du(z.cronSchedule)}),n.jsx("div",{className:"text-xs text-slate-500 font-mono mt-1",children:z.cronSchedule})]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Next Run"}),J(p.executor.nextRun,z.cronSchedule)]}),n.jsxs("div",{className:`flex items-center space-x-2 text-sm ${p.executor.installed?"text-green-400":"text-amber-400"}`,children:[n.jsx(tn,{className:"h-4 w-4"}),n.jsx("span",{children:p.executor.installed?"Installed":"Not installed"})]})]})})]}),n.jsxs(be,{className:`p-6 ${z.reviewerEnabled?"":"opacity-50"}`,children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Reviewer Schedule"}),!z.reviewerEnabled&&n.jsx("span",{className:"text-xs text-slate-500 bg-slate-800 px-2 py-1 rounded",children:"Disabled"})]}),v.isEditing?B("Reviewer",v.reviewerSchedule,P=>g(ue=>({...ue,reviewerSchedule:P})),!z.reviewerEnabled):n.jsx(n.Fragment,{children:n.jsx("div",{className:"space-y-4",children:z.reviewerEnabled?n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Schedule"}),n.jsx("div",{className:"text-lg text-slate-200 font-medium",children:du(z.reviewerSchedule)}),n.jsx("div",{className:"text-xs text-slate-500 font-mono mt-1",children:z.reviewerSchedule})]}),n.jsxs("div",{children:[n.jsx("div",{className:"text-sm text-slate-400 mb-1",children:"Next Run"}),J(p.reviewer.nextRun,z.reviewerSchedule)]}),n.jsxs("div",{className:`flex items-center space-x-2 text-sm ${p.reviewer.installed?"text-green-400":"text-amber-400"}`,children:[n.jsx(tn,{className:"h-4 w-4"}),n.jsx("span",{children:p.reviewer.installed?"Installed":"Not installed"})]})]}):n.jsx("div",{className:"text-slate-500 text-sm",children:"Automated reviews are disabled. Enable them in Settings to configure the reviewer schedule."})})})]})]}),n.jsxs(be,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center space-x-2 mb-4",children:[n.jsx(Ri,{className:"h-5 w-5 text-slate-400"}),n.jsx("h3",{className:"text-lg font-semibold text-slate-200",children:"Active Crontab Entries"})]}),p.entries.length===0?n.jsx("div",{className:"text-slate-500 text-sm",children:"No crontab entries found."}):n.jsx("div",{className:"space-y-2",children:p.entries.map((P,ue)=>n.jsx("div",{className:"bg-slate-950/50 rounded-lg p-3 font-mono text-sm text-slate-300 border border-slate-800",children:P},ue))})]}),v.isEditing&&n.jsxs("div",{className:"flex items-center justify-end space-x-4 pt-4 border-t border-slate-800",children:[n.jsx(re,{variant:"ghost",onClick:q,children:"Cancel"}),n.jsxs(re,{onClick:L,loading:f,children:[n.jsx(tn,{className:"h-4 w-4 mr-2"}),"Save & Install"]})]})]})},i1=({tabs:c,activeTab:o,onChange:d,className:r=""})=>{var g,p;const[m,f]=Qe.useState((g=c[0])==null?void 0:g.id),h=o||m,v=N=>{d?d(N):f(N)};return n.jsxs("div",{className:`flex flex-col ${r}`,children:[n.jsx("div",{className:"border-b border-slate-800 mb-6",children:n.jsx("nav",{className:"-mb-px flex space-x-8 overflow-x-auto scrollbar-hide",children:c.map(N=>n.jsx("button",{onClick:()=>v(N.id),className:`
|
|
471
471
|
whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm transition-all duration-200
|
|
472
472
|
${h===N.id?"border-indigo-500 text-indigo-400":"border-transparent text-slate-500 hover:text-slate-300 hover:border-slate-700"}
|
|
473
473
|
`,children:N.label},N.id))})}),n.jsx("div",{className:"flex-1 animate-in fade-in slide-in-from-bottom-2 duration-300",children:(p=c.find(N=>N.id===h))==null?void 0:p.content})]})},c1={enabled:!1,botToken:"",channels:{eng:"",prs:"",incidents:"",releases:""},autoCreateProjectChannels:!1,discussionEnabled:!1},g0=c=>({provider:c.provider,defaultBranch:c.defaultBranch,branchPrefix:c.branchPrefix,branchPatterns:c.branchPatterns||[],reviewerEnabled:c.reviewerEnabled,minReviewScore:c.minReviewScore,maxRuntime:c.maxRuntime,reviewerMaxRuntime:c.reviewerMaxRuntime,maxLogSize:c.maxLogSize,cronScheduleOffset:c.cronScheduleOffset??0,maxRetries:c.maxRetries??3,providerEnv:c.providerEnv||{},notifications:c.notifications||{webhooks:[]},prdPriority:c.prdPriority||[],roadmapScanner:c.roadmapScanner||{enabled:!1,roadmapPath:"ROADMAP.md",autoScanInterval:300},templatesDir:c.templatesDir||".night-watch/templates",slack:c.slack??c1}),r1=c=>["TOKEN","SECRET","KEY","PASSWORD","AUTH","API_KEY"].some(d=>c.toUpperCase().includes(d)),u1=({value:c,isSensitive:o})=>{const[d,r]=Qe.useState(!1);return o?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-slate-300 font-mono",children:d?c:"••••••••••••"}),n.jsx("button",{type:"button",onClick:()=>r(!d),className:"text-slate-500 hover:text-slate-300",children:d?n.jsx(xu,{className:"h-4 w-4"}):n.jsx(zi,{className:"h-4 w-4"})})]}):n.jsx("span",{className:"text-sm text-slate-300 font-mono truncate max-w-xs",children:c})},o1=({envVars:c,onChange:o})=>{const[d,r]=Qe.useState(""),[m,f]=Qe.useState(""),[h,v]=Qe.useState(null),[g,p]=Qe.useState(""),N=()=>{if(d.trim()){if(!/^[A-Z_][A-Z0-9_]*$/.test(d)){alert("Key must be uppercase with underscores (e.g., API_KEY)");return}o({...c,[d]:m}),r(""),f("")}},w=R=>{const Q={...c};delete Q[R],o(Q)},D=R=>{v(R),p(c[R])},z=()=>{h&&(o({...c,[h]:g}),v(null),p(""))},U=()=>{v(null),p("")},A=Object.entries(c);return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-slate-400 mb-4",children:"Configure environment variables passed to the provider CLI (API keys, base URLs)"}),n.jsx("div",{className:"space-y-2",children:A.length===0?n.jsx("p",{className:"text-slate-500 text-sm italic",children:"No provider environment variables configured."}):A.map(([R,Q])=>n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md border border-slate-800 bg-slate-950/40",children:[n.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[n.jsx("span",{className:"text-sm font-mono text-indigo-400 w-48 truncate",children:R}),h===R?n.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[n.jsx("input",{type:"text",value:g,onChange:q=>p(q.target.value),className:"flex-1 bg-slate-800 border border-slate-700 rounded px-2 py-1 text-sm text-slate-200"}),n.jsx("button",{type:"button",onClick:z,className:"p-1 text-green-400 hover:text-green-300",children:n.jsx(tn,{className:"h-4 w-4"})}),n.jsx("button",{type:"button",onClick:U,className:"p-1 text-slate-400 hover:text-slate-300",children:n.jsx(Ft,{className:"h-4 w-4"})})]}):n.jsx(u1,{value:Q,isSensitive:r1(R)})]}),h!==R&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>D(R),className:"p-1 text-slate-400 hover:text-slate-200",children:n.jsx(Ru,{className:"h-4 w-4"})}),n.jsx("button",{type:"button",onClick:()=>w(R),className:"p-1 text-red-400 hover:text-red-300",children:n.jsx(Mu,{className:"h-4 w-4"})})]})]},R))}),n.jsxs("div",{className:"flex items-end gap-3 pt-4 border-t border-slate-800",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"block text-xs font-medium text-slate-500 mb-1",children:"Key"}),n.jsx("input",{type:"text",value:d,onChange:R=>r(R.target.value.toUpperCase()),placeholder:"e.g., ANTHROPIC_BASE_URL",className:"w-full bg-slate-800 border border-slate-700 rounded px-3 py-2 text-sm text-slate-200 placeholder-slate-500"})]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"block text-xs font-medium text-slate-500 mb-1",children:"Value"}),n.jsx("input",{type:"text",value:m,onChange:R=>f(R.target.value),placeholder:"e.g., https://api.example.com",className:"w-full bg-slate-800 border border-slate-700 rounded px-3 py-2 text-sm text-slate-200 placeholder-slate-500"})]}),n.jsxs(re,{onClick:N,disabled:!d.trim(),children:[n.jsx(gl,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})},d1=({notifications:c,onChange:o})=>{const[d,r]=Qe.useState(null),[m,f]=Qe.useState(!1),[h,v]=Qe.useState({type:"slack",url:"",events:[]}),g=[{label:"Run Started",value:"run_started"},{label:"Run Succeeded",value:"run_succeeded"},{label:"Run Failed",value:"run_failed"},{label:"Run Timeout",value:"run_timeout"},{label:"Review Completed",value:"review_completed"},{label:"PR Auto-Merged",value:"pr_auto_merged"},{label:"Rate Limit Fallback",value:"rate_limit_fallback"},{label:"QA Completed",value:"qa_completed"}],p=()=>{o({webhooks:[...c.webhooks,h]}),v({type:"slack",url:"",events:[]}),f(!1)},N=(U,A)=>{const R=[...c.webhooks];R[U]=A,o({webhooks:R})},w=U=>{o({webhooks:c.webhooks.filter((A,R)=>R!==U)})},D=(U,A)=>U.includes(A)?U.filter(R=>R!==A):[...U,A],z=({webhook:U,onChange:A,onSave:R,onCancel:Q,isNew:q})=>n.jsxs("div",{className:"p-4 rounded-md border border-slate-700 bg-slate-900/50 space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Zl,{label:"Type",value:U.type,onChange:L=>{const J=L;A(J==="telegram"?{type:J,botToken:"",chatId:"",events:U.events}:{type:J,url:"",events:U.events})},options:[{label:"Slack",value:"slack"},{label:"Discord",value:"discord"},{label:"Telegram",value:"telegram"}]}),U.type==="telegram"?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"relative",children:n.jsx(Me,{label:"Bot Token",type:"password",value:U.botToken||"",onChange:L=>A({...U,botToken:L.target.value}),placeholder:"123456789:ABCdefGHIjklMNOpqrsTUVwxyz"})}),n.jsx(Me,{label:"Chat ID",value:U.chatId||"",onChange:L=>A({...U,chatId:L.target.value}),placeholder:"123456789"})]}):n.jsx("div",{className:"md:col-span-2",children:n.jsx(Me,{label:"Webhook URL",type:"password",value:U.url||"",onChange:L=>A({...U,url:L.target.value}),placeholder:"https://hooks.slack.com/services/..."})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-2",children:"Events"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:g.map(L=>n.jsx("button",{type:"button",onClick:()=>A({...U,events:D(U.events,L.value)}),className:`px-3 py-1.5 rounded-md text-sm transition-colors ${U.events.includes(L.value)?"bg-indigo-600 text-white":"bg-slate-800 text-slate-400 hover:bg-slate-700"}`,children:L.label},L.value))})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(re,{variant:"ghost",onClick:Q,children:"Cancel"}),n.jsx(re,{onClick:R,disabled:U.events.length===0||(U.type==="telegram"?!U.botToken||!U.chatId:!U.url),children:q?"Add Webhook":"Save Changes"})]})]});return n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-slate-400 mb-4",children:"Receive notifications when events occur via Slack, Discord, or Telegram"}),n.jsx("div",{className:"space-y-3",children:c.webhooks.length===0?n.jsx("p",{className:"text-slate-500 text-sm italic",children:"No webhooks configured."}):c.webhooks.map((U,A)=>n.jsx("div",{children:d===A?n.jsx(z,{webhook:U,onChange:R=>N(A,R),onSave:()=>r(null),onCancel:()=>r(null)}):n.jsxs("div",{className:"flex items-center justify-between p-4 rounded-md border border-slate-800 bg-slate-950/40",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("span",{className:"text-sm font-medium text-slate-200 capitalize",children:U.type}),U.type==="telegram"&&n.jsxs("span",{className:"text-xs text-slate-500",children:["Chat ID: ",U.chatId]})]}),n.jsx("div",{className:"flex flex-wrap gap-1",children:U.events.map(R=>n.jsx("span",{className:"px-2 py-0.5 bg-slate-800 rounded text-xs text-slate-400",children:R.replace("_"," ")},R))})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>r(A),className:"p-2 text-slate-400 hover:text-slate-200",children:n.jsx(Ru,{className:"h-4 w-4"})}),n.jsx("button",{type:"button",onClick:()=>w(A),className:"p-2 text-red-400 hover:text-red-300",children:n.jsx(Mu,{className:"h-4 w-4"})})]})]})},A))}),m?n.jsx(z,{webhook:h,onChange:v,onSave:p,onCancel:()=>f(!1),isNew:!0}):n.jsxs(re,{variant:"ghost",onClick:()=>f(!0),children:[n.jsx(gl,{className:"h-4 w-4 mr-2"}),"Add Webhook"]})]})},v0=({label:c,value:o,onChange:d,placeholder:r,helpText:m})=>{const[f,h]=Qe.useState(""),v=()=>{f.trim()&&!o.includes(f.trim())&&(d([...o,f.trim()]),h(""))},g=N=>{d(o.filter(w=>w!==N))},p=N=>{N.key==="Enter"&&(N.preventDefault(),v())};return n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-2",children:c}),n.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:o.map(N=>n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-slate-800 rounded text-sm text-slate-300",children:[N,n.jsx("button",{type:"button",onClick:()=>g(N),className:"text-slate-500 hover:text-red-400",children:n.jsx(Ft,{className:"h-3 w-3"})})]},N))}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{type:"text",value:f,onChange:N=>h(N.target.value),onKeyDown:p,placeholder:r,className:"flex-1 bg-slate-800 border border-slate-700 rounded px-3 py-2 text-sm text-slate-200 placeholder-slate-500"}),n.jsx(re,{onClick:v,disabled:!f.trim(),children:n.jsx(gl,{className:"h-4 w-4"})})]}),m&&n.jsx("p",{className:"text-xs text-slate-500 mt-1",children:m})]})},f1=()=>{const{addToast:c,projectName:o,selectedProjectId:d,globalModeLoading:r}=rt(),[m,f]=Qe.useState(!1),[h,v]=Qe.useState(null),{data:g,loading:p,error:N,refetch:w}=ct(zu,[d],{enabled:!r}),{data:D,loading:z,refetch:U}=ct(sy,[d],{enabled:!r}),A=D??[];Qe.useEffect(()=>{g&&v(g0(g))},[g]);const R=(B,C)=>{v(V=>V&&{...V,[B]:C})},Q=async()=>{if(h){f(!0);try{await Du({provider:h.provider,defaultBranch:h.defaultBranch,branchPrefix:h.branchPrefix,branchPatterns:h.branchPatterns,reviewerEnabled:h.reviewerEnabled,minReviewScore:h.minReviewScore,maxRuntime:h.maxRuntime,reviewerMaxRuntime:h.reviewerMaxRuntime,maxLogSize:h.maxLogSize,cronScheduleOffset:h.cronScheduleOffset,maxRetries:h.maxRetries,providerEnv:h.providerEnv,notifications:h.notifications,prdPriority:h.prdPriority,roadmapScanner:h.roadmapScanner,templatesDir:h.templatesDir,slack:h.slack}),c({title:"Settings Saved",message:"Configuration updated successfully.",type:"success"}),w(),U()}catch(B){c({title:"Save Failed",message:B instanceof Error?B.message:"Failed to save configuration",type:"error"})}finally{f(!1)}}},q=()=>{g&&(v(g0(g)),c({title:"Reset Complete",message:"Unsaved changes were discarded.",type:"info"}))},L=async B=>{try{const C=await W0(B);R("roadmapScanner",C.roadmapScanner),c({title:B?"Roadmap Scanner Enabled":"Roadmap Scanner Disabled",message:`Roadmap scanner has been ${B?"enabled":"disabled"}.`,type:"success"})}catch(C){c({title:"Toggle Failed",message:C instanceof Error?C.message:"Failed to toggle roadmap scanner",type:"error"})}};if(p||!h)return n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("div",{className:"text-slate-400",children:"Loading settings..."})});if(N)return n.jsxs("div",{className:"flex flex-col items-center justify-center h-full space-y-4",children:[n.jsx(Kt,{className:"h-12 w-12 text-red-400"}),n.jsx("div",{className:"text-slate-300",children:"Failed to load settings"}),n.jsx("div",{className:"text-sm text-slate-500",children:N.message}),n.jsx(re,{onClick:()=>w(),children:"Retry"})]});const J=[{id:"general",label:"General",content:n.jsxs(be,{className:"p-6 space-y-4",children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200",children:"Project Configuration"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsx(Me,{label:"Project Name",value:o,disabled:!0}),n.jsx(Zl,{label:"Provider",value:h.provider,onChange:B=>R("provider",B),options:[{label:"Anthropic (Claude)",value:"claude"},{label:"OpenAI (Codex)",value:"codex"}]}),n.jsx(Me,{label:"Default Branch",value:h.defaultBranch,onChange:B=>R("defaultBranch",B.target.value)}),n.jsx(Me,{label:"Branch Prefix",value:h.branchPrefix,onChange:B=>R("branchPrefix",B.target.value)}),n.jsx("div",{className:"md:col-span-2",children:n.jsx(ma,{label:"Enable Automated Reviews",checked:h.reviewerEnabled,onChange:B=>R("reviewerEnabled",B)})})]})]})},{id:"runtime",label:"Runtime",content:n.jsxs(be,{className:"p-6 space-y-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-slate-400 mb-2",children:"Min Review Score (0-100)"}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("input",{type:"range",min:"0",max:"100",value:h.minReviewScore,onChange:B=>R("minReviewScore",Number(B.target.value)),className:"w-full h-2 bg-slate-800 rounded-lg appearance-none cursor-pointer accent-indigo-500"}),n.jsx("span",{className:"text-sm font-bold text-slate-200 w-10",children:h.minReviewScore})]}),n.jsx("p",{className:"text-xs text-slate-500 mt-1",children:'PRs below this score will be marked as "Needs Work".'})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsx(Me,{label:"Max Runtime (Executor)",type:"number",value:String(h.maxRuntime),onChange:B=>R("maxRuntime",Number(B.target.value||0)),rightIcon:n.jsx("span",{className:"text-xs",children:"sec"})}),n.jsx(Me,{label:"Max Runtime (Reviewer)",type:"number",value:String(h.reviewerMaxRuntime),onChange:B=>R("reviewerMaxRuntime",Number(B.target.value||0)),rightIcon:n.jsx("span",{className:"text-xs",children:"sec"})}),n.jsx(Me,{label:"Max Log Size",type:"number",value:String(h.maxLogSize),onChange:B=>R("maxLogSize",Number(B.target.value||0)),rightIcon:n.jsx("span",{className:"text-xs",children:"bytes"})})]})]})},{id:"env",label:"Provider Env",content:n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200 mb-2",children:"Provider Environment Variables"}),n.jsx(o1,{envVars:h.providerEnv,onChange:B=>R("providerEnv",B)})]})},{id:"notifications",label:"Notifications",content:n.jsxs(be,{className:"p-6",children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200 mb-2",children:"Notification Webhooks"}),n.jsx(d1,{notifications:h.notifications,onChange:B=>R("notifications",B)})]})},{id:"slack",label:"Slack Bot",content:n.jsxs(be,{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200",children:"Slack Bot Integration"}),n.jsx("p",{className:"text-sm text-slate-400",children:"Post notifications as agent personas using the Slack Bot API"})]}),n.jsx(ma,{checked:h.slack.enabled,onChange:B=>R("slack",{...h.slack,enabled:B})})]}),n.jsx("div",{className:"grid grid-cols-1 gap-6 pt-4 border-t border-slate-800",children:n.jsx("div",{className:"relative",children:n.jsx(Me,{label:"Bot Token (xoxb-...)",type:"password",value:h.slack.botToken,onChange:B=>R("slack",{...h.slack,botToken:B.target.value}),placeholder:"xoxb-...",helperText:"OAuth Bot Token from your Slack App settings"})})}),n.jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-800",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("h4",{className:"text-sm font-medium text-slate-300",children:"Channel IDs"}),n.jsx("button",{type:"button",className:"px-3 py-1.5 text-xs rounded-md bg-slate-800 text-slate-400 hover:bg-slate-700 hover:text-slate-200 transition-colors",onClick:()=>{alert("Coming soon: will list workspace channels")},children:"Detect Channels"})]}),n.jsx("p",{className:"text-xs text-slate-500",children:"Enter the Slack channel IDs (e.g. C01ABCDEF) where agent messages will be posted."}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Me,{label:"#eng Channel ID",value:h.slack.channels.eng,onChange:B=>R("slack",{...h.slack,channels:{...h.slack.channels,eng:B.target.value}}),placeholder:"C01ABCDEF"}),n.jsx(Me,{label:"#prs Channel ID",value:h.slack.channels.prs,onChange:B=>R("slack",{...h.slack,channels:{...h.slack.channels,prs:B.target.value}}),placeholder:"C01ABCDEF"}),n.jsx(Me,{label:"#incidents Channel ID",value:h.slack.channels.incidents,onChange:B=>R("slack",{...h.slack,channels:{...h.slack.channels,incidents:B.target.value}}),placeholder:"C01ABCDEF"}),n.jsx(Me,{label:"#releases Channel ID",value:h.slack.channels.releases,onChange:B=>R("slack",{...h.slack,channels:{...h.slack.channels,releases:B.target.value}}),placeholder:"C01ABCDEF"})]})]}),n.jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-800",children:[n.jsx("h4",{className:"text-sm font-medium text-slate-300",children:"Options"}),n.jsx(ma,{label:"Auto-create project channels",checked:h.slack.autoCreateProjectChannels,onChange:B=>R("slack",{...h.slack,autoCreateProjectChannels:B})}),n.jsx(ma,{label:"Enable agent deliberation",checked:h.slack.discussionEnabled,onChange:B=>R("slack",{...h.slack,discussionEnabled:B})})]})]})},{id:"roadmap",label:"Roadmap",content:n.jsxs(be,{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200",children:"Roadmap Scanner"}),n.jsx("p",{className:"text-sm text-slate-400",children:"Automatically scan ROADMAP.md and generate PRDs for unchecked items"})]}),n.jsx(ma,{checked:h.roadmapScanner.enabled,onChange:L})]}),h.roadmapScanner.enabled&&n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 pt-4 border-t border-slate-800",children:[n.jsx(Me,{label:"Roadmap Path",value:h.roadmapScanner.roadmapPath,onChange:B=>R("roadmapScanner",{...h.roadmapScanner,roadmapPath:B.target.value})}),n.jsx(Me,{label:"Auto Scan Interval",type:"number",value:String(h.roadmapScanner.autoScanInterval),onChange:B=>R("roadmapScanner",{...h.roadmapScanner,autoScanInterval:Math.max(30,Number(B.target.value||30))}),rightIcon:n.jsx("span",{className:"text-xs",children:"sec (min 30)"})})]})]})},{id:"advanced",label:"Advanced",content:n.jsxs(be,{className:"p-6 space-y-6",children:[n.jsx("h3",{className:"text-lg font-medium text-slate-200",children:"Advanced Settings"}),n.jsx("p",{className:"text-sm text-slate-400",children:"Less commonly used configuration options"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsx(Me,{label:"Templates Directory",value:h.templatesDir,onChange:B=>R("templatesDir",B.target.value),helperText:"Directory for custom template overrides"}),n.jsx(Me,{label:"Cron Schedule Offset",type:"number",min:"0",max:"59",value:String(h.cronScheduleOffset),onChange:B=>{const C=Math.min(59,Math.max(0,Number(B.target.value||0)));R("cronScheduleOffset",C)},helperText:"Minutes offset (0-59) for cron schedules"}),n.jsx(Me,{label:"Max Retries",type:"number",min:"1",value:String(h.maxRetries),onChange:B=>{const C=Math.max(1,Number(B.target.value||1));R("maxRetries",C)},helperText:"Retry attempts for rate-limited API calls"})]}),n.jsxs("div",{className:"pt-4 border-t border-slate-800 space-y-4",children:[n.jsx(v0,{label:"Branch Patterns",value:h.branchPatterns,onChange:B=>R("branchPatterns",B),placeholder:"e.g., feat/",helpText:"Patterns to match for PR reviews"}),n.jsx(v0,{label:"PRD Priority",value:h.prdPriority,onChange:B=>R("prdPriority",B),placeholder:"e.g., feature-x",helpText:"PRDs matching these names are executed first"})]})]})}];return n.jsxs("div",{className:"max-w-4xl mx-auto pb-10",children:[n.jsx("h2",{className:"text-2xl font-bold text-slate-100 mb-6",children:"Settings"}),n.jsx(i1,{tabs:J}),n.jsxs("div",{className:"flex items-center justify-end space-x-4 pt-6 mt-6 border-t border-slate-800",children:[n.jsxs(re,{variant:"ghost",className:"text-slate-400 hover:text-slate-300",onClick:q,children:[n.jsx(Di,{className:"h-4 w-4 mr-2"}),"Reset"]}),n.jsxs(re,{onClick:Q,loading:m,children:[n.jsx(Cb,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]}),n.jsxs("div",{className:"mt-12",children:[n.jsxs("h3",{className:"text-lg font-bold text-slate-200 mb-4 flex items-center",children:[n.jsx(q0,{className:"h-5 w-5 mr-2 text-indigo-500"}),"System Health"]}),n.jsx(be,{className:"divide-y divide-slate-800",children:z?n.jsx("div",{className:"p-4 text-sm text-slate-500",children:"Loading health checks..."}):A.map((B,C)=>{const V=B.status==="pass",Z=B.status==="warn",P=V?"bg-green-500/10 text-green-400 border-green-500/20":Z?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-red-500/10 text-red-400 border-red-500/20";return n.jsxs("div",{className:"p-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-slate-200",children:B.name}),n.jsx("p",{className:"text-xs text-slate-500",children:B.detail})]}),n.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium border ${P}`,children:B.status.toUpperCase()})]},`${B.name}-${C}`)})})]})]})},m1=()=>(Ty(),n.jsx(ev,{children:n.jsxs("div",{className:"flex h-screen bg-[#030712] text-slate-300 overflow-hidden relative",children:[n.jsx("div",{className:"absolute top-0 left-0 w-full h-96 bg-indigo-900/10 rounded-full blur-[120px] -translate-y-1/2 pointer-events-none z-0"}),n.jsx(wy,{}),n.jsxs("div",{className:"flex-1 flex flex-col min-w-0 z-10",children:[n.jsx(Cy,{}),n.jsx("main",{className:"flex-1 overflow-auto p-6 scroll-smooth relative",children:n.jsx("div",{className:"max-w-7xl mx-auto w-full",children:n.jsxs(_g,{children:[n.jsx(Lt,{path:"/",element:n.jsx(Vy,{})}),n.jsx(Lt,{path:"/prds",element:n.jsx(Ky,{})}),n.jsx(Lt,{path:"/prs",element:n.jsx(Jy,{})}),n.jsx(Lt,{path:"/board",element:n.jsx(Gy,{})}),n.jsx(Lt,{path:"/scheduling",element:n.jsx(s1,{})}),n.jsx(Lt,{path:"/logs",element:n.jsx(Zy,{})}),n.jsx(Lt,{path:"/roadmap",element:n.jsx(Fy,{})}),n.jsx(Lt,{path:"/integrations",element:n.jsx(Xy,{})}),n.jsx(Lt,{path:"/agents",element:n.jsx(Hy,{})}),n.jsx(Lt,{path:"/settings",element:n.jsx(f1,{})}),n.jsx(Lt,{path:"*",element:n.jsx(Tg,{to:"/",replace:!0})})]})})})]}),n.jsx(Ay,{})]})})),I0=document.getElementById("root");if(!I0)throw new Error("Could not find root element to mount to");const h1=zp.createRoot(I0);h1.render(n.jsx(Qe.StrictMode,{children:n.jsx(m1,{})}));
|
package/web/dist/index.html
CHANGED
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
animation: gradient-x 3s ease infinite;
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
|
-
<script type="module" crossorigin src="/assets/index-
|
|
76
|
+
<script type="module" crossorigin src="/assets/index-D3awZ0gS.js"></script>
|
|
77
77
|
<link rel="stylesheet" crossorigin href="/assets/index-BtxQU4oX.css">
|
|
78
78
|
</head>
|
|
79
79
|
<body class="bg-[#030712] text-slate-300 font-sans antialiased overflow-hidden selection:bg-indigo-500/30 selection:text-indigo-200">
|