orbital-command 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/bin/orbital.js +3 -3
  3. package/dist/assets/Landing-B6q9U0Vd.js +11 -0
  4. package/dist/assets/{PrimitivesConfig-DThSipFy.js → PrimitivesConfig-TlFvypvg.js} +9 -14
  5. package/dist/assets/{QualityGates-B4kxM5UU.js → QualityGates-D8uvclW4.js} +1 -1
  6. package/dist/assets/SessionTimeline-QUaJw6Aa.js +1 -0
  7. package/dist/assets/Settings-CAEnAZAk.js +12 -0
  8. package/dist/assets/{SourceControl-BMNIz7Lt.js → SourceControl-DPeSBaMV.js} +7 -12
  9. package/dist/assets/{WorkflowVisualizer-CxuSBOYu.js → WorkflowVisualizer-DHrIjx6W.js} +1 -1
  10. package/dist/assets/{arrow-down-DVPp6_qp.js → arrow-down-DnfKgF33.js} +1 -1
  11. package/dist/assets/{bot-NFaJBDn_.js → bot-DUPnHZfM.js} +1 -1
  12. package/dist/assets/{circle-x-IsFCkBZu.js → circle-x-B4nA79je.js} +1 -1
  13. package/dist/assets/{file-text-J1cebZXF.js → file-text-PnzRO4pO.js} +1 -1
  14. package/dist/assets/{globe-WzeyHsUc.js → globe-CIX_GBr0.js} +1 -1
  15. package/dist/assets/index-B-B-tTjw.css +1 -0
  16. package/dist/assets/index-DQVAzHMu.js +354 -0
  17. package/dist/assets/{key-CKR8JJSj.js → key-DpAZM-3d.js} +1 -1
  18. package/dist/assets/{minus-CHBsJyjp.js → minus-CJlpKNUB.js} +1 -1
  19. package/dist/assets/{radio-xqZaR-Uk.js → radio-DhynLcSx.js} +1 -1
  20. package/dist/assets/{rocket-D_xvvNG6.js → rocket-DnuQh3sF.js} +1 -1
  21. package/dist/assets/{shield-TdB1yv_a.js → shield-DLMQmvFQ.js} +1 -1
  22. package/dist/assets/{ui-BmsSg9jU.js → ui-QhrRH5wk.js} +6 -6
  23. package/dist/assets/{useSocketListener-0L5yiN5i.js → useSocketListener-DPrExNDV.js} +1 -1
  24. package/dist/assets/{useWorkflowEditor-CqeRWVQX.js → useWorkflowEditor-BxN7phfr.js} +2 -2
  25. package/dist/assets/{workflow-constants-Rw-GmgHZ.js → workflow-constants-ZcCN11vm.js} +1 -1
  26. package/dist/assets/{zap-C9wqYMpl.js → zap-eJ3z8HRI.js} +1 -1
  27. package/dist/index.html +3 -3
  28. package/dist/server/server/index.js +8 -1
  29. package/dist/server/server/routes/sync-routes.js +175 -0
  30. package/dist/server/server/wizard/index.js +18 -24
  31. package/dist/server/server/wizard/phases/setup-wizard.js +4 -34
  32. package/dist/server/server/wizard/types.js +1 -22
  33. package/dist/server/shared/workflow-presets.js +22 -0
  34. package/package.json +1 -1
  35. package/server/index.ts +7 -1
  36. package/server/routes/sync-routes.ts +205 -0
  37. package/server/wizard/index.ts +17 -31
  38. package/server/wizard/phases/setup-wizard.ts +7 -38
  39. package/server/wizard/types.ts +2 -28
  40. package/shared/workflow-presets.ts +28 -0
  41. package/dist/assets/Landing-CfQdHR0N.js +0 -11
  42. package/dist/assets/SessionTimeline-Bz1iZnmg.js +0 -1
  43. package/dist/assets/Settings-DLcZwbCT.js +0 -12
  44. package/dist/assets/index-BdJ57EhC.css +0 -1
  45. package/dist/assets/index-o4ScMAuR.js +0 -349
@@ -0,0 +1,12 @@
1
+ import{j as e}from"./ui-QhrRH5wk.js";import{a as d}from"./vendor-Bqt8AJn2.js";import{c as Se,q as Te,Y as he,s as ye,C as $e,b as Pe,U as E,h as D,an as V,B as xe,a as v,a3 as pe,a5 as fe,a6 as ge,a7 as je,am as w,ao as J,K as Ue,ap as be,a8 as De,S as Ae,aq as _e,H as we,ar as Ie,as as Be,T as ze,at as Ve,aa as He,E as Je,au as Ge,d as We,P as z,X as Ee,av as Me,aw as ke,ax as Ke,ay as Ye,az as Le,g as qe}from"./index-DQVAzHMu.js";import{M as H}from"./minus-CJlpKNUB.js";import"./charts-LGLb8hyU.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Xe=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Oe=Se("archive",Xe);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Qe=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],Ze=Se("skip-forward",Qe);function et(){const{getApiBase:t}=Te(),[i,s]=d.useState(null),[o,a]=d.useState(null),[n,r]=d.useState([]),[m,u]=d.useState(null),[c,p]=d.useState(null),[b,x]=d.useState(null),[l,f]=d.useState(null),[N,M]=d.useState(null),[y,O]=d.useState(null),[G,W]=d.useState(null),[Z,ee]=d.useState(!0),[A,g]=d.useState(null),$=d.useCallback(async()=>{try{const h=await fetch("/api/orbital/aggregate/manifest/status");if(h.ok){const j=await h.json();s(j)}}catch{}finally{ee(!1)}},[]),C=d.useCallback(async h=>{try{const j=await fetch(`${t(h)}/manifest/files`);if(j.ok){const F=await j.json();r(F.data??[])}}catch{}},[t]);d.useEffect(()=>{$()},[$]),he(()=>{$(),o&&C(o)}),d.useEffect(()=>{const h=()=>{$(),o&&C(o)};return ye.on("manifest:changed",h),()=>{ye.off("manifest:changed",h)}},[$,C,o]);const te=d.useCallback(h=>{if(o===h){a(null),r([]);return}a(h),r([]),C(h)},[o,C]),se=d.useCallback(()=>{a(null),r([])},[]),K=d.useCallback(async()=>{g("update-all");try{await fetch("/api/orbital/aggregate/manifest/update-all",{method:"POST",headers:{"Content-Type":"application/json"}}),await $()}catch{}finally{g(null)}},[$]),Y=d.useCallback(async h=>{g(`preview:${h}`);try{const j=await fetch(`${t(h)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!0})});if(j.ok){const F=await j.json();p(F.data),x(h)}}catch{}finally{g(null)}},[t]),ae=d.useCallback(async h=>{g(`update:${h}`);try{(await fetch(`${t(h)}/manifest/update`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dryRun:!1})})).ok&&(p(null),x(null),await $())}catch{}finally{g(null)}},[t,$]),_=d.useCallback(async h=>{g(`init:${h}`);try{await fetch(`${t(h)}/manifest/init`,{method:"POST",headers:{"Content-Type":"application/json"}}),await $()}catch{}finally{g(null)}},[t,$]),ne=d.useCallback(async h=>{g(`validate:${h}`);try{const j=await fetch(`${t(h)}/manifest/validate`);if(j.ok){const F=await j.json();u(F.data)}}catch{}finally{g(null)}},[t]),re=d.useCallback(async(h,j,F)=>{g(`pin:${j}`);try{await fetch(`${t(h)}/manifest/pin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j,reason:F})})}catch{}finally{g(null)}},[t]),L=d.useCallback(async(h,j)=>{g(`unpin:${j}`);try{await fetch(`${t(h)}/manifest/unpin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),q=d.useCallback(async(h,j)=>{g(`reset:${j}`);try{await fetch(`${t(h)}/manifest/reset`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),X=d.useCallback(async(h,j)=>{g(`revert:${j}`);try{await fetch(`${t(h)}/manifest/revert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:j})})}catch{}finally{g(null)}},[t]),Q=d.useCallback(async(h,j,F)=>{var Ne;g(`diff:${j}`),M(j),O(F??null),W(h);try{const ve=await fetch(`${t(h)}/manifest/diff?file=${encodeURIComponent(j)}`);if(ve.ok){const Re=await ve.json();f(((Ne=Re.data)==null?void 0:Ne.diff)??null)}}catch{}finally{g(null)}},[t]),k=d.useCallback(()=>{f(null),M(null),O(null),W(null)},[]),S=d.useCallback(()=>{p(null),x(null)},[]),le=d.useCallback(()=>u(null),[]);return{summary:i,loading:Z,actionLoading:A,expandedProjectId:o,projectFiles:n,validation:m,updatePreview:c,updatePreviewProjectId:b,diffContent:l,diffFile:N,diffFileStatus:y,diffProjectId:G,expandProject:te,collapseProject:se,fetchSummary:$,updateAll:K,previewProjectUpdate:Y,applyProjectUpdate:ae,clearUpdatePreview:S,initProject:_,validateProject:ne,clearValidation:le,pinFile:re,unpinFile:L,resetFile:q,revertFile:X,getDiff:Q,clearDiff:k}}function tt({files:t,actionLoading:i,onPin:s,onUnpin:o,onReset:a,onRevert:n,onDiff:r}){const m=t.filter(l=>l.status==="missing"),u=t.filter(l=>l.status==="outdated"),c=t.filter(l=>l.status==="modified"),p=t.filter(l=>l.status==="pinned"),b=t.filter(l=>l.status==="synced"),x=t.filter(l=>l.status==="user-owned");return t.length===0?e.jsx("div",{className:"text-xs text-muted-foreground/40 py-2 pl-4",children:"No tracked files."}):e.jsxs("div",{className:"pl-4 pb-2",children:[e.jsx(I,{title:`Missing (${m.length})`,description:"expected but not found on disk",files:m,defaultOpen:!0,renderRow:l=>e.jsx(B,{file:l,children:e.jsx(P,{label:"Restore",variant:"cyan",onClick:()=>a(l.path),loading:i===`reset:${l.path}`})},l.path)}),e.jsx(I,{title:`Outdated (${u.length})`,description:"newer template version available",files:u,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Update",variant:"cyan",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Modified (${c.length})`,description:"edited by you",files:c,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Reset",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),e.jsx(P,{label:"Pin",variant:"blue",onClick:()=>s(l.path),loading:i===`pin:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Pinned (${p.length})`,description:"locked from updates",files:p,defaultOpen:!1,renderRow:l=>e.jsxs(B,{file:l,meta:l.pinnedReason?`"${l.pinnedReason}"`:void 0,children:[e.jsx(P,{label:"View changes",onClick:()=>r(l.path,l.status),loading:i===`diff:${l.path}`}),e.jsx(P,{label:"Unpin",onClick:()=>o(l.path),loading:i===`unpin:${l.path}`}),e.jsx(P,{label:"Reset",onClick:()=>a(l.path),loading:i===`reset:${l.path}`}),l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})]},l.path)}),e.jsx(I,{title:`Synced (${b.length})`,description:"matches template",files:b,defaultOpen:!1,renderRow:l=>e.jsx(B,{file:l,children:l.hasPrev&&e.jsx(P,{label:"Revert",onClick:()=>n(l.path),loading:i===`revert:${l.path}`})},l.path)}),e.jsx(I,{title:`User (${x.length})`,description:"your files, not managed",files:x,defaultOpen:!1,renderRow:l=>e.jsx(B,{file:l},l.path)})]})}function I({title:t,description:i,files:s,defaultOpen:o,renderRow:a}){const[n,r]=d.useState(o);return s.length===0?null:e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{onClick:()=>r(!n),className:"flex items-center gap-1.5 text-xs text-muted-foreground/70 hover:text-muted-foreground transition-colors mb-1",children:[n?e.jsx($e,{className:"h-3 w-3"}):e.jsx(Pe,{className:"h-3 w-3"}),e.jsx("span",{children:t}),e.jsx("span",{className:"text-muted-foreground/40 font-normal",children:i})]}),n&&e.jsx("div",{className:"space-y-1.5 ml-4",children:s.map(a)})]})}function B({file:t,meta:i,children:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-foreground/70",children:t.path}),i&&e.jsx("span",{className:"text-xs text-muted-foreground/40 italic",children:i}),s]})}function P({label:t,variant:i,onClick:s,loading:o}){const a="rounded border px-1.5 py-0 text-[10px] leading-5 transition-colors disabled:opacity-40",n={cyan:"border-cyan-500/30 bg-cyan-500/10 text-cyan-400 hover:bg-cyan-500/20",blue:"border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20",default:"border-border bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"};return e.jsxs("button",{onClick:s,disabled:o,className:`${a} ${n[i??"default"]}`,children:[o?e.jsx(E,{className:"h-3 w-3 animate-spin inline mr-1"}):null,t]})}function st({project:t,expanded:i,files:s,actionLoading:o,onToggle:a,onUpdate:n,onInit:r,onPin:m,onUnpin:u,onReset:c,onRevert:p,onDiff:b}){const{projectId:x,projectName:l,projectColor:f,status:N,manifest:M}=t;if(N==="no-manifest")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground truncate",children:l}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"No manifest"})]}),e.jsxs(D,{size:"sm",variant:"outline",onClick:r,disabled:o===`init:${x}`,className:"h-6 px-2 text-xs border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[o===`init:${x}`?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),"Initialize"]})]})});if(N==="error")return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 opacity-40",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground/50 truncate",children:l}),e.jsx("span",{className:"text-xs text-red-400/60",children:"Offline"})]})});const y=M,O=y.files.outdated>0||y.files.missing>0||y.needsUpdate;return e.jsxs("div",{className:"py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer hover:opacity-80 transition-opacity",onClick:a,children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${f})`}}),e.jsx("span",{className:"text-sm text-foreground truncate w-[80px] sm:w-[140px] shrink-0",children:l}),e.jsxs(xe,{variant:"outline",className:v("text-[10px] px-1.5 py-0 shrink-0",y.needsUpdate?"border-amber-500/30 text-amber-400 bg-amber-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",y.installedVersion]}),y.needsUpdate&&e.jsxs("span",{className:"text-[10px] text-amber-400/60 shrink-0",children:["→ v",y.packageVersion]}),e.jsxs("span",{className:"hidden md:flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:v("w-[80px] text-center",y.files.missing>0?"text-red-400":"text-red-400/25"),children:[y.files.missing," missing"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.outdated>0?"text-amber-400":"text-amber-400/25"),children:[y.files.outdated," outdated"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.modified>0?"text-orange-400":"text-orange-400/25"),children:[y.files.modified," modified"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.pinned>0?"text-blue-400":"text-blue-400/25"),children:[y.files.pinned," pinned"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.synced>0?"text-green-400/50":"text-green-400/20"),children:[y.files.synced," synced"]}),e.jsxs("span",{className:v("w-[80px] text-center",y.files.userOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[y.files.userOwned," user"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"outline",onClick:O?n:void 0,disabled:!O||o===`preview:${x}`||o===`update:${x}`,className:v("h-6 px-2 text-xs w-auto sm:w-[130px] justify-center",O?"border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10":"border-green-500/30 text-green-400/60"),children:[o===`preview:${x}`||o===`update:${x}`?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),O?"Update Project":"Up to Date"]}),e.jsx("button",{onClick:a,className:"flex items-center justify-center h-6 w-6 rounded text-muted-foreground/40 hover:text-muted-foreground hover:bg-white/5 transition-colors",children:i?e.jsx($e,{className:"h-3.5 w-3.5"}):e.jsx(Pe,{className:"h-3.5 w-3.5"})})]})]}),i&&e.jsx(tt,{files:s,actionLoading:o,onPin:m,onUnpin:u,onReset:c,onRevert:p,onDiff:b})]})}function at({updatePreview:t,projectName:i,updatePreviewProjectId:s,actionLoading:o,onApply:a,onClose:n}){return e.jsx(pe,{open:t!==null,onOpenChange:r=>{r||n()},children:e.jsxs(fe,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsxs(je,{className:"text-sm",children:["Update ",i]}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"Review what will happen before applying"})]}),e.jsx(w,{}),t&&!t.isEmpty&&e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[(t.toUpdate.length>0||t.toAdd.length>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toUpdate.length+t.toAdd.length," file",t.toUpdate.length+t.toAdd.length!==1?"s":""," will be updated"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files replaced with the latest template version"}),e.jsxs("div",{className:"mt-1.5 space-y-0.5",children:[t.toUpdate.map(r=>e.jsx("div",{className:"text-xs font-mono text-cyan-400/70",children:r},r)),t.toAdd.map(r=>e.jsxs("div",{className:"text-xs font-mono text-green-400/70",children:[r," ",e.jsx("span",{className:"text-muted-foreground/40",children:"(new)"})]},r))]})]})]}),t.toRename.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ue,{className:"h-4 w-4 text-purple-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toRename.length," file",t.toRename.length!==1?"s":""," will be renamed"]}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toRename.map(r=>e.jsxs("div",{className:"text-xs font-mono text-purple-400/70",children:[r.from," → ",r.to]},r.from))})]})]}),t.toRemove.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{className:"h-4 w-4 text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[t.toRemove.length," file",t.toRemove.length!==1?"s":""," will be removed"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"No longer part of the template"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toRemove.map(r=>e.jsx("div",{className:"text-xs font-mono text-red-400/70",children:r},r))})]})]}),t.toSkip.length>0&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ze,{className:"h-4 w-4 text-muted-foreground/50 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[t.toSkip.length," file",t.toSkip.length!==1?"s":""," will be skipped"]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Modified or pinned files are never overwritten"}),e.jsx("div",{className:"mt-1.5 space-y-0.5",children:t.toSkip.map(r=>e.jsxs("div",{className:"text-xs font-mono text-muted-foreground/40",children:[r.file," ",e.jsxs("span",{className:"text-muted-foreground/30",children:["(",r.reason,")"]})]},r.file))})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),t&&t.isEmpty&&e.jsx("div",{className:"px-5 py-8 text-center text-sm text-muted-foreground",children:"Everything is up to date. No changes needed."}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Cancel"})}),t&&!t.isEmpty&&s&&e.jsxs(D,{size:"sm",onClick:()=>a(s),disabled:o===`update:${s}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o===`update:${s}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update Project"]})]})]})})}function nt({open:t,onOpenChange:i,summary:s,actionLoading:o,onUpdateAll:a}){return e.jsx(pe,{open:t,onOpenChange:i,children:e.jsxs(fe,{className:"max-w-md p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(je,{className:"text-sm",children:"Update All Projects"}),e.jsx(De,{className:"text-xs text-muted-foreground/60",children:"Review what will happen across all projects"})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-4 space-y-3 overflow-auto min-h-0",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"h-4 w-4 text-cyan-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground",children:[s.totalOutdated+s.totalMissing," file",s.totalOutdated+s.totalMissing!==1?"s":""," to sync across ",s.projectsOutdated||s.projects.filter(n=>n.manifest&&(n.manifest.files.outdated>0||n.manifest.files.missing>0)).length," project",s.projects.filter(n=>n.manifest&&(n.manifest.files.outdated>0||n.manifest.files.missing>0)).length!==1?"s":""]}),e.jsx("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"Synced and outdated files will be replaced with the latest template version"})]})]}),(s.totalModified>0||s.totalPinned>0)&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ae,{className:"h-4 w-4 text-green-400/60 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-foreground/70",children:[s.totalModified+s.totalPinned," file",s.totalModified+s.totalPinned!==1?"s":""," will not be touched"]}),e.jsxs("div",{className:"text-xs text-muted-foreground/60 mt-0.5",children:[s.totalModified>0&&e.jsxs(e.Fragment,{children:[s.totalModified," modified"]}),s.totalModified>0&&s.totalPinned>0&&" and ",s.totalPinned>0&&e.jsxs(e.Fragment,{children:[s.totalPinned," pinned"]})," ","file",s.totalModified+s.totalPinned!==1?"s":""," are never overwritten"]})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Oe,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs text-muted-foreground/50",children:"Previous versions will be backed up and can be reverted"})]})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Cancel"})}),e.jsxs(D,{size:"sm",onClick:()=>{i(!1),a()},disabled:o==="update-all",className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[o==="update-all"&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update All Projects"]})]})]})})}function rt(t){const i=t.split(`
12
+ `),s=[];let o=0,a=0;for(const n of i){const r=n.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)/);if(r){o=parseInt(r[1],10),a=parseInt(r[2],10),s.push({type:"hunk",content:n});continue}if(n.startsWith("diff ")||n.startsWith("index ")||n.startsWith("--- ")||n.startsWith("+++ ")){s.push({type:"meta",content:n});continue}if(n.startsWith("-"))s.push({type:"remove",content:n.slice(1),oldNum:o}),o++;else if(n.startsWith("+"))s.push({type:"add",content:n.slice(1),newNum:a}),a++;else{const m=n.startsWith(" ")?n.slice(1):n;s.push({type:"context",content:m,oldNum:o,newNum:a}),o++,a++}}return s}function lt({diff:t}){const i=rt(t),s=i.reduce((a,n)=>Math.max(a,n.oldNum??0,n.newNum??0),0),o=String(s).length;return e.jsx("div",{className:"text-[11px] font-mono leading-[1.6] pb-1",children:i.map((a,n)=>{if(a.type==="meta")return null;if(a.type==="hunk")return e.jsx("div",{className:"px-3 py-1.5 mt-1 first:mt-0 text-cyan-400/60 bg-cyan-500/5 border-y border-cyan-500/10 select-none",children:a.content},n);const r=a.oldNum!=null?String(a.oldNum).padStart(o):"".padStart(o),m=a.newNum!=null?String(a.newNum).padStart(o):"".padStart(o),u=v("flex",a.type==="add"&&"bg-green-500/10",a.type==="remove"&&"bg-red-500/10"),c=v("select-none border-r border-border/40 px-2 text-right shrink-0",a.type==="add"&&"text-green-400/40",a.type==="remove"&&"text-red-400/40",a.type==="context"&&"text-muted-foreground/25"),p=v("px-3 whitespace-pre-wrap break-all flex-1 min-w-0",a.type==="add"&&"text-green-400",a.type==="remove"&&"text-red-400",a.type==="context"&&"text-foreground/50"),b=a.type==="add"?"+":a.type==="remove"?"-":" ";return e.jsxs("div",{className:u,children:[e.jsx("span",{className:c,children:r}),e.jsx("span",{className:c,children:m}),e.jsx("span",{className:v("w-4 text-center shrink-0 select-none",a.type==="add"&&"text-green-400/60",a.type==="remove"&&"text-red-400/60",a.type==="context"&&"text-transparent"),children:b}),e.jsx("span",{className:p,children:a.content||" "})]},n)})})}function it({diffFile:t,diffContent:i,diffFileStatus:s,diffProjectId:o,actionLoading:a,onResetFile:n,onClearDiff:r}){return e.jsx(pe,{open:t!==null,onOpenChange:m=>{m||r()},children:e.jsxs(fe,{className:"max-w-2xl p-0 max-h-[80vh] overflow-hidden grid grid-rows-[auto_auto_auto_1fr_auto_auto]",children:[e.jsxs(ge,{className:"px-5 pt-4 pb-3 pr-10",children:[e.jsx(je,{className:"text-sm font-mono",children:t}),e.jsx(De,{className:"text-xs text-muted-foreground/60",children:"Template → Your file"})]}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-2 text-xs text-muted-foreground/50",children:[e.jsx("span",{className:"text-red-400/70",children:"−"})," template version",e.jsx("span",{className:"mx-2",children:"·"}),e.jsx("span",{className:"text-green-400/70",children:"+"})," your local file"]}),e.jsx("div",{className:"overflow-auto min-h-0",children:i?e.jsx(lt,{diff:i}):e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground text-sm",children:[e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Loading diff..."]})}),e.jsx(w,{}),e.jsxs("div",{className:"px-5 py-3 flex justify-end gap-2",children:[e.jsx(be,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"sm",children:"Close"})}),s==="outdated"&&o&&e.jsxs(D,{size:"sm",onClick:()=>{n(o,t),r()},disabled:a===`reset:${t}`,className:"bg-cyan-600 hover:bg-cyan-700 text-white",children:[a===`reset:${t}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Update to latest"]}),s==="modified"&&o&&e.jsxs(D,{size:"sm",onClick:()=>{n(o,t),r()},disabled:a===`reset:${t}`,variant:"outline",children:[a===`reset:${t}`&&e.jsx(E,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Reset to template"]})]})]})})}function ot(){var Q;const{summary:t,loading:i,actionLoading:s,expandedProjectId:o,projectFiles:a,updatePreview:n,updatePreviewProjectId:r,diffContent:m,diffFile:u,diffFileStatus:c,diffProjectId:p,expandProject:b,updateAll:x,previewProjectUpdate:l,applyProjectUpdate:f,clearUpdatePreview:N,initProject:M,pinFile:y,unpinFile:O,resetFile:G,revertFile:W,getDiff:Z,clearDiff:ee}=et(),{version:A,updateAvailable:g,behindCount:$,updateStage:C,updateError:te,checkForUpdate:se,performUpdate:K}=_e(),Y=d.useRef(C);Y.current=C;const ae=d.useCallback(async()=>{await K(),Y.current!=="error"&&await x()},[K,x]),_=C==="pulling"||C==="installing",ne=C==="checking"||C==="checked",[re,L]=d.useState(!1);if(i)return e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(E,{className:"h-4 w-4 animate-spin"}),"Loading configuration status..."]});if(!t||t.total===0)return e.jsx("div",{className:"text-sm text-muted-foreground/60",children:"No projects registered."});const q=t.projects.length>0&&t.projects.every(k=>{var S;return k.status==="ok"&&!((S=k.manifest)!=null&&S.needsUpdate)})&&t.noManifest===0&&t.totalOutdated===0&&t.totalMissing===0&&t.totalModified===0&&t.totalPinned===0,X=t.projects.filter(k=>{var S;return k.status==="ok"&&((S=k.manifest)==null?void 0:S.needsUpdate)}).length;return e.jsxs(e.Fragment,{children:[A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Package"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Globally installed Orbital Command version"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm text-foreground",children:"Orbital Command"}),e.jsxs(xe,{variant:"outline",className:v("text-[10px] px-1.5 py-0",g?"border-emerald-500/30 text-emerald-400 bg-emerald-500/10":"border-green-500/30 text-green-400 bg-green-500/10"),children:["v",A.version]}),g&&e.jsxs("span",{className:"text-xs text-emerald-400/70",children:[$," update",$!==1?"s":""," available"]}),C==="checked"&&!g&&e.jsx("span",{className:"text-xs text-green-400",children:"Up to date"}),C==="done"&&e.jsx("span",{className:"text-xs text-green-400",children:"Updated — restart server to apply"}),C==="error"&&e.jsx("span",{className:"text-xs text-red-400 truncate",children:te}),_&&e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(E,{className:"h-3 w-3 animate-spin"}),C==="pulling"?"Pulling...":"Installing..."]})]}),e.jsxs("div",{className:"flex gap-1.5 shrink-0",children:[e.jsxs(D,{size:"sm",variant:"ghost",onClick:se,disabled:_||ne,className:"h-7 px-2 text-xs",children:[C==="checked"&&!g?e.jsx(we,{className:"h-3 w-3 mr-1 text-green-400"}):e.jsx(Ie,{className:v("h-3 w-3 mr-1",C==="checking"&&"animate-spin")}),C==="checked"&&!g?"Latest":"Check"]}),g&&C!=="done"&&e.jsxs(D,{size:"sm",variant:"outline",onClick:ae,disabled:_,className:"h-7 px-2.5 text-xs border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10",children:[_?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(Be,{className:"h-3 w-3 mr-1"}),"Update"]})]})]}),e.jsx(w,{className:"mb-4"})]}),e.jsxs("div",{className:"mb-2 flex items-baseline gap-3",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground/70",children:"Project Sync"}),e.jsx("span",{className:"text-[11px] text-muted-foreground/40",children:"Sync templates and config to your installed version"})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 pl-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[q?e.jsx(we,{className:"h-2 w-2 text-green-400 shrink-0"}):e.jsx(ze,{className:"h-2 w-2 text-amber-400 shrink-0"}),e.jsx("span",{className:"text-sm text-foreground truncate w-[80px] sm:w-[140px] shrink-0",children:"All Projects"}),A&&e.jsxs(xe,{variant:"outline",className:"text-[10px] px-1.5 py-0 shrink-0 border-green-500/30 text-green-400 bg-green-500/10",children:["v",A.version]}),e.jsxs("span",{className:"hidden md:flex items-center text-xs shrink-0 tabular-nums",children:[e.jsxs("span",{className:v("w-[80px] text-center",t.totalMissing>0?"text-red-400":"text-red-400/25"),children:[t.totalMissing," missing"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalOutdated>0?"text-amber-400":"text-amber-400/25"),children:[t.totalOutdated," outdated"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalModified>0?"text-orange-400":"text-orange-400/25"),children:[t.totalModified," modified"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalPinned>0?"text-blue-400":"text-blue-400/25"),children:[t.totalPinned," pinned"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalSynced>0?"text-green-400/50":"text-green-400/20"),children:[t.totalSynced," synced"]}),e.jsxs("span",{className:v("w-[80px] text-center",t.totalUserOwned>0?"text-muted-foreground/40":"text-muted-foreground/20"),children:[t.totalUserOwned," user"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:q?e.jsxs(D,{size:"sm",variant:"outline",disabled:!0,className:"h-6 px-2 text-xs w-auto sm:w-[130px] justify-center border-green-500/30 text-green-400/60",children:[e.jsx(V,{className:"h-3 w-3 mr-1"}),"Up to Date"]}):e.jsxs(D,{size:"sm",variant:"outline",onClick:()=>L(!0),disabled:s==="update-all",className:"h-6 px-2 text-xs w-auto sm:w-[130px] justify-center border-[rgba(0,188,212,0.3)] text-cyan-400 hover:bg-cyan-500/10",children:[s==="update-all"?e.jsx(E,{className:"h-3 w-3 mr-1 animate-spin"}):e.jsx(V,{className:"h-3 w-3 mr-1"}),X>0?`Update ${X}/${t.projects.length}`:"Update All"]})})]}),e.jsx(w,{className:"mb-2"}),e.jsx("div",{className:"space-y-0.5 pl-3",children:t.projects.map(k=>e.jsx(st,{project:k,expanded:o===k.projectId,files:o===k.projectId?a:[],actionLoading:s,onToggle:()=>b(k.projectId),onUpdate:()=>l(k.projectId),onInit:()=>M(k.projectId),onPin:S=>y(k.projectId,S),onUnpin:S=>O(k.projectId,S),onReset:S=>G(k.projectId,S),onRevert:S=>W(k.projectId,S),onDiff:(S,le)=>Z(k.projectId,S,le)},k.projectId))}),e.jsx(at,{updatePreview:n,projectName:(Q=t.projects.find(k=>k.projectId===r))==null?void 0:Q.projectName,updatePreviewProjectId:r,actionLoading:s,onApply:f,onClose:N}),e.jsx(nt,{open:re,onOpenChange:L,summary:t,actionLoading:s,onUpdateAll:x}),e.jsx(it,{diffFile:u,diffContent:m,diffFileStatus:c,diffProjectId:p,actionLoading:s,onResetFile:G,onClearDiff:ee})]})}function ct(){return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Configuration"}),e.jsx(ot,{})]})}function dt(){const{projects:t}=Te(),[i,s]=d.useState(null),[o,a]=d.useState(null),[n,r]=d.useState(null);async function m(c,p){s(c),a(null);try{const b=await fetch(`/api/orbital/projects/${c}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});if(!b.ok){const x=await b.json().catch(()=>({}));a(x.error??`Failed to update project (HTTP ${b.status})`)}}catch{a("Failed to update project")}finally{s(null)}}async function u(c){s(c),a(null);try{const p=await fetch(`/api/orbital/projects/${c}`,{method:"DELETE"});if(!p.ok){const b=await p.json().catch(()=>({}));a(b.error??`Failed to remove project (HTTP ${p.status})`)}}catch{a("Failed to remove project")}finally{s(null),r(null)}}return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Projects"}),e.jsxs("div",{className:"space-y-2",children:[t.map(c=>e.jsx(xt,{project:c,updating:i===c.id,confirmDelete:n===c.id,onUpdate:p=>m(c.id,p),onDeleteRequest:()=>r(c.id),onDeleteConfirm:()=>u(c.id),onDeleteCancel:()=>r(null)},c.id)),o&&e.jsx("p",{className:"text-[11px] text-destructive",children:o})]})]})}function xt({project:t,updating:i,confirmDelete:s,onUpdate:o,onDeleteRequest:a,onDeleteConfirm:n,onDeleteCancel:r}){const[m,u]=d.useState(!1),[c,p]=d.useState(t.name),b=d.useRef(null);d.useEffect(()=>{var N;m&&((N=b.current)==null||N.focus())},[m]),d.useEffect(()=>{m||p(t.name)},[t.name,m]);const x=c.trim()!==""&&c.trim()!==t.name,l=d.useCallback(()=>{u(!1);const N=c.trim();N&&N!==t.name?o({name:N}):p(t.name)},[c,t.name,o]),f=t.status==="active"?"bg-green-400":t.status==="error"?"bg-red-400":"bg-muted-foreground/40";return e.jsxs("div",{className:v("flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 rounded border border-white/[0.08] px-3 py-2","transition-colors hover:border-[rgba(var(--neon-cyan),0.2)]",!t.enabled&&"opacity-50"),children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(Ve,{value:t.color,onChange:N=>o({color:N}),disabled:i}),e.jsxs("div",{className:"flex-1 min-w-0",children:[m?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:b,value:c,onChange:N=>p(N.target.value),onBlur:()=>{p(t.name),u(!1)},onKeyDown:N=>{N.key==="Enter"&&l(),N.key==="Escape"&&(p(t.name),u(!1))},className:"flex-1 min-w-0 bg-transparent text-xs font-medium outline-none border-b border-primary/50 pb-0.5"}),x&&e.jsx("button",{onMouseDown:N=>{N.preventDefault(),l()},className:"shrink-0 text-primary hover:text-primary/80 transition-colors",title:"Save name",children:e.jsx(He,{className:"h-3.5 w-3.5"})})]}):e.jsx("div",{className:"text-xs font-medium truncate cursor-text hover:text-primary transition-colors",onClick:()=>u(!0),title:"Click to rename",children:t.name}),e.jsx("div",{className:"text-[10px] text-muted-foreground/60 font-mono truncate",children:t.path})]}),e.jsx("span",{className:v("h-1.5 w-1.5 rounded-full shrink-0",f),title:t.status})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0 self-end sm:self-auto",children:s?e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[e.jsx("span",{className:"text-destructive",children:"Remove?"}),e.jsx("button",{onClick:n,disabled:i,className:"text-destructive hover:text-destructive/80 font-medium transition-colors disabled:opacity-50",children:"Yes"}),e.jsx("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o({enabled:!t.enabled}),disabled:i,className:"shrink-0 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",title:t.enabled?"Disable project":"Enable project",children:t.enabled?e.jsx(Je,{className:"h-3.5 w-3.5"}):e.jsx(Ge,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:a,disabled:i,className:"shrink-0 text-muted-foreground/50 hover:text-destructive transition-colors disabled:opacity-50",title:"Remove project",children:e.jsx(We,{className:"h-3.5 w-3.5"})})]})})]})}function U({checked:t,onCheckedChange:i,disabled:s}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:s,onClick:()=>i(!t),className:v("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border transition-colors duration-200",t?"border-[rgba(0,188,212,0.4)] bg-[rgba(0,188,212,0.25)]":"border-[rgba(255,255,255,0.1)] bg-[rgba(255,255,255,0.05)]",s&&"cursor-not-allowed opacity-40"),children:e.jsx("span",{className:v("pointer-events-none block h-3.5 w-3.5 rounded-full transition-all duration-200",t?"translate-x-[18px] bg-[rgb(0,188,212)] shadow-[0_0_8px_rgba(0,188,212,0.5)]":"translate-x-[2px] bg-[rgba(255,255,255,0.4)]")})})}const ie={permissionMode:"bypass",verbose:!0,allowedTools:[],disallowedTools:[],appendSystemPrompt:"",outputFormat:"",noMarkdown:!1,printMode:!1},mt={staleTimeoutMinutes:10,maxBatchSize:20,maxConcurrent:0,envVars:{}},oe="/api/orbital/aggregate/config/dispatch-flags";function ut(){const[t,i]=d.useState(ie),[s,o]=d.useState(!0),[a,n]=d.useState(!1),[r,m]=d.useState(null),u=d.useRef(t);u.current=t;const c=d.useCallback(async()=>{try{const x=await fetch(oe);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l),m(null)}catch(x){console.warn("[Orbital] Dispatch flags fetch failed:",x),m("Failed to load dispatch settings")}finally{o(!1)}},[]),p=d.useCallback(async x=>{const l={...u.current,...x};i(l),n(!0),m(null);try{const f=await fetch(oe,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!f.ok){const M=await f.json().catch(()=>({}));throw new Error(M.error??`HTTP ${f.status}`)}const{data:N}=await f.json();i(N)}catch(f){console.warn("[Orbital] Dispatch flags update failed:",f),m(f instanceof Error?f.message:"Failed to save"),c()}finally{n(!1)}},[c]),b=d.useCallback(async()=>{i(ie),n(!0),m(null);try{const x=await fetch(oe,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)});if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l)}catch(x){console.warn("[Orbital] Dispatch flags reset failed:",x),m("Failed to reset"),c()}finally{n(!1)}},[c]);return d.useEffect(()=>{c()},[c]),he(c),{flags:t,loading:s,saving:a,error:r,updateFlags:p,resetToDefaults:b}}const R="flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",Fe="flex items-center gap-1.5 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-40",me="h-8 w-full rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] placeholder:text-muted-foreground/40";function ue({value:t,onChange:i,options:s,disabled:o,label:a}){return e.jsx("div",{role:"group","aria-label":a,className:"card-glass inline-flex flex-wrap rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.02)] p-0.5",children:s.map(n=>e.jsx("button",{onClick:()=>i(n.value),disabled:o,"aria-pressed":t===n.value,className:`px-2.5 py-1 text-xs rounded-[3px] transition-all duration-150 ${t===n.value?"bg-[rgba(0,188,212,0.2)] text-[rgb(0,188,212)] shadow-[0_0_8px_rgba(0,188,212,0.15)]":"text-muted-foreground hover:text-foreground"} ${o?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:n.label},n.value))})}function T({label:t,description:i,children:s}){return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-foreground",children:t}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:i})]}),e.jsx("div",{className:"flex-shrink-0",children:s})]})}function Ce({label:t,description:i,value:s,onChange:o,disabled:a}){const[n,r]=d.useState(""),m=()=>{const u=n.trim();u&&!s.includes(u)&&(o([...s,u]),r(""))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:t}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:i})]}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{type:"text",value:n,onChange:u=>r(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),m())},disabled:a,placeholder:"Tool name (e.g. Read, Bash)","aria-label":`Add ${t.toLowerCase()}`,className:me}),e.jsx("button",{onClick:m,disabled:a||!n.trim(),"aria-label":`Add tool to ${t.toLowerCase()}`,className:R+" !w-8 !h-8",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]}),s.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(u=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2 py-0.5 text-xs text-muted-foreground",children:[u,e.jsx("button",{onClick:()=>o(s.filter(c=>c!==u)),disabled:a,"aria-label":`Remove ${u}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(Ee,{className:"h-3 w-3"})})]},u))})]})}function ht({value:t,onChange:i,disabled:s}){const[o,a]=d.useState(""),[n,r]=d.useState(""),m=Object.entries(t),u=()=>{const c=o.trim();c&&(i({...t,[c]:n}),a(""),r(""))};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:"Environment Variables"}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:"Custom env vars passed to every dispatched session"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mb-2",children:[e.jsx("input",{type:"text",value:o,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},disabled:s,placeholder:"KEY","aria-label":"Environment variable name",className:me+" sm:w-1/3"}),e.jsxs("div",{className:"flex gap-2 flex-1",children:[e.jsx("input",{type:"text",value:n,onChange:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),u())},disabled:s,placeholder:"value","aria-label":"Environment variable value",className:me+" flex-1"}),e.jsx("button",{onClick:u,disabled:s||!o.trim(),"aria-label":"Add environment variable",className:R+" !w-8 !h-8",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})]}),m.length>0&&e.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(([c,p])=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 py-1",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:c}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"="}),e.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",children:p}),e.jsx("button",{onClick:()=>{const b={...t};delete b[c],i(b)},disabled:s,"aria-label":`Remove ${c}`,className:"text-muted-foreground/60 hover:text-foreground transition-colors",children:e.jsx(Ee,{className:"h-3 w-3"})})]},c))})]})}function pt(){const{flags:t,loading:i,saving:s,error:o,updateFlags:a,resetToDefaults:n}=ut();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${i?"opacity-60":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary",children:"Dispatch"}),o&&e.jsx("span",{className:"text-[11px] text-destructive",children:o})]}),e.jsxs("button",{onClick:n,disabled:s||i,className:Fe,children:[e.jsx(J,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx(T,{label:"Permission Mode",description:"How permission prompts are handled in dispatched sessions",children:e.jsx(ue,{label:"Permission Mode",value:t.permissionMode,onChange:r=>a({permissionMode:r}),options:[{value:"bypass",label:"Bypass"},{value:"default",label:"Default"},{value:"plan",label:"Plan"},{value:"acceptEdits",label:"Accept Edits"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Verbose Logging",description:"Enable verbose CLI output in dispatched sessions",children:e.jsx(U,{checked:t.verbose,onCheckedChange:r=>a({verbose:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"No Markdown",description:"Disable markdown rendering in terminal output",children:e.jsx(U,{checked:t.noMarkdown,onCheckedChange:r=>a({noMarkdown:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Print Mode",description:"Force non-interactive mode for single dispatches",children:e.jsx(U,{checked:t.printMode,onCheckedChange:r=>a({printMode:r}),disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Output Format",description:"Output format for non-interactive mode",children:e.jsx(ue,{label:"Output Format",value:t.outputFormat,onChange:r=>a({outputFormat:r}),options:[{value:"",label:"Default"},{value:"text",label:"Text"},{value:"json",label:"JSON"},{value:"stream-json",label:"Stream"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(Ce,{label:"Allowed Tools",description:"Whitelist specific tools (leave empty for all)",value:t.allowedTools,onChange:r=>a({allowedTools:r}),disabled:s}),e.jsx(w,{className:"my-4"}),e.jsx(Ce,{label:"Disallowed Tools",description:"Block specific tools from being used",value:t.disallowedTools,onChange:r=>a({disallowedTools:r}),disabled:s}),e.jsx(w,{className:"my-4"}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-sm text-foreground",children:"System Prompt"}),e.jsx("div",{className:"text-xs text-muted-foreground/60",children:"Custom instructions appended to every dispatched session"})]}),e.jsx("textarea",{value:t.appendSystemPrompt,onChange:r=>a({appendSystemPrompt:r.target.value}),disabled:s,rows:3,placeholder:"Enter additional instructions...",className:"w-full rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 py-2 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] placeholder:text-muted-foreground/40 resize-y"})]})]})}const ce={...mt,terminalAdapter:"auto"},de="/api/orbital/aggregate/config/dispatch-settings";function ft(){const[t,i]=d.useState(ce),[s,o]=d.useState(!0),[a,n]=d.useState(!1),[r,m]=d.useState(null),u=d.useRef(t);u.current=t;const c=d.useCallback(async()=>{try{const x=await fetch(de);if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l),m(null)}catch(x){console.warn("[Orbital] Dispatch settings fetch failed:",x),m("Failed to load dispatch operations")}finally{o(!1)}},[]),p=d.useCallback(async x=>{const l={...u.current,...x};i(l),n(!0),m(null);try{const f=await fetch(de,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!f.ok){const M=await f.json().catch(()=>({}));throw new Error(M.error??`HTTP ${f.status}`)}const{data:N}=await f.json();i(N)}catch(f){console.warn("[Orbital] Dispatch settings update failed:",f),m(f instanceof Error?f.message:"Failed to save"),c()}finally{n(!1)}},[c]),b=d.useCallback(async()=>{i(ce),n(!0),m(null);try{const x=await fetch(de,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ce)});if(!x.ok)throw new Error(`HTTP ${x.status}`);const{data:l}=await x.json();i(l)}catch(x){console.warn("[Orbital] Dispatch settings reset failed:",x),m("Failed to reset"),c()}finally{n(!1)}},[c]);return d.useEffect(()=>{c()},[c]),he(c),{settings:t,loading:s,saving:a,error:r,updateSettings:p,resetToDefaults:b}}function gt(){const{settings:t,loading:i,saving:s,error:o,updateSettings:a,resetToDefaults:n}=ft();return e.jsxs("section",{className:`card-glass settings-panel rounded-xl p-5 ${i?"opacity-60":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary",children:"Dispatch: Operations"}),o&&e.jsx("span",{className:"text-[11px] text-destructive",children:o})]}),e.jsxs("button",{onClick:n,disabled:s||i,className:Fe,children:[e.jsx(J,{className:"h-3 w-3"}),"Reset to defaults"]})]}),e.jsx(T,{label:"Terminal Adapter",description:"How dispatch windows are opened",children:e.jsx(ue,{label:"Terminal Adapter",value:t.terminalAdapter,onChange:r=>a({terminalAdapter:r}),options:[{value:"auto",label:"Auto"},{value:"iterm2",label:"iTerm2"},{value:"subprocess",label:"Subprocess"},{value:"none",label:"None"}],disabled:s})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Stale Timeout",description:"Minutes before unlinked dispatch is marked abandoned",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({staleTimeoutMinutes:Math.max(1,t.staleTimeoutMinutes-1)}),disabled:s||t.staleTimeoutMinutes<=1,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"w-12 text-center text-sm tabular-nums",children:[t.staleTimeoutMinutes,"m"]}),e.jsx("button",{onClick:()=>a({staleTimeoutMinutes:t.staleTimeoutMinutes+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Max Batch Size",description:"Maximum scopes per batch dispatch",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({maxBatchSize:Math.max(1,t.maxBatchSize-1)}),disabled:s||t.maxBatchSize<=1,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"w-12 text-center text-sm tabular-nums",children:t.maxBatchSize}),e.jsx("button",{onClick:()=>a({maxBatchSize:t.maxBatchSize+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Max Concurrent",description:"Limit simultaneous dispatches, 0 = unlimited",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>a({maxConcurrent:Math.max(0,t.maxConcurrent-1)}),disabled:s||t.maxConcurrent<=0,className:R,children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"w-12 text-center text-sm tabular-nums",children:t.maxConcurrent===0?"∞":t.maxConcurrent}),e.jsx("button",{onClick:()=>a({maxConcurrent:t.maxConcurrent+1}),disabled:s,className:R,children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(ht,{value:t.envVars,onChange:r=>a({envVars:r}),disabled:s})]})}const jt={monospace:"Monospace","sans-serif":"Sans-Serif",display:"Display"},bt=["monospace","sans-serif","display"];function Nt(){var a;const{settings:t,updateSetting:i}=Me(),s=()=>{const n=Math.max(.8,Math.round((t.fontScale-.05)*100)/100);i("fontScale",n)},o=()=>{const n=Math.min(1.3,Math.round((t.fontScale+.05)*100)/100);i("fontScale",n)};return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Appearance"}),e.jsx(T,{label:"Font Family",description:"Typeface used across the dashboard",children:e.jsx("select",{value:t.fontFamily,onChange:n=>i("fontFamily",n.target.value),style:{fontFamily:`'${t.fontFamily}', ${((a=ke.find(n=>n.family===t.fontFamily))==null?void 0:a.category)==="monospace"?"monospace":"sans-serif"}`,backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},className:"h-8 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-2.5 pr-7 text-sm text-foreground outline-none transition-colors hover:border-[rgba(0,188,212,0.3)] focus:border-[rgba(0,188,212,0.5)] focus:shadow-[0_0_8px_rgba(0,188,212,0.15)] appearance-none cursor-pointer",children:bt.map(n=>e.jsx("optgroup",{label:jt[n],children:ke.filter(r=>r.category===n).map(r=>e.jsxs("option",{value:r.family,children:[r.label,r.family==="Space Grotesk"?" (default)":""]},r.family))},n))})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Font Size",description:"Scale text across the dashboard",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:s,disabled:t.fontScale<=.8,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(H,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"w-12 text-center text-sm tabular-nums",children:[Math.round(t.fontScale*100),"%"]}),e.jsx("button",{onClick:o,disabled:t.fontScale>=1.3,className:"flex h-7 w-7 items-center justify-center rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(z,{className:"h-3.5 w-3.5"})})]})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Reduce Motion",description:"Disable animations and transitions",children:e.jsx(U,{checked:t.reduceMotion,onCheckedChange:n=>i("reduceMotion",n)})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Background Effects",description:"Animated orbs and grid overlay",children:e.jsx(U,{checked:t.showBackgroundEffects,onCheckedChange:n=>i("showBackgroundEffects",n)})})]})}function vt(){const{settings:t,updateSetting:i}=Me();return e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Display"}),e.jsx(T,{label:"Status Bar",description:"Scope progress bar at bottom",children:e.jsx(U,{checked:t.showStatusBar,onCheckedChange:s=>i("showStatusBar",s)})}),e.jsx(w,{className:"my-4"}),e.jsx(T,{label:"Compact Mode",description:"Reduce spacing for denser layout",children:e.jsx(U,{checked:t.compactMode,onCheckedChange:s=>i("compactMode",s)})})]})}function Tt(){const{restart:t}=Ke();return d.useEffect(()=>{Ye()},[]),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col -mt-4",children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx(Le,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Settings"})]}),e.jsx(qe,{className:"flex-1",children:e.jsxs("div",{className:"columns-1 lg:columns-2 gap-4 sm:gap-6 pr-1 sm:pr-4 pb-8 [&>*]:mb-4 sm:[&>*]:mb-6 [&>*]:break-inside-avoid",children:[e.jsx("div",{className:"lg:[column-span:all]",children:e.jsx(ct,{})}),e.jsx("div",{className:"lg:[column-span:all]",children:e.jsx(dt,{})}),e.jsx(pt,{}),e.jsx(gt,{}),e.jsx(Nt,{}),e.jsx(vt,{}),e.jsxs("section",{className:"card-glass settings-panel rounded-xl p-5",children:[e.jsx("h2",{className:"text-sm font-medium uppercase tracking-wider text-primary mb-5",children:"Onboarding"}),e.jsx(T,{label:"Guided Tour",description:"Interactive walkthrough of all pages",children:e.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 rounded-md border border-[rgba(255,255,255,0.08)] bg-[rgba(255,255,255,0.03)] px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-[rgba(0,188,212,0.3)] hover:text-foreground",children:[e.jsx(J,{className:"h-3 w-3"}),"Restart tour"]})})]})]})})]})}export{Tt as Settings};
@@ -1,36 +1,31 @@
1
- import{j as e}from"./ui-BmsSg9jU.js";import{a as i}from"./vendor-Bqt8AJn2.js";import{c as D,e as G,V as Pe,s as W,j as Me,o as k,O as S,G as B,Y as z,Z as Q,_ as T,$ as J,B as f,a0 as _,q as ge,R as I,M as A,N as R,I as xe,g as je,a as w,J as He,a1 as Ee,a2 as Te,h as V,a3 as _e,a4 as $e,a5 as Ie,a6 as Ge,a7 as pe,a8 as ee,i as Oe,C as te,b as ae,X as Ue,U as Fe,T as Ne,a9 as be,F as Le,w as he}from"./index-o4ScMAuR.js";import{u as qe,f as O}from"./useSocketListener-0L5yiN5i.js";import{R as Ve,A as We,a as ze}from"./charts-LGLb8hyU.js";import{A as ye}from"./arrow-down-DVPp6_qp.js";import{G as we}from"./globe-WzeyHsUc.js";import{K as Qe}from"./key-CKR8JJSj.js";import{R as se}from"./rocket-D_xvvNG6.js";import{C as me}from"./circle-x-IsFCkBZu.js";/**
1
+ import{j as e}from"./ui-QhrRH5wk.js";import{a as i}from"./vendor-Bqt8AJn2.js";import{c as $,e as G,Y as Pe,s as W,j as He,o as k,Q as S,G as B,Z as z,_ as Q,$ as E,a0 as J,B as f,a1 as T,a2 as K,q as ge,U as I,N as A,O as R,J as xe,g as je,a as w,K as Me,a3 as Ee,a4 as Te,h as V,a5 as $e,a6 as _e,a7 as Ie,a8 as Ge,a9 as pe,aa as ee,i as Oe,C as te,b as ae,X as Ue,V as Le,T as Ne,ab as be,H as Fe,w as he}from"./index-DQVAzHMu.js";import{u as qe,f as O}from"./useSocketListener-DPrExNDV.js";import{R as Ve,A as We,a as ze}from"./charts-LGLb8hyU.js";import{A as ye}from"./arrow-down-DnfKgF33.js";import{G as we}from"./globe-CIX_GBr0.js";import{K as Qe}from"./key-DpAZM-3d.js";import{R as se}from"./rocket-DnuQh3sF.js";import{C as me}from"./circle-x-B4nA79je.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Je=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ke=D("activity",Je);/**
6
+ */const Je=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ke=$("activity",Je);/**
7
7
  * @license lucide-react v0.577.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Xe=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ke=D("arrow-up-down",Xe);/**
11
+ */const Xe=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],ke=$("arrow-up-down",Xe);/**
12
12
  * @license lucide-react v0.577.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Ze=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ve=D("arrow-up",Ze);/**
16
+ */const Ze=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ve=$("arrow-up",Ze);/**
17
17
  * @license lucide-react v0.577.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Ye=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],re=D("git-pull-request",Ye);/**
21
+ */const Ye=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],re=$("git-pull-request",Ye);/**
22
22
  * @license lucide-react v0.577.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const es=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],K=D("github",es);/**
26
+ */const es=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ss=$("lock",es);/**
27
27
  * @license lucide-react v0.577.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const ss=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ts=D("lock",ss);/**
32
- * @license lucide-react v0.577.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const as=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],rs=D("log-out",as),L=50;function ns(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),[l,x]=i.useState([]),[u,d]=i.useState(null),[m,g]=i.useState(!0),[b,p]=i.useState([]),[v,P]=i.useState(null),[M,H]=i.useState([]),[C,y]=i.useState(!0),[$,X]=i.useState(!0),Z=i.useRef(0),E=i.useCallback(async j=>{if(s)try{const[N,F,ce,ie,oe,le,de]=await Promise.all([fetch(t("/git/overview"),{signal:j}),fetch(t(`/git/commits?limit=${L}&offset=0`),{signal:j}),fetch(t("/git/branches"),{signal:j}),fetch(t("/git/worktrees"),{signal:j}),fetch(t("/git/drift"),{signal:j}),fetch(t("/git/health"),{signal:j}),fetch(t("/git/activity?days=30"),{signal:j})]);if(N.ok&&r(await N.json()),F.ok){const Y=await F.json();c(Y),Z.current=Y.length,X(Y.length>=L)}ce.ok&&n(await ce.json()),ie.ok&&x(await ie.json()),oe.ok&&p(await oe.json()),le.ok&&P(await le.json()),de.ok&&H(await de.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||y(!1)}},[t,s]),U=i.useCallback(async j=>{if(s){g(!0);try{const N=await fetch(t("/github/status"),{signal:j});N.ok&&d(await N.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||g(!1)}}},[t,s]),ne=i.useCallback(()=>{E(),U()},[E,U]),De=i.useCallback(async()=>{try{const j=await fetch(t(`/git/commits?limit=${L}&offset=${Z.current}`));if(j.ok){const N=await j.json();c(F=>[...F,...N]),Z.current+=N.length,X(N.length>=L)}}catch{}},[t]);return i.useEffect(()=>{if(!s){y(!1),g(!1);return}const j=new AbortController;return E(j.signal),U(j.signal),()=>j.abort()},[s,E,U]),Pe(ne),i.useEffect(()=>{function j(){E()}return W.on("git:status:changed",j),()=>{W.off("git:status:changed",j)}},[E]),{overview:a,commits:o,branches:h,worktrees:l,github:u,githubChecking:m,drift:b,health:v,activity:M,loading:C,refetch:ne,loadMoreCommits:De,hasMoreCommits:$,buildUrl:t}}function cs(s){const[t,a]=i.useState([]),[r,o]=i.useState([]),[c,h]=i.useState([]),[n,l]=i.useState([]),[x,u]=i.useState(new Map),[d,m]=i.useState(!0),g=i.useCallback(async()=>{if(s)try{const[p,v,P,M,H]=await Promise.all([fetch("/api/orbital/aggregate/git/overview"),fetch("/api/orbital/aggregate/git/commits?limit=50"),fetch("/api/orbital/aggregate/github/prs"),fetch("/api/orbital/aggregate/git/health"),fetch("/api/orbital/aggregate/git/activity?days=30")]);if(p.ok&&a(await p.json()),v.ok&&o(await v.json()),P.ok&&h(await P.json()),M.ok&&l(await M.json()),H.ok){const C=await H.json(),y=new Map;for(const $ of C)y.set($.projectId,$.series);u(y)}}catch{}finally{m(!1)}},[s]),b=i.useCallback(()=>{g()},[g]);return i.useEffect(()=>{s&&(m(!0),g())},[s,g]),i.useEffect(()=>{if(!s)return;function p(){g()}return W.on("git:status:changed",p),()=>{W.off("git:status:changed",p)}},[s,g]),{projectOverviews:t,commits:r,prs:c,branchHealth:n,activitySeries:x,loading:d,refetch:b}}function is(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),l=i.useCallback(async()=>{if(!s)return;const[u,d,m]=await Promise.all([fetch(t("/pipeline/drift")),fetch(t("/deployments/frequency")),fetch(t("/deployments"))]);u.ok&&r(await u.json()),d.ok&&c(await d.json()),m.ok&&n(await m.json())},[t,s]),{loading:x}=Me(l);return qe("deploy:updated",()=>{l()},[l]),{drift:a,frequency:o,deployments:h,loading:x,refetch:l}}function Ce({data:s,color:t="210 80% 55%",height:a=28}){if(s.length===0)return null;const r=`hsl(${t})`;return e.jsx("div",{style:{width:"100%",height:a},children:e.jsx(Ve,{width:"100%",height:"100%",children:e.jsxs(We,{data:s,margin:{top:0,right:0,bottom:0,left:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`sparkFill-${t.replace(/\s/g,"")}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:.25}),e.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:.02})]})}),e.jsx(ze,{type:"monotone",dataKey:"count",stroke:r,strokeWidth:1.5,fill:`url(#sparkFill-${t.replace(/\s/g,"")})`,isAnimationActive:!1})]})})})}function os({overview:s,github:t,githubChecking:a,activity:r}){var o;return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex flex-wrap items-center gap-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),e.jsx("code",{className:"font-mono text-sm",children:s.currentBranch}),s.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(T,{className:"h-2.5 w-2.5 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsx(f,{variant:"outline",className:"text-xs",children:s.branchingMode}),s.mainHead&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"HEAD"}),e.jsx("code",{className:"font-mono text-xs",children:s.mainHead.sha.slice(0,7)}),e.jsx("span",{className:"max-w-[200px] truncate",children:s.mainHead.message})]}),s.aheadBehind&&(s.aheadBehind.ahead>0||s.aheadBehind.behind>0)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(ke,{className:"h-3 w-3 text-muted-foreground"}),s.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[s.aheadBehind.ahead,"↑"]}),s.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[s.aheadBehind.behind,"↓"]})]}),s.branchingMode==="worktree"&&s.worktreeCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(_,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.worktreeCount," worktree",s.worktreeCount!==1?"s":""]})]}),s.branchingMode==="trunk"&&s.featureBranchCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.featureBranchCount," feature branch",s.featureBranchCount!==1?"es":""]})]}),r&&r.length>0&&e.jsx("div",{className:"w-20",children:e.jsx(Ce,{data:r,height:22})}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"}),a?e.jsxs(f,{variant:"outline",className:"text-xs text-muted-foreground gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking…"]}):t!=null&&t.connected?e.jsxs(z,{children:[e.jsx(Q,{children:e.jsxs(f,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(T,{className:"h-1.5 w-1.5 fill-bid-green text-bid-green"}),((o=t.repo)==null?void 0:o.fullName)??"Connected"]})}),e.jsx(J,{children:t.authUser?`Signed in as ${t.authUser}`:"Connected to GitHub"})]}):e.jsx(f,{variant:"outline",className:"text-xs text-muted-foreground",children:"Not connected"})]})]})})}function Se({projectId:s,className:t}){const{hasMultipleProjects:a,getProjectColor:r,getProjectName:o}=ge();if(!a||!s)return null;const c=r(s),h=o(s);return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0 text-[10px] ${t??""}`,style:{borderColor:`hsl(${c} / 0.4)`,color:`hsl(${c})`,borderWidth:"1px",borderStyle:"solid"},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${c})`}}),h]})}const ue=new Map,ls=6e4;function Be({commitSha:s,pr:t}){const a=G(),[r,o]=i.useState(null),[c,h]=i.useState(!1),n=i.useRef(!1),l=s??(t==null?void 0:t.branch);if(!l)return null;const x=async()=>{if(n.current||c)return;const m=ue.get(l);if(m&&Date.now()-m.ts<ls){o(m.data),n.current=!0;return}h(!0);try{const g=await fetch(a(`/github/checks/${l}`));if(g.ok){const b=await g.json();ue.set(l,{data:b,ts:Date.now()}),o(b)}}catch{}h(!1),n.current=!0};let u="text-muted-foreground/30",d="CI";if(r&&r.length>0){const m=r.some(p=>p.conclusion==="failure"),g=r.some(p=>p.status==="in_progress"||p.status==="queued"),b=r.every(p=>p.conclusion==="success"||p.conclusion==="neutral");m?(u="text-ask-red",d=`${r.filter(p=>p.conclusion==="failure").length} failing`):g?(u="text-warning-amber",d="Running"):b&&(u="text-bid-green",d="Passed")}return e.jsxs(z,{children:[e.jsx(Q,{className:"shrink-0",onMouseEnter:x,children:c?e.jsx(I,{className:"h-3 w-3 animate-spin text-muted-foreground/50"}):e.jsx(T,{className:`h-2.5 w-2.5 fill-current ${u}`})}),e.jsx(J,{side:"top",className:"max-w-xs",children:r===null?e.jsx("span",{className:"text-xs",children:"Hover to load CI status"}):r.length===0?e.jsx("span",{className:"text-xs",children:"No CI checks"}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:d}),r.slice(0,5).map((m,g)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(T,{className:`h-1.5 w-1.5 fill-current ${m.conclusion==="success"?"text-bid-green":m.conclusion==="failure"?"text-ask-red":"text-warning-amber"}`}),e.jsx("span",{className:"truncate",children:m.name})]},g)),r.length>5&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",r.length-5," more"]})]})})]})}function ds({commit:s}){return e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(Be,{commitSha:s.sha}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-primary",children:s.shortSha}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:s.message}),e.jsx(Se,{projectId:s.project_id}),s.branch&&e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:s.branch}),s.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",s.scopeId]}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:s.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(s.date),{addSuffix:!0})})]})}function Ae({commits:s,branches:t,hasMore:a,onLoadMore:r}){const[o,c]=i.useState("all"),h=i.useMemo(()=>{const x=new Set(["main","master","dev","develop","staging","production"]);for(const u of t)!u.isRemote&&!u.name.startsWith("feat/")&&!u.name.startsWith("fix/")&&x.add(u.name);return x},[t]),n=i.useMemo(()=>o==="all"?s:o==="main"?s.filter(x=>!x.branch||h.has(x.branch)):s.filter(x=>x.branch&&!h.has(x.branch)),[s,o,h]),l=[{key:"all",label:"All"},{key:"main",label:"Main"},{key:"feature",label:"Feature"}];return e.jsxs(k,{className:"lg:col-span-2",children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4 text-primary"}),"Commits"," ",e.jsx(f,{variant:"secondary",children:n.length})]}),e.jsx("div",{className:"flex gap-1",children:l.map(x=>e.jsx("button",{onClick:()=>c(x.key),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${o===x.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:x.label},x.key))})]})}),e.jsx(S,{children:n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(xe,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No commits found."})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"max-h-[600px]",children:e.jsx("div",{className:"space-y-0.5",children:n.map(x=>e.jsx(ds,{commit:x},x.sha))})}),a&&e.jsx("button",{onClick:r,className:"mt-3 w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:"Load more commits"})]})})]})}function xs({branches:s}){const t=[...s].filter(a=>!a.isRemote).sort((a,r)=>a.isCurrent?-1:r.isCurrent?1:a.isStale!==r.isStale?a.isStale?1:-1:new Date(r.headDate).getTime()-new Date(a.headDate).getTime());return t.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(B,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No branches found."})]}):e.jsx("div",{className:"space-y-0.5",children:t.map(a=>e.jsxs("div",{className:w("flex items-center gap-2 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",a.isStale&&"opacity-50"),children:[e.jsx(B,{className:w("h-3.5 w-3.5 shrink-0",a.isCurrent?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:w("min-w-0 flex-1 truncate font-mono text-xs",a.isCurrent&&"text-foreground font-medium"),children:a.name}),a.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",a.scopeId]}),a.aheadBehind&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-xs",children:[a.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),a.aheadBehind.ahead]}),a.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),a.aheadBehind.behind]})]}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:a.headSha}),a.headDate&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(a.headDate),{addSuffix:!0})})]},a.name))})}function hs({worktrees:s}){return s.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(_,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active worktrees."})]}):e.jsx("div",{className:"space-y-1",children:s.map(t=>e.jsxs("div",{className:"rounded border border-border/50 px-3 py-2 transition-colors hover:bg-surface-light",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.branch}),t.dirty&&e.jsx(T,{className:"h-2 w-2 shrink-0 fill-warning-amber text-warning-amber"}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:t.head})]}),t.scopeId&&e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs(f,{variant:"secondary",className:"text-xs",children:["#",t.scopeId]}),t.scopeTitle&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.scopeTitle}),t.scopeStatus&&e.jsx(f,{variant:"outline",className:w("shrink-0 text-xs capitalize"),children:t.scopeStatus})]}),t.aheadBehind&&(t.aheadBehind.ahead>0||t.aheadBehind.behind>0)&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs",children:[t.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),t.aheadBehind.ahead," ahead"]}),t.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),t.aheadBehind.behind," behind"]})]})]},t.path))})}function ms(s){return s===0?"text-bid-green":s<=5?"text-accent-blue":s<=20?"text-warning-amber":"text-ask-red"}function us({branches:s,worktrees:t,drift:a,branchingMode:r}){const o=r==="worktree",[c,h]=i.useState("branches");return e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),o?c==="branches"?"Branches":"Worktrees":"Branches",e.jsx(f,{variant:"secondary",children:c==="branches"?s.filter(n=>!n.isRemote).length:t.length})]}),o&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>h("branches"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="branches"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(B,{className:"inline h-3 w-3 mr-1"}),"Branches"]}),e.jsxs("button",{onClick:()=>h("worktrees"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="worktrees"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(_,{className:"inline h-3 w-3 mr-1"}),"Worktrees"]})]})]})}),e.jsxs(S,{children:[e.jsx(je,{className:"max-h-[400px]",children:c==="branches"?e.jsx(xs,{branches:s}):e.jsx(hs,{worktrees:t})}),a.length>0&&e.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Branch Drift"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("code",{className:"font-mono text-muted-foreground",children:n.from}),e.jsx(He,{className:"h-3 w-3 text-muted-foreground/50"}),e.jsx("code",{className:"font-mono text-muted-foreground",children:n.to}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",ms(n.count)),children:n.count===0?"in sync":`${n.count} commit${n.count!==1?"s":""}`})]},`${n.from}-${n.to}`))})]})]})]})}function fs({error:s,onConnected:t}){const a=G(),[r,o]=i.useState(!1),[c,h]=i.useState("oauth"),[n,l]=i.useState("idle"),[x,u]=i.useState(""),[d,m]=i.useState(""),g=i.useRef(),b=i.useRef(),p=s==null?void 0:s.includes("not installed"),v=i.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0)},[]);i.useEffect(()=>()=>{v(),clearTimeout(b.current)},[v]);const P=async()=>{l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"oauth"})})).json();y.success?(l("polling"),g.current=setInterval(async()=>{try{(await(await fetch(a("/github/auth-status"))).json()).authenticated&&(v(),clearTimeout(b.current),l("success"),setTimeout(()=>{o(!1),t()},1e3))}catch{}},2e3),b.current=setTimeout(()=>{g.current&&(v(),l("error"),m("Authentication timed out. Please try again."))},12e4)):(l("error"),m(y.error??"Failed to start OAuth flow"))}catch{l("error"),m("Failed to connect to server")}},M=async()=>{if(x.trim()){l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"pat",token:x.trim()})})).json();y.success?(l("success"),u(""),setTimeout(()=>{o(!1),t()},1e3)):(l("error"),m(y.error??"Authentication failed"))}catch{l("error"),m("Failed to connect to server")}}},H=C=>{o(C),C||(v(),l("idle"),m(""),u(""))};return e.jsxs(Ee,{open:r,onOpenChange:H,children:[e.jsx(Te,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Connect GitHub"]})}),e.jsxs(_e,{className:"sm:max-w-md",children:[e.jsxs($e,{children:[e.jsxs(Ie,{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5"}),"Connect to GitHub"]}),e.jsx(Ge,{children:p?"The GitHub CLI (gh) is required. Install it first, then authenticate.":"Authenticate with GitHub to see PRs, CI status, and repo info."})]}),p?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"rounded border border-border bg-surface-light p-3",children:[e.jsx("p",{className:"text-sm mb-2",children:"Install the GitHub CLI:"}),e.jsx("code",{className:"text-xs font-mono bg-background px-2 py-1 rounded",children:"brew install gh"}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Or visit"," ",e.jsxs("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-primary hover:underline",children:["cli.github.com ",e.jsx(pe,{className:"h-2.5 w-2.5"})]})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-1 rounded-md bg-surface-light p-1",children:[e.jsxs("button",{onClick:()=>h("oauth"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="oauth"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(we,{className:"h-4 w-4"}),"Browser OAuth"]}),e.jsxs("button",{onClick:()=>h("pat"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="pat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Qe,{className:"h-4 w-4"}),"Access Token"]})]}),c==="oauth"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens your browser to authenticate with GitHub. This is the recommended method."}),e.jsxs(V,{onClick:P,disabled:n==="connecting"||n==="polling"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="polling"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="polling"?"Waiting for browser...":n==="success"?"Connected!":"Connect with GitHub"]})]}),c==="pat"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a GitHub Personal Access Token. Needs ",e.jsx("code",{className:"text-xs",children:"repo"})," and ",e.jsx("code",{className:"text-xs",children:"read:org"})," scopes."]}),e.jsx("input",{type:"password",placeholder:"ghp_xxxxxxxxxxxxxxxxxxxx",value:x,onChange:C=>u(C.target.value),disabled:n==="connecting"||n==="success",className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50"}),e.jsxs(V,{onClick:M,disabled:!x.trim()||n==="connecting"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="success"?"Connected!":"Authenticate"]})]}),n==="error"&&d&&e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ask-red/10 px-3 py-2 text-xs text-ask-red",children:[e.jsx(Oe,{className:"h-4 w-4 shrink-0"}),d]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:"GitHub authentication is global — connecting here applies to all projects."})]})]})]})}function gs({github:s,githubChecking:t,onConnectionChange:a}){var l;const r=G(),[o,c]=i.useState(!0),h=i.useCallback(async()=>{try{await fetch(r("/github/disconnect"),{method:"POST"}),a==null||a()}catch{}},[r,a]),n=((l=s==null?void 0:s.repo)==null?void 0:l.visibility)==="public"?we:ts;return e.jsxs(k,{className:"mt-6",children:[e.jsx(A,{className:"cursor-pointer select-none",onClick:()=>c(!o),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[o?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(K,{className:"h-4 w-4 text-primary"}),"GitHub",(s==null?void 0:s.connected)&&s.repo&&e.jsxs(f,{variant:"secondary",className:"ml-1 text-xs gap-1",children:[e.jsx(n,{className:"h-2.5 w-2.5"}),s.repo.fullName]}),s!=null&&s.openPRs?e.jsxs(f,{variant:"outline",className:"text-xs",children:[s.openPRs," open PR",s.openPRs!==1?"s":""]}):null]})}),o&&e.jsx(S,{children:t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking GitHub connection…"]}):!s||!s.connected?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to GitHub to see repository info, pull requests, and CI status."}),e.jsx(fs,{error:(s==null?void 0:s.error)??null,onConnected:()=>a==null?void 0:a()})]}):e.jsxs("div",{className:"space-y-4",children:[s.repo&&e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repository"}),e.jsx("a",{href:s.repo.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.repo.fullName}),e.jsx("span",{className:"text-muted-foreground",children:"Default branch"}),e.jsx("code",{className:"font-mono",children:s.repo.defaultBranch}),e.jsx("span",{className:"text-muted-foreground",children:"Visibility"}),e.jsxs("span",{className:"flex items-center gap-1 capitalize",children:[e.jsx(n,{className:"h-3 w-3"}),s.repo.visibility]}),s.authUser&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Signed in as"}),e.jsx("span",{children:s.authUser})]})]}),e.jsx("div",{className:"border-t border-border pt-3",children:e.jsxs(V,{variant:"ghost",size:"sm",onClick:x=>{x.stopPropagation(),h()},className:"gap-2 text-xs text-muted-foreground hover:text-ask-red",children:[e.jsx(rs,{className:"h-3 w-3"}),"Disconnect"]})})]})})]})}function js({decision:s}){return s==="APPROVED"?e.jsx(ee,{className:"h-3.5 w-3.5 text-bid-green"}):s==="CHANGES_REQUESTED"?e.jsx(Ue,{className:"h-3.5 w-3.5 text-ask-red"}):e.jsx(Fe,{className:"h-3.5 w-3.5 text-warning-amber"})}function Re(s){const[t,a]=i.useState(!0),[r,o]=i.useState("all"),[c,h]=i.useState([]),n=i.useCallback(async()=>{if(!(s.isAggregate||!s.buildUrl))try{const d=await fetch(s.buildUrl("/github/prs"));d.ok&&h(await d.json())}catch{}},[s.isAggregate,s.buildUrl]);i.useEffect(()=>{s.isAggregate||n()},[s.isAggregate,n]);const l=s.isAggregate?s.prs:c,x=l.filter(d=>r==="all"?!0:r==="pending"?!d.reviewDecision||d.reviewDecision==="REVIEW_REQUIRED":r==="approved"?d.reviewDecision==="APPROVED":r==="changes"?d.reviewDecision==="CHANGES_REQUESTED":!0);if(l.length===0)return null;const u=[{key:"all",label:"All"},{key:"pending",label:"Pending"},{key:"approved",label:"Approved"},{key:"changes",label:"Changes"}];return e.jsxs(k,{className:"mb-6",children:[e.jsx(A,{className:"cursor-pointer select-none pb-2",onClick:()=>a(!t),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[t?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(re,{className:"h-4 w-4 text-primary"}),"Pull Requests",e.jsx(f,{variant:"secondary",children:l.length})]})}),t&&e.jsxs(S,{children:[e.jsx("div",{className:"mb-3 flex gap-1",children:u.map(d=>e.jsx("button",{onClick:m=>{m.stopPropagation(),o(d.key)},className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===d.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.key))}),e.jsx("div",{className:"space-y-0.5",children:x.map(d=>e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light group",children:[e.jsx(js,{decision:d.reviewDecision}),e.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["#",d.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:d.title}),e.jsx(Se,{projectId:d.project_id}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.branch}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.baseBranch}),d.scopeIds.map(m=>e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",m]},m)),e.jsx(Be,{pr:d}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:d.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(d.lastActivityAt??d.createdAt),{addSuffix:!0})}),e.jsx(pe,{className:"h-3 w-3 shrink-0 text-muted-foreground/40 opacity-0 group-hover:opacity-100 transition-opacity"})]},`${d.project_id??""}-${d.number}`))}),x.length===0&&e.jsx("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No PRs match this filter."})]})]})}function ps({overviews:s,activitySeries:t}){return s.length===0?null:e.jsx("div",{className:"mb-6 grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>e.jsx(Ns,{project:a,activity:t.get(a.projectId)??[]},a.projectId))})}function Ns({project:s,activity:t}){const{projectName:a,projectColor:r,status:o,overview:c,error:h}=s;return e.jsx(k,{className:"overflow-hidden",children:e.jsxs(S,{className:"py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${r})`}}),e.jsx("span",{className:"font-medium text-sm",style:{color:`hsl(${r})`},children:a}),o==="error"&&e.jsx(f,{variant:"destructive",className:"text-xs ml-auto",children:"Error"})]}),o==="error"?e.jsx("p",{className:"text-xs text-muted-foreground",children:h}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"font-mono text-xs",children:c.currentBranch}),c.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(T,{className:"h-2 w-2 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.aheadBehind&&(c.aheadBehind.ahead>0||c.aheadBehind.behind>0)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),c.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[c.aheadBehind.ahead,"↑"]}),c.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[c.aheadBehind.behind,"↓"]})]}),c.featureBranchCount>0&&e.jsxs("span",{children:[c.featureBranchCount," branch",c.featureBranchCount!==1?"es":""]}),e.jsx(f,{variant:"outline",className:"text-[10px] py-0",children:c.branchingMode})]}),c.mainHead&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:c.mainHead.message}),e.jsx("span",{className:"shrink-0 text-muted-foreground/60",children:O(new Date(c.mainHead.date),{addSuffix:!0})})]}),t.length>0&&e.jsx(Ce,{data:t,color:r})]}):null]})})}function bs(s){return s==="clean"?"text-bid-green":s==="low"?"text-accent-blue":s==="moderate"?"text-warning-amber":"text-ask-red"}function ys({health:s}){return s.length===0?e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No branch data available."})})]}):e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("div",{className:"space-y-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-2 transition-colors hover:bg-surface-light",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${t.projectColor})`}}),e.jsx("span",{className:"text-sm font-medium min-w-[100px]",style:{color:`hsl(${t.projectColor})`},children:t.projectName}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.branchCount," branch",t.branchCount!==1?"es":""]}),t.staleBranchCount>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-warning-amber",children:[e.jsx(Ne,{className:"h-3 w-3"}),t.staleBranchCount," stale"]}),t.featureBranchCount>0&&e.jsxs(f,{variant:"secondary",className:"text-xs",children:[t.featureBranchCount," feature"]}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",bs(t.maxDriftSeverity)),children:t.maxDriftSeverity==="clean"?"in sync":`${t.maxDriftSeverity} drift`})]},t.projectId))})})]})}function ws(s){return s==="A"?"text-bid-green":s==="B"?"text-accent-blue":s==="C"?"text-warning-amber":"text-ask-red"}function ks(s){return s==="A"?"bg-bid-green/10":s==="B"?"bg-accent-blue/10":s==="C"?"bg-warning-amber/10":"bg-ask-red/10"}function vs({health:s}){return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex items-center gap-6 py-3",children:[e.jsx("div",{className:w("flex items-center justify-center h-12 w-12 rounded-lg text-2xl font-bold shrink-0",ks(s.grade),ws(s.grade)),children:s.grade}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1",children:[e.jsx(q,{icon:e.jsx(Ke,{className:"h-3.5 w-3.5"}),label:"Commits/week",value:String(s.commitsPerWeek),warn:s.commitsPerWeek<5}),e.jsx(q,{icon:e.jsx(re,{className:"h-3.5 w-3.5"}),label:"Avg PR age",value:s.avgPrAgeDays>0?`${s.avgPrAgeDays}d`:"--",warn:s.avgPrAgeDays>3}),e.jsx(q,{icon:e.jsx(B,{className:"h-3.5 w-3.5"}),label:"Stale branches",value:String(s.staleBranchCount),warn:s.staleBranchCount>0}),e.jsx(q,{icon:e.jsx(Ne,{className:"h-3.5 w-3.5"}),label:"Drift",value:s.driftSeverity,warn:s.driftSeverity!=="clean"})]})]})})}function q({icon:s,label:t,value:a,warn:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:r?"text-warning-amber":"text-muted-foreground",children:s}),e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("span",{className:w("font-medium",r?"text-warning-amber":"text-foreground"),children:a})]})}const Cs={deploying:{icon:I,color:"text-accent-blue",label:"Deploying",animate:"animate-spin"},healthy:{icon:Le,color:"text-bid-green",label:"Healthy"},failed:{icon:me,color:"text-ask-red",label:"Failed"},"rolled-back":{icon:me,color:"text-warning-amber",label:"Rolled Back"}},fe=20;function Ss(s){const t=new Map;for(const a of s){const r=a.started_at?be(new Date(a.started_at),"yyyy-MM-dd"):"Unknown",o=t.get(r);o?o.push(a):t.set(r,[a])}return t}function Bs(s){if(!s.started_at||!s.completed_at)return null;const t=new Date(s.completed_at).getTime()-new Date(s.started_at).getTime();return t<1e3?"<1s":t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`}function As({deployments:s}){const[t,a]=i.useState(!1),r=t?s:s.slice(0,fe),o=Ss(r);return e.jsxs(k,{children:[e.jsx(A,{children:e.jsxs(R,{className:"text-base",children:["Deployment History",e.jsx(f,{variant:"secondary",className:"ml-2",children:s.length})]})}),e.jsx(S,{children:s.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(se,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deployments recorded yet."})]}):e.jsxs("div",{className:"space-y-4",children:[[...o.entries()].map(([c,h])=>e.jsxs("div",{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-card pb-1 pt-0.5",children:e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:c==="Unknown"?"Unknown date":be(new Date(c),"EEEE, MMM d")})}),e.jsx("div",{className:"space-y-0.5",children:h.map(n=>{const l=Cs[n.status],x=l.icon,u=Bs(n);return e.jsxs("div",{className:"flex items-center gap-4 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(x,{className:w("h-4 w-4 shrink-0",l.color,l.animate)}),e.jsx(f,{variant:"outline",className:"capitalize shrink-0",children:n.environment}),e.jsx("span",{className:"text-xs font-normal shrink-0",children:l.label}),n.commit_sha&&e.jsx("code",{className:"font-mono text-xs text-muted-foreground shrink-0",children:n.commit_sha.slice(0,7)}),n.branch&&e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.branch}),u&&e.jsx("span",{className:"font-mono text-xs text-muted-foreground/60 shrink-0",children:u}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/60 shrink-0",children:n.started_at?O(new Date(n.started_at),{addSuffix:!0}):"—"})]},n.id)})})]},c)),!t&&s.length>fe&&e.jsxs("button",{onClick:()=>a(!0),className:"w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:["Show all ",s.length," deployments"]})]})})]})}function Us(){const{activeProjectId:s,hasMultipleProjects:t}=ge(),a=t&&s===null,r=ns(!a),o=cs(a),{deployments:c}=is(!a),[h,n]=i.useState(!0);return(a?o.loading:r.loading)?e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"})})]}):e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a?e.jsx(Ds,{aggregate:o}):e.jsx(Rs,{sourceControl:r,deployments:c,deployExpanded:h,setDeployExpanded:n})})]})}function Rs({sourceControl:s,deployments:t,deployExpanded:a,setDeployExpanded:r}){const{overview:o,commits:c,branches:h,worktrees:n,github:l,githubChecking:x,drift:u,loadMoreCommits:d,hasMoreCommits:m,health:g,activity:b,refetch:p}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(_,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),o&&e.jsx(f,{variant:"secondary",children:o.currentBranch})]}),o&&e.jsx(os,{overview:o,github:l,githubChecking:x,activity:b}),g&&e.jsx(vs,{health:g}),(l==null?void 0:l.connected)&&e.jsx(Re,{buildUrl:s.buildUrl}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:c,branches:h,hasMore:m,onLoadMore:d}),e.jsx(us,{branches:h,worktrees:n,drift:u,branchingMode:(o==null?void 0:o.branchingMode)??"trunk"})]}),e.jsx(gs,{github:l,githubChecking:x,onConnectionChange:p}),t.length>0&&e.jsx("div",{className:"mt-6",children:a?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(!1),className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx(se,{className:"h-4 w-4"}),"Deploy History"]}),e.jsx(As,{deployments:t})]}):e.jsx(k,{className:"cursor-pointer select-none",onClick:()=>r(!0),children:e.jsx(A,{children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(se,{className:"h-4 w-4 text-primary"}),"Deploy History",e.jsx(f,{variant:"secondary",children:t.length})]})})})})]})}function Ds({aggregate:s}){const{projectOverviews:t,commits:a,prs:r,branchHealth:o,activitySeries:c}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(_,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),e.jsx(f,{variant:"secondary",children:"All Projects"})]}),e.jsx(ps,{overviews:t,activitySeries:c}),r.length>0&&e.jsx(Re,{prs:r,isAggregate:!0}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:a,branches:[],hasMore:!1,onLoadMore:()=>{}}),e.jsx(ys,{health:o})]})]})}export{Us as SourceControl};
31
+ */const ts=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],as=$("log-out",ts),F=50;function rs(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),[l,x]=i.useState([]),[u,d]=i.useState(null),[m,g]=i.useState(!0),[b,p]=i.useState([]),[v,D]=i.useState(null),[P,H]=i.useState([]),[C,y]=i.useState(!0),[_,X]=i.useState(!0),Z=i.useRef(0),M=i.useCallback(async j=>{if(s)try{const[N,L,ce,ie,oe,le,de]=await Promise.all([fetch(t("/git/overview"),{signal:j}),fetch(t(`/git/commits?limit=${F}&offset=0`),{signal:j}),fetch(t("/git/branches"),{signal:j}),fetch(t("/git/worktrees"),{signal:j}),fetch(t("/git/drift"),{signal:j}),fetch(t("/git/health"),{signal:j}),fetch(t("/git/activity?days=30"),{signal:j})]);if(N.ok&&r(await N.json()),L.ok){const Y=await L.json();c(Y),Z.current=Y.length,X(Y.length>=F)}ce.ok&&n(await ce.json()),ie.ok&&x(await ie.json()),oe.ok&&p(await oe.json()),le.ok&&D(await le.json()),de.ok&&H(await de.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||y(!1)}},[t,s]),U=i.useCallback(async j=>{if(s){g(!0);try{const N=await fetch(t("/github/status"),{signal:j});N.ok&&d(await N.json())}catch(N){if(N instanceof DOMException&&N.name==="AbortError")return}finally{j!=null&&j.aborted||g(!1)}}},[t,s]),ne=i.useCallback(()=>{M(),U()},[M,U]),De=i.useCallback(async()=>{try{const j=await fetch(t(`/git/commits?limit=${F}&offset=${Z.current}`));if(j.ok){const N=await j.json();c(L=>[...L,...N]),Z.current+=N.length,X(N.length>=F)}}catch{}},[t]);return i.useEffect(()=>{if(!s){y(!1),g(!1);return}const j=new AbortController;return M(j.signal),U(j.signal),()=>j.abort()},[s,M,U]),Pe(ne),i.useEffect(()=>{function j(){M()}return W.on("git:status:changed",j),()=>{W.off("git:status:changed",j)}},[M]),{overview:a,commits:o,branches:h,worktrees:l,github:u,githubChecking:m,drift:b,health:v,activity:P,loading:C,refetch:ne,loadMoreCommits:De,hasMoreCommits:_,buildUrl:t}}function ns(s){const[t,a]=i.useState([]),[r,o]=i.useState([]),[c,h]=i.useState([]),[n,l]=i.useState([]),[x,u]=i.useState(new Map),[d,m]=i.useState(!0),g=i.useCallback(async()=>{if(s)try{const[p,v,D,P,H]=await Promise.all([fetch("/api/orbital/aggregate/git/overview"),fetch("/api/orbital/aggregate/git/commits?limit=50"),fetch("/api/orbital/aggregate/github/prs"),fetch("/api/orbital/aggregate/git/health"),fetch("/api/orbital/aggregate/git/activity?days=30")]);if(p.ok&&a(await p.json()),v.ok&&o(await v.json()),D.ok&&h(await D.json()),P.ok&&l(await P.json()),H.ok){const C=await H.json(),y=new Map;for(const _ of C)y.set(_.projectId,_.series);u(y)}}catch{}finally{m(!1)}},[s]),b=i.useCallback(()=>{g()},[g]);return i.useEffect(()=>{s&&(m(!0),g())},[s,g]),i.useEffect(()=>{if(!s)return;function p(){g()}return W.on("git:status:changed",p),()=>{W.off("git:status:changed",p)}},[s,g]),{projectOverviews:t,commits:r,prs:c,branchHealth:n,activitySeries:x,loading:d,refetch:b}}function cs(s=!0){const t=G(),[a,r]=i.useState(null),[o,c]=i.useState([]),[h,n]=i.useState([]),l=i.useCallback(async()=>{if(!s)return;const[u,d,m]=await Promise.all([fetch(t("/pipeline/drift")),fetch(t("/deployments/frequency")),fetch(t("/deployments"))]);u.ok&&r(await u.json()),d.ok&&c(await d.json()),m.ok&&n(await m.json())},[t,s]),{loading:x}=He(l);return qe("deploy:updated",()=>{l()},[l]),{drift:a,frequency:o,deployments:h,loading:x,refetch:l}}function Ce({data:s,color:t="210 80% 55%",height:a=28}){if(s.length===0)return null;const r=`hsl(${t})`;return e.jsx("div",{style:{width:"100%",height:a},children:e.jsx(Ve,{width:"100%",height:"100%",children:e.jsxs(We,{data:s,margin:{top:0,right:0,bottom:0,left:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:`sparkFill-${t.replace(/\s/g,"")}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:.25}),e.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:.02})]})}),e.jsx(ze,{type:"monotone",dataKey:"count",stroke:r,strokeWidth:1.5,fill:`url(#sparkFill-${t.replace(/\s/g,"")})`,isAnimationActive:!1})]})})})}function is({overview:s,github:t,githubChecking:a,activity:r}){var o;return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex flex-wrap items-center gap-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),e.jsx("code",{className:"font-mono text-sm",children:s.currentBranch}),s.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(E,{className:"h-2.5 w-2.5 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsx(f,{variant:"outline",className:"text-xs",children:s.branchingMode}),s.mainHead&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:"HEAD"}),e.jsx("code",{className:"font-mono text-xs",children:s.mainHead.sha.slice(0,7)}),e.jsx("span",{className:"max-w-[200px] truncate",children:s.mainHead.message})]}),s.aheadBehind&&(s.aheadBehind.ahead>0||s.aheadBehind.behind>0)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsx(ke,{className:"h-3 w-3 text-muted-foreground"}),s.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[s.aheadBehind.ahead,"↑"]}),s.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[s.aheadBehind.behind,"↓"]})]}),s.branchingMode==="worktree"&&s.worktreeCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(T,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.worktreeCount," worktree",s.worktreeCount!==1?"s":""]})]}),s.branchingMode==="trunk"&&s.featureBranchCount>0&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsxs("span",{children:[s.featureBranchCount," feature branch",s.featureBranchCount!==1?"es":""]})]}),r&&r.length>0&&e.jsx("div",{className:"w-20",children:e.jsx(Ce,{data:r,height:22})}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"}),a?e.jsxs(f,{variant:"outline",className:"text-xs text-muted-foreground gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking…"]}):t!=null&&t.connected?e.jsxs(z,{children:[e.jsx(Q,{children:e.jsxs(f,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(E,{className:"h-1.5 w-1.5 fill-bid-green text-bid-green"}),((o=t.repo)==null?void 0:o.fullName)??"Connected"]})}),e.jsx(J,{children:t.authUser?`Signed in as ${t.authUser}`:"Connected to GitHub"})]}):e.jsx(f,{variant:"outline",className:"text-xs text-muted-foreground",children:"Not connected"})]})]})})}function Se({projectId:s,className:t}){const{hasMultipleProjects:a,getProjectColor:r,getProjectName:o}=ge();if(!a||!s)return null;const c=r(s),h=o(s);return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0 text-[10px] ${t??""}`,style:{borderColor:`hsl(${c} / 0.4)`,color:`hsl(${c})`,borderWidth:"1px",borderStyle:"solid"},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${c})`}}),h]})}const ue=new Map,os=6e4;function Be({commitSha:s,pr:t}){const a=G(),[r,o]=i.useState(null),[c,h]=i.useState(!1),n=i.useRef(!1),l=s??(t==null?void 0:t.branch);if(!l)return null;const x=async()=>{if(n.current||c)return;const m=ue.get(l);if(m&&Date.now()-m.ts<os){o(m.data),n.current=!0;return}h(!0);try{const g=await fetch(a(`/github/checks/${l}`));if(g.ok){const b=await g.json();ue.set(l,{data:b,ts:Date.now()}),o(b)}}catch{}h(!1),n.current=!0};let u="text-muted-foreground/30",d="CI";if(r&&r.length>0){const m=r.some(p=>p.conclusion==="failure"),g=r.some(p=>p.status==="in_progress"||p.status==="queued"),b=r.every(p=>p.conclusion==="success"||p.conclusion==="neutral");m?(u="text-ask-red",d=`${r.filter(p=>p.conclusion==="failure").length} failing`):g?(u="text-warning-amber",d="Running"):b&&(u="text-bid-green",d="Passed")}return e.jsxs(z,{children:[e.jsx(Q,{className:"shrink-0",onMouseEnter:x,children:c?e.jsx(I,{className:"h-3 w-3 animate-spin text-muted-foreground/50"}):e.jsx(E,{className:`h-2.5 w-2.5 fill-current ${u}`})}),e.jsx(J,{side:"top",className:"max-w-xs",children:r===null?e.jsx("span",{className:"text-xs",children:"Hover to load CI status"}):r.length===0?e.jsx("span",{className:"text-xs",children:"No CI checks"}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium",children:d}),r.slice(0,5).map((m,g)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx(E,{className:`h-1.5 w-1.5 fill-current ${m.conclusion==="success"?"text-bid-green":m.conclusion==="failure"?"text-ask-red":"text-warning-amber"}`}),e.jsx("span",{className:"truncate",children:m.name})]},g)),r.length>5&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["+",r.length-5," more"]})]})})]})}function ls({commit:s}){return e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(Be,{commitSha:s.sha}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-primary",children:s.shortSha}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:s.message}),e.jsx(Se,{projectId:s.project_id}),s.branch&&e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:s.branch}),s.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",s.scopeId]}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:s.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(s.date),{addSuffix:!0})})]})}function Ae({commits:s,branches:t,hasMore:a,onLoadMore:r}){const[o,c]=i.useState("all"),h=i.useMemo(()=>{const x=new Set(["main","master","dev","develop","staging","production"]);for(const u of t)!u.isRemote&&!u.name.startsWith("feat/")&&!u.name.startsWith("fix/")&&x.add(u.name);return x},[t]),n=i.useMemo(()=>o==="all"?s:o==="main"?s.filter(x=>!x.branch||h.has(x.branch)):s.filter(x=>x.branch&&!h.has(x.branch)),[s,o,h]),l=[{key:"all",label:"All"},{key:"main",label:"Main"},{key:"feature",label:"Feature"}];return e.jsxs(k,{className:"lg:col-span-2",children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(xe,{className:"h-4 w-4 text-primary"}),"Commits"," ",e.jsx(f,{variant:"secondary",children:n.length})]}),e.jsx("div",{className:"flex gap-1",children:l.map(x=>e.jsx("button",{onClick:()=>c(x.key),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${o===x.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:x.label},x.key))})]})}),e.jsx(S,{children:n.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(xe,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No commits found."})]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"max-h-[600px]",children:e.jsx("div",{className:"space-y-0.5",children:n.map(x=>e.jsx(ls,{commit:x},x.sha))})}),a&&e.jsx("button",{onClick:r,className:"mt-3 w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:"Load more commits"})]})})]})}function ds({branches:s}){const t=[...s].filter(a=>!a.isRemote).sort((a,r)=>a.isCurrent?-1:r.isCurrent?1:a.isStale!==r.isStale?a.isStale?1:-1:new Date(r.headDate).getTime()-new Date(a.headDate).getTime());return t.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(B,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No branches found."})]}):e.jsx("div",{className:"space-y-0.5",children:t.map(a=>e.jsxs("div",{className:w("flex items-center gap-2 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",a.isStale&&"opacity-50"),children:[e.jsx(B,{className:w("h-3.5 w-3.5 shrink-0",a.isCurrent?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:w("min-w-0 flex-1 truncate font-mono text-xs",a.isCurrent&&"text-foreground font-medium"),children:a.name}),a.scopeId&&e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",a.scopeId]}),a.aheadBehind&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-xs",children:[a.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),a.aheadBehind.ahead]}),a.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),a.aheadBehind.behind]})]}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:a.headSha}),a.headDate&&e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(a.headDate),{addSuffix:!0})})]},a.name))})}function xs({worktrees:s}){return s.length===0?e.jsxs("div",{className:"py-6 text-center",children:[e.jsx(T,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active worktrees."})]}):e.jsx("div",{className:"space-y-1",children:s.map(t=>e.jsxs("div",{className:"rounded border border-border/50 px-3 py-2 transition-colors hover:bg-surface-light",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t.branch}),t.dirty&&e.jsx(E,{className:"h-2 w-2 shrink-0 fill-warning-amber text-warning-amber"}),e.jsx("code",{className:"shrink-0 font-mono text-xs text-muted-foreground/60",children:t.head})]}),t.scopeId&&e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsxs(f,{variant:"secondary",className:"text-xs",children:["#",t.scopeId]}),t.scopeTitle&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.scopeTitle}),t.scopeStatus&&e.jsx(f,{variant:"outline",className:w("shrink-0 text-xs capitalize"),children:t.scopeStatus})]}),t.aheadBehind&&(t.aheadBehind.ahead>0||t.aheadBehind.behind>0)&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs",children:[t.aheadBehind.ahead>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-bid-green",children:[e.jsx(ve,{className:"h-2.5 w-2.5"}),t.aheadBehind.ahead," ahead"]}),t.aheadBehind.behind>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-ask-red",children:[e.jsx(ye,{className:"h-2.5 w-2.5"}),t.aheadBehind.behind," behind"]})]})]},t.path))})}function hs(s){return s===0?"text-bid-green":s<=5?"text-accent-blue":s<=20?"text-warning-amber":"text-ask-red"}function ms({branches:s,worktrees:t,drift:a,branchingMode:r}){const o=r==="worktree",[c,h]=i.useState("branches");return e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),o?c==="branches"?"Branches":"Worktrees":"Branches",e.jsx(f,{variant:"secondary",children:c==="branches"?s.filter(n=>!n.isRemote).length:t.length})]}),o&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>h("branches"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="branches"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(B,{className:"inline h-3 w-3 mr-1"}),"Branches"]}),e.jsxs("button",{onClick:()=>h("worktrees"),className:w("rounded-md px-2.5 py-1 text-xs transition-colors",c==="worktrees"?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"),children:[e.jsx(T,{className:"inline h-3 w-3 mr-1"}),"Worktrees"]})]})]})}),e.jsxs(S,{children:[e.jsx(je,{className:"max-h-[400px]",children:c==="branches"?e.jsx(ds,{branches:s}):e.jsx(xs,{worktrees:t})}),a.length>0&&e.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Branch Drift"}),e.jsx("div",{className:"space-y-1.5",children:a.map(n=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("code",{className:"font-mono text-muted-foreground",children:n.from}),e.jsx(Me,{className:"h-3 w-3 text-muted-foreground/50"}),e.jsx("code",{className:"font-mono text-muted-foreground",children:n.to}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",hs(n.count)),children:n.count===0?"in sync":`${n.count} commit${n.count!==1?"s":""}`})]},`${n.from}-${n.to}`))})]})]})]})}function us({error:s,onConnected:t}){const a=G(),[r,o]=i.useState(!1),[c,h]=i.useState("oauth"),[n,l]=i.useState("idle"),[x,u]=i.useState(""),[d,m]=i.useState(""),g=i.useRef(),b=i.useRef(),p=s==null?void 0:s.includes("not installed"),v=i.useCallback(()=>{g.current&&(clearInterval(g.current),g.current=void 0)},[]);i.useEffect(()=>()=>{v(),clearTimeout(b.current)},[v]);const D=async()=>{l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"oauth"})})).json();y.success?(l("polling"),g.current=setInterval(async()=>{try{(await(await fetch(a("/github/auth-status"))).json()).authenticated&&(v(),clearTimeout(b.current),l("success"),setTimeout(()=>{o(!1),t()},1e3))}catch{}},2e3),b.current=setTimeout(()=>{g.current&&(v(),l("error"),m("Authentication timed out. Please try again."))},12e4)):(l("error"),m(y.error??"Failed to start OAuth flow"))}catch{l("error"),m("Failed to connect to server")}},P=async()=>{if(x.trim()){l("connecting"),m("");try{const y=await(await fetch(a("/github/connect"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"pat",token:x.trim()})})).json();y.success?(l("success"),u(""),setTimeout(()=>{o(!1),t()},1e3)):(l("error"),m(y.error??"Authentication failed"))}catch{l("error"),m("Failed to connect to server")}}},H=C=>{o(C),C||(v(),l("idle"),m(""),u(""))};return e.jsxs(Ee,{open:r,onOpenChange:H,children:[e.jsx(Te,{asChild:!0,children:e.jsxs(V,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"Connect GitHub"]})}),e.jsxs($e,{className:"sm:max-w-md",children:[e.jsxs(_e,{children:[e.jsxs(Ie,{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5"}),"Connect to GitHub"]}),e.jsx(Ge,{children:p?"The GitHub CLI (gh) is required. Install it first, then authenticate.":"Authenticate with GitHub to see PRs, CI status, and repo info."})]}),p?e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"rounded border border-border bg-surface-light p-3",children:[e.jsx("p",{className:"text-sm mb-2",children:"Install the GitHub CLI:"}),e.jsx("code",{className:"text-xs font-mono bg-background px-2 py-1 rounded",children:"brew install gh"}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Or visit"," ",e.jsxs("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 text-primary hover:underline",children:["cli.github.com ",e.jsx(pe,{className:"h-2.5 w-2.5"})]})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-1 rounded-md bg-surface-light p-1",children:[e.jsxs("button",{onClick:()=>h("oauth"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="oauth"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(we,{className:"h-4 w-4"}),"Browser OAuth"]}),e.jsxs("button",{onClick:()=>h("pat"),className:`flex-1 flex items-center justify-center gap-2 rounded px-3 py-2 text-sm transition-colors ${c==="pat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Qe,{className:"h-4 w-4"}),"Access Token"]})]}),c==="oauth"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Opens your browser to authenticate with GitHub. This is the recommended method."}),e.jsxs(V,{onClick:D,disabled:n==="connecting"||n==="polling"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="polling"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="polling"?"Waiting for browser...":n==="success"?"Connected!":"Connect with GitHub"]})]}),c==="pat"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paste a GitHub Personal Access Token. Needs ",e.jsx("code",{className:"text-xs",children:"repo"})," and ",e.jsx("code",{className:"text-xs",children:"read:org"})," scopes."]}),e.jsx("input",{type:"password",placeholder:"ghp_xxxxxxxxxxxxxxxxxxxx",value:x,onChange:C=>u(C.target.value),disabled:n==="connecting"||n==="success",className:"flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50"}),e.jsxs(V,{onClick:P,disabled:!x.trim()||n==="connecting"||n==="success",className:"w-full gap-2",children:[n==="connecting"&&e.jsx(I,{className:"h-4 w-4 animate-spin"}),n==="success"&&e.jsx(ee,{className:"h-4 w-4"}),n==="success"?"Connected!":"Authenticate"]})]}),n==="error"&&d&&e.jsxs("div",{className:"flex items-center gap-2 rounded bg-ask-red/10 px-3 py-2 text-xs text-ask-red",children:[e.jsx(Oe,{className:"h-4 w-4 shrink-0"}),d]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:"GitHub authentication is global — connecting here applies to all projects."})]})]})]})}function fs({github:s,githubChecking:t,onConnectionChange:a}){var l;const r=G(),[o,c]=i.useState(!0),h=i.useCallback(async()=>{try{await fetch(r("/github/disconnect"),{method:"POST"}),a==null||a()}catch{}},[r,a]),n=((l=s==null?void 0:s.repo)==null?void 0:l.visibility)==="public"?we:ss;return e.jsxs(k,{className:"mt-6",children:[e.jsx(A,{className:"cursor-pointer select-none",onClick:()=>c(!o),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[o?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(K,{className:"h-4 w-4 text-primary"}),"GitHub",(s==null?void 0:s.connected)&&s.repo&&e.jsxs(f,{variant:"secondary",className:"ml-1 text-xs gap-1",children:[e.jsx(n,{className:"h-2.5 w-2.5"}),s.repo.fullName]}),s!=null&&s.openPRs?e.jsxs(f,{variant:"outline",className:"text-xs",children:[s.openPRs," open PR",s.openPRs!==1?"s":""]}):null]})}),o&&e.jsx(S,{children:t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"Checking GitHub connection…"]}):!s||!s.connected?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect to GitHub to see repository info, pull requests, and CI status."}),e.jsx(us,{error:(s==null?void 0:s.error)??null,onConnected:()=>a==null?void 0:a()})]}):e.jsxs("div",{className:"space-y-4",children:[s.repo&&e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Repository"}),e.jsx("a",{href:s.repo.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.repo.fullName}),e.jsx("span",{className:"text-muted-foreground",children:"Default branch"}),e.jsx("code",{className:"font-mono",children:s.repo.defaultBranch}),e.jsx("span",{className:"text-muted-foreground",children:"Visibility"}),e.jsxs("span",{className:"flex items-center gap-1 capitalize",children:[e.jsx(n,{className:"h-3 w-3"}),s.repo.visibility]}),s.authUser&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Signed in as"}),e.jsx("span",{children:s.authUser})]})]}),e.jsx("div",{className:"border-t border-border pt-3",children:e.jsxs(V,{variant:"ghost",size:"sm",onClick:x=>{x.stopPropagation(),h()},className:"gap-2 text-xs text-muted-foreground hover:text-ask-red",children:[e.jsx(as,{className:"h-3 w-3"}),"Disconnect"]})})]})})]})}function gs({decision:s}){return s==="APPROVED"?e.jsx(ee,{className:"h-3.5 w-3.5 text-bid-green"}):s==="CHANGES_REQUESTED"?e.jsx(Ue,{className:"h-3.5 w-3.5 text-ask-red"}):e.jsx(Le,{className:"h-3.5 w-3.5 text-warning-amber"})}function Re(s){const[t,a]=i.useState(!0),[r,o]=i.useState("all"),[c,h]=i.useState([]),n=i.useCallback(async()=>{if(!(s.isAggregate||!s.buildUrl))try{const d=await fetch(s.buildUrl("/github/prs"));d.ok&&h(await d.json())}catch{}},[s.isAggregate,s.buildUrl]);i.useEffect(()=>{s.isAggregate||n()},[s.isAggregate,n]);const l=s.isAggregate?s.prs:c,x=l.filter(d=>r==="all"?!0:r==="pending"?!d.reviewDecision||d.reviewDecision==="REVIEW_REQUIRED":r==="approved"?d.reviewDecision==="APPROVED":r==="changes"?d.reviewDecision==="CHANGES_REQUESTED":!0);if(l.length===0)return null;const u=[{key:"all",label:"All"},{key:"pending",label:"Pending"},{key:"approved",label:"Approved"},{key:"changes",label:"Changes"}];return e.jsxs(k,{className:"mb-6",children:[e.jsx(A,{className:"cursor-pointer select-none pb-2",onClick:()=>a(!t),children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[t?e.jsx(te,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(re,{className:"h-4 w-4 text-primary"}),"Pull Requests",e.jsx(f,{variant:"secondary",children:l.length})]})}),t&&e.jsxs(S,{children:[e.jsx("div",{className:"mb-3 flex gap-1",children:u.map(d=>e.jsx("button",{onClick:m=>{m.stopPropagation(),o(d.key)},className:`rounded-md px-2.5 py-1 text-xs transition-colors ${r===d.key?"bg-surface-light text-foreground":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.key))}),e.jsx("div",{className:"space-y-0.5",children:x.map(d=>e.jsxs("a",{href:d.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light group",children:[e.jsx(gs,{decision:d.reviewDecision}),e.jsxs("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:["#",d.number]}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:d.title}),e.jsx(Se,{projectId:d.project_id}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.branch}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"→"}),e.jsx(f,{variant:"outline",className:"shrink-0 text-xs font-normal",children:d.baseBranch}),d.scopeIds.map(m=>e.jsxs(f,{variant:"secondary",className:"shrink-0 text-xs",children:["#",m]},m)),e.jsx(Be,{pr:d}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:d.author}),e.jsx("span",{className:"shrink-0 text-xs text-muted-foreground/60",children:O(new Date(d.lastActivityAt??d.createdAt),{addSuffix:!0})}),e.jsx(pe,{className:"h-3 w-3 shrink-0 text-muted-foreground/40 opacity-0 group-hover:opacity-100 transition-opacity"})]},`${d.project_id??""}-${d.number}`))}),x.length===0&&e.jsx("p",{className:"py-4 text-center text-xs text-muted-foreground",children:"No PRs match this filter."})]})]})}function js({overviews:s,activitySeries:t}){return s.length===0?null:e.jsx("div",{className:"mb-6 grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>e.jsx(ps,{project:a,activity:t.get(a.projectId)??[]},a.projectId))})}function ps({project:s,activity:t}){const{projectName:a,projectColor:r,status:o,overview:c,error:h}=s;return e.jsx(k,{className:"overflow-hidden",children:e.jsxs(S,{className:"py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:`hsl(${r})`}}),e.jsx("span",{className:"font-medium text-sm",style:{color:`hsl(${r})`},children:a}),o==="error"&&e.jsx(f,{variant:"destructive",className:"text-xs ml-auto",children:"Error"})]}),o==="error"?e.jsx("p",{className:"text-xs text-muted-foreground",children:h}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("code",{className:"font-mono text-xs",children:c.currentBranch}),c.dirty&&e.jsxs(z,{children:[e.jsx(Q,{children:e.jsx(E,{className:"h-2 w-2 fill-warning-amber text-warning-amber"})}),e.jsx(J,{children:"Uncommitted changes"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[c.aheadBehind&&(c.aheadBehind.ahead>0||c.aheadBehind.behind>0)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),c.aheadBehind.ahead>0&&e.jsxs("span",{className:"text-bid-green",children:[c.aheadBehind.ahead,"↑"]}),c.aheadBehind.behind>0&&e.jsxs("span",{className:"text-ask-red",children:[c.aheadBehind.behind,"↓"]})]}),c.featureBranchCount>0&&e.jsxs("span",{children:[c.featureBranchCount," branch",c.featureBranchCount!==1?"es":""]}),e.jsx(f,{variant:"outline",className:"text-[10px] py-0",children:c.branchingMode})]}),c.mainHead&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(re,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:c.mainHead.message}),e.jsx("span",{className:"shrink-0 text-muted-foreground/60",children:O(new Date(c.mainHead.date),{addSuffix:!0})})]}),t.length>0&&e.jsx(Ce,{data:t,color:r})]}):null]})})}function Ns(s){return s==="clean"?"text-bid-green":s==="low"?"text-accent-blue":s==="moderate"?"text-warning-amber":"text-ask-red"}function bs({health:s}){return s.length===0?e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No branch data available."})})]}):e.jsxs(k,{children:[e.jsx(A,{className:"pb-2",children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(B,{className:"h-4 w-4 text-primary"}),"Branch Health"]})}),e.jsx(S,{children:e.jsx("div",{className:"space-y-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-3 rounded px-2.5 py-2 transition-colors hover:bg-surface-light",children:[e.jsx("span",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:`hsl(${t.projectColor})`}}),e.jsx("span",{className:"text-sm font-medium min-w-[100px]",style:{color:`hsl(${t.projectColor})`},children:t.projectName}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.branchCount," branch",t.branchCount!==1?"es":""]}),t.staleBranchCount>0&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-warning-amber",children:[e.jsx(Ne,{className:"h-3 w-3"}),t.staleBranchCount," stale"]}),t.featureBranchCount>0&&e.jsxs(f,{variant:"secondary",className:"text-xs",children:[t.featureBranchCount," feature"]}),e.jsx(f,{variant:"outline",className:w("ml-auto text-xs",Ns(t.maxDriftSeverity)),children:t.maxDriftSeverity==="clean"?"in sync":`${t.maxDriftSeverity} drift`})]},t.projectId))})})]})}function ys(s){return s==="A"?"text-bid-green":s==="B"?"text-accent-blue":s==="C"?"text-warning-amber":"text-ask-red"}function ws(s){return s==="A"?"bg-bid-green/10":s==="B"?"bg-accent-blue/10":s==="C"?"bg-warning-amber/10":"bg-ask-red/10"}function ks({health:s}){return e.jsx(k,{className:"mb-6",children:e.jsxs(S,{className:"flex items-center gap-6 py-3",children:[e.jsx("div",{className:w("flex items-center justify-center h-12 w-12 rounded-lg text-2xl font-bold shrink-0",ws(s.grade),ys(s.grade)),children:s.grade}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1",children:[e.jsx(q,{icon:e.jsx(Ke,{className:"h-3.5 w-3.5"}),label:"Commits/week",value:String(s.commitsPerWeek),warn:s.commitsPerWeek<5}),e.jsx(q,{icon:e.jsx(re,{className:"h-3.5 w-3.5"}),label:"Avg PR age",value:s.avgPrAgeDays>0?`${s.avgPrAgeDays}d`:"--",warn:s.avgPrAgeDays>3}),e.jsx(q,{icon:e.jsx(B,{className:"h-3.5 w-3.5"}),label:"Stale branches",value:String(s.staleBranchCount),warn:s.staleBranchCount>0}),e.jsx(q,{icon:e.jsx(Ne,{className:"h-3.5 w-3.5"}),label:"Drift",value:s.driftSeverity,warn:s.driftSeverity!=="clean"})]})]})})}function q({icon:s,label:t,value:a,warn:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:r?"text-warning-amber":"text-muted-foreground",children:s}),e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("span",{className:w("font-medium",r?"text-warning-amber":"text-foreground"),children:a})]})}const vs={deploying:{icon:I,color:"text-accent-blue",label:"Deploying",animate:"animate-spin"},healthy:{icon:Fe,color:"text-bid-green",label:"Healthy"},failed:{icon:me,color:"text-ask-red",label:"Failed"},"rolled-back":{icon:me,color:"text-warning-amber",label:"Rolled Back"}},fe=20;function Cs(s){const t=new Map;for(const a of s){const r=a.started_at?be(new Date(a.started_at),"yyyy-MM-dd"):"Unknown",o=t.get(r);o?o.push(a):t.set(r,[a])}return t}function Ss(s){if(!s.started_at||!s.completed_at)return null;const t=new Date(s.completed_at).getTime()-new Date(s.started_at).getTime();return t<1e3?"<1s":t<6e4?`${Math.round(t/1e3)}s`:`${Math.round(t/6e4)}m`}function Bs({deployments:s}){const[t,a]=i.useState(!1),r=t?s:s.slice(0,fe),o=Cs(r);return e.jsxs(k,{children:[e.jsx(A,{children:e.jsxs(R,{className:"text-base",children:["Deployment History",e.jsx(f,{variant:"secondary",className:"ml-2",children:s.length})]})}),e.jsx(S,{children:s.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(se,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deployments recorded yet."})]}):e.jsxs("div",{className:"space-y-4",children:[[...o.entries()].map(([c,h])=>e.jsxs("div",{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-card pb-1 pt-0.5",children:e.jsx("span",{className:"text-xxs font-medium uppercase tracking-wider text-muted-foreground",children:c==="Unknown"?"Unknown date":be(new Date(c),"EEEE, MMM d")})}),e.jsx("div",{className:"space-y-0.5",children:h.map(n=>{const l=vs[n.status],x=l.icon,u=Ss(n);return e.jsxs("div",{className:"flex items-center gap-4 rounded px-2.5 py-1.5 transition-colors hover:bg-surface-light",children:[e.jsx(x,{className:w("h-4 w-4 shrink-0",l.color,l.animate)}),e.jsx(f,{variant:"outline",className:"capitalize shrink-0",children:n.environment}),e.jsx("span",{className:"text-xs font-normal shrink-0",children:l.label}),n.commit_sha&&e.jsx("code",{className:"font-mono text-xs text-muted-foreground shrink-0",children:n.commit_sha.slice(0,7)}),n.branch&&e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:n.branch}),u&&e.jsx("span",{className:"font-mono text-xs text-muted-foreground/60 shrink-0",children:u}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/60 shrink-0",children:n.started_at?O(new Date(n.started_at),{addSuffix:!0}):"—"})]},n.id)})})]},c)),!t&&s.length>fe&&e.jsxs("button",{onClick:()=>a(!0),className:"w-full rounded border border-border py-2 text-xs text-muted-foreground transition-colors hover:bg-surface-light hover:text-foreground",children:["Show all ",s.length," deployments"]})]})})]})}function Os(){const{activeProjectId:s,hasMultipleProjects:t}=ge(),a=t&&s===null,r=rs(!a),o=ns(a),{deployments:c}=cs(!a),[h,n]=i.useState(!0);return(a?o.loading:r.loading)?e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent"})})]}):e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[e.jsx(he,{}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:a?e.jsx(Rs,{aggregate:o}):e.jsx(As,{sourceControl:r,deployments:c,deployExpanded:h,setDeployExpanded:n})})]})}function As({sourceControl:s,deployments:t,deployExpanded:a,setDeployExpanded:r}){const{overview:o,commits:c,branches:h,worktrees:n,github:l,githubChecking:x,drift:u,loadMoreCommits:d,hasMoreCommits:m,health:g,activity:b,refetch:p}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(T,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),o&&e.jsx(f,{variant:"secondary",children:o.currentBranch})]}),o&&e.jsx(is,{overview:o,github:l,githubChecking:x,activity:b}),g&&e.jsx(ks,{health:g}),(l==null?void 0:l.connected)&&e.jsx(Re,{buildUrl:s.buildUrl}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:c,branches:h,hasMore:m,onLoadMore:d}),e.jsx(ms,{branches:h,worktrees:n,drift:u,branchingMode:(o==null?void 0:o.branchingMode)??"trunk"})]}),e.jsx(fs,{github:l,githubChecking:x,onConnectionChange:p}),t.length>0&&e.jsx("div",{className:"mt-6",children:a?e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(!1),className:"mb-2 flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx(se,{className:"h-4 w-4"}),"Deploy History"]}),e.jsx(Bs,{deployments:t})]}):e.jsx(k,{className:"cursor-pointer select-none",onClick:()=>r(!0),children:e.jsx(A,{children:e.jsxs(R,{className:"flex items-center gap-2 text-base",children:[e.jsx(ae,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(se,{className:"h-4 w-4 text-primary"}),"Deploy History",e.jsx(f,{variant:"secondary",children:t.length})]})})})})]})}function Rs({aggregate:s}){const{projectOverviews:t,commits:a,prs:r,branchHealth:o,activitySeries:c}=s;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx(T,{className:"h-4 w-4 text-primary"}),e.jsx("h1",{className:"text-xl font-light",children:"Repo"}),e.jsx(f,{variant:"secondary",children:"All Projects"})]}),e.jsx(js,{overviews:t,activitySeries:c}),r.length>0&&e.jsx(Re,{prs:r,isAggregate:!0}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsx(Ae,{commits:a,branches:[],hasMore:!1,onLoadMore:()=>{}}),e.jsx(bs,{health:o})]})]})}export{Os as SourceControl};
@@ -1,4 +1,4 @@
1
- import{j as r,x as ts,t as ns,O as ss,v as rs,y as os,w as Ue}from"./ui-BmsSg9jU.js";import{r as Xr,g as ic,d as is,a as N,b as ac}from"./vendor-Bqt8AJn2.js";import{i as cc,e as Hs,f as Os,g as lc,h as dc,j as uc,k as qt,l as En}from"./charts-LGLb8hyU.js";import{c as Ce,e as as,p as Gr,al as qr,q as Ur,X as he,G as Kr,f as be,l as cs,J as De,F as Jt,C as fc,aq as hc,d as ls,T as st,P as Te,a1 as pc,a3 as xc,a4 as mc,a5 as gc,a6 as bc,g as yc,R as Zr,U as Qr,b as Jr,a7 as wc,a8 as eo,aC as to,aD as Ie,aE as vc,aF as Nc,aG as jc,aH as Cc,aI as zc,aJ as kc,aK as no,n as Sc,u as Ec,aL as _c,aM as Mc,aN as ds,aO as Ic,r as Tc,t as Bs,aP as Ac,z as Pc,D as $c,aQ as Dc,aR as Lc,aS as Rc,aB as so,aT as Hc,E as Oc,k as Bc,K as Fc,aU as Vc,w as Yc,aV as Wc}from"./index-o4ScMAuR.js";import{Z as rt}from"./zap-C9wqYMpl.js";import{b as ot,c as us,d as Xc}from"./workflow-constants-Rw-GmgHZ.js";import{K as Gc}from"./key-CKR8JJSj.js";import{G as fs}from"./globe-WzeyHsUc.js";import{R as hs}from"./radio-xqZaR-Uk.js";import{S as ro,u as qc,P as Uc}from"./useWorkflowEditor-CqeRWVQX.js";import{M as oo}from"./minus-CHBsJyjp.js";import{S as hn}from"./shield-TdB1yv_a.js";import{B as en}from"./bot-NFaJBDn_.js";import{C as Kc}from"./circle-x-IsFCkBZu.js";/**
1
+ import{j as r,d as ts,a as ns,O as ss,b as rs,e as os,c as Ue}from"./ui-QhrRH5wk.js";import{r as Xr,g as ic,d as is,a as N,b as ac}from"./vendor-Bqt8AJn2.js";import{i as cc,e as Hs,f as Os,g as lc,h as dc,j as uc,k as qt,l as En}from"./charts-LGLb8hyU.js";import{c as Ce,e as as,p as Gr,an as qr,q as Ur,X as he,G as Kr,f as be,l as cs,K as De,H as Jt,C as fc,as as hc,d as ls,T as st,P as Te,a3 as pc,a5 as xc,a6 as mc,a7 as gc,a8 as bc,g as yc,U as Zr,V as Qr,b as Jr,a9 as wc,aa as eo,aA as to,aB as Ie,aC as vc,aD as Nc,aE as jc,aF as Cc,aG as zc,aH as kc,aI as no,n as Sc,u as Ec,aJ as _c,aK as Mc,aL as ds,aM as Ic,r as Tc,t as Bs,aN as Ac,z as Pc,D as $c,aO as Dc,aP as Lc,aQ as Rc,az as so,aR as Hc,E as Oc,k as Bc,M as Fc,aS as Vc,w as Yc,aT as Wc}from"./index-DQVAzHMu.js";import{Z as rt}from"./zap-eJ3z8HRI.js";import{b as ot,c as us,d as Xc}from"./workflow-constants-ZcCN11vm.js";import{K as Gc}from"./key-DpAZM-3d.js";import{G as fs}from"./globe-CIX_GBr0.js";import{R as hs}from"./radio-DhynLcSx.js";import{S as ro,u as qc,P as Uc}from"./useWorkflowEditor-BxN7phfr.js";import{M as oo}from"./minus-CJlpKNUB.js";import{S as hn}from"./shield-DLMQmvFQ.js";import{B as en}from"./bot-DUPnHZfM.js";import{C as Kc}from"./circle-x-B4nA79je.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-o4ScMAuR.js";/**
1
+ import{c as o}from"./index-DQVAzHMu.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-o4ScMAuR.js";/**
1
+ import{c as t}from"./index-DQVAzHMu.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c}from"./index-o4ScMAuR.js";/**
1
+ import{c}from"./index-DQVAzHMu.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-o4ScMAuR.js";/**
1
+ import{c as e}from"./index-DQVAzHMu.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c}from"./index-o4ScMAuR.js";/**
1
+ import{c}from"./index-DQVAzHMu.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.