cogpit 2.4.2 → 2.6.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.
- package/dist/cli.js +4806 -1917
- package/dist/web/assets/CommandPaletteHost-DfaMCzBW.js +1 -0
- package/dist/web/assets/{ConfigBrowser-x0UdXG0K.js → ConfigBrowser-CYyPu1XZ.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-D0TDZx8S.js → HighlightedEditor-D0E4fNIR.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-2606YXAx.js → KeyboardShortcutsDialog-Cmk72Wcu.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B4dwGXMS.js → MobileFileChanges-B5e6WRrN.js} +1 -1
- package/dist/web/assets/{PreviewPanel-CJdf-VLC.js → PreviewPanel-L5TxNJuc.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-9mVexNJQ.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-D8boI2Qx.js → ProjectSwitcherModal-D37bS3Y8.js} +1 -1
- package/dist/web/assets/{TerminalOutput-C-6RWc6C.js → TerminalOutput-qo7CUaKh.js} +1 -1
- package/dist/web/assets/ThemeSelectorModal-DeKpqiLO.js +1 -0
- package/dist/web/assets/WorkflowsPanel-Dvy1NPzW.js +1 -0
- package/dist/web/assets/{WorktreePanel-D-BUTFL2.js → WorktreePanel-DJdlsguj.js} +1 -1
- package/dist/web/assets/index-BnTYSkBh.css +1 -0
- package/dist/web/assets/{index-ztb2qsgi.js → index-C1O8__7w.js} +4 -4
- package/dist/web/assets/index-CdXCbj1g.js +157 -0
- package/dist/web/assets/index-CyRmDc3P.js +1 -0
- package/dist/web/assets/{index-BBKPLXTq.js → index-aYw7Kb2u.js} +1 -1
- package/dist/web/assets/index-vzYZixNy.js +1 -0
- package/dist/web/assets/session-parser.worker-CnmfpqaO.js +29 -0
- package/dist/web/assets/{vendor-ui-RwWl1mlR.js → vendor-ui-CevbH8m5.js} +188 -163
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/CommandPaletteHost-DJghey7B.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-3GzuQyp3.js +0 -4
- package/dist/web/assets/ThemeSelectorModal-DZ9JuT6j.js +0 -1
- package/dist/web/assets/WorkflowsPanel-i3GanFyN.js +0 -1
- package/dist/web/assets/index-CMQcske6.js +0 -1
- package/dist/web/assets/index-C_0XOtqJ.css +0 -1
- package/dist/web/assets/index-D6p4gVB_.js +0 -154
- package/dist/web/assets/session-parser.worker-D3MwyNH5.js +0 -29
package/dist/web/index.html
CHANGED
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
.dark body { background: #09090b; color: #fafafa; }
|
|
16
16
|
body { background: #fafafa; color: #09090b; }
|
|
17
17
|
</style>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-CdXCbj1g.js"></script>
|
|
19
19
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-gGw_S5I_.js">
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-ui-
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-ui-CevbH8m5.js">
|
|
21
21
|
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-BE1gYnO9.js">
|
|
22
22
|
<link rel="modulepreload" crossorigin href="/assets/vendor-shiki-DOn6sF-i.js">
|
|
23
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
23
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BnTYSkBh.css">
|
|
24
24
|
</head>
|
|
25
25
|
<body>
|
|
26
26
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as oe,j as u,r as H}from"./vendor-react-gGw_S5I_.js";import{ar as h,as as Q,a3 as le,O as ce,J as re,at as de,au as me,P as ue,C as he,N as ge,x as fe,av as ve,aw as Y,ax as W,ay as we,az as Ce,aA as je,aB as Se,w as ye}from"./index-D6p4gVB_.js";import{S as xe,p as Z,q as be,P as Pe,L as Te,H as Oe,F as Ne,r as ke,d as ee,G as Ee,l as Fe,h as Ie,s as $e,t as Re,u as Ae,v as De,w as te,x as Le,y as He,z as Me,K as qe,E as Be,A as Ke,B as pe,D as ne,I as ze,J as Ge,N as Ue}from"./vendor-ui-RwWl1mlR.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,c,i,m,d){return{id:t,label:e,icon:c,run:i,shortcut:m,description:d,value:`${e} ${s}`}}function _(...t){return t.filter(e=>e!==!1&&e!==void 0)}function We(t){const e=oe.c(40);let s,c,i,m,d,v,w,r,C,g,y,f,x,k,b;if(e[0]!==t){const $=_(a("home","Go to dashboard","home overview",Oe,t.onGoHome),a("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",Te,t.onToggleMissionControl,h("missionControl")),a("new-session","Start a new session","project agent chat create",Pe,t.onNewSession,h("newSession")),t.onDuplicateSession&&a("duplicate-session","Duplicate this session","copy fork clone branch thread",be,t.onDuplicateSession),t.canFocusComposer&&a("focus-composer","Focus message composer","chat prompt input",Z,t.onFocusComposer,h("focusComposer")),t.onFindInConversation&&a("find-in-conversation","Find in conversation","search text transcript turns matches",xe,t.onFindInConversation,h("findInConversation"))),F=(t.projects??[]).slice(0,8).map(n=>a(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,Ne,()=>{var l;return(l=t.onOpenProject)==null?void 0:l.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),o=(t.recentSessions??[]).slice(0,10).map(n=>{const j=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,p=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,j,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,Z,()=>{var q;return(q=t.onOpenSession)==null?void 0:q.call(t,n.dirName,n.fileName)},void 0,p)}),I=t.devices??[],P=I.length>1&&t.onSwitchDevice?I.slice(0,Q.length).map((n,l)=>a(`device-${n.id}`,n.isActive?`${n.name} (current)`:`Switch to ${n.name}`,`device machine host remote ${n.id}`,n.isLocal?ke:ee,()=>{var j;return(j=t.onSwitchDevice)==null?void 0:j.call(t,n.id)},h(Q[l]))):[],R=_(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Re,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",$e,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",Ie,t.onToggleProjectFiles,h("projectFiles")),t.hasFileChanges&&a("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",Fe,t.onToggleFileChanges),t.supportsWorktrees&&t.canOpenTerminal&&a("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Ee,t.onToggleWorktrees)),A=_(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",Ge,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",ze,t.onRevealProject),t.onCopyResumeCommand&&a("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",ne,t.onCopyResumeCommand),t.onCopyProjectPath&&a("copy-project-path","Copy project path","workspace directory clipboard",ne,t.onCopyProjectPath),t.onOpenIntegratedTerminal&&a("integrated-terminal","New integrated terminal","embedded shell command line process panel",pe,t.onOpenIntegratedTerminal,h("newIntegratedTerminal")),t.canOpenTerminal&&a("terminal","Open in system terminal","external shell command line app",Ke,t.onOpenTerminal,h("systemTerminal")),t.onTogglePreview&&a("preview","Toggle development preview","browser localhost dev server website",Be,t.onTogglePreview,h("preview")),t.onOpenKeyboardShortcuts&&a("keyboard-shortcuts","Customize keyboard shortcuts","keybindings hotkeys settings",qe,t.onOpenKeyboardShortcuts),t.onOpenConfig&&a("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",Me,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",He,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",Le,t.onOpenTheme,h("themeSelector")),a("expand","Expand all groups","conversation details",te,t.onExpandAll,h("expandAll")),a("expand-payloads","Expand all tool payloads","raw input result diff conversation details",te,t.onExpandToolPayloads,h("expandToolPayloads")),a("collapse","Collapse all","conversation groups payloads details",De,t.onCollapseAll),t.onKillAll&&a("kill-all","Kill all agent processes","stop terminate halt everything runaway",Ae,t.onKillAll),t.onOpenDevices&&a("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",Ue,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"manage")}),t.onOpenDevices&&a("add-device","Add device…","remote machine hub host connect pair new",ee,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),D=[{value:"Navigation",items:$},...o.length>0?[{value:"Recent sessions",items:o}]:[],...F.length>0?[{value:"Projects",items:F}]:[],...P.length>0?[{value:"Devices",items:P}]:[],{value:"View",items:R},{value:"Tools",items:A}],E=function(l){t.onOpenChange(!1),l.run()};i=me,x=t.open,k=t.onOpenChange,b="Command palette",v="Search for a Cogpit action to run.",w="max-w-xl",c=ue,C="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(he,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[16]=y):y=e[16],e[17]!==t.loadingNavigation?(f=t.loadingNavigation&&u.jsxs("div",{className:"motion-enter flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",role:"status",children:[u.jsx(le,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[17]=t.loadingNavigation,e[18]=f):f=e[18],s=ge,m="max-h-[min(26rem,60vh)]",e[19]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(fe,{children:"No matching actions."}),e[19]=d):d=e[19],r=D.map(n=>u.jsx(ce,{heading:n.value,children:n.items.map(l=>{const j=l.icon;return u.jsxs(re,{value:l.value,onSelect:()=>E(l),children:[u.jsx(j,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:l.label}),l.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l.description})]}),l.shortcut&&u.jsx(de,{children:l.shortcut})]},l.id)})},n.value)),e[0]=t,e[1]=s,e[2]=c,e[3]=i,e[4]=m,e[5]=d,e[6]=v,e[7]=w,e[8]=r,e[9]=C,e[10]=g,e[11]=y,e[12]=f,e[13]=x,e[14]=k,e[15]=b}else s=e[1],c=e[2],i=e[3],m=e[4],d=e[5],v=e[6],w=e[7],r=e[8],C=e[9],g=e[10],y=e[11],f=e[12],x=e[13],k=e[14],b=e[15];let T;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==r?(T=u.jsxs(s,{className:m,children:[d,r]}),e[20]=s,e[21]=m,e[22]=d,e[23]=r,e[24]=T):T=e[24];let O;e[25]!==c||e[26]!==T||e[27]!==C||e[28]!==g||e[29]!==y||e[30]!==f?(O=u.jsxs(c,{label:C,loop:g,children:[y,f,T]}),e[25]=c,e[26]=T,e[27]=C,e[28]=g,e[29]=y,e[30]=f,e[31]=O):O=e[31];let N;return e[32]!==i||e[33]!==v||e[34]!==w||e[35]!==O||e[36]!==x||e[37]!==k||e[38]!==b?(N=u.jsx(i,{open:x,onOpenChange:k,title:b,description:v,className:w,children:O}),e[32]=i,e[33]=v,e[34]=w,e[35]=O,e[36]=x,e[37]=k,e[38]=b,e[39]=N):N=e[39],N}async function ae(t,e){const s=await ye(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const c=await s.json();return Array.isArray(c)?c:[]}function Ye(t){var J;const e=oe.c(48);let s,c,i,m,d,v;e[0]!==t?({open:i,currentProjectDirName:s,projectCwd:d,onProcessStarted:c,launchTerminalRequest:v,...m}=t,e[0]=t,e[1]=s,e[2]=c,e[3]=i,e[4]=m,e[5]=d,e[6]=v):(s=e[1],c=e[2],i=e[3],m=e[4],d=e[5],v=e[6]);const w=v===void 0?0:v,r=ve();let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[7]=C):C=e[7];const[g,y]=H.useState(C);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[x,k]=H.useState(f),[b,T]=H.useState(!1),O=H.useRef(0);let N,$;e[9]!==i?(N=()=>{if(!i)return;const S=new AbortController;return T(!0),Promise.allSettled([ae("/api/projects",S.signal),ae("/api/active-sessions?limit=12&perProject=3",S.signal)]).then(M=>{const[V,X]=M;S.signal.aborted||(y(V.status==="fulfilled"?V.value:[]),k(X.status==="fulfilled"?X.value:[]),T(!1))}),()=>S.abort()},$=[i],e[9]=i,e[10]=N,e[11]=$):(N=e[10],$=e[11]),H.useEffect(N,$);let F;e:{if(d){F=d;break e}if(!s){F=null;break e}let S;e[12]!==s||e[13]!==g?(S=((J=g.find(M=>M.dirName===s))==null?void 0:J.path)??null,e[12]=s,e[13]=g,e[14]=S):S=e[14],F=S}const o=F;let I;e[15]!==c||e[16]!==r||e[17]!==o?(I=()=>{if(!o)return;const S=r.spawnTerminal({cwd:o}),M=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";c({id:S,name:M,type:"terminal",status:"running",source:o})},e[15]=c,e[16]=r,e[17]=o,e[18]=I):I=e[18];const P=I;let R,A;e[19]!==P||e[20]!==w||e[21]!==r.status||e[22]!==o?(R=()=>{w<=O.current||!o||r.status!=="connected"||(O.current=w,P())},A=[P,w,r.status,o],e[19]=P,e[20]=w,e[21]=r.status,e[22]=o,e[23]=R,e[24]=A):(R=e[23],A=e[24]),H.useEffect(R,A);let D;e[25]!==s||e[26]!==o?(D={path:o,dirName:s},e[25]=s,e[26]=o,e[27]=D):D=e[27];const E=D;let n;e[28]!==E?(n=()=>Ce(E),e[28]=E,e[29]=n):n=e[29];const l=n;let j;e[30]!==E?(j=()=>je(E),e[30]=E,e[31]=j):j=e[31];const p=j,q=!Y()&&W("hostFiles"),se=W("hostFiles")&&(!Y()||we());let B;e[32]!==o?(B=()=>{o&&Se(o)},e[32]=o,e[33]=B):B=e[33];const ie=B;let L;e[34]!==P||e[35]!==r.status||e[36]!==o?(L=o&&r.status==="connected"&&W("terminal")?P:void 0,e[34]=P,e[35]=r.status,e[36]=o,e[37]=L):L=e[37];const z=o&&se?l:void 0,G=o&&q?p:void 0,U=o?ie:void 0;let K;return e[38]!==b||e[39]!==i||e[40]!==m||e[41]!==g||e[42]!==x||e[43]!==L||e[44]!==z||e[45]!==G||e[46]!==U?(K=u.jsx(We,{...m,open:i,projects:g,recentSessions:x,loadingNavigation:b,onOpenIntegratedTerminal:L,onOpenProjectInEditor:z,onRevealProject:G,onCopyProjectPath:U}),e[38]=b,e[39]=i,e[40]=m,e[41]=g,e[42]=x,e[43]=L,e[44]=z,e[45]=G,e[46]=U,e[47]=K):K=e[47],K}export{Ye as CommandPaletteHost};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-gGw_S5I_.js";import{w as V,a0 as wt,a1 as Ct,B as w,l as Q,a2 as I,m as Nt,I as St,n as kt,Y as Xe,Z as le,q as Et,a3 as re,E as z,y as $,z as P,G,H,a4 as Dt,_ as Ye,a5 as Rt,a6 as Ft,D as Lt,h as Tt,i as Mt,j as Ut,k as At,a7 as It,a8 as zt,a9 as $t,aa as Pt,ab as Gt,ac as Ht,ad as Kt,ae as Ot,af as Wt,ag as Bt,Q as Xt}from"./index-D6p4gVB_.js";import{H as Yt}from"./HighlightedEditor-D0TDZx8S.js";import{h as Ve,X as Vt,G as Qt,S as qt,b as Qe,i as be,j as qe,k as Jt,l as ve}from"./vendor-ui-RwWl1mlR.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const we=520,Zt=760,Je="cogpit-project-files-width",_t={"?":{label:"Untracked",className:"text-info"},A:{label:"Added",className:"text-success"},M:{label:"Modified",className:"text-warning"},D:{label:"Deleted",className:"text-destructive"},R:{label:"Renamed",className:"text-info"},C:{label:"Copied",className:"text-info"},U:{label:"Conflicted",className:"text-destructive"}};function ye(r){const x=r.workTreeStatus.trim()||r.indexStatus.trim();return _t[x]??{label:"Changed",className:"text-muted-foreground"}}function es(){try{const r=Number(localStorage.getItem(Je));if(Number.isFinite(r)&&r>=we)return r}catch{}return Zt}async function q(r,x){try{const u=await r.json();if(u&&typeof u=="object"&&typeof u.error=="string")return u.error}catch{}return x}function ts(r){return r<1024?`${r} B`:`${(r/1024).toFixed(r<10*1024?1:0)} KB`}function ss(r,x){let u=0;for(let m=1;m<x;m+=1){const S=r.indexOf(`
|
|
2
|
-
`,u);if(S<0)return u;u=S+1}return u}function cs({cwd:r,onClose:x,onAddToPrompt:u,openRequest:m,embedded:S=!1}){const Ce=s.useRef(null),oe=s.useRef(null),ce=s.useRef(null),k=s.useRef(null),[J,Ze]=s.useState(es),Ne=s.useRef(J),[K,_e]=s.useState(""),[Se,ke]=s.useState([]),[et,Ee]=s.useState(!0),[tt,De]=s.useState(null),[de,st]=s.useState(0),[Re,nt]=s.useState(!1),[at,it]=s.useState(0),ue=s.useRef(!1),[a,Fe]=s.useState(null),[f,E]=s.useState(""),[lt,O]=s.useState(""),[b,W]=s.useState(null),[rt,Le]=s.useState(0),[D,Te]=s.useState(!1),[R,Me]=s.useState(!1),[Ue,F]=s.useState(null),[ot,L]=s.useState(!1),[p,fe]=s.useState("all"),[o,Ae]=s.useState(null),[Ie,ze]=s.useState(!1),[ct,$e]=s.useState(null),[c,Z]=s.useState("edit"),[d,_]=s.useState(null),[B,Pe]=s.useState(!1),[Ge,he]=s.useState(null),[X,C]=s.useState(null),[v,ee]=s.useState(null),[te,xe]=s.useState(""),[y,Y]=s.useState(null),h=a!==null&&f!==lt,g=s.useMemo(()=>new Map(((o==null?void 0:o.files)??[]).flatMap(t=>[[t.path,t],...t.originalPath?[[t.originalPath,t]]:[]])),[o==null?void 0:o.files]),T=s.useCallback(async()=>{ze(!0),$e(null);try{const t=await V(`/api/git-status?cwd=${encodeURIComponent(r)}`);if(!t.ok)throw new Error(await q(t,"Unable to read git status"));const n=await t.json();Ae(n),n.isRepository||fe("all")}catch(t){Ae(null),fe("all"),$e(t instanceof Error?t.message:"Unable to read git status")}finally{ze(!1)}},[r]);s.useEffect(()=>{T()},[T]),s.useEffect(()=>{const t=new AbortController,n=window.setTimeout(async()=>{Ee(!0),De(null);const i=ue.current;ue.current=!1;try{const l=await V(`/api/project-files?cwd=${encodeURIComponent(r)}&q=${encodeURIComponent(K)}&limit=100${i?"&refresh=1":""}`,{signal:t.signal});if(!l.ok)throw new Error(await q(l,"Unable to list project files"));const j=await l.json();if(t.signal.aborted)return;const A=wt(j),ie=j.totalMatches;ke(A),st(typeof ie=="number"?ie:A.length),nt(j.scanLimited===!0)}catch(l){t.signal.aborted||(ke([]),De(l instanceof Error?l.message:"Unable to list project files"))}finally{t.signal.aborted||Ee(!1)}},120);return()=>{window.clearTimeout(n),t.abort()}},[r,K,at]),s.useEffect(()=>{Fe(null),E(""),O(""),W(null),F(null),C(null),Z("edit"),_(null),he(null),Y(null)},[r]),s.useEffect(()=>{if(!h)return;const t=n=>n.preventDefault();return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[h]);const dt=s.useCallback((t,n)=>{const i=oe.current;if(!i)return;if(!n||n<1){i.focus();return}const l=ss(t,n);i.blur(),i.setSelectionRange(l,l),i.focus()},[]);s.useEffect(()=>{const t=ce.current;!t||!oe.current||(ce.current=null,dt(t.text,t.line))});const M=s.useCallback(async(t,n)=>{Te(!0),F(null),L(!1),C(null);try{const i=await V(`/api/project-file?cwd=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}`);if(!i.ok)throw new Error(await q(i,"Unable to open file"));const l=await i.json();E(l.content),O(l.content),W(l.mtimeMs),Le(l.size),ce.current={text:l.content,line:n}}catch(i){E(""),O(""),W(null),F(i instanceof Error?i.message:"Unable to open file")}finally{Te(!1)}},[r]),U=s.useCallback(async(t,n)=>{Pe(!0),he(null),_(null);try{const i=n?`&originalPath=${encodeURIComponent(n)}`:"",l=await V(`/api/git-diff?cwd=${encodeURIComponent(r)}&path=${encodeURIComponent(t)}${i}`);if(!l.ok)throw new Error(await q(l,"Unable to diff file"));_(await l.json())}catch(i){he(i instanceof Error?i.message:"Unable to diff file")}finally{Pe(!1)}},[r]),se=s.useCallback(({path:t,mode:n,line:i})=>{var l;if(Fe(t),Z(n),n==="edit"){M(t,i);return}E(""),O(""),W(null),F(null),L(!1),C(null),U(t,(l=g.get(t))==null?void 0:l.originalPath)},[g,U,M]),ne=s.useCallback(t=>{if(h){Y({type:"file",target:t});return}se(t)},[h,se]),ut=s.useCallback(t=>{if(t===a)return;const n=p==="changes"&&g.has(t)?"diff":"edit";ne({path:t,mode:n})},[g,p,ne,a]),He=s.useRef(0);s.useEffect(()=>{!m||m.token===He.current||(He.current=m.token,ne({path:m.file,mode:m.mode,line:m.line}))},[m,ne]);const ft=s.useCallback(()=>{var t;!a||c==="diff"||(Z("diff"),(d==null?void 0:d.path)!==a&&!B&&U(a,(t=g.get(a))==null?void 0:t.originalPath))},[g,d==null?void 0:d.path,B,U,a,c]),ht=s.useCallback(()=>{!a||c==="edit"||(Z("edit"),b===null&&!D&&M(a))},[D,M,b,a,c]),me=s.useCallback(()=>{var t;if(a){if(c==="diff"){U(a,(t=g.get(a))==null?void 0:t.originalPath);return}M(a)}},[g,U,M,a,c]),xt=s.useCallback(()=>{ue.current=!0,it(t=>t+1),T(),c==="diff"&&me()},[T,me,c]),pe=s.useCallback(async()=>{if(!(!a||b===null||!h||R)){Me(!0),F(null),L(!1);try{const t=await V("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:r,path:a,content:f,expectedMtimeMs:b})});if(!t.ok)throw new Error(await q(t,"Unable to save file"));const n=await t.json();O(f),W(n.mtimeMs),Le(n.size),L(!0),_(null),T()}catch(t){F(t instanceof Error?t.message:"Unable to save file")}finally{Me(!1)}}},[f,r,h,T,b,R,a]);s.useEffect(()=>{function t(n){var i;(i=Ce.current)!=null&&i.contains(document.activeElement)&&Xt("projectFileSave",n)&&(n.preventDefault(),pe())}return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[pe]);const mt=s.useCallback(()=>{if(h){Y({type:"close"});return}x()},[h,x]),pt=s.useCallback(()=>{if(!y)return;const t=y;if(Y(null),t.type==="file"){se(t.target);return}x()},[x,se,y]),gt=s.useCallback(t=>{if(t.key!=="Tab")return;t.preventDefault();const n=t.currentTarget,i=n.selectionStart,l=n.selectionEnd,j=`${f.slice(0,i)} ${f.slice(l)}`;E(j),L(!1),C(null),requestAnimationFrame(()=>{n.selectionStart=i+2,n.selectionEnd=i+2})},[f]),jt=s.useCallback(t=>{const n=t.currentTarget;if(n.selectionStart===n.selectionEnd){C(null);return}const i=f.slice(n.selectionStart,n.selectionEnd),l=f.slice(0,n.selectionStart).split(`
|
|
3
|
-
`).length,j=l+i.split(`
|
|
4
|
-
`).length-1;C({text:i,startLine:l,endLine:j})},[f]),bt=s.useCallback(t=>{t.preventDefault(),k.current={startX:t.clientX,startWidth:J},t.currentTarget.setPointerCapture(t.pointerId)},[J]),vt=s.useCallback(t=>{if(!k.current)return;const n=Math.max(we,window.innerWidth*.9),i=k.current.startWidth+(k.current.startX-t.clientX),l=Math.min(n,Math.max(we,i));Ne.current=l,Ze(l)},[]),Ke=s.useCallback(()=>{if(k.current){k.current=null;try{localStorage.setItem(Je,String(Ne.current))}catch{}}},[]),ge=s.useMemo(()=>(a==null?void 0:a.split("/").at(-1))??null,[a]),ae=a?g.get(a):void 0,je=s.useMemo(()=>d&&!d.binary&&!d.tooLarge?Ct(d.original??"",d.current??""):null,[d]),N=s.useMemo(()=>{if(p==="all")return Se;const t=K.trim().toLowerCase();return((o==null?void 0:o.files)??[]).map(n=>n.path).filter((n,i,l)=>l.indexOf(n)===i).filter(n=>!t||n.toLowerCase().includes(t)).sort((n,i)=>n.localeCompare(i))},[p,Se,o==null?void 0:o.files,K]),Oe=s.useMemo(()=>a&&!N.includes(a)?[a,...N]:N,[N,a]),yt=p==="changes"?Ie:et,We=p==="changes"?ct:tt,Be=Ie;return e.jsxs("aside",{ref:Ce,"aria-label":"Project files",className:Ye("relative flex min-h-0 flex-col bg-background",S?"size-full":"view-transition-right-panel panel-enter-right shrink-0 border-l"),style:S?void 0:{width:J},children:[!S&&e.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-accent",onPointerDown:bt,onPointerMove:vt,onPointerUp:Ke,onPointerCancel:Ke}),e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsx(Ve,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:r,children:r}),e.jsx(w,{variant:"ghost",size:"icon-sm",onClick:mt,"aria-label":"Close project files",children:e.jsx(Vt,{"data-icon":"inline-start"})})]}),e.jsx(Q,{}),(o==null?void 0:o.isRepository)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[e.jsx(Qt,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),e.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:o.branch??"Detached HEAD",children:o.branch??"detached HEAD"}),o.upstream&&e.jsxs("span",{className:"truncate",children:["tracks ",o.upstream]}),(o.ahead??0)>0&&e.jsxs(I,{variant:"outline",children:["↑ ",o.ahead]}),(o.behind??0)>0&&e.jsxs(I,{variant:"outline",children:["↓ ",o.behind]}),e.jsx("span",{className:"flex-1"}),e.jsxs("span",{children:[o.files.length," changed"]})]}),e.jsx(Q,{})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsxs("section",{"aria-label":"File browser",className:"flex w-56 shrink-0 flex-col",children:[e.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(Nt,{className:"min-w-0 flex-1",children:[e.jsx(St,{children:e.jsx(qt,{"data-icon":"inline-start"})}),e.jsx(kt,{"aria-label":"Search project files",value:K,onChange:t=>_e(t.target.value),placeholder:"Filter files…",spellCheck:!1})]}),e.jsx(w,{variant:"ghost",size:"icon-sm",disabled:Be,onClick:xt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:e.jsx(Qe,{"data-icon":"inline-start",className:Be?"animate-spin":void 0})})]}),(o==null?void 0:o.isRepository)&&e.jsxs(Xe,{"aria-label":"File scope",value:[p],onValueChange:t=>{const n=t[0];(n==="all"||n==="changes")&&fe(n)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[e.jsx(le,{value:"all",className:"flex-1",children:"All files"}),e.jsx(le,{value:"changes",className:"flex-1",children:"Changes"})]})]}),e.jsx(Q,{}),e.jsx(Et,{className:"min-h-0 flex-1",children:yt?e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[e.jsx(re,{}),"Loading files…"]}):We?e.jsx(z,{className:"min-h-48 rounded-none p-4",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(be,{})}),e.jsx(G,{children:"Could not load files"}),e.jsx(H,{children:We})]})}):Oe.length===0?e.jsx(z,{className:"min-h-48 rounded-none p-4",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(Ve,{})}),e.jsx(G,{children:p==="changes"?"No working-tree changes":"No matching files"}),e.jsx(H,{children:p==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):e.jsxs("div",{className:"flex flex-col py-1",children:[Oe.map(t=>{const n=t.split("/").at(-1)??t,i=t.includes("/")?t.slice(0,t.lastIndexOf("/")):"",l=g.get(t),j=l?`${l.indexStatus}${l.workTreeStatus}`.trim()||"?":null,A=l?ye(l):null,ie=Dt(t);return e.jsxs(w,{variant:a===t?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>ut(t),title:t,children:[e.jsx(ie,{"data-icon":"inline-start",className:"text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-xs",children:n}),i&&e.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:i})]}),j&&A&&e.jsx(I,{variant:"outline",className:Ye("font-mono",A.className),title:A.label,children:j})]},t)}),p==="all"&&(de>N.length||Re)&&e.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[de>N.length&&`Showing ${N.length} of ${de} matches. Type to narrow the list. `,Re&&"This project is too large to scan completely."]})]})})]}),e.jsx(Q,{orientation:"vertical"}),e.jsx("section",{"aria-label":"File editor",className:"flex min-w-0 flex-1 flex-col",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-xs font-medium",title:a,children:ge}),e.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:a})]}),(ae||c==="diff")&&e.jsxs(Xe,{"aria-label":"File view",value:[c],onValueChange:t=>{t[0]==="diff"?ft():t[0]==="edit"&&ht()},variant:"outline",size:"sm",spacing:0,children:[e.jsx(le,{value:"diff",children:"Diff"}),e.jsx(le,{value:"edit",children:"Edit"})]}),c==="diff"&&ae&&e.jsx(I,{variant:"outline",className:ye(ae).className,children:ye(ae).label}),c==="diff"&&je&&e.jsx(Rt,{add:je.add,del:je.del}),c==="edit"&&h&&e.jsx(I,{variant:"outline",children:"Unsaved"}),c==="edit"&&!h&&ot&&e.jsx(I,{variant:"secondary",children:"Saved"}),c==="edit"&&b!==null&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ts(rt)}),u&&e.jsxs(w,{variant:"outline",size:"sm",disabled:c==="diff"?B||d===null:D||b===null,onClick:()=>{X?(xe(""),ee(X)):u({path:a})},"aria-label":X?"Add selected lines to prompt":"Reference file in prompt",title:X?"Add selected lines to prompt":"Reference file in prompt",children:[e.jsx(qe,{"data-icon":"inline-start"}),X?"Add selection":"Reference"]}),e.jsx(w,{variant:"ghost",size:"icon-sm",disabled:c==="diff"?B:D||R,onClick:me,"aria-label":c==="diff"?"Reload diff":"Reload file",title:c==="diff"?"Reload diff":"Reload file",children:e.jsx(Qe,{"data-icon":"inline-start"})}),c==="edit"&&e.jsxs(w,{size:"sm",disabled:!h||D||R||b===null,onClick:()=>void pe(),children:[R?e.jsx(re,{"data-icon":"inline-start"}):e.jsx(Jt,{"data-icon":"inline-start"}),R?"Saving…":"Save"]})]}),e.jsx(Q,{}),c==="edit"&&Ue&&e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[e.jsx(be,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),e.jsx("span",{children:Ue})]}),c==="diff"?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:B?e.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[e.jsx(re,{}),"Loading diff…"]}):Ge?e.jsx(z,{className:"rounded-none",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(be,{})}),e.jsx(G,{children:"Could not diff this file"}),e.jsx(H,{children:Ge})]})}):d===null?null:d.binary||d.tooLarge?e.jsx(z,{className:"rounded-none",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(ve,{})}),e.jsx(G,{children:d.binary?"Binary file":"File is too large to diff"}),e.jsx(H,{children:d.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):d.original===d.current?e.jsx(z,{className:"rounded-none",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(ve,{})}),e.jsx(G,{children:"No content changes"}),e.jsx(H,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(Ft,{oldString:d.original??"",newString:d.current??"",filePath:a,compact:!1,hideHeader:!0})})}):e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:D?e.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[e.jsx(re,{}),"Opening file…"]}):b!==null?e.jsx(Yt,{textareaRef:oe,ariaLabel:`Editing ${a}`,filePath:a,value:f,readOnly:!1,onChange:t=>{E(t),L(!1),C(null)},onKeyDown:gt,onSelect:jt}):null})]}):e.jsx(z,{className:"rounded-none",children:e.jsxs($,{children:[e.jsx(P,{variant:"icon",children:e.jsx(ve,{})}),e.jsx(G,{children:"Select a file"}),e.jsx(H,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),e.jsx(Lt,{open:v!==null,onOpenChange:t=>{t||ee(null)},children:e.jsxs(Tt,{children:[e.jsxs(Mt,{children:[e.jsx(Ut,{children:"Comment on selected lines"}),e.jsxs(At,{children:["Add a review instruction for ",a," lines ",v==null?void 0:v.startLine,"-",v==null?void 0:v.endLine,"."]})]}),e.jsxs("form",{className:"flex flex-col gap-4",onSubmit:t=>{t.preventDefault();const n=te.trim();!a||!v||!n||!u||(u({path:a,...v,comment:n}),ee(null),xe(""))},children:[e.jsx(It,{autoFocus:!0,"aria-label":"Review comment",value:te,onChange:t=>xe(t.target.value),placeholder:"Describe the change you want…",onKeyDown:t=>{var n;(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&te.trim()&&(t.preventDefault(),(n=t.currentTarget.form)==null||n.requestSubmit())}}),e.jsxs(zt,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>ee(null),children:"Cancel"}),e.jsxs(w,{type:"submit",disabled:!te.trim(),children:[e.jsx(qe,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),e.jsx($t,{open:y!==null,onOpenChange:t=>{t||Y(null)},children:e.jsxs(Pt,{size:"sm",children:[e.jsxs(Gt,{children:[e.jsx(Ht,{children:"Discard unsaved changes?"}),e.jsx(Kt,{children:(y==null?void 0:y.type)==="file"?`Your edits to ${ge??"this file"} will be lost when you open ${y.target.path}.`:`Your edits to ${ge??"this file"} will be lost when you close the file workspace.`})]}),e.jsxs(Ot,{children:[e.jsx(Wt,{size:"sm",children:"Keep editing"}),e.jsx(Bt,{variant:"destructive",size:"sm",onClick:pt,children:"Discard changes"})]})]})})]})}export{cs as ProjectFilesPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as H,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{aC as W,Z as _,i as L,j as U,k as Z,Y as $,h as q,D as B}from"./index-D6p4gVB_.js";import{O as J,x as Q}from"./vendor-ui-RwWl1mlR.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const I=[{id:"narrow",name:"Narrow",css:"44rem"},{id:"medium",name:"Medium",css:"56rem"},{id:"wide",name:"Wide",css:"64rem"},{id:"full",name:"Full",css:"100%"}],Y="cogpit-chat-width",O="medium";function V(){try{const s=localStorage.getItem(Y);if(I.some(e=>e.id===s))return s}catch{}return O}let R=typeof window>"u"?O:V();const M=new Set;function K(s){if(typeof document>"u")return;const e=I.find(t=>t.id===s)??I[1];document.documentElement.style.setProperty("--chat-width",e.css)}K(R);function X(){return R}function ee(s){R=s;try{localStorage.setItem(Y,s)}catch{}K(s),M.forEach(e=>e())}function te(s){return M.add(s),()=>M.delete(s)}function se(){const s=H.c(2),e=g.useSyncExternalStore(te,X,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return O}function de(s){const e=H.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[p,P]=g.useState(0),[z,A]=se();let j,w;e[0]!==l||e[1]!==t?(j=()=>{if(t){const a=W.findIndex(D=>D.id===l);P(a>=0?a:0)}},w=[t,l],e[0]=l,e[1]=t,e[2]=j,e[3]=w):(j=e[2],w=e[3]),g.useEffect(j,w);let N,b;e[4]!==i||e[5]!==t||e[6]!==p?(N=()=>{t&&i(W[p].id)},b=[p,t,i],e[4]=i,e[5]=t,e[6]=p,e[7]=N,e[8]=b):(N=e[7],b=e[8]),g.useEffect(N,b);let C,S;e[9]!==i||e[10]!==t?(C=()=>{t||i(null)},S=[t,i],e[9]=i,e[10]=t,e[11]=C,e[12]=S):(C=e[11],S=e[12]),g.useEffect(C,S);let y;e[13]!==r||e[14]!==k?(y=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=y):y=e[15];const F=y;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs(L,{className:"border-b p-4 pr-12",children:[n.jsxs(U,{className:"flex items-center gap-2 text-sm",children:[n.jsx(Q,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(Z,{children:"Preview a color theme and set the chat width."})]}),e[18]=E):E=e[18];const G=W[p];let c;e[19]!==G.id?(c=[G.id],e[19]=G.id,e[20]=c):c=e[20];let d;e[21]!==l||e[22]!==F?(d=W.map((a,D)=>n.jsxs(_,{value:a.id,className:"h-auto w-full justify-start gap-3 px-3 py-2.5 text-left text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>F(a),onMouseEnter:()=>P(D),onFocus:()=>P(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),l===a.id&&n.jsx(J,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=l,e[22]=F,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx($,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=v):v=e[27];let f;e[28]!==z?(f=[z],e[28]=z,e[29]=f):f=e[29];let u;e[30]!==A?(u=I.map(a=>n.jsx(_,{value:a.id,className:"flex-1 text-xs text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>A(a.id),children:a.name},a.id)),e[30]=A,e[31]=u):u=e[31];let h;e[32]!==f||e[33]!==u?(h=n.jsxs("div",{className:"border-t p-3",children:[v,n.jsx($,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let x;e[35]!==m||e[36]!==h?(x=n.jsxs(q,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[E,m,h]}),e[35]=m,e[36]=h,e[37]=x):x=e[37];let T;return e[38]!==t||e[39]!==x||e[40]!==o?(T=n.jsx(B,{open:t,onOpenChange:o,children:x}),e[38]=t,e[39]=x,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{de as ThemeSelectorModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as X,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{_ as le,aK as mt,aL as ft,aM as xt,aN as Ke,a2 as pe,aO as Ve,a3 as je,am as Se,an as Ce,B as ne,ao as Te,w as Ie,aI as Me,aE as Le,aF as Fe,l as De,aG as Ue,A as Ge,aP as pt,p as Qe,aQ as ht,aR as gt,aS as jt,E as ze,y as Ae,G as We,H as Oe,aT as bt,d as Nt,c as wt,S as yt,a as vt,aU as kt,b as St,q as Ct,z as Tt,al as It}from"./index-D6p4gVB_.js";import{M as Rt}from"./vendor-markdown-BE1gYnO9.js";import{V as Xe,W as Ze,Y as et,_ as $t,$ as Re,R as _t,O as tt,D as st,a0 as qe,m as zt,a1 as At,a2 as Wt,J as Ot,a3 as Ye,b as Pt,U as Et}from"./vendor-ui-RwWl1mlR.js";import"./vendor-shiki-DOn6sF-i.js";const Mt=new Set(["done","error","skipped"]);function He(l){return Mt.has(l)}function Lt(l){return l!=="completed"&&l!=="failed"&&l!=="killed"}function lt(l){switch(l){case"completed":return{label:"Completed",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"failed":return{label:"Failed",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"killed":return{label:"Stopped",badge:"border-warning/30 bg-warning/10 text-warning",dot:"bg-warning"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Ft(l){switch(l){case"done":return{label:"Done",badge:"border-success/30 bg-success/10 text-success",dot:"bg-success"};case"skipped":return{label:"Skipped",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};case"error":return{label:"Error",badge:"border-destructive/30 bg-destructive/10 text-destructive",dot:"bg-destructive"};case"queued":return{label:"Queued",badge:"border-border bg-muted/30 text-muted-foreground",dot:"bg-muted-foreground"};default:return{label:"Running",badge:"border-info/30 bg-info/10 text-info",dot:"bg-info"}}}function Dt(l){const e=new Map;l.phases.forEach((a,n)=>{const i=n+1;e.set(i,{index:i,title:a.title,detail:a.detail,agents:[]})});const t=[];for(const a of l.agents){const n=e.get(a.phaseIndex);n?n.agents.push(a):t.push(a)}const r=[...e.values()];t.length>0&&r.push({index:r.length+1,title:t[0].phaseTitle||"Other",agents:t});for(const a of r)a.agents.sort((n,i)=>n.index-i.index);return r}function Ut(l){return l.total===0?0:(l.done+l.error)/l.total}function nt(l){return l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}k`:`${l}`}const at=["headline","oneLineSell","verdict","summary","name","lens"],Bt=new Set(["title","name"]),Jt=new Set(["headline","oneLineSell","verdict"]);function Be(l){return typeof l=="object"&&l!==null&&!Array.isArray(l)}function rt(l){const e=l.trim();if(!e.startsWith("{")&&!e.startsWith("["))return l;try{return JSON.parse(e)}catch{return l}}function qt(l){try{return JSON.parse(`"${l}"`)}catch{return l.replace(/\\n/g," ").replace(/\\"/g,'"')}}function Yt(l){const e=rt(l);if(e!==l)return $e(e);for(const t of at){const r=l.match(new RegExp(`"${t}"\\s*:\\s*"((?:\\\\.|[^"\\\\])*)"`));if(r!=null&&r[1])return qt(r[1])}return l.replace(/^[#>*\s-]+/,"").replace(/[`*_#]/g,"").split(/\n\s*\n|\n/)[0].trim()}function $e(l){if(typeof l=="string")return Yt(l);if(typeof l=="number"||typeof l=="boolean")return String(l);if(Array.isArray(l))return l.length>0?$e(l[0]):"";if(Be(l))for(const e of at){const t=l[e];if(typeof t=="string"&&t.trim())return t.trim()}return""}function Je(l){if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}function Ht(l){const e={oneLineSell:"In one line",quickWins:"Quick wins",whatIsLost:"What is lost",whyItHurts:"Why it hurts",restingState:"Resting state",fatalFlaws:"Fatal flaws",bestIdeasRegardlessOfConcept:"Best ideas across concepts"};return e[l]?e[l]:l.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^./,t=>t.toUpperCase())}function it(l){const e=X.c(4),{children:t}=l;let r;e[0]!==t?(r=mt(t),e[0]=t,e[1]=r):r=e[1];const a=r;let n;return e[2]!==a?(n=s.jsx(Rt,{components:xt,remarkPlugins:ft,children:a}),e[2]=a,e[3]=n):n=e[3],n}function ot(l){const e=X.c(7),{value:t}=l;if(typeof t=="string"){let n;return e[0]!==t?(n=s.jsx(it,{children:t}),e[0]=t,e[1]=n):n=e[1],n}if(t===null){let n;return e[2]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground",children:"None"}),e[2]=n):n=e[2],n}if(typeof t=="boolean"){const n=t?"Yes":"No";let i;return e[3]!==n?(i=s.jsx("span",{children:n}),e[3]=n,e[4]=i):i=e[4],i}const r=String(t);let a;return e[5]!==r?(a=s.jsx("span",{children:r}),e[5]=r,e[6]=a):a=e[6],a}function Pe(l){const e=X.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Be(t)&&!Array.isArray(t)){let i;return e[0]!==t?(i=s.jsx(ot,{value:t}),e[0]=t,e[1]=i):i=e[1],i}if(a>5){let i;e[2]!==t?(i=Je(t),e[2]=t,e[3]=i):i=e[3];let o;return e[4]!==i?(o=s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs text-muted-foreground",children:i}),e[4]=i,e[5]=o):o=e[5],o}if(Array.isArray(t)){if(t.length===0){let d;return e[6]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"}),e[6]=d):d=e[6],d}if(t.every(Gt)){let d;e[7]!==t?(d=t.map(Vt),e[7]=t,e[8]=d):d=e[8];let u;return e[9]!==d?(u=s.jsx("ul",{className:"flex list-disc flex-col gap-2 pl-5 marker:text-muted-foreground",children:d}),e[9]=d,e[10]=u):u=e[10],u}let o;if(e[11]!==a||e[12]!==t){let d;e[14]!==a?(d=(u,c)=>s.jsx("article",{className:"border-l pl-4",children:s.jsx(Pe,{value:u,depth:a+1})},c),e[14]=a,e[15]=d):d=e[15],o=t.map(d),e[11]=a,e[12]=t,e[13]=o}else o=e[13];let m;return e[16]!==o?(m=s.jsx("div",{className:"flex flex-col gap-3",children:o}),e[16]=o,e[17]=m):m=e[17],m}let n;if(e[18]!==a||e[19]!==t){const i=Object.entries(t),o=i.find(Kt),m=i.filter(d=>{const[u]=d;return u!==(o==null?void 0:o[0])});n=s.jsxs("div",{className:"flex flex-col gap-4",children:[o&&s.jsx("h3",{className:le("font-semibold text-foreground",a===0?"text-lg":"text-base"),children:o[1]}),m.map(d=>{const[u,c]=d;return c===void 0?null:Jt.has(u)&&typeof c=="string"?s.jsx("div",{className:"border-l-2 border-foreground/30 pl-4 text-sm font-medium leading-relaxed",children:s.jsx(it,{children:c})},u):s.jsxs("section",{className:"flex min-w-0 flex-col gap-2",children:[s.jsx("h4",{className:"text-xs font-medium text-muted-foreground",children:Ht(u)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Pe,{value:c,depth:a+1})})]},u)})]}),e[18]=a,e[19]=t,e[20]=n}else n=e[20];return n}function Kt(l){const[e,t]=l;return Bt.has(e)&&typeof t=="string"&&t.trim().length>0}function Vt(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Gt(l){return!Be(l)&&!Array.isArray(l)}function Ee(l){const e=X.c(19),{value:t,className:r}=l;let a;e[0]!==t?(a=typeof t=="string"?rt(t):t,e[0]=t,e[1]=a):a=e[1];const n=a;if(typeof n=="string"&&(n.trim().startsWith("{")||n.trim().startsWith("["))){let u;e[2]!==n?(u=$e(n),e[2]=n,e[3]=u):u=e[3];const c=u;let f;e[4]!==r?(f=le("flex flex-col gap-2",r),e[4]=r,e[5]=f):f=e[5];let x;e[6]!==c?(x=c&&s.jsx("p",{className:"text-sm leading-relaxed text-foreground",children:c}),e[6]=c,e[7]=x):x=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx("p",{className:"text-xs text-muted-foreground",children:"Only a shortened preview was saved for this response."}),e[8]=h):h=e[8];let p;return e[9]!==f||e[10]!==x?(p=s.jsxs("div",{className:f,children:[x,h]}),e[9]=f,e[10]=x,e[11]=p):p=e[11],p}let o;e[12]!==r?(o=le("min-w-0 text-sm",r),e[12]=r,e[13]=o):o=e[13];let m;e[14]!==n?(m=s.jsx(Pe,{value:n}),e[14]=n,e[15]=m):m=e[15];let d;return e[16]!==o||e[17]!==m?(d=s.jsx("div",{className:o,children:m}),e[16]=o,e[17]=m,e[18]=d):d=e[18],d}function Qt(l){return l.replace(/\[[0-9;]*m\]/g,"")}function Xt(l){return(l.includes(":")?l.slice(l.indexOf(":")+1):l).replace(/[-_]+/g," ")}function Zt(l){const e=X.c(135),{agent:t,dirName:r,sessionId:a,runId:n}=l,[i,o]=C.useState(!1),[m,d]=C.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={status:"idle"},e[0]=u):u=e[0];const[c,f]=C.useState(u),[x,h]=Ke();let p,j,b,N,S,w,v,g,T,R,A,Y,I,y,k,$,W,_,O,P,z;if(e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==c.status||e[5]!==c.value||e[6]!==n||e[7]!==a){T=Ft(t.state);let Ne;e[29]!==t.state?(Ne=!He(t.state)&&t.state!=="queued",e[29]=t.state,e[30]=Ne):Ne=e[30],g=Ne;let we;e[31]!==t.resultPreview?(we=t.resultPreview?$e(t.resultPreview):"",e[31]=t.resultPreview,e[32]=we):we=e[32];const ye=we;let ve;e[33]!==t.agentId||e[34]!==r||e[35]!==n||e[36]!==a?(ve=async()=>{f({status:"loading"});try{const he=await Ie(`/api/workflow-agent-result/${encodeURIComponent(r)}/${encodeURIComponent(a)}/${encodeURIComponent(n)}/${encodeURIComponent(t.agentId)}`);if(!he.ok){f({status:"unavailable"});return}const ut=await he.json();f({status:"loaded",value:ut.result})}catch{f({status:"unavailable"})}},e[33]=t.agentId,e[34]=r,e[35]=n,e[36]=a,e[37]=ve):ve=e[37],v=ve;let ke;e[38]!==t.state||e[39]!==v||e[40]!==c.status?(ke=he=>{o(he),he&&c.status==="idle"&&He(t.state)&&v()},e[38]=t.state,e[39]=v,e[40]=c.status,e[41]=ke):ke=e[41];const ct=ke;z=c.status==="loaded"?c.value:t.resultPreview,w=c.status==="unavailable",S=Se,A=i,Y=ct,N=Me,P="sm",R="motion-card motion-list-item gap-0 py-0",b=Le,O="px-0 py-0",j=Ce,$="group flex w-full items-start gap-3 rounded-lg px-3.5 py-3 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",W=s.jsx("span",{className:le("mt-1.5 size-2 shrink-0 rounded-full",T.dot)});const dt=t.label;let ae;e[42]!==t.label?(ae=Xt(t.label),e[42]=t.label,e[43]=ae):ae=e[43];let re;e[44]!==t.label||e[45]!==ae?(re=s.jsx(Fe,{className:"truncate capitalize",title:dt,children:ae}),e[44]=t.label,e[45]=ae,e[46]=re):re=e[46];let ie;e[47]!==t.attempt?(ie=t.attempt&&t.attempt>1&&s.jsxs(pe,{variant:"outline",className:"text-muted-foreground",children:["Attempt ",t.attempt]}),e[47]=t.attempt,e[48]=ie):ie=e[48];let oe;e[49]!==re||e[50]!==ie?(oe=s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[re,ie]}),e[49]=re,e[50]=ie,e[51]=oe):oe=e[51];let ce;e[52]!==t.lastToolName||e[53]!==t.lastToolSummary||e[54]!==g||e[55]!==ye?(ce=ye?s.jsx("p",{className:"mt-1 line-clamp-2 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:ye}):g&&t.lastToolName?s.jsxs("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:["Working in ",t.lastToolName,t.lastToolSummary?`: ${t.lastToolSummary}`:""]}):null,e[52]=t.lastToolName,e[53]=t.lastToolSummary,e[54]=g,e[55]=ye,e[56]=ce):ce=e[56];let de;e[57]!==t.model?(de=t.model&&s.jsx("span",{children:Qt(t.model)}),e[57]=t.model,e[58]=de):de=e[58];let ue;e[59]!==t.tokens?(ue=typeof t.tokens=="number"&&t.tokens>0&&s.jsxs(_e,{icon:Xe,children:[nt(t.tokens)," tokens"]}),e[59]=t.tokens,e[60]=ue):ue=e[60];let me;e[61]!==t.toolCalls?(me=typeof t.toolCalls=="number"&&t.toolCalls>0&&s.jsxs(_e,{icon:Ze,children:[t.toolCalls," tools"]}),e[61]=t.toolCalls,e[62]=me):me=e[62];let fe;e[63]!==t.durationMs?(fe=typeof t.durationMs=="number"&&s.jsx(_e,{icon:et,children:Ve(t.durationMs)}),e[63]=t.durationMs,e[64]=fe):fe=e[64];let xe;e[65]!==de||e[66]!==ue||e[67]!==me||e[68]!==fe?(xe=s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[de,ue,me,fe]}),e[65]=de,e[66]=ue,e[67]=me,e[68]=fe,e[69]=xe):xe=e[69],e[70]!==oe||e[71]!==ce||e[72]!==xe?(_=s.jsxs("div",{className:"min-w-0 flex-1",children:[oe,ce,xe]}),e[70]=oe,e[71]=ce,e[72]=xe,e[73]=_):_=e[73],k="flex shrink-0 items-center gap-2",p=pe,I="outline",y=le("hidden sm:inline-flex",T.badge),e[1]=t,e[2]=r,e[3]=i,e[4]=c.status,e[5]=c.value,e[6]=n,e[7]=a,e[8]=p,e[9]=j,e[10]=b,e[11]=N,e[12]=S,e[13]=w,e[14]=v,e[15]=g,e[16]=T,e[17]=R,e[18]=A,e[19]=Y,e[20]=I,e[21]=y,e[22]=k,e[23]=$,e[24]=W,e[25]=_,e[26]=O,e[27]=P,e[28]=z}else p=e[8],j=e[9],b=e[10],N=e[11],S=e[12],w=e[13],v=e[14],g=e[15],T=e[16],R=e[17],A=e[18],Y=e[19],I=e[20],y=e[21],k=e[22],$=e[23],W=e[24],_=e[25],O=e[26],P=e[27],z=e[28];let E;e[74]!==g?(E=g&&s.jsx(je,{"data-icon":"inline-start"}),e[74]=g,e[75]=E):E=e[75];let Z;e[76]!==p||e[77]!==T.label||e[78]!==E||e[79]!==I||e[80]!==y?(Z=s.jsxs(p,{variant:I,className:y,children:[E,T.label]}),e[76]=p,e[77]=T.label,e[78]=E,e[79]=I,e[80]=y,e[81]=Z):Z=e[81];let H;e[82]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx(Re,{className:"mt-0.5 size-4 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"}),e[82]=H):H=e[82];let M;e[83]!==Z||e[84]!==k?(M=s.jsxs("div",{className:k,children:[Z,H]}),e[83]=Z,e[84]=k,e[85]=M):M=e[85];let L;e[86]!==j||e[87]!==M||e[88]!==$||e[89]!==W||e[90]!==_?(L=s.jsxs(j,{className:$,children:[W,_,M]}),e[86]=j,e[87]=M,e[88]=$,e[89]=W,e[90]=_,e[91]=L):L=e[91];let ee;e[92]!==b||e[93]!==L||e[94]!==O?(ee=s.jsx(b,{className:O,children:L}),e[92]=b,e[93]=L,e[94]=O,e[95]=ee):ee=e[95];let K;e[96]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(De,{}),e[96]=K):K=e[96];let V;e[97]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:"Response"}),e[97]=V):V=e[97];const te=c.status==="loaded"?"Complete agent response":"Saved response preview";let F;e[98]!==te?(F=s.jsxs("div",{children:[V,s.jsx("p",{className:"text-xs text-muted-foreground",children:te})]}),e[98]=te,e[99]=F):F=e[99];let D;e[100]!==w||e[101]!==v?(D=w&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>void v(),children:[s.jsx(_t,{"data-icon":"inline-start"}),"Retry"]}),e[100]=w,e[101]=v,e[102]=D):D=e[102];let U;e[103]!==x||e[104]!==h||e[105]!==z?(U=z!==void 0&&s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>h(Je(z)),"aria-label":x?"Response copied":"Copy response",title:x?"Copied":"Copy response",children:x?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})}),e[103]=x,e[104]=h,e[105]=z,e[106]=U):U=e[106];let B;e[107]!==D||e[108]!==U?(B=s.jsxs("div",{className:"flex items-center gap-1",children:[D,U]}),e[107]=D,e[108]=U,e[109]=B):B=e[109];let J;e[110]!==F||e[111]!==B?(J=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[F,B]}),e[110]=F,e[111]=B,e[112]=J):J=e[112];let q;e[113]!==c.status||e[114]!==g||e[115]!==z?(q=c.status==="loading"?s.jsxs("div",{className:"flex items-center gap-2 py-5 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading the complete response…"]}):z!==void 0?s.jsx(Ee,{value:z}):s.jsx("p",{className:"text-sm text-muted-foreground",children:g?"This agent has not returned a response yet.":"No response was saved for this agent."}),e[113]=c.status,e[114]=g,e[115]=z,e[116]=q):q=e[116];let G;e[117]!==t.promptPreview||e[118]!==m?(G=t.promptPreview&&s.jsxs(Se,{open:m,onOpenChange:d,children:[s.jsxs(Ce,{render:s.jsx(ne,{variant:"ghost",size:"sm",className:"w-full justify-start"}),children:[s.jsx($t,{"data-icon":"inline-start"}),"Agent prompt",s.jsx(Re,{"data-icon":"inline-end",className:le("ml-auto transition-transform",m&&"rotate-180")})]}),s.jsx(Te,{className:"pt-2",children:s.jsx("div",{className:"rounded-md border bg-muted/30 p-3 text-xs leading-relaxed text-muted-foreground",children:s.jsx(Ee,{value:t.promptPreview})})})]}),e[117]=t.promptPreview,e[118]=m,e[119]=G):G=e[119];let Q;e[120]!==J||e[121]!==q||e[122]!==G?(Q=s.jsxs(Te,{children:[K,s.jsxs(Ue,{className:"flex flex-col gap-4 px-4 py-4",children:[J,q,G]})]}),e[120]=J,e[121]=q,e[122]=G,e[123]=Q):Q=e[123];let se;e[124]!==N||e[125]!==R||e[126]!==ee||e[127]!==Q||e[128]!==P?(se=s.jsxs(N,{size:P,className:R,children:[ee,Q]}),e[124]=N,e[125]=R,e[126]=ee,e[127]=Q,e[128]=P,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==Y||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:Y,children:se}),e[130]=S,e[131]=A,e[132]=Y,e[133]=se,e[134]=be):be=e[134],be}function _e(l){const e=X.c(5),{icon:t,children:r}=l;let a;e[0]!==t?(a=s.jsx(t,{className:"size-3"}),e[0]=t,e[1]=a):a=e[1];let n;return e[2]!==r||e[3]!==a?(n=s.jsxs("span",{className:"inline-flex items-center gap-1",children:[a,r]}),e[2]=r,e[3]=a,e[4]=n):n=e[4],n}function es(l){const e=X.c(102),{detail:t,dirName:r,sessionId:a,stopping:n,confirming:i,onForceStop:o}=l;let m,d,u,c,f,x,h,p;if(e[0]!==i||e[1]!==t||e[2]!==r||e[3]!==o||e[4]!==a||e[5]!==n){const w=lt(t.status);let v;e[14]!==t.status?(v=Lt(t.status),e[14]=t.status,e[15]=v):v=e[15];const g=v,T=Dt(t),R=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const Y=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let I;e[16]!==w||e[17]!==Y?(I=s.jsxs(pe,{variant:"outline",className:w.badge,children:[Y,w.label]}),e[16]=w,e[17]=Y,e[18]=I):I=e[18];let y;e[19]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx("span",{className:"text-xs text-muted-foreground",children:"Workflow run"}),e[19]=y):y=e[19];let k;e[20]!==I?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[I,y]}),e[20]=I,e[21]=k):k=e[21];let $;e[22]!==t.workflowName?($=s.jsx("h2",{className:"text-xl font-semibold tracking-tight text-foreground",title:t.workflowName,children:t.workflowName}),e[22]=t.workflowName,e[23]=$):$=e[23];let W;e[24]!==t.summary?(W=t.summary&&s.jsx("p",{className:"mt-1.5 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=W):W=e[25];let _;e[26]!==k||e[27]!==$||e[28]!==W?(_=s.jsxs("div",{className:"min-w-0",children:[k,$,W]}),e[26]=k,e[27]=$,e[28]=W,e[29]=_):_=e[29];let O;e[30]!==g||e[31]!==A||e[32]!==i||e[33]!==o||e[34]!==n?(O=g&&s.jsxs("div",{className:"flex shrink-0 flex-col items-start gap-1 sm:items-end",children:[s.jsxs(ne,{variant:i?"destructive":"outline",size:"sm",disabled:!A||n,onClick:o,children:[n?s.jsx(je,{"data-icon":"inline-start"}):s.jsx(qe,{"data-icon":"inline-start"}),i?"Confirm stop":"Stop workflow"]}),!A&&s.jsx("span",{className:"text-xs text-muted-foreground",children:"This run is not controlled by Cogpit"})]}),e[30]=g,e[31]=A,e[32]=i,e[33]=o,e[34]=n,e[35]=O):O=e[35];let P;e[36]!==_||e[37]!==O?(P=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,O]}),e[36]=_,e[37]=O,e[38]=P):P=e[38];const z=`${t.agentCounts.done+t.agentCounts.error}/${t.agentCount}`;let E;e[39]!==z?(E=s.jsx(ge,{icon:At,value:z,label:"Agents finished"}),e[39]=z,e[40]=E):E=e[40];const Z=String(t.phaseCount);let H;e[41]!==Z?(H=s.jsx(ge,{icon:Wt,value:Z,label:"Phases"}),e[41]=Z,e[42]=H):H=e[42];let M;e[43]!==t.totalTokens?(M=nt(t.totalTokens),e[43]=t.totalTokens,e[44]=M):M=e[44];let L;e[45]!==M?(L=s.jsx(ge,{icon:Xe,value:M,label:"Tokens"}),e[45]=M,e[46]=L):L=e[46];const ee=String(t.totalToolCalls);let K;e[47]!==ee?(K=s.jsx(ge,{icon:Ze,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=K):K=e[48];let V;e[49]!==t.durationMs?(V=typeof t.durationMs=="number"?Ve(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=V):V=e[50];let te;e[51]!==V?(te=s.jsx(ge,{icon:et,value:V,label:"Duration",className:"col-span-2 sm:col-span-1"}),e[51]=V,e[52]=te):te=e[52];let F;e[53]!==E||e[54]!==H||e[55]!==L||e[56]!==K||e[57]!==te?(F=s.jsxs("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border sm:grid-cols-5",children:[E,H,L,K,te]}),e[53]=E,e[54]=H,e[55]=L,e[56]=K,e[57]=te,e[58]=F):F=e[58];let D;e[59]!==R?(D=Math.round(R*100),e[59]=R,e[60]=D):D=e[60];let U;e[61]!==D?(U=s.jsx(jt,{value:D,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=D,e[62]=U):U=e[62];let B;e[63]!==R?(B=Math.round(R*100),e[63]=R,e[64]=B):B=e[64];let J;e[65]!==B?(J=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[B,"%"]}),e[65]=B,e[66]=J):J=e[66];let q;e[67]!==U||e[68]!==J?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,J]}),e[67]=U,e[68]=J,e[69]=q):q=e[69],e[70]!==P||e[71]!==F||e[72]!==q?(x=s.jsxs("section",{className:"flex flex-col gap-4",children:[P,F,q]}),e[70]=P,e[71]=F,e[72]=q,e[73]=x):x=e[73],e[74]!==t.error?(h=t.error&&s.jsxs(Ge,{variant:"destructive",children:[s.jsx(qe,{}),s.jsx(pt,{children:"Workflow error"}),s.jsx(Qe,{children:s.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-xs",children:t.error})})]}),e[74]=t.error,e[75]=h):h=e[75],e[76]!==t.resultPreview||e[77]!==t.runId||e[78]!==r||e[79]!==a?(p=t.resultPreview&&s.jsx(ns,{preview:t.resultPreview,dirName:r,sessionId:a,runId:t.runId}),e[76]=t.resultPreview,e[77]=t.runId,e[78]=r,e[79]=a,e[80]=p):p=e[80],u="grid items-start gap-6 md:grid-cols-[180px_minmax(0,1fr)]";let G;e[81]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=G):G=e[81],c=s.jsxs("nav",{className:"sticky top-0 hidden rounded-lg border bg-card p-2 md:block","aria-label":"Workflow phases",children:[G,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="flex min-w-0 flex-col gap-8";let Q;e[82]!==t.runId||e[83]!==r||e[84]!==a?(Q=se=>s.jsx(ss,{group:se,dirName:r,sessionId:a,runId:t.runId},`${se.index}-${se.title}`),e[82]=t.runId,e[83]=r,e[84]=a,e[85]=Q):Q=e[85],d=T.map(Q),e[0]=i,e[1]=t,e[2]=r,e[3]=o,e[4]=a,e[5]=n,e[6]=m,e[7]=d,e[8]=u,e[9]=c,e[10]=f,e[11]=x,e[12]=h,e[13]=p}else m=e[6],d=e[7],u=e[8],c=e[9],f=e[10],x=e[11],h=e[12],p=e[13];let j;e[86]!==m||e[87]!==d?(j=s.jsx("div",{className:m,children:d}),e[86]=m,e[87]=d,e[88]=j):j=e[88];let b;e[89]!==u||e[90]!==c||e[91]!==j?(b=s.jsxs("div",{className:u,children:[c,j]}),e[89]=u,e[90]=c,e[91]=j,e[92]=b):b=e[92];let N;e[93]!==t.script?(N=t.script&&s.jsx(as,{script:t.script}),e[93]=t.script,e[94]=N):N=e[94];let S;return e[95]!==b||e[96]!==N||e[97]!==f||e[98]!==x||e[99]!==h||e[100]!==p?(S=s.jsxs("div",{className:f,children:[x,h,p,b,N]}),e[95]=b,e[96]=N,e[97]=f,e[98]=x,e[99]=h,e[100]=p,e[101]=S):S=e[101],S}function ts(l){return s.jsxs(ne,{variant:"ghost",size:"sm",type:"button",onClick:()=>{var e;return(e=document.getElementById(`workflow-phase-${l.index}`))==null?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs text-muted-foreground",children:[s.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-xs font-medium text-foreground",children:l.index}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.title}),s.jsx("span",{className:"tabular-nums",children:l.agents.length})]},`${l.index}-${l.title}`)}function ge(l){const e=X.c(15),{icon:t,value:r,label:a,className:n}=l;let i;e[0]!==n?(i=le("flex items-center gap-2.5 bg-card px-3 py-3",n),e[0]=n,e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsx(t,{className:"size-4 shrink-0 text-muted-foreground"}),e[2]=t,e[3]=o):o=e[3];let m;e[4]!==r?(m=s.jsx("p",{className:"truncate text-sm font-semibold tabular-nums text-foreground",children:r}),e[4]=r,e[5]=m):m=e[5];let d;e[6]!==a?(d=s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a}),e[6]=a,e[7]=d):d=e[7];let u;e[8]!==m||e[9]!==d?(u=s.jsxs("div",{className:"min-w-0",children:[m,d]}),e[8]=m,e[9]=d,e[10]=u):u=e[10];let c;return e[11]!==i||e[12]!==o||e[13]!==u?(c=s.jsxs("div",{className:i,children:[o,u]}),e[11]=i,e[12]=o,e[13]=u,e[14]=c):c=e[14],c}function ss(l){const e=X.c(29),{group:t,dirName:r,sessionId:a,runId:n}=l;let i;e[0]!==t.agents?(i=t.agents.filter(ls),e[0]=t.agents,e[1]=i):i=e[1];const o=i.length,m=`workflow-phase-${t.index}`;let d;e[2]!==t.index?(d=s.jsx("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-lg bg-primary text-xs font-semibold text-primary-foreground",children:t.index}),e[2]=t.index,e[3]=d):d=e[3];let u;e[4]!==t.title?(u=s.jsx("h3",{className:"text-base font-semibold text-foreground",children:t.title}),e[4]=t.title,e[5]=u):u=e[5];let c;e[6]!==o||e[7]!==t.agents.length?(c=s.jsxs("span",{className:"text-xs text-muted-foreground",children:[o,"/",t.agents.length," complete"]}),e[6]=o,e[7]=t.agents.length,e[8]=c):c=e[8];let f;e[9]!==u||e[10]!==c?(f=s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[u,c]}),e[9]=u,e[10]=c,e[11]=f):f=e[11];let x;e[12]!==t.detail?(x=t.detail&&s.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.detail}),e[12]=t.detail,e[13]=x):x=e[13];let h;e[14]!==f||e[15]!==x?(h=s.jsxs("div",{className:"min-w-0 flex-1",children:[f,x]}),e[14]=f,e[15]=x,e[16]=h):h=e[16];let p;e[17]!==d||e[18]!==h?(p=s.jsxs("div",{className:"mb-3 flex items-start gap-3",children:[d,h]}),e[17]=d,e[18]=h,e[19]=p):p=e[19];let j;e[20]!==r||e[21]!==t.agents||e[22]!==n||e[23]!==a?(j=t.agents.length===0?s.jsx(ze,{className:"border py-6",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"No agents yet"}),s.jsx(Oe,{children:"No agents have started this phase."})]})}):s.jsx("div",{className:"flex flex-col gap-2",children:t.agents.map(N=>s.jsx(Zt,{agent:N,dirName:r,sessionId:a,runId:n},`${n}:${N.agentId||N.index}`))}),e[20]=r,e[21]=t.agents,e[22]=n,e[23]=a,e[24]=j):j=e[24];let b;return e[25]!==j||e[26]!==m||e[27]!==p?(b=s.jsxs("section",{id:m,className:"scroll-mt-4",children:[p,j]}),e[25]=j,e[26]=m,e[27]=p,e[28]=b):b=e[28],b}function ls(l){return l.state==="done"||l.state==="skipped"}function ns({preview:l,dirName:e,sessionId:t,runId:r}){const[a,n]=C.useState(!0),[i,o]=C.useState(),[m,d]=C.useState(!1),[u,c]=C.useState(!1),[f,x]=Ke(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Ie(`/api/workflow-result/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${encodeURIComponent(r)}`);if(!b.ok){c(!0);return}const N=await b.json();o(N.result)}catch{c(!0)}finally{d(!1)}},[e,r,t]);return s.jsx(Se,{open:a,onOpenChange:n,children:s.jsxs(Me,{className:"motion-enter gap-0 py-0",children:[s.jsxs(Le,{className:"py-4",children:[s.jsxs(Ce,{className:"group flex min-w-0 items-center gap-3 text-left outline-none",children:[s.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:s.jsx(zt,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx(Fe,{children:"Workflow outcome"}),s.jsx(ht,{children:"The synthesized answer from this run"})]}),s.jsx(Re,{className:"size-4 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"})]}),s.jsxs(gt,{className:"flex items-center gap-1",children:[h&&i===void 0&&s.jsxs(ne,{variant:"outline",size:"sm",disabled:m,onClick:()=>void j(),children:[m&&s.jsx(je,{"data-icon":"inline-start"}),u?"Retry full result":"Load full result"]}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:()=>x(Je(p)),"aria-label":f?"Outcome copied":"Copy outcome",title:f?"Copied":"Copy outcome",children:f?s.jsx(tt,{"data-icon":"inline-start"}):s.jsx(st,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(De,{}),s.jsx(Ue,{className:"py-5",children:s.jsx(Ee,{value:p})})]})]})})}function as(l){const e=X.c(7),{script:t}=l,[r,a]=C.useState(!1);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Le,{className:"px-0 py-0",children:s.jsxs(Ce,{className:"group flex w-full items-center gap-2 px-3 py-3 text-left text-sm font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/40 hover:text-foreground",children:[s.jsx(Ot,{className:"size-4"}),s.jsx(Fe,{children:"Orchestration script"}),s.jsx(Re,{className:"ml-auto size-4 transition-transform group-data-panel-open:rotate-180"})]})}),e[0]=n):n=e[0];let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(De,{}),e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsxs(Me,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[i,s.jsx(Ue,{className:"py-3",children:s.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted p-3 text-xs leading-relaxed text-muted-foreground",children:t})})]})]}),e[2]=t,e[3]=o):o=e[3];let m;return e[4]!==r||e[5]!==o?(m=s.jsx(Se,{open:r,onOpenChange:a,children:o}),e[4]=r,e[5]=o,e[6]=m):m=e[6],m}function ms({open:l,onOpenChange:e,dirName:t,sessionId:r,workflows:a,isLive:n,onRefetchList:i}){var I;const[o,m]=C.useState(null),[d,u]=C.useState(!1),[c,f]=C.useState(null),[x,h]=C.useState(!1),[p,j]=C.useState(!1),[b,N]=C.useState(!1),[S,w]=C.useState(null),v=C.useRef(0),g=d?null:o&&a.some(y=>y.runId===o)?o:((I=a[0])==null?void 0:I.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Ie(`/api/workflow-detail/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(g)}`);if(!k.ok){y===v.current&&f(null);return}const $=await k.json();y===v.current&&f($)}catch{y===v.current&&f(null)}finally{y===v.current&&h(!1)}},[t,r,g]);C.useEffect(()=>{if(!g){f(null);return}f(null),h(!0),N(!1),w(null),T()},[g,T]),bt(l?t:null,l?r:null,l?g:null,()=>{T(),i()});const R=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Ie("/api/workflow-stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:r,runId:g})})).json().catch(()=>({}));k!=null&&k.success?w("Stop signal sent."):(k==null?void 0:k.controllable)===!1?w("This workflow runs in a session Cogpit doesn't control."):w("Couldn't stop. The session may have already exited."),T(),i()}catch{w("Stop request failed.")}finally{j(!1),N(!1)}}},[b,r,g,T,i]),A=a.length>1,Y=a.find(y=>y.runId===g);return s.jsx(Nt,{open:l,onOpenChange:e,children:s.jsxs(wt,{side:"right",className:"w-full data-[side=right]:max-w-[1120px]",children:[s.jsx(yt,{className:"min-h-14 justify-center border-b py-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 pr-9",children:[s.jsxs(vt,{className:"flex items-center gap-2",children:[s.jsx(Ye,{className:"size-4"}),"Workflows",a.length>0&&s.jsx(pe,{variant:"secondary",children:a.length}),n&&s.jsxs(pe,{variant:"outline",className:"border-info/30 text-info",children:[s.jsx(kt,{className:"size-1.5"}),"Live"]})]}),s.jsx(St,{className:"sr-only",children:"Inspect workflow runs, agent progress, and run controls for this session."}),s.jsx(ne,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Refresh workflows",title:"Refresh workflows",children:s.jsx(Pt,{"data-icon":"inline-start"})})]})}),s.jsx(Ct,{className:"h-[calc(100dvh-3.5rem)]",children:s.jsx("div",{className:"px-5 py-6 sm:px-6",children:a.length===0?s.jsx(ze,{className:"min-h-[60dvh]",children:s.jsxs(Ae,{children:[s.jsx(Tt,{variant:"icon",children:s.jsx(Ye,{})}),s.jsx(We,{children:"No workflows in this session"}),s.jsx(Oe,{children:"Phases, agents, and their responses will appear here when this session starts a workflow."})]})}):s.jsxs(s.Fragment,{children:[A&&s.jsxs("div",{className:"mb-6 flex flex-col gap-2",children:[g&&c&&s.jsxs(ne,{variant:"ghost",size:"sm",onClick:()=>u(!0),className:"w-fit px-2 text-muted-foreground",children:[s.jsx(Et,{"data-icon":"inline-start"}),"All runs"]}),(!g||!c)&&a.map(y=>s.jsx(rs,{workflow:y,active:y.runId===g,onClick:()=>{m(y.runId),u(!1)}},y.runId))]}),x&&!c?s.jsxs("div",{className:"flex min-h-[50dvh] items-center justify-center gap-2 text-sm text-muted-foreground",children:[s.jsx(je,{}),"Loading workflow…"]}):c?s.jsxs(s.Fragment,{children:[S&&s.jsx(Ge,{className:"mb-4",children:s.jsx(Qe,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:R})]}):Y?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Oe,{children:"The journal may have moved or the run may no longer be available."})]})}):null]})})})]})})}function rs(l){const e=X.c(45),{workflow:t,active:r,onClick:a}=l;let n,i,o,m,d,u,c;if(e[0]!==r||e[1]!==a||e[2]!==t.agentCounts.done||e[3]!==t.agentCounts.error||e[4]!==t.status){o=lt(t.status),i=t.agentCounts.done+t.agentCounts.error,n=ne,d="ghost",u=a;const g=r?"border-foreground/20 bg-accent":"bg-background hover:bg-muted/50";e[12]!==g?(c=le("h-auto w-full justify-start gap-3 whitespace-normal border px-3 py-3 text-left",g),e[12]=g,e[13]=c):c=e[13],m=le("size-2 shrink-0 rounded-full",o.dot),e[0]=r,e[1]=a,e[2]=t.agentCounts.done,e[3]=t.agentCounts.error,e[4]=t.status,e[5]=n,e[6]=i,e[7]=o,e[8]=m,e[9]=d,e[10]=u,e[11]=c}else n=e[5],i=e[6],o=e[7],m=e[8],d=e[9],u=e[10],c=e[11];let f;e[14]!==m?(f=s.jsx("span",{className:m}),e[14]=m,e[15]=f):f=e[15];let x;e[16]!==t.workflowName?(x=s.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:t.workflowName}),e[16]=t.workflowName,e[17]=x):x=e[17];let h;e[18]!==o.badge||e[19]!==o.label?(h=s.jsx(pe,{variant:"outline",className:o.badge,children:o.label}),e[18]=o.badge,e[19]=o.label,e[20]=h):h=e[20];let p;e[21]!==x||e[22]!==h?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,h]}),e[21]=x,e[22]=h,e[23]=p):p=e[23];let j;e[24]!==t.summary?(j=t.summary&&s.jsx("p",{className:"mt-1 line-clamp-1 text-xs text-muted-foreground",children:t.summary}),e[24]=t.summary,e[25]=j):j=e[25];let b;e[26]!==i||e[27]!==t.agentCount?(b=s.jsxs("span",{children:[i,"/",t.agentCount," agents"]}),e[26]=i,e[27]=t.agentCount,e[28]=b):b=e[28];let N;e[29]!==t.startTime?(N=t.startTime>0&&s.jsx("span",{children:It(new Date(t.startTime).toISOString())}),e[29]=t.startTime,e[30]=N):N=e[30];let S;e[31]!==b||e[32]!==N?(S=s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-xs text-muted-foreground",children:[b,N]}),e[31]=b,e[32]=N,e[33]=S):S=e[33];let w;e[34]!==S||e[35]!==p||e[36]!==j?(w=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,j,S]}),e[34]=S,e[35]=p,e[36]=j,e[37]=w):w=e[37];let v;return e[38]!==n||e[39]!==w||e[40]!==d||e[41]!==u||e[42]!==c||e[43]!==f?(v=s.jsxs(n,{variant:d,onClick:u,className:c,children:[f,w]}),e[38]=n,e[39]=w,e[40]=d,e[41]=u,e[42]=c,e[43]=f,e[44]=v):v=e[44],v}export{ms as WorkflowsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as Y,j as t,r as v}from"./vendor-react-gGw_S5I_.js";import{_ as Ye,V as le,aV as Ee,aW as J,m as dt,n as ut,I as ft,W as Ct,X as _t,aX as At,B as ce,aY as mt,w as Ie,aZ as ht,am as xt,an as pt,ao as gt,a_ as nt,a2 as et,a$ as $t,aw as Et,ax as zt,b0 as jt,i as Tt,j as It,k as Dt,b1 as Pt,U as Lt,a8 as Ft,h as Rt,D as Ut}from"./index-D6p4gVB_.js";import{a5 as Bt,a6 as Ot,a7 as Vt,a8 as Mt,e as Ht,T as Gt,M as Wt,a9 as Xt,aa as qt,ab as Kt,$ as bt,C as vt,ac as it,ad as Jt,F as Yt,A as Zt,ae as Qt,J as es,af as ts,ag as ss}from"./vendor-ui-RwWl1mlR.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function ns(s){const e=Y.c(11);let n,a,i;e[0]!==s?({className:n,size:i,...a}=s,e[0]=s,e[1]=n,e[2]=a,e[3]=i):(n=e[1],a=e[2],i=e[3]);const r=i===void 0?"default":i;let l;e[4]!==n?(l=Ye("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",n),e[4]=n,e[5]=l):l=e[5];let f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(Ot,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"}),e[6]=f):f=e[6];let c;return e[7]!==a||e[8]!==r||e[9]!==l?(c=t.jsx(Bt,{"data-slot":"switch","data-size":r,className:l,...a,children:f}),e[7]=a,e[8]=r,e[9]=l,e[10]=c):c=e[10],c}function as(s){const e=Y.c(3),{name:n}=s,a=n.toLowerCase();if(a.includes("iphone")||a.includes("android")){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ht,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=r):r=e[0],r}if(a.includes("ipad")||a.includes("tablet")){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Gt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[1]=r):r=e[1],r}let i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(Wt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[2]=i):i=e[2],i}function at(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const n=Math.floor(e/60);if(n<60)return`${n}m ago`;const a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function is(s){const e=[`Shared ${at(s.createdAt)}`,s.lastAccessAt>0?`opened ${at(s.lastAccessAt)}`:"never opened"];return s.guests>0&&e.push(s.guests===1?"1 guest":`${s.guests} guests`),e.join(" · ")}function ls(){const s=Y.c(12),{shares:e,revoke:n,revokeAll:a}=At();let i;s[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Shared sessions"}),s[0]=i):i=s[0];let r;s[1]!==a||s[2]!==e.length?(r=e.length>0&&t.jsx(ce,{variant:"ghost",size:"xs",className:"text-destructive hover:text-destructive",onClick:()=>void a(),children:"Revoke all"}),s[1]=a,s[2]=e.length,s[3]=r):r=s[3];let l;s[4]!==r?(l=t.jsxs("div",{className:"flex h-6 items-center justify-between",children:[i,r]}),s[4]=r,s[5]=l):l=s[5];let f;s[6]!==n||s[7]!==e?(f=e.length===0?t.jsx("p",{className:"text-xs text-muted-foreground",children:"No sessions are shared."}):t.jsx("div",{className:"flex flex-col gap-1.5",children:e.map(o=>{const m=o.title||o.sessionId;return t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm text-foreground",children:m}),t.jsx("p",{className:"text-xs text-muted-foreground",children:is(o)})]}),t.jsx(ce,{variant:"ghost",size:"xs","aria-label":`Revoke share of ${m}`,className:"text-destructive hover:text-destructive",onClick:()=>void n(o.sessionId),children:"Revoke"})]},o.sessionId)})}),s[6]=n,s[7]=e,s[8]=f):f=s[8];let c;return s[9]!==l||s[10]!==f?(c=t.jsxs("div",{className:"flex flex-col gap-2",children:[l,f]}),s[9]=l,s[10]=f,s[11]=c):c=s[11],c}function rs(s){const e=Y.c(30),{networkAccess:n,setNetworkAccess:a,networkPassword:i,setNetworkPassword:r,showNetworkPassword:l,setShowNetworkPassword:f,hasExistingPassword:c,initialNetworkAccess:o,connectedDevices:m,minPasswordLength:b}=s;let x;e[0]!==n?(x=n?t.jsx(Xt,{"data-icon":"inline-start",className:"size-4 text-success"}):t.jsx(qt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[0]=n,e[1]=x):x=e[1];let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Network Access"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow other devices to connect"})]}),e[2]=j):j=e[2];let y;e[3]!==x?(y=t.jsxs("div",{className:"flex items-center gap-2",children:[x,j]}),e[3]=x,e[4]=y):y=e[4];let C;e[5]!==a?(C=_=>a(_),e[5]=a,e[6]=C):C=e[6];let w;e[7]!==n||e[8]!==C?(w=t.jsx(ns,{"aria-label":"Network Access",checked:n,onCheckedChange:C}),e[7]=n,e[8]=C,e[9]=w):w=e[9];let N;e[10]!==y||e[11]!==w?(N=t.jsxs("div",{className:"flex items-center justify-between",children:[y,w]}),e[10]=y,e[11]=w,e[12]=N):N=e[12];let p;e[13]!==c||e[14]!==b||e[15]!==n||e[16]!==i||e[17]!==r||e[18]!==f||e[19]!==l?(p=n&&t.jsxs(le,{"data-invalid":i.length>0&&i.length<b,children:[t.jsx(Ee,{htmlFor:"network-password",children:"Password"}),t.jsx(J,{children:c&&i.length===0?"A password is already set. Leave blank to keep it.":`Use at least ${b} characters.`}),t.jsxs(dt,{children:[t.jsx(ut,{id:"network-password",type:l?"text":"password",value:i,onChange:_=>r(_.target.value),placeholder:c?"Enter new password to change":"Set a password for remote access"}),t.jsx(ft,{align:"inline-end",children:t.jsx(Ct,{size:"icon-xs","aria-label":l?"Hide password":"Show password",onClick:()=>f(!l),children:l?t.jsx(Vt,{"data-icon":"inline-start"}):t.jsx(Mt,{"data-icon":"inline-start"})})})]}),i.length>0&&i.length<b&&t.jsxs(_t,{children:["Password must be at least ",b," characters (",i.length,"/",b,")"]}),t.jsx(J,{children:"Requires app restart. Remote browsers need an HTTPS reverse proxy; port 19384 remains available to Cogpit hubs and device clients."})]}),e[13]=c,e[14]=b,e[15]=n,e[16]=i,e[17]=r,e[18]=f,e[19]=l,e[20]=p):p=e[20];let u;e[21]!==m||e[22]!==o||e[23]!==n?(u=n&&o&&m.length>0&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected devices"}),t.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(os)})]}),e[21]=m,e[22]=o,e[23]=n,e[24]=u):u=e[24];let S;e[25]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(ls,{}),e[25]=S):S=e[25];let h;return e[26]!==N||e[27]!==p||e[28]!==u?(h=t.jsxs("div",{className:"flex flex-col gap-4 border-t pt-5",children:[N,p,u,S]}),e[26]=N,e[27]=p,e[28]=u,e[29]=h):h=e[29],h}function os(s,e){return t.jsxs("div",{className:"flex items-center justify-between rounded-lg border px-3 py-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx(as,{name:s.deviceName}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-foreground",children:s.deviceName}),t.jsx("p",{className:"text-xs text-muted-foreground",children:s.ip})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-success"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:at(s.lastActivity)})]})]},`${s.ip}-${e}`)}const cs=["auto","path","npm","bundled","custom"],tt={source:"auto"},ds=["path","npm","bundled"];function us(s){return cs.includes(s)}function fs(s){if(!s||typeof s!="object")return;const{source:e,path:n}=s;if(!(!us(e)||e==="auto"))return e==="custom"?typeof n=="string"&&n.trim()?{source:e,path:n.trim()}:void 0:{source:e}}const Te={auto:"Automatic",path:"Installed on PATH",npm:"Global npm install",bundled:"Bundled with Cogpit",custom:"Custom path"};function wt(s,e){return e?`v${e} · ${s}`:s}function ms(s,e){return s===null?"Checking installed binaries…":e?e.version===null?`${e.path} did not report a version — check the path.`:`Now running: ${wt(e.path,e.version)}`:"No launchable binary for the saved choice — sessions cannot start."}function hs(s){return s!==null&&s.version!==null}function xs(s){const e=Y.c(92),{kind:n,value:a,onChange:i,disabled:r,reportVersion:l}=s;let f;e[0]!==n?(f=mt(n),e[0]=n,e[1]=f):f=e[1];const{displayName:c}=f,[o,m]=v.useState(null),[b,x]=v.useState(!1),j=`agent-executable-${n}`;let y;e[2]!==n?(y=()=>{let I=!1;return Ie(`/api/agent-executable/${n}`).then(js).then(te=>{I||m(te)}).catch(gs),()=>{I=!0}},e[2]=n,e[3]=y):y=e[3];let C;e[4]!==n||e[5]!==l?(C=[n,l],e[4]=n,e[5]=l,e[6]=C):C=e[6],v.useEffect(y,C);let w,N,p,u,S,h,_,z,T,k,A,D,g;if(e[7]!==r||e[8]!==c||e[9]!==j||e[10]!==i||e[11]!==b||e[12]!==(o==null?void 0:o.active)||e[13]!==(o==null?void 0:o.candidates)||e[14]!==a.path||e[15]!==a.source){const I=new Map((o==null?void 0:o.candidates.map(ps))??[]);u=(o==null?void 0:o.active)??null;let te;e[29]!==r||e[30]!==j||e[31]!==i||e[32]!==a.path||e[33]!==a.source?(te=(L,B,ae,oe)=>{const lt=oe===void 0?!0:oe,K=`${j}-${L}`;return t.jsxs(le,{orientation:"horizontal",children:[t.jsx("input",{type:"radio",id:K,name:j,className:"mt-1 size-4 shrink-0 accent-primary",checked:a.source===L,disabled:r||!lt,onChange:()=>i(L==="custom"?{source:L,path:a.path??""}:{source:L})}),t.jsxs(ht,{children:[t.jsx(Ee,{htmlFor:K,children:B}),t.jsx(J,{className:"break-all",children:ae})]})]},L)},e[29]=r,e[30]=j,e[31]=i,e[32]=a.path,e[33]=a.source,e[34]=te):te=e[34],S=te;const se=L=>{const B=I.get(L);return S(L,Te[L],B?wt(B.path,B.version):"Not found on this machine.",B!==void 0||a.source===L)},ze=u?`${Te[a.source]} · v${u.version??"?"}`:Te[a.source];p=xt,D=b,g=x,h="flex flex-col gap-2";let X;e[35]===Symbol.for("react.memo_cache_sentinel")?(X=t.jsx(ce,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 font-medium hover:bg-transparent"}),e[35]=X):X=e[35];let ne;e[36]===Symbol.for("react.memo_cache_sentinel")?(ne=t.jsx(Kt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[36]=ne):ne=e[36];let q;e[37]!==c?(q=t.jsxs("span",{className:"flex items-center gap-2",children:[ne,c," executable"]}),e[37]=c,e[38]=q):q=e[38];let F;e[39]!==ze?(F=t.jsx("span",{className:"truncate",children:ze}),e[39]=ze,e[40]=F):F=e[40];let R;e[41]!==b?(R=b?t.jsx(bt,{className:"size-4 shrink-0"}):t.jsx(vt,{className:"size-4 shrink-0"}),e[41]=b,e[42]=R):R=e[42];let U;e[43]!==F||e[44]!==R?(U=t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-normal text-muted-foreground",children:[F,R]}),e[43]=F,e[44]=R,e[45]=U):U=e[45],e[46]!==q||e[47]!==U?(_=t.jsxs(pt,{render:X,children:[q,U]}),e[46]=q,e[47]=U,e[48]=_):_=e[48],N=gt,w=le,e[49]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(J,{children:"Which binary new sessions run. Automatic uses your installed CLI unless it is older than the copy bundled with Cogpit."}),e[49]=A):A=e[49],z="flex flex-col gap-2 pl-1",e[50]!==S?(T=S("auto",Te.auto,"Recommended."),e[50]=S,e[51]=T):T=e[51],k=ds.map(se),e[7]=r,e[8]=c,e[9]=j,e[10]=i,e[11]=b,e[12]=o==null?void 0:o.active,e[13]=o==null?void 0:o.candidates,e[14]=a.path,e[15]=a.source,e[16]=w,e[17]=N,e[18]=p,e[19]=u,e[20]=S,e[21]=h,e[22]=_,e[23]=z,e[24]=T,e[25]=k,e[26]=A,e[27]=D,e[28]=g}else w=e[16],N=e[17],p=e[18],u=e[19],S=e[20],h=e[21],_=e[22],z=e[23],T=e[24],k=e[25],A=e[26],D=e[27],g=e[28];const P=`${c} executable path`,H=a.source==="custom"?a.path??"":"",re=r||a.source!=="custom";let Z;e[52]!==i?(Z=I=>i({source:"custom",path:I.target.value}),e[52]=i,e[53]=Z):Z=e[53];let $;e[54]!==P||e[55]!==H||e[56]!==re||e[57]!==Z?($=t.jsx(nt,{"aria-label":P,value:H,placeholder:"/path/to/binary",disabled:re,onChange:Z,className:"mt-1"}),e[54]=P,e[55]=H,e[56]=re,e[57]=Z,e[58]=$):$=e[58];let G;e[59]!==S||e[60]!==$?(G=S("custom",Te.custom,$),e[59]=S,e[60]=$,e[61]=G):G=e[61];let O;e[62]!==G||e[63]!==z||e[64]!==T||e[65]!==k?(O=t.jsxs("div",{className:z,children:[T,k,G]}),e[62]=G,e[63]=z,e[64]=T,e[65]=k,e[66]=O):O=e[66];let Q;e[67]!==u?(Q=hs(u)?"text-muted-foreground":"text-destructive",e[67]=u,e[68]=Q):Q=e[68];let E;e[69]!==Q?(E=Ye("text-xs",Q),e[69]=Q,e[70]=E):E=e[70];let W;e[71]!==u||e[72]!==o?(W=ms(o,u),e[71]=u,e[72]=o,e[73]=W):W=e[73];let V;e[74]!==E||e[75]!==W?(V=t.jsx("p",{className:E,"aria-live":"polite",children:W}),e[74]=E,e[75]=W,e[76]=V):V=e[76];let ee;e[77]!==w||e[78]!==O||e[79]!==V||e[80]!==A?(ee=t.jsxs(w,{children:[A,O,V]}),e[77]=w,e[78]=O,e[79]=V,e[80]=A,e[81]=ee):ee=e[81];let M;e[82]!==N||e[83]!==ee?(M=t.jsx(N,{children:ee}),e[82]=N,e[83]=ee,e[84]=M):M=e[84];let de;return e[85]!==p||e[86]!==h||e[87]!==_||e[88]!==M||e[89]!==D||e[90]!==g?(de=t.jsxs(p,{open:D,onOpenChange:g,className:h,children:[_,M]}),e[85]=p,e[86]=h,e[87]=_,e[88]=M,e[89]=D,e[90]=g,e[91]=de):de=e[91],de}function ps(s){return[s.source,s]}function gs(){}function js(s){return s.ok?s.json():null}function Nt(s){return s instanceof Error?s.message:String(s)}async function St(s){const e=await s.json().catch(()=>null);return typeof(e==null?void 0:e.error)=="string"?e.error:`Request failed (${s.status})`}async function rt(s){try{const e=await Ie(`/api/agent-accounts/${s}`);return e.status===404?{status:"missing"}:e.ok?await e.json():{status:"error",error:await St(e)}}catch(e){return{status:"error",error:Nt(e)}}}function bs(s){const[e,n]=v.useState(null),[a,i]=v.useState(null),[r,l]=v.useState(null);v.useEffect(()=>{let c=!1;return rt(s).then(o=>{c||n(o)}),()=>{c=!0}},[s]);const f=v.useCallback(async c=>{i(c),l(null);try{const o=await Ie(`/api/agent-accounts/${s}/switch`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slot:c})});if(!o.ok){l({kind:"failed",error:await St(o)});return}l({kind:"switched",result:await o.json()}),n(await rt(s))}catch(o){l({kind:"failed",error:Nt(o)})}finally{i(null)}},[s]);return{report:e,switchingSlot:a,outcome:r,switchTo:f}}const vs={token_expired:"Token expired",relogin_required:"Login needed",no_credentials:"No credentials",keychain_unavailable:"Keychain locked",foreign_credential:"Credential mismatch",api_key:"API key",unavailable:"Usage unavailable"};function st(s){return s.alias??s.email}function ot(s){const e=Y.c(18),{label:n,window:a}=s;if(!a)return null;const i=a.pct>=80,r=a.resetsIn?`${n} window resets in ${a.resetsIn}`:void 0;let l;e[0]!==n?(l=t.jsx("span",{className:"w-5",children:n}),e[0]=n,e[1]=l):l=e[1];const f=i?"bg-destructive":"bg-primary";let c;e[2]!==f?(c=Ye("absolute inset-y-0 left-0 rounded-full",f),e[2]=f,e[3]=c):c=e[3];const o=`${a.pct}%`;let m;e[4]!==o?(m={width:o},e[4]=o,e[5]=m):m=e[5];let b;e[6]!==c||e[7]!==m?(b=t.jsx("span",{className:"relative h-1 w-16 overflow-hidden rounded-full bg-muted",children:t.jsx("span",{className:c,style:m})}),e[6]=c,e[7]=m,e[8]=b):b=e[8];let x;e[9]!==a.pct?(x=Math.round(a.pct),e[9]=a.pct,e[10]=x):x=e[10];let j;e[11]!==x?(j=t.jsxs("span",{className:"tabular-nums",children:[x,"%"]}),e[11]=x,e[12]=j):j=e[12];let y;return e[13]!==r||e[14]!==l||e[15]!==b||e[16]!==j?(y=t.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",title:r,children:[l,b,j]}),e[13]=r,e[14]=l,e[15]=b,e[16]=j,e[17]=y):y=e[17],y}function ct(s){return/[.!?]$/.test(s)?s:`${s}.`}function ws(s,e){if(s.kind==="failed")return`Switch failed: ${s.error}`;const{result:n}=s,a=[ct(n.message)];return n.switched&&a.push(n.credentialStore==="keychain"?`Running ${e} sessions pick it up within about 30 seconds; restart one to apply it immediately.`:`New messages in ${e} use it from now on.`),[...a,...n.warnings.map(ct)].join(" ")}function Ns(s){const e=Y.c(41),{kind:n,disabled:a}=s;let i;e[0]!==n?(i=mt(n),e[0]=n,e[1]=i):i=e[1];const{displayName:r}=i,{report:l,switchingSlot:f,outcome:c,switchTo:o}=bs(n),[m,b]=v.useState(!1);if(l===null||l.status==="missing")return null;let x,j;if(e[2]!==l.accounts||e[3]!==l.status){x=l.status==="ok"?l.accounts:[];const g=x.find(Ss)??null;j=l.status==="error"?"Unavailable":g?`${st(g)} · ${x.length} account${x.length===1?"":"s"}`:`${x.length} account${x.length===1?"":"s"}`,e[2]=l.accounts,e[3]=l.status,e[4]=x,e[5]=j}else x=e[4],j=e[5];const y=j;let C;e[6]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(ce,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 font-medium hover:bg-transparent"}),e[6]=C):C=e[6];let w;e[7]===Symbol.for("react.memo_cache_sentinel")?(w=t.jsx(Jt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),e[7]=w):w=e[7];let N;e[8]!==r?(N=t.jsxs("span",{className:"flex items-center gap-2",children:[w,r," accounts"]}),e[8]=r,e[9]=N):N=e[9];let p;e[10]!==y?(p=t.jsx("span",{className:"truncate",children:y}),e[10]=y,e[11]=p):p=e[11];let u;e[12]!==m?(u=m?t.jsx(bt,{className:"size-4 shrink-0"}):t.jsx(vt,{className:"size-4 shrink-0"}),e[12]=m,e[13]=u):u=e[13];let S;e[14]!==p||e[15]!==u?(S=t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-normal text-muted-foreground",children:[p,u]}),e[14]=p,e[15]=u,e[16]=S):S=e[16];let h;e[17]!==N||e[18]!==S?(h=t.jsxs(pt,{render:C,children:[N,S]}),e[17]=N,e[18]=S,e[19]=h):h=e[19];const _=l.status==="ok"&&`Logins managed by ${l.tool}${l.version?` ${l.version}`:""}. `;let z;e[20]!==r||e[21]!==_?(z=t.jsxs(J,{children:[_,"Switching changes which login ",r," sessions authenticate with."]}),e[20]=r,e[21]=_,e[22]=z):z=e[22];let T;e[23]!==x||e[24]!==a||e[25]!==l.error||e[26]!==l.status||e[27]!==o||e[28]!==f?(T=l.status==="error"?t.jsx("p",{className:"text-xs text-destructive",role:"alert",children:l.error}):t.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border",children:x.map(g=>{const P=f===g.slot,H=vs[g.usageStatus];return t.jsxs("li",{className:"flex items-center gap-3 px-3 py-2",children:[t.jsx("span",{className:"w-5 shrink-0 text-xs tabular-nums text-muted-foreground",children:g.slot}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:st(g)}),g.alias&&t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:g.email}),g.active&&t.jsx(et,{children:"Active"}),g.disabled&&t.jsx(et,{variant:"outline",children:"Disabled"}),H&&t.jsx(et,{variant:"destructive",children:H})]}),g.organization&&t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:g.organization}),g.usage&&t.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:[t.jsx(ot,{label:"5h",window:g.usage.fiveHour}),t.jsx(ot,{label:"7d",window:g.usage.sevenDay})]})]}),!a&&!g.active&&t.jsx(ce,{type:"button",size:"sm",variant:"outline",disabled:f!==null,onClick:()=>o(g.slot),"aria-label":`Switch to ${st(g)}`,children:P?t.jsxs(t.Fragment,{children:[t.jsx(it,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Switching…"]}):"Switch"})]},g.slot)})}),e[23]=x,e[24]=a,e[25]=l.error,e[26]=l.status,e[27]=o,e[28]=f,e[29]=T):T=e[29];let k;e[30]!==r||e[31]!==c?(k=c&&t.jsx("p",{className:Ye("text-xs",c.kind==="failed"?"text-destructive":"text-muted-foreground"),"aria-live":"polite",role:c.kind==="failed"?"alert":"status",children:ws(c,r)}),e[30]=r,e[31]=c,e[32]=k):k=e[32];let A;e[33]!==z||e[34]!==T||e[35]!==k?(A=t.jsx(gt,{children:t.jsxs(le,{children:[z,T,k]})}),e[33]=z,e[34]=T,e[35]=k,e[36]=A):A=e[36];let D;return e[37]!==m||e[38]!==A||e[39]!==h?(D=t.jsxs(xt,{open:m,onOpenChange:b,className:"flex flex-col gap-2",children:[h,A]}),e[37]=m,e[38]=A,e[39]=h,e[40]=D):D=e[40],D}function Ss(s){return s.active}const ys=jt().filter(s=>s.cli.bundledBySdk).map(s=>s.kind),ks=jt().filter(s=>s.capabilities.accountSwitching).map(s=>s.kind);function Cs(s,e){return s.source===e.source&&(s.source!=="custom"||s.path===e.path)}function _s(s){const e=Y.c(5),{status:n,error:a}=s;if(n==="validating"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(it,{"data-icon":"inline-start",className:"size-3.5 animate-spin"}),"Checking path..."]}),e[0]=i):i=e[0],i}if(n==="valid"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-success",children:[t.jsx(ts,{"data-icon":"inline-start",className:"size-3.5"}),"Valid .claude directory found"]}),e[1]=i):i=e[1],i}if(n==="invalid"&&a){let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=t.jsx(ss,{"data-icon":"inline-start",className:"size-3.5"}),e[2]=i):i=e[2];let r;return e[3]!==a?(r=t.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[i,a]}),e[3]=a,e[4]=r):r=e[4],r}return null}function Rs(s){const e=Y.c(110),{open:n,currentPath:a,onClose:i,onSaved:r}=s,[l,f]=v.useState(a),[c,o]=v.useState(!1),{status:m,error:b,debouncedValidate:x,reset:j,save:y}=$t();let C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=Et(),e[0]=C):C=e[0];const w=C;let N;e[1]===Symbol.for("react.memo_cache_sentinel")?(N=zt("configWrite"),e[1]=N):N=e[1];const p=N,[u,S]=v.useState(!1),[h,_]=v.useState(""),[z,T]=v.useState(!1),[k,A]=v.useState(""),[D,g]=v.useState(""),[P,H]=v.useState(""),[re,Z]=v.useState(""),[$,G]=v.useState(!1),[O,Q]=v.useState(!1),[E,W]=v.useState(tt),[V,ee]=v.useState(0),[M,de]=v.useState(tt),[I,te]=v.useState(!1),[se,ze]=v.useState(!1);let X;e[2]===Symbol.for("react.memo_cache_sentinel")?(X=[],e[2]=X):X=e[2];const[ne,q]=v.useState(X);let F,R;e[3]!==a||e[4]!==n||e[5]!==j?(F=()=>{n&&(f(a),j(),Ie("/api/config").then(Ts).then(d=>{const ie=(d==null?void 0:d.networkAccess)||!1;S(ie),te(ie),ze(!!(d!=null&&d.networkPassword)),_("");const Xe=(d==null?void 0:d.terminalApp)||"";A(Xe),g(Xe);const qe=(d==null?void 0:d.editorApp)||"";H(qe),Z(qe);const Ke=(d==null?void 0:d.useBuiltInEditor)===!0;G(Ke),Q(Ke);const Je=fs(d==null?void 0:d.agentExecutable)??tt;W(Je),de(Je),ie&&(d!=null&&d.networkPassword)&&!w?Ie("/api/connected-devices").then(zs).then($e=>q(($e==null?void 0:$e.devices)||[])).catch(Es):q([])}).catch($s))},R=[n,a,j,w],e[3]=a,e[4]=n,e[5]=j,e[6]=F,e[7]=R):(F=e[6],R=e[7]),v.useEffect(F,R);let U;e[8]!==x?(U=d=>{const ie=d.target.value;f(ie),x(ie)},e[8]=x,e[9]=U):U=e[9];const L=U;let B;e[10]!==E||e[11]!==P||e[12]!==I||e[13]!==u||e[14]!==h||e[15]!==r||e[16]!==l||e[17]!==y||e[18]!==k||e[19]!==$?(B=async()=>{o(!0);const d=await y(l,{networkAccess:w?I:u,networkPassword:!w&&u&&h.length>0?h:void 0,terminalApp:k.trim()||void 0,editorApp:P.trim()||void 0,useBuiltInEditor:$,agentExecutable:E});d.success&&d.claudeDir&&(ee(As),r(d.claudeDir)),o(!1)},e[10]=E,e[11]=P,e[12]=I,e[13]=u,e[14]=h,e[15]=r,e[16]=l,e[17]=y,e[18]=k,e[19]=$,e[20]=B):B=e[20];const ae=B;let oe;e[21]!==E||e[22]!==P||e[23]!==se||e[24]!==M||e[25]!==re||e[26]!==I||e[27]!==D||e[28]!==O||e[29]!==u||e[30]!==h||e[31]!==m||e[32]!==k||e[33]!==$?(oe=function(){var $e;if(m==="validating"||m==="invalid")return!1;const ie=m==="valid",Xe=!w&&(u!==I||u&&h.length>0),qe=k!==D,Ke=P!==re||$!==O,Je=!Cs(E,M);if(!ie&&!Xe&&!qe&&!Ke&&!Je||E.source==="custom"&&!(($e=E.path)!=null&&$e.trim()))return!1;if(!w&&u){const yt=h.length>0&&h.length<16,kt=!se&&h.length===0;if(yt||kt)return!1}return!0},e[21]=E,e[22]=P,e[23]=se,e[24]=M,e[25]=re,e[26]=I,e[27]=D,e[28]=O,e[29]=u,e[30]=h,e[31]=m,e[32]=k,e[33]=$,e[34]=oe):oe=e[34];const K=oe();let ue;e[35]!==i?(ue=d=>{d||i()},e[35]=i,e[36]=ue):ue=e[36];let De;e[37]===Symbol.for("react.memo_cache_sentinel")?(De=t.jsxs(Tt,{children:[t.jsx(It,{className:"text-foreground",children:"Configuration"}),t.jsx(Dt,{className:"text-muted-foreground",children:"Manage local paths, preferred apps, and remote access."})]}),e[37]=De):De=e[37];let Pe,Le;e[38]===Symbol.for("react.memo_cache_sentinel")?(Pe=t.jsx(Ee,{htmlFor:"claude-directory",children:"Claude directory"}),Le=t.jsx(J,{children:"The directory containing your Claude configuration."}),e[38]=Pe,e[39]=Le):(Pe=e[38],Le=e[39]);let Fe;e[40]===Symbol.for("react.memo_cache_sentinel")?(Fe=t.jsx(ft,{children:t.jsx(Yt,{"data-icon":"inline-start"})}),e[40]=Fe):Fe=e[40];let fe;e[41]!==K||e[42]!==ae||e[43]!==c?(fe=d=>{d.key==="Enter"&&K&&!c&&ae()},e[41]=K,e[42]=ae,e[43]=c,e[44]=fe):fe=e[44];let me;e[45]!==L||e[46]!==l||e[47]!==fe?(me=t.jsxs(dt,{children:[Fe,t.jsx(ut,{id:"claude-directory",value:l,onChange:L,placeholder:"/Users/you/.claude",disabled:!p,onKeyDown:fe})]}),e[45]=L,e[46]=l,e[47]=fe,e[48]=me):me=e[48];let he;e[49]!==b||e[50]!==m?(he=t.jsx("div",{"aria-live":"polite",children:t.jsx(_s,{status:m,error:b})}),e[49]=b,e[50]=m,e[51]=he):he=e[51];let xe;e[52]!==me||e[53]!==he?(xe=t.jsxs(le,{children:[Pe,Le,me,he]}),e[52]=me,e[53]=he,e[54]=xe):xe=e[54];let Re,Ue;e[55]===Symbol.for("react.memo_cache_sentinel")?(Re=t.jsxs(Ee,{htmlFor:"terminal-application",children:[t.jsx(Zt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Terminal application"]}),Ue=t.jsx(J,{children:"Leave blank to use the system default for Ctrl+Cmd+T."}),e[55]=Re,e[56]=Ue):(Re=e[55],Ue=e[56]);let Be;e[57]===Symbol.for("react.memo_cache_sentinel")?(Be=d=>A(d.target.value),e[57]=Be):Be=e[57];let pe;e[58]!==k?(pe=t.jsxs(le,{children:[Re,Ue,t.jsx(nt,{id:"terminal-application",value:k,onChange:Be,placeholder:"Ghostty, iTerm, or /path/to/binary",disabled:!p})]}),e[58]=k,e[59]=pe):pe=e[59];let Oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(Oe=d=>G(d===!0),e[60]=Oe):Oe=e[60];let ge;e[61]!==$?(ge=t.jsx(Pt,{id:"use-built-in-editor",checked:$,onCheckedChange:Oe,disabled:!p}),e[61]=$,e[62]=ge):ge=e[62];let Ve;e[63]===Symbol.for("react.memo_cache_sentinel")?(Ve=t.jsxs(ht,{children:[t.jsxs(Ee,{htmlFor:"use-built-in-editor",children:[t.jsx(Qt,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Open files in Cogpit"]}),t.jsx(J,{children:"Files and diffs open in Cogpit’s file workspace instead of launching an external editor."})]}),e[63]=Ve):Ve=e[63];let je;e[64]!==ge?(je=t.jsxs(le,{orientation:"horizontal",children:[ge,Ve]}),e[64]=ge,e[65]=je):je=e[65];let Me;e[66]===Symbol.for("react.memo_cache_sentinel")?(Me=t.jsxs(Ee,{htmlFor:"editor-application",children:[t.jsx(es,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Editor application"]}),e[66]=Me):Me=e[66];const Ze=$?"Not used while files open in Cogpit.":"Leave blank to use $VISUAL or automatic detection.";let be;e[67]!==Ze?(be=t.jsx(J,{children:Ze}),e[67]=Ze,e[68]=be):be=e[68];let He;e[69]===Symbol.for("react.memo_cache_sentinel")?(He=d=>H(d.target.value),e[69]=He):He=e[69];const Qe=!p||$;let ve;e[70]!==P||e[71]!==Qe?(ve=t.jsx(nt,{id:"editor-application",value:P,onChange:He,placeholder:"cursor, code, zed, or /path/to/binary",disabled:Qe}),e[70]=P,e[71]=Qe,e[72]=ve):ve=e[72];let we;e[73]!==be||e[74]!==ve?(we=t.jsxs(le,{children:[Me,be,ve]}),e[73]=be,e[74]=ve,e[75]=we):we=e[75];let Ne;e[76]!==E||e[77]!==V?(Ne=ys.map(d=>t.jsx(xs,{kind:d,value:E,onChange:W,disabled:!p,reportVersion:V},d)),e[76]=E,e[77]=V,e[78]=Ne):Ne=e[78];let Ge;e[79]===Symbol.for("react.memo_cache_sentinel")?(Ge=ks.map(d=>t.jsx(Ns,{kind:d,disabled:!p},d)),e[79]=Ge):Ge=e[79];let Se;e[80]!==ne||e[81]!==se||e[82]!==I||e[83]!==u||e[84]!==h||e[85]!==z?(Se=!w&&p&&t.jsx(rs,{networkAccess:u,setNetworkAccess:S,networkPassword:h,setNetworkPassword:_,showNetworkPassword:z,setShowNetworkPassword:T,hasExistingPassword:se,initialNetworkAccess:I,connectedDevices:ne,minPasswordLength:16}),e[80]=ne,e[81]=se,e[82]=I,e[83]=u,e[84]=h,e[85]=z,e[86]=Se):Se=e[86];let ye;e[87]!==xe||e[88]!==pe||e[89]!==je||e[90]!==we||e[91]!==Ne||e[92]!==Se?(ye=t.jsxs(Lt,{children:[xe,pe,je,we,Ne,Ge,Se]}),e[87]=xe,e[88]=pe,e[89]=je,e[90]=we,e[91]=Ne,e[92]=Se,e[93]=ye):ye=e[93];let ke;e[94]!==i?(ke=t.jsx(ce,{variant:"outline",onClick:i,children:"Cancel"}),e[94]=i,e[95]=ke):ke=e[95];let Ce;e[96]!==K||e[97]!==ae||e[98]!==c?(Ce=p&&t.jsx(ce,{disabled:!K||c,onClick:ae,children:c?t.jsxs(t.Fragment,{children:[t.jsx(it,{"data-icon":"inline-start",className:"size-4 animate-spin"}),"Saving..."]}):"Save"}),e[96]=K,e[97]=ae,e[98]=c,e[99]=Ce):Ce=e[99];let _e;e[100]!==ke||e[101]!==Ce?(_e=t.jsxs(Ft,{children:[ke,Ce]}),e[100]=ke,e[101]=Ce,e[102]=_e):_e=e[102];let Ae;e[103]!==ye||e[104]!==_e?(Ae=t.jsxs(Rt,{className:"max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg",children:[De,ye,_e]}),e[103]=ye,e[104]=_e,e[105]=Ae):Ae=e[105];let We;return e[106]!==n||e[107]!==Ae||e[108]!==ue?(We=t.jsx(Ut,{open:n,onOpenChange:ue,children:Ae}),e[106]=n,e[107]=Ae,e[108]=ue,e[109]=We):We=e[109],We}function As(s){return s+1}function $s(){}function Es(){}function zs(s){return s.json()}function Ts(s){return s.json()}export{Rs as ConfigDialog};
|