cogpit 2.6.5 → 2.7.4
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 +16883 -10322
- package/dist/web/assets/{CommandPaletteHost-DrCXDZkP.js → CommandPaletteHost-ByD_7YRK.js} +1 -1
- package/dist/web/assets/ConfigBrowser-vXK8JNMg.js +1 -0
- package/dist/web/assets/{HighlightedEditor-Cm-79JuL.js → HighlightedEditor-BwET41dr.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-DKPBP4Tr.js → KeyboardShortcutsDialog-DQuepxQo.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-B2aGoWIm.js → MobileFileChanges-B6rggNR6.js} +1 -1
- package/dist/web/assets/PluginsDialog-DTF9NnK7.js +1 -0
- package/dist/web/assets/{PreviewPanel-Bo7DnIca.js → PreviewPanel-BaXxki5D.js} +1 -1
- package/dist/web/assets/ProjectFilesPanel-CO6Znhgi.js +4 -0
- package/dist/web/assets/{ProjectSwitcherModal-lncPQd9P.js → ProjectSwitcherModal-Chi-U3vv.js} +1 -1
- package/dist/web/assets/{TerminalOutput-fFrlHJcb.js → TerminalOutput-CUmbXM9h.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-E23TFwmi.js → ThemeSelectorModal-B2m42_1f.js} +1 -1
- package/dist/web/assets/WorkflowsPanel-CiYzHaQg.js +1 -0
- package/dist/web/assets/{WorktreePanel-psgNQDIs.js → WorktreePanel-CldMZY3n.js} +1 -1
- package/dist/web/assets/{index-BtpxC457.js → index-BA1eUNuR.js} +4 -4
- package/dist/web/assets/{index-C-D_sWB4.js → index-C-0I_ZqI.js} +1 -1
- package/dist/web/assets/index-C6wvrmo0.js +221 -0
- package/dist/web/assets/index-CYN2JttE.js +1 -0
- package/dist/web/assets/index-DYWsIgvZ.css +1 -0
- package/dist/web/assets/index-QH_v3Ygj.js +1 -0
- package/dist/web/assets/session-parser.worker-CnA52U1J.js +29 -0
- package/dist/web/assets/vendor-ui-ZKZkD5k3.js +887 -0
- package/dist/web/index.html +3 -3
- package/package.json +8 -2
- package/dist/web/assets/ConfigBrowser-B3IvCBt5.js +0 -1
- package/dist/web/assets/ProjectFilesPanel-BURFV70d.js +0 -4
- package/dist/web/assets/WorkflowsPanel-dlTy3KtX.js +0 -1
- package/dist/web/assets/index-CImOF4Hf.js +0 -1
- package/dist/web/assets/index-CriFWu3H.js +0 -1
- package/dist/web/assets/index-DOkVkYA9.js +0 -157
- package/dist/web/assets/index-DpPYXAB1.css +0 -1
- package/dist/web/assets/session-parser.worker-DlF00ZHH.js +0 -29
- package/dist/web/assets/vendor-ui-DpPWL3l4.js +0 -922
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as oe,j as u,r as H}from"./vendor-react-gGw_S5I_.js";import{ak as h,al as Q,am as le,O as re,J as ce,an as de,ao as me,P as ue,C as he,N as ge,x as fe,ap as ve,aq as Y,ar as p,as as we,at as Ce,au as Se,av as je,w as be}from"./index-DOkVkYA9.js";import{S as ye,l as Z,m as xe,P as Pe,L as Te,H as Oe,F as Ne,n as ke,d as ee,G as Ee,k as Fe,o as Ie,p as $e,q as Re,r as De,s as Ae,t as Le,u as te,v as He,w as Me,x as Be,K as qe,E as Ge,y as Ke,z as ze,A as ne,B as Ue,D as We,I as pe}from"./vendor-ui-DpPWL3l4.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,r,i,m,d){return{id:t,label:e,icon:r,run:i,shortcut:m,description:d,value:`${e} ${s}`}}function _(...t){return t.filter(e=>e!==!1&&e!==void 0)}function _e(t){const e=oe.c(40);let s,r,i,m,d,v,w,c,C,g,b,f,y,k,x;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",xe,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",ye,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 S=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,K=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,S,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,Z,()=>{var B;return(B=t.onOpenSession)==null?void 0:B.call(t,n.dirName,n.fileName)},void 0,K)}),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 S;return(S=t.onSwitchDevice)==null?void 0:S.call(t,n.id)},h(Q[l]))):[],R=_(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",De,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",Re,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",$e,t.onToggleProjectFiles,h("projectFiles")),t.onToggleBrowser&&a("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",Ie,t.onToggleBrowser),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)),D=_(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",We,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",Ue,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",ze,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",Ge,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",Be,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",Me,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",He,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",Le,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",pe,()=>{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")})),A=[{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:D}],E=function(l){t.onOpenChange(!1),l.run()};i=me,y=t.open,k=t.onOpenChange,x="Command palette",v="Search for a Cogpit action to run.",w="max-w-xl",r=ue,C="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(he,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[16]=b):b=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],c=A.map(n=>u.jsx(re,{heading:n.value,children:n.items.map(l=>{const S=l.icon;return u.jsxs(ce,{value:l.value,onSelect:()=>E(l),children:[u.jsx(S,{"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]=r,e[3]=i,e[4]=m,e[5]=d,e[6]=v,e[7]=w,e[8]=c,e[9]=C,e[10]=g,e[11]=b,e[12]=f,e[13]=y,e[14]=k,e[15]=x}else s=e[1],r=e[2],i=e[3],m=e[4],d=e[5],v=e[6],w=e[7],c=e[8],C=e[9],g=e[10],b=e[11],f=e[12],y=e[13],k=e[14],x=e[15];let T;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==c?(T=u.jsxs(s,{className:m,children:[d,c]}),e[20]=s,e[21]=m,e[22]=d,e[23]=c,e[24]=T):T=e[24];let O;e[25]!==r||e[26]!==T||e[27]!==C||e[28]!==g||e[29]!==b||e[30]!==f?(O=u.jsxs(r,{label:C,loop:g,children:[b,f,T]}),e[25]=r,e[26]=T,e[27]=C,e[28]=g,e[29]=b,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]!==y||e[37]!==k||e[38]!==x?(N=u.jsx(i,{open:y,onOpenChange:k,title:x,description:v,className:w,children:O}),e[32]=i,e[33]=v,e[34]=w,e[35]=O,e[36]=y,e[37]=k,e[38]=x,e[39]=N):N=e[39],N}async function ae(t,e){const s=await be(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const r=await s.json();return Array.isArray(r)?r:[]}function Ze(t){var V;const e=oe.c(48);let s,r,i,m,d,v;e[0]!==t?({open:i,currentProjectDirName:s,projectCwd:d,onProcessStarted:r,launchTerminalRequest:v,...m}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i,e[4]=m,e[5]=d,e[6]=v):(s=e[1],r=e[2],i=e[3],m=e[4],d=e[5],v=e[6]);const w=v===void 0?0:v,c=ve();let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[7]=C):C=e[7];const[g,b]=H.useState(C);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[y,k]=H.useState(f),[x,T]=H.useState(!1),O=H.useRef(0);let N,$;e[9]!==i?(N=()=>{if(!i)return;const j=new AbortController;return T(!0),Promise.allSettled([ae("/api/projects",j.signal),ae("/api/active-sessions?limit=12&perProject=3",j.signal)]).then(M=>{const[J,X]=M;j.signal.aborted||(b(J.status==="fulfilled"?J.value:[]),k(X.status==="fulfilled"?X.value:[]),T(!1))}),()=>j.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 j;e[12]!==s||e[13]!==g?(j=((V=g.find(M=>M.dirName===s))==null?void 0:V.path)??null,e[12]=s,e[13]=g,e[14]=j):j=e[14],F=j}const o=F;let I;e[15]!==r||e[16]!==c||e[17]!==o?(I=()=>{if(!o)return;const j=c.spawnTerminal({cwd:o}),M=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";r({id:j,name:M,type:"terminal",status:"running",source:o})},e[15]=r,e[16]=c,e[17]=o,e[18]=I):I=e[18];const P=I;let R,D;e[19]!==P||e[20]!==w||e[21]!==c.status||e[22]!==o?(R=()=>{w<=O.current||!o||c.status!=="connected"||(O.current=w,P())},D=[P,w,c.status,o],e[19]=P,e[20]=w,e[21]=c.status,e[22]=o,e[23]=R,e[24]=D):(R=e[23],D=e[24]),H.useEffect(R,D);let A;e[25]!==s||e[26]!==o?(A={path:o,dirName:s},e[25]=s,e[26]=o,e[27]=A):A=e[27];const E=A;let n;e[28]!==E?(n=()=>Ce(E),e[28]=E,e[29]=n):n=e[29];const l=n;let S;e[30]!==E?(S=()=>Se(E),e[30]=E,e[31]=S):S=e[31];const K=S,B=!Y()&&p("hostFiles"),se=p("hostFiles")&&(!Y()||we());let q;e[32]!==o?(q=()=>{o&&je(o)},e[32]=o,e[33]=q):q=e[33];const ie=q;let L;e[34]!==P||e[35]!==c.status||e[36]!==o?(L=o&&c.status==="connected"&&p("terminal")?P:void 0,e[34]=P,e[35]=c.status,e[36]=o,e[37]=L):L=e[37];const z=o&&se?l:void 0,U=o&&B?K:void 0,W=o?ie:void 0;let G;return e[38]!==x||e[39]!==i||e[40]!==m||e[41]!==g||e[42]!==y||e[43]!==L||e[44]!==z||e[45]!==U||e[46]!==W?(G=u.jsx(_e,{...m,open:i,projects:g,recentSessions:y,loadingNavigation:x,onOpenIntegratedTerminal:L,onOpenProjectInEditor:z,onRevealProject:U,onCopyProjectPath:W}),e[38]=x,e[39]=i,e[40]=m,e[41]=g,e[42]=y,e[43]=L,e[44]=z,e[45]=U,e[46]=W,e[47]=G):G=e[47],G}export{Ze as CommandPaletteHost};
|
|
1
|
+
import{c as oe,j as u,r as H}from"./vendor-react-gGw_S5I_.js";import{ak as h,al as Q,am as le,O as re,J as ce,an as de,ao as me,P as ue,C as he,N as ge,x as fe,ap as ve,aq as Y,ar as p,as as we,at as Ce,au as Se,av as je,w as be}from"./index-C6wvrmo0.js";import{S as ye,l as Z,m as xe,P as Pe,L as Te,H as Oe,F as Ne,n as ke,d as ee,G as Ee,k as Fe,o as Ie,p as $e,q as Re,r as De,s as Ae,t as Le,u as te,v as He,w as Me,x as Be,K as qe,E as Ge,y as Ke,z as ze,A as ne,B as Ue,D as We,I as pe}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,r,i,m,d){return{id:t,label:e,icon:r,run:i,shortcut:m,description:d,value:`${e} ${s}`}}function _(...t){return t.filter(e=>e!==!1&&e!==void 0)}function _e(t){const e=oe.c(40);let s,r,i,m,d,v,w,c,C,g,b,f,y,k,x;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",xe,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",ye,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 S=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,K=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,S,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,Z,()=>{var B;return(B=t.onOpenSession)==null?void 0:B.call(t,n.dirName,n.fileName)},void 0,K)}),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 S;return(S=t.onSwitchDevice)==null?void 0:S.call(t,n.id)},h(Q[l]))):[],R=_(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",De,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",Re,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",$e,t.onToggleProjectFiles,h("projectFiles")),t.onToggleBrowser&&a("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",Ie,t.onToggleBrowser),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)),D=_(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",We,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",Ue,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",ze,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",Ge,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",Be,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",Me,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",He,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",Le,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",pe,()=>{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")})),A=[{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:D}],E=function(l){t.onOpenChange(!1),l.run()};i=me,y=t.open,k=t.onOpenChange,x="Command palette",v="Search for a Cogpit action to run.",w="max-w-xl",r=ue,C="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(he,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[16]=b):b=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],c=A.map(n=>u.jsx(re,{heading:n.value,children:n.items.map(l=>{const S=l.icon;return u.jsxs(ce,{value:l.value,onSelect:()=>E(l),children:[u.jsx(S,{"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]=r,e[3]=i,e[4]=m,e[5]=d,e[6]=v,e[7]=w,e[8]=c,e[9]=C,e[10]=g,e[11]=b,e[12]=f,e[13]=y,e[14]=k,e[15]=x}else s=e[1],r=e[2],i=e[3],m=e[4],d=e[5],v=e[6],w=e[7],c=e[8],C=e[9],g=e[10],b=e[11],f=e[12],y=e[13],k=e[14],x=e[15];let T;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==c?(T=u.jsxs(s,{className:m,children:[d,c]}),e[20]=s,e[21]=m,e[22]=d,e[23]=c,e[24]=T):T=e[24];let O;e[25]!==r||e[26]!==T||e[27]!==C||e[28]!==g||e[29]!==b||e[30]!==f?(O=u.jsxs(r,{label:C,loop:g,children:[b,f,T]}),e[25]=r,e[26]=T,e[27]=C,e[28]=g,e[29]=b,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]!==y||e[37]!==k||e[38]!==x?(N=u.jsx(i,{open:y,onOpenChange:k,title:x,description:v,className:w,children:O}),e[32]=i,e[33]=v,e[34]=w,e[35]=O,e[36]=y,e[37]=k,e[38]=x,e[39]=N):N=e[39],N}async function ae(t,e){const s=await be(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const r=await s.json();return Array.isArray(r)?r:[]}function Ze(t){var V;const e=oe.c(48);let s,r,i,m,d,v;e[0]!==t?({open:i,currentProjectDirName:s,projectCwd:d,onProcessStarted:r,launchTerminalRequest:v,...m}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=i,e[4]=m,e[5]=d,e[6]=v):(s=e[1],r=e[2],i=e[3],m=e[4],d=e[5],v=e[6]);const w=v===void 0?0:v,c=ve();let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[7]=C):C=e[7];const[g,b]=H.useState(C);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[y,k]=H.useState(f),[x,T]=H.useState(!1),O=H.useRef(0);let N,$;e[9]!==i?(N=()=>{if(!i)return;const j=new AbortController;return T(!0),Promise.allSettled([ae("/api/projects",j.signal),ae("/api/active-sessions?limit=12&perProject=3",j.signal)]).then(M=>{const[J,X]=M;j.signal.aborted||(b(J.status==="fulfilled"?J.value:[]),k(X.status==="fulfilled"?X.value:[]),T(!1))}),()=>j.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 j;e[12]!==s||e[13]!==g?(j=((V=g.find(M=>M.dirName===s))==null?void 0:V.path)??null,e[12]=s,e[13]=g,e[14]=j):j=e[14],F=j}const o=F;let I;e[15]!==r||e[16]!==c||e[17]!==o?(I=()=>{if(!o)return;const j=c.spawnTerminal({cwd:o}),M=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";r({id:j,name:M,type:"terminal",status:"running",source:o})},e[15]=r,e[16]=c,e[17]=o,e[18]=I):I=e[18];const P=I;let R,D;e[19]!==P||e[20]!==w||e[21]!==c.status||e[22]!==o?(R=()=>{w<=O.current||!o||c.status!=="connected"||(O.current=w,P())},D=[P,w,c.status,o],e[19]=P,e[20]=w,e[21]=c.status,e[22]=o,e[23]=R,e[24]=D):(R=e[23],D=e[24]),H.useEffect(R,D);let A;e[25]!==s||e[26]!==o?(A={path:o,dirName:s},e[25]=s,e[26]=o,e[27]=A):A=e[27];const E=A;let n;e[28]!==E?(n=()=>Ce(E),e[28]=E,e[29]=n):n=e[29];const l=n;let S;e[30]!==E?(S=()=>Se(E),e[30]=E,e[31]=S):S=e[31];const K=S,B=!Y()&&p("hostFiles"),se=p("hostFiles")&&(!Y()||we());let q;e[32]!==o?(q=()=>{o&&je(o)},e[32]=o,e[33]=q):q=e[33];const ie=q;let L;e[34]!==P||e[35]!==c.status||e[36]!==o?(L=o&&c.status==="connected"&&p("terminal")?P:void 0,e[34]=P,e[35]=c.status,e[36]=o,e[37]=L):L=e[37];const z=o&&se?l:void 0,U=o&&B?K:void 0,W=o?ie:void 0;let G;return e[38]!==x||e[39]!==i||e[40]!==m||e[41]!==g||e[42]!==y||e[43]!==L||e[44]!==z||e[45]!==U||e[46]!==W?(G=u.jsx(_e,{...m,open:i,projects:g,recentSessions:y,loadingNavigation:x,onOpenIntegratedTerminal:L,onOpenProjectInEditor:z,onRevealProject:U,onCopyProjectPath:W}),e[38]=x,e[39]=i,e[40]=m,e[41]=g,e[42]=y,e[43]=L,e[44]=z,e[45]=U,e[46]=W,e[47]=G):G=e[47],G}export{Ze as CommandPaletteHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{b4 as ye,bp as Ce,_ as F,U as ke,V as W,aY as X,Y as ve,Z,b1 as ae,B as O,w as A,bq as Ne,br as Se,bs as we,bt as De,bu as Te,bv as Ee,bw as V,bx as Re,by as ee,bz as Ie,a4 as te,aa as le,bA as Oe,ab as ie,ac as re,ae as oe,af as ce,ag as de,ah as ue,ai as me,am as ze,E as Ae,y as Le,z as Be,G as $e,H as Fe,a3 as Ge,m as Me,I as ne,n as Pe,W as Ue,q as _e,bB as Ve}from"./index-C6wvrmo0.js";import{al as He,z as Ke,h as Ye,a5 as Qe,am as qe,an as Je,ao as xe,o as fe,ap as We,aq as Xe,V as H,X as K,P as Ze,ar as he,as as et,j as tt,a2 as nt,S as st,Q as at}from"./vendor-ui-ZKZkD5k3.js";import{H as lt}from"./HighlightedEditor-BwET41dr.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const it={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},rt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},se=["instructions","agents","skills","commands","settings"],ot={instructions:{label:"Instructions",icon:qe,color:"text-muted-foreground"},agents:{label:"Agents",icon:Qe,color:"text-muted-foreground"},skills:{label:"Skills",icon:Ye,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ke,color:"text-muted-foreground"},settings:{label:"Settings",icon:He,color:"text-muted-foreground"}};function Y(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Y(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function ct(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Y(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function pe(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Je,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const dt=Object.fromEntries(ye().map(l=>[l.kind,Ce(l.kind)]));function ge(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=dt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function je(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=F("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Xe,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let g;return e[6]!==u||e[7]!==m||e[8]!==d?(g=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=g):g=e[9],g}function ut({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,g]=o.useState(!1),w=o.useRef(null),y=o.useId();o.useEffect(()=>{var x;(x=w.current)==null||x.focus()},[]);const k=m==="project"&&e?e:l,b=!!l&&!!e;async function S(){if(!(!r.trim()||!k)){g(!0);try{const x=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:k,fileType:i,name:r.trim()})});if(x.ok){const p=await x.json();n(p.path,i,m)}}finally{g(!1)}}}return t.jsxs(ke,{className:"gap-3 px-3 py-2",children:[b&&t.jsxs(W,{children:[t.jsx(X,{children:"Scope"}),t.jsxs(ve,{"aria-label":"File scope",value:[m],onValueChange:x=>{const p=x[0];(p==="global"||p==="project")&&c(p)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(Z,{value:"global",className:"flex-1",children:[t.jsx(fe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(Z,{value:"project",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(W,{children:[t.jsxs(X,{htmlFor:y,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{id:y,ref:w,type:"text",value:r,onChange:x=>u(x.target.value),onKeyDown:x=>{x.key==="Enter"&&S(),x.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void S(),disabled:d||!r.trim()||!k,children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(K,{"data-icon":"inline-start"})})]})]})]})}function mt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:g,onRenameValueChange:w,onRenameSubmit:y,onRenameCancel:k,creatingInCategory:b,onCreated:S,onCancelCreate:x}=l,p=ot[i],C=p.icon;if(n.length===0&&!u)return null;let N;e[0]!==p.color?(N=F("size-3.5",p.color),e[0]=p.color,e[1]=N):N=e[1];let v;e[2]!==C||e[3]!==N?(v=t.jsx(C,{"data-icon":"inline-start",className:N}),e[2]=C,e[3]=N,e[4]=v):v=e[4];let T;e[5]!==p.label?(T=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:p.label}),e[5]=p.label,e[6]=T):T=e[6];let E;e[7]!==n.length?(E=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=E):E=e[8];let f;e[9]!==i||e[10]!==u?(f=u&&t.jsxs(Ne,{children:[t.jsx(Se,{render:t.jsx(O,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(Ze,{"data-icon":"inline-start"})}),t.jsxs(we,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=f):f=e[11];let D;e[12]!==v||e[13]!==T||e[14]!==E||e[15]!==f?(D=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[v,T,E,f]}),e[12]=v,e[13]=T,e[14]=E,e[15]=f,e[16]=D):D=e[16];let z;if(e[17]!==n||e[18]!==m||e[19]!==k||e[20]!==c||e[21]!==y||e[22]!==w||e[23]!==r||e[24]!==g||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==k||e[30]!==c||e[31]!==y||e[32]!==w||e[33]!==r||e[34]!==g||e[35]!==d||e[36]!==s?(B=j=>{const U=s===j.path;if(d===j.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(ae,{value:g,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&y(),$.key==="Escape"&&k()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:y,disabled:!g.trim(),children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:k,children:t.jsx(K,{"data-icon":"inline-start"})})]},j.path);const M=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:j.name}),t.jsx(je,{linkTarget:j.linkTarget}),j.readOnly&&t.jsx(he,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),j.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:j.description})]}),t.jsx(ge,{cli:j.cli}),t.jsx(pe,{scope:j.scope,pluginName:j.pluginName})]}),P=F("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:P,onClick:()=>r(j),children:M},j.path):t.jsxs(De,{children:[t.jsx(Te,{render:t.jsx("button",{type:"button",className:P,onClick:()=>r(j)}),children:M}),t.jsx(Ee,{className:"min-w-36",children:j.readOnly?t.jsx(V,{children:t.jsx(Re,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(ee,{onClick:()=>c(j),children:"Rename"})}),t.jsx(Ie,{}),t.jsx(V,{children:t.jsx(ee,{variant:"destructive",onClick:()=>m(j),children:"Delete"})})]})})]},j.path)},e[28]=m,e[29]=k,e[30]=c,e[31]=y,e[32]=w,e[33]=r,e[34]=g,e[35]=d,e[36]=s,e[37]=B):B=e[37],z=n.map(B),e[17]=n,e[18]=m,e[19]=k,e[20]=c,e[21]=y,e[22]=w,e[23]=r,e[24]=g,e[25]=d,e[26]=s,e[27]=z}else z=e[27];let R;e[38]!==b||e[39]!==n.length?(R=n.length===0&&!b&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=b,e[39]=n.length,e[40]=R):R=e[40];let I;e[41]!==b||e[42]!==x||e[43]!==S?(I=b&&t.jsx(ut,{globalDir:b.globalDir,projectDir:b.projectDir,fileType:b.fileType,onCreated:S,onCancel:x}),e[41]=b,e[42]=x,e[43]=S,e[44]=I):I=e[44];let L;return e[45]!==D||e[46]!==z||e[47]!==R||e[48]!==I?(L=t.jsxs("section",{children:[D,z,R,I]}),e[45]=D,e[46]=z,e[47]=R,e[48]=I,e[49]=L):L=e[49],L}function xt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,g]=o.useState(!1),[w,y]=o.useState(!1),[k,b]=o.useState(!1),[S,x]=o.useState(!1),p=n!==null&&n!==r,C=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),y(!1),b(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(f=>f.json()).then(f=>{s(f.content??""),u(f.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const N=o.useCallback(async()=>{if(!(!p||C)){g(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),y(!0),setTimeout(()=>y(!1),2e3))}finally{g(!1)}}},[n,l.path,p,C]),v=o.useCallback(()=>{s(r)},[r]),T=o.useCallback(async()=>{if(!C){x(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(b(!1),e())}catch{}finally{x(!1)}}},[l.path,C,e]);o.useEffect(()=>{function f(D){!C&&(D.metaKey||D.ctrlKey)&&D.key==="s"&&(D.preventDefault(),N())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[N,C]);function E(){return w?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(te,{variant:"outline",className:F("h-5 text-xs",it[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(pe,{scope:l.scope,pluginName:l.pluginName}),t.jsx(ge,{cli:l.cli,variant:"full"}),C&&t.jsxs(te,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(he,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),p&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(je,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(lt,{value:n??"",onChange:s,readOnly:C,filePath:l.path}),!C&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(O,{size:"xs",onClick:N,disabled:!p||d,children:[t.jsx(H,{"data-icon":"inline-start"}),E()]}),t.jsxs(O,{variant:"outline",size:"xs",onClick:v,disabled:!p,children:[t.jsx(et,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(le,{open:k,onOpenChange:b,children:[t.jsxs(Oe,{render:t.jsx(O,{variant:"outline",size:"xs"}),children:[t.jsx(tt,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",disabled:S,children:"Cancel"}),t.jsxs(me,{variant:"destructive",size:"sm",disabled:S,onClick:()=>void T(),children:[S&&t.jsx(ze,{"data-icon":"inline-start"}),S?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ft(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ae,{className:"border-0",children:t.jsxs(Le,{children:[t.jsx(Be,{variant:"icon",children:t.jsx(nt,{})}),t.jsx($e,{children:"Select a configuration file"}),t.jsx(Fe,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function ht(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function pt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",ht(n)].some(r=>r.toLowerCase().includes(i)))}const vt=o.memo(function({projectPath:e,initialFilePath:i}){var q,J;const n=Ge("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[g,w]=o.useState(!1),[y,k]=o.useState(null),[b,S]=o.useState(""),[x,p]=o.useState(null),[C,N]=o.useState(""),[v,T]=o.useState(null),E=o.useRef(!1),f=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",h=await A(a);if(h.ok){const _=await h.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!i||u||E.current)return;const a=s.flatMap(h=>Y(h.items,h.scope,h.pluginName)).find(h=>h.path===i);a&&(d(a),E.current=!0)},[i,u,s]);const D=ct(s),z=Object.fromEntries(se.map(a=>[a,pt(D[a],b)])),R=(q=s.find(a=>a.scope==="global"))==null?void 0:q.baseDir,I=(J=s.find(a=>a.scope==="project"))==null?void 0:J.baseDir,L=o.useCallback(a=>{d(a),w(!1),k(null)},[]),B=o.useCallback((a,h,_)=>{k(null),f(),d({path:a,name:a.split("/").pop()||"",fileType:h,readOnly:!1,scope:_,description:""})},[f]),j=o.useCallback(()=>{d(null),f()},[f]),U=o.useCallback(a=>{if(!n||!R&&!I)return;const h=rt[a];h&&k({category:a,globalDir:R?`${R}/${h.subdir}`:null,projectDir:I?`${I}/${h.subdir}`:null,fileType:h.fileType})},[n,R,I]),Q=o.useCallback(a=>{!n||a.readOnly||T(a)},[n]),M=o.useCallback(async()=>{if(!n||!v||v.readOnly)return;const a=v;T(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),f())}catch{}},[n,f,v,c]),P=o.useCallback(a=>{if(!n||a.readOnly)return;const h=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");p(a),N(h)},[n]),$=o.useCallback(async()=>{if(!(!n||!x||!C.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:x.path,newName:C.trim()})});if(a.ok){const h=await a.json();p(null),N(""),await f(),h.newPath&&d({...x,path:h.newPath,name:h.newPath.split("/").pop()||x.name})}}catch{}},[n,x,C,f]),be=o.useCallback(()=>{p(null),N("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:F("min-h-0 shrink-0 flex-col border-r bg-sidebar md:flex md:w-80",c&&!g?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Me,{children:[t.jsx(ne,{children:t.jsx(st,{"data-icon":"inline-start"})}),t.jsx(Pe,{value:b,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),b&&t.jsx(ne,{align:"inline-end",children:t.jsx(Ue,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(K,{"data-icon":"inline-start"})})})]})}),t.jsx(_e,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,h)=>t.jsx(Ve,{className:"h-8 w-full"},h))}):se.map(a=>{const h=a==="agents"||a==="skills"||a==="commands";return t.jsx(mt,{category:a,items:z[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:L,onNewFile:n&&h?()=>U(a):void 0,onDeleteItem:n?Q:void 0,onRenameItem:n?P:void 0,renamingPath:(x==null?void 0:x.path)??null,renameValue:C,onRenameValueChange:N,onRenameSubmit:$,onRenameCancel:be,creatingInCategory:n&&(y==null?void 0:y.category)===a?y:null,onCreated:B,onCancelCreate:()=>k(null)},a)})})})]}),t.jsx("div",{className:F("min-h-0 min-w-0 flex-1 flex-col md:flex",c&&!g?"flex":"hidden"),children:c?t.jsxs(t.Fragment,{children:[t.jsxs(O,{variant:"ghost",className:"min-h-11 shrink-0 justify-start md:hidden",onClick:()=>w(!0),children:[t.jsx(at,{"data-icon":"inline-start"}),"All configuration files"]}),t.jsx(xt,{file:c,onDeleted:j,readOnly:!n})]}):t.jsx(ft,{})}),t.jsx(le,{open:v!==null,onOpenChange:a=>{a||T(null)},children:t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',v==null?void 0:v.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",children:"Cancel"}),t.jsx(me,{variant:"destructive",size:"sm",onClick:()=>void M(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{vt as ConfigBrowser};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as z,r as _,j as f}from"./vendor-react-gGw_S5I_.js";import{a0 as F,a1 as K,_ as A,a2 as O}from"./index-
|
|
1
|
+
import{c as z,r as _,j as f}from"./vendor-react-gGw_S5I_.js";import{a0 as F,a1 as K,_ as A,a2 as O}from"./index-C6wvrmo0.js";const X=2e5;function Q(l){const e=z.c(35),{value:t,onChange:v,readOnly:u,filePath:y,ariaLabel:E,textareaRef:p,onKeyDown:L,onSelect:S}=l,h=F(),[d,I]=_.useState(null),m=_.useRef(null),x=_.useRef(null);let g;e[0]!==y?(g=K(y)??"markdown",e[0]=y,e[1]=g):g=e[1];const b=g,j=t.length>X;let k,R;e[2]!==h||e[3]!==b||e[4]!==j||e[5]!==t?(k=()=>{if(j){I(null);return}let r=!1;const M=setTimeout(()=>{O(t,b,h).then(P=>{r||I(P)})},80);return()=>{r=!0,clearTimeout(M)}},R=[t,b,h,j],e[2]=h,e[3]=b,e[4]=j,e[5]=t,e[6]=k,e[7]=R):(k=e[6],R=e[7]),_.useEffect(k,R);let T;e[8]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{m.current&&x.current&&(x.current.scrollTop=m.current.scrollTop,x.current.scrollLeft=m.current.scrollLeft)},e[8]=T):T=e[8];const G=T;let w;e[9]!==p?(w=r=>{m.current=r,p&&(p.current=r)},e[9]=p,e[10]=w):w=e[10];const C=w,N=u&&"opacity-70";let n;e[11]!==N?(n=A("absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",N),e[11]=N,e[12]=n):n=e[12];let s;e[13]!==d||e[14]!==t?(s=d?d.map($):f.jsx("code",{className:"text-foreground",children:t}),e[13]=d,e[14]=t,e[15]=s):s=e[15];let o;e[16]!==n||e[17]!==s?(o=f.jsx("pre",{ref:x,"aria-hidden":!0,className:n,children:s}),e[16]=n,e[17]=s,e[18]=o):o=e[18];let a;e[19]!==v?(a=r=>v(r.target.value),e[19]=v,e[20]=a):a=e[20];const D=u&&"cursor-default";let c;e[21]!==D?(c=A("absolute inset-0 w-full h-full resize-none bg-transparent font-mono text-[13px] leading-relaxed p-4 outline-none","text-transparent caret-foreground selection:bg-info/30","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",D),e[21]=D,e[22]=c):c=e[22];let i;e[23]!==E||e[24]!==C||e[25]!==L||e[26]!==S||e[27]!==u||e[28]!==a||e[29]!==c||e[30]!==t?(i=f.jsx("textarea",{ref:C,"aria-label":E,value:t,onChange:a,onScroll:G,onKeyDown:L,onSelect:S,readOnly:u,spellCheck:!1,className:c,placeholder:"Empty file"}),e[23]=E,e[24]=C,e[25]=L,e[26]=S,e[27]=u,e[28]=a,e[29]=c,e[30]=t,e[31]=i):i=e[31];let H;return e[32]!==i||e[33]!==o?(H=f.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[o,i]}),e[32]=i,e[33]=o,e[34]=H):H=e[34],H}function $(l,e){return f.jsxs("span",{children:[l.map(q),`
|
|
2
2
|
`]},e)}function q(l,e){return f.jsx("span",{style:{color:l.color},children:l.content},e)}export{Q as H};
|
package/dist/web/assets/{KeyboardShortcutsDialog-DKPBP4Tr.js → KeyboardShortcutsDialog-DQuepxQo.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-
|
|
1
|
+
import{c as q,j as t,r as k}from"./vendor-react-gGw_S5I_.js";import{D as F,g as $,K as T,e as Q,B as P,f as Y,r as _,h as H,i as M,j as U,k as J,l as V,I as W,m as X,n as Z,o as ee,A as te,p as se,q as ae,s as le,t as ne,u as re}from"./index-C6wvrmo0.js";import{R as O,K as oe,S as ce}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const ie=new Set(["Alt","Control","Meta","Shift"]);function fe(e){const s=q.c(6),{open:f,onOpenChange:l}=e,x=f?"open":"closed";let a;s[0]!==x?(a=t.jsx(de,{},x),s[0]=x,s[1]=a):a=s[1];let r;return s[2]!==l||s[3]!==f||s[4]!==a?(r=t.jsx(F,{open:f,onOpenChange:l,children:a}),s[2]=l,s[3]=f,s[4]=a,s[5]=r):r=s[5],r}function de(){const e=q.c(45),[s,f]=k.useState(""),[l,x]=k.useState(null),[a,r]=k.useState(null),[B,G]=k.useState($);let E,I;e[0]!==l?(E=()=>{if(!l)return;const D=l,A=function(n){if(n.key==="Escape"){n.preventDefault(),n.stopPropagation(),x(null),r(null);return}if(ie.has(n.key))return;n.preventDefault(),n.stopPropagation();const c=le(n),p=ne(c,D);if(p){r(`Already assigned to “${p.label}”.`);return}re(D,c),G($()),x(null),r(null)};return window.addEventListener("keydown",A,!0),()=>window.removeEventListener("keydown",A,!0)},I=[l],e[0]=l,e[1]=E,e[2]=I):(E=e[1],I=e[2]),k.useEffect(E,I);let g,j,d,y,b,N,S,w,m,u,h;if(e[3]!==B||e[4]!==a||e[5]!==s||e[6]!==l){const D=s.trim().toLowerCase(),A=D?T.filter(i=>`${i.label} ${i.description} ${i.group}`.toLowerCase().includes(D)):T;j=H,S="max-w-2xl gap-0 overflow-hidden p-0",w=!1,e[18]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsxs(M,{className:"p-4 pb-3",children:[t.jsxs(U,{className:"flex items-center gap-2",children:[t.jsx(oe,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4"}),"Keyboard shortcuts"]}),t.jsx(J,{children:"Click a shortcut, then press a new key combination. Changes are saved on this device."})]}),u=t.jsx(V,{}),e[18]=m,e[19]=u):(m=e[18],u=e[19]);let K;e[20]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx(W,{children:t.jsx(ce,{"data-icon":"inline-start","aria-hidden":"true"})}),e[20]=K):K=e[20];let n;e[21]===Symbol.for("react.memo_cache_sentinel")?(n=i=>f(i.target.value),e[21]=n):n=e[21];let c;e[22]!==s?(c=t.jsxs(X,{className:"flex-1",children:[K,t.jsx(Z,{"aria-label":"Search keyboard shortcuts",value:s,onChange:n,placeholder:"Search shortcuts…"})]}),e[22]=s,e[23]=c):c=e[23];let p;e[24]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsxs(P,{variant:"outline",size:"sm",onClick:()=>{ee(),G($()),r(null)},children:[t.jsx(O,{"data-icon":"inline-start"}),"Reset all"]}),e[24]=p):p=e[24],e[25]!==c?(h=t.jsxs("div",{className:"flex items-center gap-2 p-3",children:[c,p]}),e[25]=c,e[26]=h):h=e[26],e[27]!==a?(d=a&&t.jsx(te,{variant:"destructive",className:"mx-3 mb-2 w-auto",children:t.jsxs(se,{children:[a," Press another shortcut or Esc to cancel."]})}),e[27]=a,e[28]=d):d=e[28],g=ae,N="h-[min(28rem,60vh)]",y="flex flex-col gap-4 px-3 pb-4",b=Q.map(i=>{const L=A.filter(o=>o.group===i);return L.length===0?null:t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"px-2 py-1 text-xs font-medium text-muted-foreground",children:i}),L.map(o=>{const z=l===o.command;return t.jsxs("div",{className:"flex min-h-12 items-center gap-3 rounded-md px-2 py-1.5 hover:bg-accent",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm",children:o.label}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:o.description})]}),t.jsx(P,{variant:z?"secondary":"outline",size:"sm",className:"min-w-28 font-mono text-xs",onClick:()=>{r(null),x(z?null:o.command)},"aria-label":`Change shortcut for ${o.label}`,children:z?"Press keys…":Y(B[o.command])}),t.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>{_(o.command),G($()),r(null)},"aria-label":`Reset shortcut for ${o.label}`,children:t.jsx(O,{"data-icon":"inline-start"})})]},o.command)})]},i)}),e[3]=B,e[4]=a,e[5]=s,e[6]=l,e[7]=g,e[8]=j,e[9]=d,e[10]=y,e[11]=b,e[12]=N,e[13]=S,e[14]=w,e[15]=m,e[16]=u,e[17]=h}else g=e[7],j=e[8],d=e[9],y=e[10],b=e[11],N=e[12],S=e[13],w=e[14],m=e[15],u=e[16],h=e[17];let C;e[29]!==y||e[30]!==b?(C=t.jsx("div",{className:y,children:b}),e[29]=y,e[30]=b,e[31]=C):C=e[31];let v;e[32]!==g||e[33]!==C||e[34]!==N?(v=t.jsx(g,{className:N,children:C}),e[32]=g,e[33]=C,e[34]=N,e[35]=v):v=e[35];let R;return e[36]!==j||e[37]!==d||e[38]!==v||e[39]!==S||e[40]!==w||e[41]!==m||e[42]!==u||e[43]!==h?(R=t.jsxs(j,{className:S,showCloseButton:w,children:[m,u,h,d,v]}),e[36]=j,e[37]=d,e[38]=v,e[39]=S,e[40]=w,e[41]=m,e[42]=u,e[43]=h,e[44]=R):R=e[44],R}export{fe as KeyboardShortcutsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-
|
|
1
|
+
import{r as x,c as d,j as s}from"./vendor-react-gGw_S5I_.js";import{S as p,a as f,b as j,c as g,F as C,d as S}from"./index-C6wvrmo0.js";import"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const E=x.memo(function(c){const e=d.c(10),{open:l,onClose:a,session:r,sessionChangeKey:h}=c;let i;e[0]!==a?(i=m=>{m||a()},e[0]=a,e[1]=i):i=e[1];let t;e[2]===Symbol.for("react.memo_cache_sentinel")?(t=s.jsxs(p,{className:"shrink-0 px-4 py-3",children:[s.jsx(f,{children:"File changes"}),s.jsx(j,{className:"sr-only",children:"Review files changed in this session."})]}),e[2]=t):t=e[2];let n;e[3]!==r||e[4]!==h?(n=s.jsxs(g,{side:"bottom",className:"h-[72svh] max-h-[92svh] rounded-t-xl",children:[t,s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(C,{session:r,sessionChangeKey:h})})]}),e[3]=r,e[4]=h,e[5]=n):n=e[5];let o;return e[6]!==l||e[7]!==i||e[8]!==n?(o=s.jsx(S,{open:l,onOpenChange:i,children:n}),e[6]=l,e[7]=i,e[8]=n,e[9]=o):o=e[9],o});export{E as MobileFileChanges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as ue,r as C,j as t}from"./vendor-react-gGw_S5I_.js";import{V as Q,b5 as Ie,aY as X,b6 as Qe,aZ as Ee,b7 as Xe,b1 as de,B as R,U as Fe,b8 as et,b9 as Ge,ba as Ke,bb as Je,bc as We,bd as Ye,be as Ze,A as se,p as ne,bf as tt,a4 as $e,bg as st,bh as Be,ae as nt,af as it,ai as lt,ac as at,ah as ot,ag as rt,ab as ct,aa as dt,aS as De,bi as ut,bj as ft,D as ht,h as mt,i as pt,j as xt,k as gt,bk as jt,bl as bt,bm as vt,bn as Ae,bo as Oe,E as yt,y as Ct,z as wt,G as Nt,H as St}from"./index-C6wvrmo0.js";import{b as kt,ak as $t}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function Me(l){const e=l.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Dt(l,e){if(l.length===0&&e.length===0)return 0;if(l.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(l.length,e.length);s+=1){const i=l[s],r=e[s];if(i===void 0)return-1;if(r===void 0)return 1;const a=/^\d+$/.test(i),n=/^\d+$/.test(r);if(a&&n){if(Number(i)!==Number(r))return Number(i)<Number(r)?-1:1;continue}if(a!==n)return a?-1:1;if(i!==r)return i<r?-1:1}return 0}function It(l,e){const s=Me(l),i=Me(e);if(!s||!i)return null;for(let r=0;r<3;r+=1)if(s.parts[r]!==i.parts[r])return s.parts[r]<i.parts[r]?-1:1;return Dt(s.prerelease,i.prerelease)}function qe(l){const e=ue.c(33),{value:s,onChange:i,projects:r,disabled:a}=l,n=a===void 0?!1:a,d=C.useId();let o;e[0]!==s.projectIds||e[1]!==s.type?(o=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=o):o=e[2];let v;e[3]!==o?(v=new Set(o),e[3]=o,e[4]=v):v=e[4];const y=v;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Qe,{children:"Available in"}),e[5]=h):h=e[5];const w=`${d}-all`,j=s.type==="all";let c;e[6]!==i?(c=N=>i(N?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=i,e[7]=c):c=e[7];let p;e[8]!==n||e[9]!==w||e[10]!==j||e[11]!==c?(p=t.jsx(Ie,{id:w,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=w,e[10]=j,e[11]=c,e[12]=p):p=e[12];const m=`${d}-all`;let x;e[13]!==m?(x=t.jsx(X,{htmlFor:m,children:"All projects on this host, including new projects"}),e[13]=m,e[14]=x):x=e[14];let g;e[15]!==x||e[16]!==p?(g=t.jsxs(Q,{orientation:"horizontal",children:[p,x]}),e[15]=x,e[16]=p,e[17]=g):g=e[17];let b;e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==r||e[22]!==y||e[23]!==s.projectIds||e[24]!==s.type?(b=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:r.map(N=>t.jsxs(Q,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-${N.id}`,checked:y.has(N.id),disabled:n,onCheckedChange:D=>i({type:"projects",projectIds:D?[...s.projectIds,N.id]:s.projectIds.filter(E=>E!==N.id)})}),t.jsx(X,{htmlFor:`${d}-${N.id}`,children:N.name})]},N.id))}),e[18]=n,e[19]=d,e[20]=i,e[21]=r,e[22]=y,e[23]=s.projectIds,e[24]=s.type,e[25]=b):b=e[25];const k=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let S;e[26]!==k?(S=t.jsx(Ee,{children:k}),e[26]=k,e[27]=S):S=e[27];let u;return e[28]!==n||e[29]!==g||e[30]!==b||e[31]!==S?(u=t.jsxs(Xe,{disabled:n,children:[h,g,b,S]}),e[28]=n,e[29]=g,e[30]=b,e[31]=S,e[32]=u):u=e[32],u}function Et(l){const e=ue.c(69),{client:s,run:i,busy:r}=l,a=C.useId(),[n,d]=C.useState(""),[o,v]=C.useState(""),[y,h]=C.useState(null),[w,j]=C.useState(""),[c,p]=C.useState(!1);let m;e[0]!==s||e[1]!==w||e[2]!==o||e[3]!==n||e[4]!==y||e[5]!==i?(m=Y=>{Y.preventDefault(),i(async()=>{var ce;if(!y||y.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((ce=globalThis.crypto)!=null&&ce.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const M=await y.arrayBuffer(),re=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",M)),Rt).join("");if(re!==w.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:o,root:new TextDecoder("utf-8",{fatal:!0}).decode(M),fingerprint:re}),p(!1),d(""),v(""),j("")})},e[0]=s,e[1]=w,e[2]=o,e[3]=n,e[4]=y,e[5]=i,e[6]=m):m=e[6];const x=`${a}-name`;let g;e[7]!==x?(g=t.jsx(X,{htmlFor:x,children:"Development publisher"}),e[7]=x,e[8]=g):g=e[8];const b=`${a}-name`;let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=Y=>d(Y.target.value),e[9]=k):k=e[9];let S;e[10]!==r||e[11]!==n||e[12]!==b?(S=t.jsx(de,{id:b,value:n,onChange:k,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:r}),e[10]=r,e[11]=n,e[12]=b,e[13]=S):S=e[13];let u;e[14]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx(Ee,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=u):u=e[14];let N;e[15]!==g||e[16]!==S?(N=t.jsxs(Q,{children:[g,S,u]}),e[15]=g,e[16]=S,e[17]=N):N=e[17];const D=`${a}-label`;let E;e[18]!==D?(E=t.jsx(X,{htmlFor:D,children:"Display name"}),e[18]=D,e[19]=E):E=e[19];const A=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let I;e[21]!==r||e[22]!==o||e[23]!==A?(I=t.jsx(de,{id:A,value:o,onChange:O,maxLength:100,required:!0,disabled:r}),e[21]=r,e[22]=o,e[23]=A,e[24]=I):I=e[24];let U;e[25]!==E||e[26]!==I?(U=t.jsxs(Q,{children:[E,I]}),e[25]=E,e[26]=I,e[27]=U):U=e[27];const H=`${a}-root`;let z;e[28]!==H?(z=t.jsx(X,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=z):z=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var M;h(((M=Y.target.files)==null?void 0:M[0])??null),p(!1)},e[30]=G):G=e[30];let F;e[31]!==r||e[32]!==ee?(F=t.jsx(de,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:r}),e[31]=r,e[32]=ee,e[33]=F):F=e[33];let K;e[34]!==z||e[35]!==F?(K=t.jsxs(Q,{children:[z,F]}),e[34]=z,e[35]=F,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(X,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let V;e[39]===Symbol.for("react.memo_cache_sentinel")?(V=Y=>{j(Y.target.value),p(!1)},e[39]=V):V=e[39];let q;e[40]!==r||e[41]!==w||e[42]!==J?(q=t.jsx(de,{id:J,value:w,onChange:V,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:r}),e[40]=r,e[41]=w,e[42]=J,e[43]=q):q=e[43];let T;e[44]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(Ee,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=T):T=e[44];let L;e[45]!==_||e[46]!==q?(L=t.jsxs(Q,{children:[_,q,T]}),e[45]=_,e[46]=q,e[47]=L):L=e[47];const f=`${a}-trust`;let $;e[48]!==r||e[49]!==f||e[50]!==c?($=t.jsx(Ie,{id:f,checked:c,onCheckedChange:p,disabled:r}),e[48]=r,e[49]=f,e[50]=c,e[51]=$):$=e[51];const W=`${a}-trust`;let B;e[52]!==W?(B=t.jsx(X,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=B):B=e[53];let Z;e[54]!==$||e[55]!==B?(Z=t.jsxs(Q,{orientation:"horizontal",children:[$,B]}),e[54]=$,e[55]=B,e[56]=Z):Z=e[56];const ae=r||!c||!y;let ie;e[57]!==ae?(ie=t.jsx(R,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==U||e[60]!==K||e[61]!==L||e[62]!==Z||e[63]!==ie||e[64]!==N?(le=t.jsxs(Fe,{children:[N,U,K,L,Z,ie]}),e[59]=U,e[60]=K,e[61]=L,e[62]=Z,e[63]=ie,e[64]=N,e[65]=le):le=e[65];let oe;return e[66]!==m||e[67]!==le?(oe=t.jsx("form",{onSubmit:m,children:le}),e[66]=m,e[67]=le,e[68]=oe):oe=e[68],oe}function Rt(l){return l.toString(16).padStart(2,"0")}const Pt={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Tt({client:l,preview:e,activation:s,key:i,onFrame:r,onComplete:a,onError:n}){const d=new AbortController;let o="loading",v,y=0;const h=()=>new Error("The installation check expired. Review the package again to retry.");function w(m){o==="canceled"||o==="finished"||(o="canceled",clearTimeout(v),d.abort(),r(null),n(m))}function j(){o==="canceled"||o==="finished"||(o="finished",clearTimeout(v),a())}async function c(m){if(o==="committing"){o="recovering",clearTimeout(v);try{const x=await l.transactionOutcome(e);if(o!=="recovering")return;x.status==="committed"?(await l.refresh(),o==="recovering"&&j()):w(m)}catch{o==="recovering"&&w(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function p(){if(o==="trial"){if(Date.now()>y){w(h());return}o="committing";try{await l.commit(e,d.signal),o==="committing"&&j()}catch(m){await c(m instanceof Error?m:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const m=await l.payload(e.transactionId,d.signal);if(d.signal.aborted||(y=await l.beginTrial(e,d.signal),d.signal.aborted))return;const x=y-Date.now();if(x<=0){w(h());return}o="trial",v=setTimeout(()=>{o==="committing"?(d.abort(),c(h())):o==="trial"&&w(h())},x),r({key:i,client:l,props:{payload:m,digest:e.digest,activationKey:i,context:Pt,active:!1,title:"Plugin installation check",execute:async(g,b)=>{if(d.signal.throwIfAborted(),b.throwIfAborted(),g.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{p()},onError:w}})}catch(m){w(m instanceof Error?m:new Error("Plugin trial failed"))}})(),()=>{o="canceled",clearTimeout(v),d.abort()}}function At(l){const e=ue.c(22),{client:s,preview:i,activation:r,onComplete:a,onError:n}=l,d=`${r}:trial:${i.transactionId}:${i.digest}:${i.registryRevision}`,[o,v]=C.useState(null);let y;e[0]!==a||e[1]!==n?(y={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=y):y=e[2];const h=C.useRef(y);let w;e[3]!==a||e[4]!==n?(w=()=>{h.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=w):w=e[5],C.useLayoutEffect(w);let j,c;e[6]!==r||e[7]!==s||e[8]!==d||e[9]!==i?(j=()=>Tt({client:s,preview:i,activation:r,key:d,onFrame:v,onComplete:()=>h.current.onComplete(),onError:g=>h.current.onError(g)}),c=[s,i,r,d],e[6]=r,e[7]=s,e[8]=d,e[9]=i,e[10]=j,e[11]=c):(j=e[10],c=e[11]),C.useLayoutEffect(j,c);let p;e[12]!==i.manifest.name?(p=t.jsxs("p",{children:["Checking that ",i.manifest.name," starts correctly…"]}),e[12]=i.manifest.name,e[13]=p):p=e[13];let m;e[14]!==r||e[15]!==s||e[16]!==o||e[17]!==d?(m=r&&(o==null?void 0:o.key)===d&&o.client===s&&t.jsx(et,{...o.props}),e[14]=r,e[15]=s,e[16]=o,e[17]=d,e[18]=m):m=e[18];let x;return e[19]!==p||e[20]!==m?(x=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[p,m]}),e[19]=p,e[20]=m,e[21]=x):x=e[21],x}function Ot({connection:l,resourceId:e,target:s,client:i,disabled:r,save:a}){const n=C.useId(),d=l.definition.resources[e],o=l.selected[e],[v,y]=C.useState(""),[h,w]=C.useState(null),[j,c]=C.useState(!1),[p,m]=C.useState(null),x=C.useRef(null);C.useEffect(()=>()=>{var u;return(u=x.current)==null?void 0:u.abort()},[]);const g=tt(l.definition,e).find(u=>!l.selected[u]),b=r||!!g||d.scope==="project"&&!s.projectId;async function k(){var N;(N=x.current)==null||N.abort();const u=new AbortController;x.current=u,c(!0),m(null);try{const D=await i.connectionOptions(s,l.id,e,u.signal);u.signal.aborted||w(D)}catch(D){u.signal.aborted||m(D instanceof Error?D.message:"Unable to load choices")}finally{u.signal.aborted||c(!1)}}const S=o&&!(h!=null&&h.some(u=>u.id===o.id))?[o,...h??[]]:h??[];return t.jsxs(Q,{"data-disabled":b,"data-invalid":!!p,children:[t.jsx(X,{htmlFor:`${n}-resource`,children:d.label}),t.jsx(Ee,{children:d.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),o&&t.jsxs("p",{className:"text-sm",children:["Selected: ",o.label]}),g&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",l.definition.resources[g].label," first."]}),d.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),d.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(R,{type:"button",variant:"outline",size:"sm",disabled:b||j,onClick:()=>{k()},children:j?"Loading choices…":h?"Refresh choices":"Browse choices"}),h&&t.jsxs(Ze,{items:S.map(u=>({value:u.id,label:u.label})),value:(o==null?void 0:o.id)??null,disabled:b||j,onValueChange:u=>{u&&u!==(o==null?void 0:o.id)&&a(l.id,"select",{resourceId:e,value:u})},children:[t.jsx(Ye,{id:`${n}-resource`,"aria-invalid":!!p,children:t.jsx(We,{placeholder:`Choose ${d.label}`})}),t.jsx(Ge,{children:t.jsx(Ke,{children:S.map(u=>t.jsx(Je,{value:u.id,children:u.label},u.id))})})]}),(h==null?void 0:h.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),d.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:u=>{u.preventDefault(),a(l.id,"select",{resourceId:e,value:v.trim()})},children:[t.jsx(de,{id:d.options?`${n}-input`:`${n}-resource`,"aria-label":`${d.label} ${d.input.urls?"URL or ID":"ID"}`,value:v,onChange:u=>y(u.target.value),maxLength:2048,disabled:b,autoComplete:"off",spellCheck:!1,placeholder:d.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(R,{type:"submit",size:"sm",variant:"outline",disabled:b||!v.trim(),children:"Validate and select"})]}),o&&t.jsxs(R,{type:"button",size:"sm",variant:"ghost",disabled:b,onClick:()=>{a(l.id,"select",{resourceId:e,value:null})},children:["Clear ",d.label]}),p&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:p})]})}function Ft(l){const e=ue.c(45),{connection:s,target:i,client:r,disabled:a,save:n}=l,d=C.useId(),[o,v]=C.useState(""),[y,h]=C.useState(!1),w=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let p;e[2]!==c?(p=t.jsx($e,{variant:"outline",children:c}),e[2]=c,e[3]=p):p=e[3];let m;e[4]!==j||e[5]!==p?(m=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,p]}),e[4]=j,e[5]=p,e[6]=m):m=e[6];let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=x):x=e[7];let g;e[8]!==s.definition.operations?(g=new Set(Object.values(s.definition.operations).map(_t)),e[8]=s.definition.operations,e[9]=g):g=e[9];let b;e[10]!==g?(b=[...g],e[10]=g,e[11]=b):b=e[11];const k=b.join(", ");let S;e[12]!==k?(S=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",k]}),e[12]=k,e[13]=S):S=e[13];let u;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==d||e[20]!==y||e[21]!==n?(u=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Q,{orientation:"horizontal",children:[t.jsx(Ie,{id:`${d}-replace`,checked:y,onCheckedChange:h,disabled:a}),t.jsx(X,{htmlFor:`${d}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(R,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:y})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=d,e[20]=y,e[21]=n,e[22]=u):u=e[22];let N;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==d||e[29]!==n||e[30]!==o?(N=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:A=>{A.preventDefault();const O=o.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Fe,{children:[t.jsxs(Q,{"data-disabled":a,children:[t.jsx(X,{htmlFor:`${d}-secret`,children:s.definition.secret.label}),t.jsx(de,{id:`${d}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:o,onChange:A=>v(A.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(R,{type:"submit",size:"sm",disabled:a||!o.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(R,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=d,e[29]=n,e[30]=o,e[31]=N):N=e[31];let D;e[32]!==r||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==i?(D=s.status!=="disconnected"&&t.jsx(Fe,{children:Object.keys(s.definition.resources).map(A=>t.jsx(Ot,{connection:s,resourceId:A,target:i,client:r,disabled:a,save:n},A))}),e[32]=r,e[33]=s,e[34]=a,e[35]=n,e[36]=i,e[37]=D):D=e[37];let E;return e[38]!==s.label||e[39]!==S||e[40]!==u||e[41]!==N||e[42]!==D||e[43]!==m?(E=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":w,children:[m,x,S,u,N,D]}),e[38]=s.label,e[39]=S,e[40]=u,e[41]=N,e[42]=D,e[43]=m,e[44]=E):E=e[44],E}function _t(l){return l.origin}function zt({client:l,target:e}){const[s,i]=C.useState(null),[r,a]=C.useState(null),[n,d]=C.useState(!1),o=C.useRef(null),v=C.useRef(!1),y=e.pluginId,h=e.projectId;C.useEffect(()=>{const j=new AbortController;return o.current=j,l.connections({pluginId:y,projectId:h},j.signal).then(c=>{j.signal.aborted||i(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),o.current=null}},[l,y,h]);async function w(j,c,p){if(!s||v.current||!o.current||o.current.signal.aborted)return;v.current=!0;const m=o.current.signal;d(!0),a(null);try{const x=await l.changeConnection(e,j,c,p,s.revision,m);m.aborted||i(x)}catch(x){m.aborted||a(x instanceof Error?x.message:"Connection change failed")}finally{v.current=!1,m.aborted||d(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[r&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:r})}),!s&&!r&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Ft,{connection:j,target:e,client:l,disabled:n,save:w},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function Vt(l){const e=ue.c(32),{client:s,status:i,pluginId:r,initialProjectId:a}=l,[n,d]=C.useState(a),o=C.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let y;e[1]!==i.projects?(y=[v,...i.projects.map(Ut)],e[1]=i.projects,e[2]=y):y=e[2];const h=y;let w;e[3]!==o?(w=t.jsx(X,{htmlFor:o,children:"Project settings"}),e[3]=o,e[4]=w):w=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=E=>d(E||null),e[5]=c):c=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=t.jsx(We,{}),e[6]=p):p=e[6];let m;e[7]!==o?(m=t.jsx(Ye,{id:o,children:p}),e[7]=o,e[8]=m):m=e[8];let x;e[9]!==h?(x=t.jsx(Ge,{children:t.jsx(Ke,{children:h.map(Lt)})}),e[9]=h,e[10]=x):x=e[10];let g;e[11]!==h||e[12]!==j||e[13]!==m||e[14]!==x?(g=t.jsxs(Ze,{items:h,value:j,onValueChange:c,children:[m,x]}),e[11]=h,e[12]=j,e[13]=m,e[14]=x,e[15]=g):g=e[15];let b;e[16]!==i.host.name?(b=t.jsxs(Ee,{children:["Connection credentials belong to ",i.host.name,". Project resources stay within the project you choose."]}),e[16]=i.host.name,e[17]=b):b=e[17];let k;e[18]!==b||e[19]!==w||e[20]!==g?(k=t.jsxs(Q,{children:[w,g,b]}),e[18]=b,e[19]=w,e[20]=g,e[21]=k):k=e[21];const S=`${r}:${n??"host"}:${i.connectionRevision??0}`;let u;e[22]!==r||e[23]!==n?(u={pluginId:r,projectId:n},e[22]=r,e[23]=n,e[24]=u):u=e[24];let N;e[25]!==s||e[26]!==S||e[27]!==u?(N=t.jsx(zt,{client:s,target:u},S),e[25]=s,e[26]=S,e[27]=u,e[28]=N):N=e[28];let D;return e[29]!==k||e[30]!==N?(D=t.jsxs("div",{className:"flex flex-col gap-4",children:[k,N]}),e[29]=k,e[30]=N,e[31]=D):D=e[31],D}function Lt(l){return t.jsx(Je,{value:l.value,children:l.label},l.value)}function Ut(l){return{value:l.id,label:l.name}}function qt(l){var ie;const e=ue.c(174),{plugin:s,status:i,client:r,busy:a,run:n,onPreview:d,onConnections:o,onUpdate:v}=l,y=C.useId(),[h,w]=C.useState(s.scope),[j,c]=C.useState(!1),[p,m]=C.useState(!1);let x,g,b,k,S,u,N,D,E,A,O,I;if(e[0]!==a||e[1]!==r||e[2]!==o||e[3]!==d||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==h||e[8]!==i.host.name||e[9]!==i.projects||e[10]!==i.runtime||e[11]!==i.store){const le=st(),oe=Be(s.manifest,le,i.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==r||e[25]!==s.id||e[26]!==n||e[27]!==i.store?(Y=(P,Te)=>n(()=>r.changeInstalled(s.id,P,Te,i.store.revision)),e[24]=r,e[25]=s.id,e[26]=n,e[27]=i.store,e[28]=Y):Y=e[28];const M=Y,re=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let ce;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==i.store?(ce=s.lastError&&((ie=i.store.availableSeeds)==null?void 0:ie.find(P=>P.manifest.id===s.id&&P.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=i.store,e[33]=ce):ce=e[33];const _e=ce;A="flex flex-col gap-3 rounded-lg border p-4";let fe;e[34]!==s.manifest.name?(fe=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=fe):fe=e[35];let he;e[36]!==s.id||e[37]!==s.manifest.version?(he=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=he):he=e[38];let me;e[39]!==fe||e[40]!==he?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[fe,he]}),e[39]=fe,e[40]=he,e[41]=me):me=e[41];const ze=re==="Enabled"?"secondary":"outline";let pe;e[42]!==re||e[43]!==ze?(pe=t.jsx($e,{variant:ze,children:re}),e[42]=re,e[43]=ze,e[44]=pe):pe=e[44],e[45]!==me||e[46]!==pe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,pe]}),e[45]=me,e[46]=pe,e[47]=O):O=e[47],e[48]!==s.lastError?(I=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=I):I=e[49],g=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(P=>t.jsxs("p",{children:[P.side==="client"?"This client":P.side==="host"?i.host.name:"This package",": ",P.name," requires ",P.required,"; available ",P.actual??"none","."]},`${P.side}:${P.code}:${P.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==M||e[51]!==s.enabled?(xe=()=>M("enabled",{enabled:!s.enabled}),e[50]=M,e[51]=s.enabled,e[52]=xe):xe=e[52];const Ve=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==Ve?(ge=t.jsx(R,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:Ve}),e[53]=a,e[54]=xe,e[55]=Ve,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==o||e[59]!==s.id||e[60]!==s.manifest.permissions.connections.length?(je=s.manifest.permissions.connections.length>0&&t.jsx(R,{size:"sm",variant:"outline",disabled:a,onClick:()=>o(s.id),children:"Connections"}),e[57]=a,e[58]=o,e[59]=s.id,e[60]=s.manifest.permissions.connections.length,e[61]=je):je=e[61];const Le=a||s.pinned;let be;e[62]!==v||e[63]!==s?(be=()=>v(s),e[62]=v,e[63]=s,e[64]=be):be=e[64];let ve;e[65]!==Le||e[66]!==be?(ve=t.jsx(R,{size:"sm",variant:"outline",disabled:Le,onClick:be,children:"Update from file"}),e[65]=Le,e[66]=be,e[67]=ve):ve=e[67];let ye;e[68]!==a||e[69]!==r||e[70]!==d||e[71]!==s.id||e[72]!==s.scope||e[73]!==_e||e[74]!==n?(ye=_e&&t.jsx(R,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>d(await r.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[68]=a,e[69]=r,e[70]=d,e[71]=s.id,e[72]=s.scope,e[73]=_e,e[74]=n,e[75]=ye):ye=e[75];let Ce;e[76]!==M||e[77]!==s.pinned?(Ce=()=>M("pin",{pinned:!s.pinned}),e[76]=M,e[77]=s.pinned,e[78]=Ce):Ce=e[78];const Ue=s.pinned?"Unpin version":"Pin version";let we;e[79]!==a||e[80]!==Ce||e[81]!==Ue?(we=t.jsx(R,{size:"sm",variant:"outline",disabled:a,onClick:Ce,children:Ue}),e[79]=a,e[80]=Ce,e[81]=Ue,e[82]=we):we=e[82];let Re;e[83]===Symbol.for("react.memo_cache_sentinel")?(Re=()=>{m(!1),c(!0)},e[83]=Re):Re=e[83];let Ne;e[84]!==a?(Ne=t.jsx(R,{size:"sm",variant:"ghost",disabled:a,onClick:Re,children:"Uninstall"}),e[84]=a,e[85]=Ne):Ne=e[85],e[86]!==ge||e[87]!==je||e[88]!==ve||e[89]!==ye||e[90]!==we||e[91]!==Ne?(b=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,we,Ne]}),e[86]=ge,e[87]=je,e[88]=ve,e[89]=ye,e[90]=we,e[91]=Ne,e[92]=b):b=e[92],e[93]!==s.pinned?(k=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[93]=s.pinned,e[94]=k):k=e[94],D="text-sm",e[95]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[95]=E):E=e[95],x="flex flex-col gap-4 pt-4",e[96]!==a||e[97]!==h||e[98]!==i.projects?(S=t.jsx(qe,{value:h,onChange:w,projects:i.projects,disabled:a}),e[96]=a,e[97]=h,e[98]=i.projects,e[99]=S):S=e[99];let Se;e[100]!==a||e[101]!==s.scope||e[102]!==h?(Se=a||JSON.stringify(h)===JSON.stringify(s.scope),e[100]=a,e[101]=s.scope,e[102]=h,e[103]=Se):Se=e[103];let ke;e[104]!==M||e[105]!==h?(ke=()=>M("scope",{scope:h}),e[104]=M,e[105]=h,e[106]=ke):ke=e[106],e[107]!==i.host.name||e[108]!==Se||e[109]!==ke?(u=t.jsxs(R,{size:"sm",variant:"outline",disabled:Se,onClick:ke,children:["Save projects on ",i.host.name]}),e[107]=i.host.name,e[108]=Se,e[109]=ke,e[110]=u):u=e[110];let Pe;e[111]!==s.selectedDigest?(Pe=P=>P.digest!==s.selectedDigest,e[111]=s.selectedDigest,e[112]=Pe):Pe=e[112],N=s.versions.filter(Pe).map(P=>{const Te=!P.unavailableReason&&Be(P.manifest,le,i.runtime,{allowPrerelease:P.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(R,{size:"sm",variant:"outline",disabled:a||s.pinned||!Te,onClick:()=>n(async()=>d({...await r.rollback(s.id,P.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",P.manifest.version]}),!Te&&t.jsx("p",{className:"text-xs text-muted-foreground",children:P.unavailableReason??"This version is incompatible with the connected host or client."})]},P.digest)}),e[0]=a,e[1]=r,e[2]=o,e[3]=d,e[4]=v,e[5]=s,e[6]=n,e[7]=h,e[8]=i.host.name,e[9]=i.projects,e[10]=i.runtime,e[11]=i.store,e[12]=x,e[13]=g,e[14]=b,e[15]=k,e[16]=S,e[17]=u,e[18]=N,e[19]=D,e[20]=E,e[21]=A,e[22]=O,e[23]=I}else x=e[12],g=e[13],b=e[14],k=e[15],S=e[16],u=e[17],N=e[18],D=e[19],E=e[20],A=e[21],O=e[22],I=e[23];let U;e[113]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[113]=U):U=e[113];let H;e[114]!==x||e[115]!==S||e[116]!==u||e[117]!==N?(H=t.jsxs("div",{className:x,children:[S,u,N,U]}),e[114]=x,e[115]=S,e[116]=u,e[117]=N,e[118]=H):H=e[118];let z;e[119]!==H||e[120]!==D||e[121]!==E?(z=t.jsxs("details",{className:D,children:[E,H]}),e[119]=H,e[120]=D,e[121]=E,e[122]=z):z=e[122];let ee;e[123]!==s.manifest.name?(ee=t.jsxs(nt,{children:["Uninstall ",s.manifest.name,"?"]}),e[123]=s.manifest.name,e[124]=ee):ee=e[124];let G;e[125]!==i.host.name?(G=t.jsxs(it,{children:["This removes the plugin from ",i.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[125]=i.host.name,e[126]=G):G=e[126];let F;e[127]!==ee||e[128]!==G?(F=t.jsxs(at,{children:[ee,G]}),e[127]=ee,e[128]=G,e[129]=F):F=e[129];const K=`${y}-delete`,te=a||i.connectionRevision===void 0;let _;e[130]!==p||e[131]!==K||e[132]!==te?(_=t.jsx(Ie,{id:K,checked:p,onCheckedChange:m,disabled:te}),e[130]=p,e[131]=K,e[132]=te,e[133]=_):_=e[133];const J=`${y}-delete`;let V;e[134]!==J?(V=t.jsx(X,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[134]=J,e[135]=V):V=e[135];let q;e[136]!==_||e[137]!==V?(q=t.jsxs(Q,{orientation:"horizontal",children:[_,V]}),e[136]=_,e[137]=V,e[138]=q):q=e[138];let T;e[139]!==p?(T=p&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[139]=p,e[140]=T):T=e[140];let L;e[141]!==a?(L=t.jsx(ot,{disabled:a,children:"Cancel"}),e[141]=a,e[142]=L):L=e[142];let f;e[143]!==r||e[144]!==p||e[145]!==s.id||e[146]!==n||e[147]!==i.connectionRevision||e[148]!==i.store?(f=()=>{c(!1),n(()=>r.changeInstalled(s.id,"uninstall",p?{deleteData:!0,expectedConnectionRevision:i.connectionRevision}:{deleteData:!1},i.store.revision))},e[143]=r,e[144]=p,e[145]=s.id,e[146]=n,e[147]=i.connectionRevision,e[148]=i.store,e[149]=f):f=e[149];let $;e[150]!==a||e[151]!==i.host.name||e[152]!==f?($=t.jsxs(lt,{variant:"destructive",disabled:a,onClick:f,children:["Uninstall from ",i.host.name]}),e[150]=a,e[151]=i.host.name,e[152]=f,e[153]=$):$=e[153];let W;e[154]!==L||e[155]!==$?(W=t.jsxs(rt,{children:[L,$]}),e[154]=L,e[155]=$,e[156]=W):W=e[156];let B;e[157]!==F||e[158]!==q||e[159]!==T||e[160]!==W?(B=t.jsxs(ct,{children:[F,q,T,W]}),e[157]=F,e[158]=q,e[159]=T,e[160]=W,e[161]=B):B=e[161];let Z;e[162]!==j||e[163]!==B?(Z=t.jsx(dt,{open:j,onOpenChange:c,children:B}),e[162]=j,e[163]=B,e[164]=Z):Z=e[164];let ae;return e[165]!==g||e[166]!==b||e[167]!==k||e[168]!==z||e[169]!==Z||e[170]!==A||e[171]!==O||e[172]!==I?(ae=t.jsxs("article",{className:A,children:[O,I,g,b,k,z,Z]}),e[165]=g,e[166]=b,e[167]=k,e[168]=z,e[169]=Z,e[170]=A,e[171]=O,e[172]=I,e[173]=ae):ae=e[173],ae}const Bt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Mt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"};function He(l){const e=l.permissions;return[...e.context.map(()=>"Read the selected project's name and plugin identifier"),...e.composer.map(()=>"Append text to your draft message"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...e.connections.flatMap(s=>s.operations.map(i=>`Use connection ${s.id}: ${i}`)),...e.integrations.flatMap(s=>s.operations.map(i=>i==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":`Read ${Bt[s.id]} ${Mt[i]} using this host's signed-in CLI`))]}function Ht(l){var j;const e=ue.c(32),{preview:s}=l;let i,r,a,n,d,o;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=He(s.manifest),p=s.previousManifest?He(s.previousManifest):null,m=p?c.filter(b=>!p.includes(b)):[],x=p?p.filter(b=>!c.includes(b)):[],g=s.previousConnectionDefinitions?s.connectionDefinitions.filter(b=>{var S;const k=(S=s.previousConnectionDefinitions)==null?void 0:S.find(u=>u.id===b.id);return!k||JSON.stringify(k)!==JSON.stringify(b)}):[];i="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(r=s.oldVersion&&t.jsxs(se,{children:[t.jsx(De,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=r):r=e[14],a=p&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),m.length===0&&x.length===0&&g.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),m.map(Qt),x.map(Zt),g.map(Yt)]}),n=s.oldVersion&&!p&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=d):d=e[15],o=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(Wt)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=i,e[7]=r,e[8]=a,e[9]=n,e[10]=d,e[11]=o}else i=e[6],r=e[7],a=e[8],n=e[9],d=e[10],o=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Gt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let y;e[18]!==s.incompatibleClients?(y=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(De,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=y):y=e[19];let h;e[20]!==s.digest?(h=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=h):h=e[21];let w;return e[22]!==i||e[23]!==r||e[24]!==a||e[25]!==n||e[26]!==d||e[27]!==o||e[28]!==v||e[29]!==y||e[30]!==h?(w=t.jsxs("div",{className:i,children:[r,a,n,d,o,v,y,h]}),e[22]=i,e[23]=r,e[24]=a,e[25]=n,e[26]=d,e[27]=o,e[28]=v,e[29]=y,e[30]=h,e[31]=w):w=e[31],w}function Gt(l){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:l.label}),t.jsxs("p",{children:["Access to ",Object.values(l.resources).map(Jt).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(l.operations).map(Kt))].join(", ")]})]},l.id)}function Kt(l){return l.origin}function Jt(l){return l.label}function Wt(l){return t.jsx("li",{children:l},l)}function Yt(l){return t.jsxs("p",{children:["Changed connection: ",l.label,". Review its destinations and access below."]},l.id)}function Zt(l){return t.jsxs("p",{children:["Removed: ",l]},`remove:${l}`)}function Qt(l){return t.jsxs("p",{children:["Added: ",l]},`add:${l}`)}function is({client:l,state:e,currentPath:s,onClose:i,initialPluginId:r}){var L;const a=C.useId(),n=e.status,d=ut(),o=(n==null?void 0:n.safeMode)||d,{project:v,resolving:y}=ft({client:l,status:n,activation:e.activation,projectPath:s}),[h,w]=C.useState(null),j=h??{type:"projects",projectIds:v?[v.id]:[]},[c,p]=C.useState(null),[m,x]=C.useState({activation:"",hostName:""}),[g,b]=C.useState(!1),[k,S]=C.useState(!1),[u,N]=C.useState(null),[D,E]=C.useState(null),[A,O]=C.useState("installed"),[I,U]=C.useState(null),[H,z]=C.useState(null),[ee,G]=C.useState(r),F=n==null?void 0:n.store.plugins.find(f=>f.id===ee),K=C.useRef(!1),te=!!(n!=null&&n.store.available)&&m.activation===e.activation;function _(f){x({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),p(f)}C.useEffect(()=>{!c||te&&!(o&&g)||(b(!1),p(null),N("The host connection or plugin execution state changed. Review the package again before installing."),l.cancel(c).catch(()=>{}))},[l,c,te,o,g]),C.useEffect(()=>()=>{c&&l.cancel(c).catch(()=>{})},[l,c]);async function J(f){if(!K.current){K.current=!0,S(!0),N(null),E(null);try{await f()}catch($){N($ instanceof Error?$.message:"Plugin action failed")}finally{K.current=!1,S(!1)}}}function V(){const f=c;b(!1),p(null),f&&l.cancel(f).catch(()=>{})}async function q(){if(!H||!I&&!h&&y)return;const f=await l.stage(H,(I==null?void 0:I.scope)??j);if(I&&f.manifest.id!==I.id)throw await l.cancel(f),new Error(`Choose a package for ${I.manifest.name} (${I.id}).`);_(f)}const T=k||g||!(n!=null&&n.store.available);return t.jsx(ht,{open:!0,onOpenChange:f=>{!f&&!k&&!g&&(V(),i())},children:t.jsxs(mt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!k&&!g,children:[t.jsxs(pt,{children:[t.jsx(xt,{children:"Plugins"}),t.jsx(gt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||u||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:n!=null&&n.store.available&&!u&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:u??e.error??(n==null?void 0:n.store.error)})]}),D&&t.jsx(se,{children:t.jsx(ne,{children:D})}),o&&t.jsxs(se,{children:[t.jsx(De,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(R,{size:"sm",variant:"outline",disabled:k||g||(n==null?void 0:n.safeMode),onClick:()=>jt(!d),children:d?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(R,{variant:"outline",disabled:k,onClick:()=>{J(()=>l.refresh())},children:[t.jsx(kt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&F&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("h2",{className:"font-medium",children:[F.manifest.name," connections"]}),t.jsx(R,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),t.jsx(Vt,{client:l,status:n,pluginId:F.id,initialProjectId:(v==null?void 0:v.id)??null},`${F.id}:${n.store.revision}`)]}),n&&!F&&!c&&t.jsxs(bt,{value:A,onValueChange:f=>{O(String(f)),U(null),z(null)},children:[t.jsxs(vt,{className:"h-auto flex-wrap",children:[t.jsx(Ae,{value:"installed",children:"Installed"}),t.jsx(Ae,{value:"browse",children:"Browse"}),t.jsx(Ae,{value:"install",children:"Install from file"}),t.jsx(Ae,{value:"publishers",children:"Publishers"})]}),t.jsx(Oe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(f=>t.jsx(qt,{plugin:f,status:n,client:l,busy:T,run:$=>{J($)},onPreview:_,onConnections:G,onUpdate:$=>{U($),z(null),O("install")}},`${f.id}:${n.store.revision}`)):t.jsx(yt,{children:t.jsxs(Ct,{children:[t.jsx(wt,{variant:"icon",children:t.jsx($t,{})}),t.jsx(Nt,{children:"No installed plugins"}),t.jsx(St,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Oe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),(n.store.availableSeeds??[]).map(f=>{const $=n.store.plugins.find(B=>B.id===f.manifest.id),W=$&&It(f.manifest.version,$.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:f.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[f.manifest.version," · ",f.manifest.publisher]})]}),W?t.jsx(R,{size:"sm",disabled:T||$.pinned,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,$.scope)))},children:$.pinned?"Pinned to installed version":"Review update"}):$?t.jsx($e,{variant:"outline",children:"Installed"}):t.jsx(R,{size:"sm",disabled:T||!h&&y,onClick:()=>{J(async()=>_(await l.stageSeed(f.manifest.id,j)))},children:"Review installation"})]},f.manifest.id)}),!((L=n.store.availableSeeds)!=null&&L.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Oe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:f=>{f.preventDefault(),J(q)},children:t.jsxs(Fe,{children:[I&&t.jsxs("p",{className:"text-sm",children:["Update ",I.manifest.name," from ",I.manifest.version,". Existing project access is retained."]}),t.jsxs(Q,{children:[t.jsx(X,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(de,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:T,required:!0,onChange:f=>{var $;return z((($=f.target.files)==null?void 0:$[0])??null)}})]}),!I&&t.jsx(qe,{value:j,onChange:w,projects:n.projects,disabled:T}),t.jsxs(R,{type:"submit",disabled:T||!H||!I&&!h&&y,children:["Review ",I?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Oe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(f=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[f.label," ",t.jsx($e,{variant:"outline",children:f.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[f.id," · ",f.fingerprint]})]},f.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Et,{client:l,busy:T,run:f=>{J(f)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",m.hostName]}),t.jsx($e,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Ht,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(f=>{var $;return(($=n==null?void 0:n.projects.find(W=>W.id===f))==null?void 0:$.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(De,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(f=>t.jsxs("li",{children:[f.side,": ",f.name," requires ",f.required,"; available ",f.actual??"none","."]},`${f.side}:${f.code}:${f.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(f=>f.name).join(", "),"."]})}),g&&te&&!o?t.jsxs(t.Fragment,{children:[t.jsx(At,{client:l,preview:c,activation:e.activation,onComplete:()=>{b(!1),p(null),E(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${m.hostName}.`),O("installed"),U(null)},onError:f=>{N(f.message),V()}}),t.jsxs(R,{variant:"outline",onClick:V,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(R,{variant:"outline",disabled:k,onClick:V,children:"Cancel"}),t.jsxs(R,{disabled:T||!te||!c.compatibility.compatible||o,onClick:()=>{N(null),b(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",m.hostName]})]})]})]})]})})}export{is as PluginsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as t}from"./vendor-react-gGw_S5I_.js";import{T as ae,B as g,l as K,U as ie,V as oe,m as le,n as ce,I as de,W as G,X as ue,Y as he,Z as pe,_ as me,E as fe,y as xe,z as we,G as ve,H as ge,$ as be,w as je,Q as b}from"./index-
|
|
1
|
+
import{r as n,j as t}from"./vendor-react-gGw_S5I_.js";import{T as ae,B as g,l as K,U as ie,V as oe,m as le,n as ce,I as de,W as G,X as ue,Y as he,Z as pe,_ as me,E as fe,y as xe,z as we,G as ve,H as ge,$ as be,w as je,Q as b}from"./index-C6wvrmo0.js";import{E as H,X as ye,b as Se,c as Ie,d as Ne,M as ke,T as Ee,e as Me,f as Pe,Z as ze,g as Re}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const W=360,Te=560,B="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",k=.5,E=1.5,N=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:Ee},desktop:{label:"Desktop",width:1280,height:800,icon:ke}};function Ce(){try{const s=Number(localStorage.getItem(B));if(Number.isFinite(s)&&s>=W)return s}catch{}return Te}function De(){try{const s=localStorage.getItem(Y);if(s&&s in h)return s}catch{}return"responsive"}function We(){try{const s=localStorage.getItem(_);if(s===null)return 1;const i=Number(s);if(Number.isFinite(i))return Math.min(E,Math.max(k,i))}catch{}return 1}function X(s){return be(`cogpit-preview-url:${s}`)}function V(s){const i=s.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const a=new URL(j);return a.protocol!=="http:"&&a.protocol!=="https:"?null:a.href}catch{return null}}function A(s,i){return`http://${i||"localhost"}:${s}/`}function Le({cwd:s,onClose:i}){const[M,j]=n.useState([]),[a,P]=n.useState(""),[$,y]=n.useState(""),[z,R]=n.useState(null),[Q,q]=n.useState(0),[J,T]=n.useState(!1),[S,ee]=n.useState(Ce),[l,te]=n.useState(De),[o,p]=n.useState(We),c=n.useRef(null),O=n.useRef(null),C=n.useRef(null),{activeDevice:m}=ae(),I=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;n.useEffect(()=>{let e="";try{e=localStorage.getItem(X(s))??""}catch{}const r=e?V(e)??"":"";P(r),y(r),R(null)},[s,re]),n.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(s)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=A(L,I);P(v=>v||w),y(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[s,I]),n.useEffect(()=>{if(a)try{localStorage.setItem(X(s),a)}catch{}},[s,a]),n.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=n.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=n.useCallback(e=>{const r=V(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),y(r),T(!0)},[]),D=n.useCallback(()=>{a&&(T(!0),q(e=>e+1))},[a]);n.useEffect(()=>{function e(r){var d,u,x;if((d=O.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),D();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=C.current)==null||u.focus(),(x=C.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(E,Number((f+N).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(k,Number((f-N).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[D]);const se=n.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:S,currentWidth:S},e.currentTarget.setPointerCapture(e.pointerId)},[S]),ne=n.useCallback(e=>{if(!c.current)return;const r=Math.max(W,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(W,d));c.current.currentWidth=u,ee(u)},[]),F=n.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(B,String(e))}catch{}},[]);return t.jsxs("aside",{ref:O,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-background",style:{width:S},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:se,onPointerMove:ne,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(ye,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U($)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:C,"aria-label":"Preview URL","aria-invalid":!!z,value:$,onChange:e=>y(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!a,onClick:D,"aria-label":"Refresh preview",children:t.jsx(Se,{"data-icon":"inline-start",className:J?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!a,onClick:()=>window.open(a,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ie,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(Ne,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(A(e,I)),"aria-label":`Open ${I}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=k,onClick:()=>p(e=>Math.max(k,Number((e-N).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=E,onClick:()=>p(e=>Math.min(E,Number((e+N).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:a?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:a,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>T(!1)},`${a}-${Q}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Le as PreviewPanel,V as normalizePreviewUrl};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as l,j as t,c as Ae}from"./vendor-react-gGw_S5I_.js";import{E as Q,y as Y,z as X,G as q,H as W,w as ae,_ as ie,ax as ot,am as je,B as A,ay as Ct,az as kt,aA as Et,aB as Rt,l as xe,a4 as le,m as Dt,I as Ft,n as Lt,Y as nt,Z as he,q as Tt,a8 as Mt,aC as zt,aD as It,D as $t,h as At,i as Ut,j as Ot,k as Pt,aE as Gt,aF as Bt,aa as Kt,ab as Ht,ac as Vt,ae as Qt,af as Yt,ag as Xt,ah as qt,ai as Wt,Q as Jt}from"./index-C6wvrmo0.js";import{H as Zt}from"./HighlightedEditor-BwET41dr.js";import{N as ge,p as $e,F as _t,O as es,C as ts,X as ss,G as ns,S as ls,b as lt,Q as as,U as at,V as is,k as ze}from"./vendor-ui-ZKZkD5k3.js";import{M as rs}from"./vendor-markdown-BE1gYnO9.js";import"./vendor-shiki-DOn6sF-i.js";const os=12,ct="h-6 w-full justify-start gap-1 rounded-none px-2 text-left font-normal";function Se(n,e){return{paddingLeft:8+n*os+(e?0:16)}}function cs(n){const e=n;return typeof e=="object"&&e!==null&&typeof e.name=="string"&&(e.type==="file"||e.type==="directory")}function ds(n){const e=n==null?void 0:n.entries;return Array.isArray(e)?e.filter(cs):[]}async function it(n,e,r){try{const o=await ae(`/api/project-files/tree?cwd=${encodeURIComponent(n)}&dir=${encodeURIComponent(e)}${r?"&refresh=1":""}`);if(!o.ok){const u=await o.json().catch(()=>null),f=u==null?void 0:u.error;throw new Error(typeof f=="string"?f:"Unable to list directory")}const c=await o.json();return{status:"ready",entries:ds(c),scanLimited:c.scanLimited===!0}}catch(o){return{status:"error",message:o instanceof Error?o.message:"Unable to list directory"}}}function fs(n){const e=n.split("/");return e.slice(0,-1).map((r,o)=>e.slice(0,o+1).join("/"))}function us({cwd:n,selectedPath:e,onSelect:r,fileStatus:o,reloadToken:c}){const[u,f]=l.useState(()=>new Map),[g,S]=l.useState(()=>new Set),b=l.useRef(new Set),R=l.useRef(n);R.current=n;const m=l.useCallback(async x=>{if(b.current.has(x))return;b.current.add(x),f(v=>new Map(v).set(x,{status:"loading"}));const w=await it(n,x,!1);b.current.delete(x),R.current===n&&f(v=>new Map(v).set(x,w))},[n]),h=l.useRef(null);l.useEffect(()=>{const x=h.current===n;h.current=n,x||S(new Set),f(new Map([["",{status:"loading"}]]));let w=!1;return it(n,"",x).then(v=>{w||f(new Map([["",v]]))}),()=>{w=!0}},[n,c]),l.useEffect(()=>{if(!e)return;const x=fs(e);x.length!==0&&S(w=>{if(x.every(D=>w.has(D)))return w;const v=new Set(w);for(const D of x)v.add(D);return v})},[e]);const N=l.useCallback(x=>{S(w=>{const v=new Set(w);return v.has(x)?v.delete(x):v.add(x),v})},[]),j=u.get(""),k=ms(j);return t.jsxs("div",{"aria-label":"Project file tree",className:"flex flex-col py-1",children:[k?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(k.Icon,{})}),t.jsx(q,{children:k.title}),t.jsx(W,{children:k.description})]})}):t.jsx(dt,{directory:"",depth:0,state:j,directories:u,expanded:g,selectedPath:e,onSelect:r,onToggle:N,onLoad:m,fileStatus:o}),(j==null?void 0:j.status)==="ready"&&j.scanLimited&&t.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"This project is too large to scan completely."})]})}function ms(n){return(n==null?void 0:n.status)==="error"?{Icon:ge,title:"Could not load files",description:n.message}:(n==null?void 0:n.status)==="ready"&&n.entries.length===0?{Icon:$e,title:"No files",description:"This project has no files to show."}:null}function dt(n){const e=Ae.c(22),{directory:r,depth:o,state:c,onLoad:u,...f}=n;let g,S;if(e[0]!==r||e[1]!==u||e[2]!==c?(g=()=>{c===void 0&&r!==""&&u(r)},S=[r,u,c],e[0]=r,e[1]=u,e[2]=c,e[3]=g,e[4]=S):(g=e[3],S=e[4]),l.useEffect(g,S),!c||c.status==="loading"){let m;e[5]!==o?(m=Se(o,!1),e[5]=o,e[6]=m):m=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(je,{className:"size-3"}),e[7]=h):h=e[7];const N=r===""&&"Loading files…";let j;return e[8]!==m||e[9]!==N?(j=t.jsxs("div",{role:"status",className:"flex h-6 items-center gap-2 text-xs text-muted-foreground",style:m,children:[h,N]}),e[8]=m,e[9]=N,e[10]=j):j=e[10],j}if(c.status==="error"){let m;e[11]!==o?(m=Se(o,!1),e[11]=o,e[12]=m):m=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ge,{"aria-hidden":"true",className:"size-3 shrink-0"}),e[13]=h):h=e[13];let N;e[14]!==c.message?(N=t.jsx("span",{className:"truncate",children:c.message}),e[14]=c.message,e[15]=N):N=e[15];let j;return e[16]!==c.message||e[17]!==m||e[18]!==N?(j=t.jsxs("div",{role:"alert",className:"flex h-6 items-center gap-1.5 truncate text-xs text-destructive",style:m,title:c.message,children:[h,N]}),e[16]=c.message,e[17]=m,e[18]=N,e[19]=j):j=e[19],j}const b=c.entries.map(m=>{const h=r?`${r}/${m.name}`:m.name;return m.type==="directory"?t.jsx(xs,{path:h,name:m.name,depth:o,onLoad:u,...f},h):t.jsx(hs,{path:h,name:m.name,depth:o,selected:f.selectedPath===h,status:f.fileStatus(h),onSelect:f.onSelect},h)});let R;return e[20]!==b?(R=t.jsx(t.Fragment,{children:b}),e[20]=b,e[21]=R):R=e[21],R}function xs(n){const e=Ae.c(48);let r,o,c,u,f,g,S,b,R,m,h,N,j,k,x,w,v;e[0]!==n?({path:S,name:f,depth:u,...b}=n,g=b.expanded.has(S),r=g?_t:es,c=A,h="ghost",N="sm",j=g,k=ct,e[18]!==u?(x=Se(u,!0),e[18]=u,e[19]=x):x=e[19],w=()=>b.onToggle(S),v=S,o=ts,R="true",m=ie("size-3 shrink-0 text-muted-foreground transition-transform",g&&"rotate-90"),e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=u,e[5]=f,e[6]=g,e[7]=S,e[8]=b,e[9]=R,e[10]=m,e[11]=h,e[12]=N,e[13]=j,e[14]=k,e[15]=x,e[16]=w,e[17]=v):(r=e[1],o=e[2],c=e[3],u=e[4],f=e[5],g=e[6],S=e[7],b=e[8],R=e[9],m=e[10],h=e[11],N=e[12],j=e[13],k=e[14],x=e[15],w=e[16],v=e[17]);let D;e[20]!==o||e[21]!==R||e[22]!==m?(D=t.jsx(o,{"aria-hidden":R,className:m}),e[20]=o,e[21]=R,e[22]=m,e[23]=D):D=e[23];let L;e[24]!==r?(L=t.jsx(r,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[24]=r,e[25]=L):L=e[25];let F;e[26]!==f?(F=t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:f}),e[26]=f,e[27]=F):F=e[27];let i;e[28]!==c||e[29]!==D||e[30]!==L||e[31]!==F||e[32]!==h||e[33]!==N||e[34]!==j||e[35]!==k||e[36]!==x||e[37]!==w||e[38]!==v?(i=t.jsxs(c,{variant:h,size:N,"aria-expanded":j,className:k,style:x,onClick:w,title:v,children:[D,L,F]}),e[28]=c,e[29]=D,e[30]=L,e[31]=F,e[32]=h,e[33]=N,e[34]=j,e[35]=k,e[36]=x,e[37]=w,e[38]=v,e[39]=i):i=e[39];let T;e[40]!==u||e[41]!==g||e[42]!==S||e[43]!==b?(T=g&&t.jsx("div",{children:t.jsx(dt,{directory:S,depth:u+1,state:b.directories.get(S),...b})}),e[40]=u,e[41]=g,e[42]=S,e[43]=b,e[44]=T):T=e[44];let U;return e[45]!==i||e[46]!==T?(U=t.jsxs("div",{children:[i,T]}),e[45]=i,e[46]=T,e[47]=U):U=e[47],U}function hs(n){const e=Ae.c(28),{path:r,name:o,depth:c,selected:u,status:f,onSelect:g}=n,S=l.useRef(null);let b;e[0]!==r?(b=ot(r),e[0]=r,e[1]=b):b=e[1];const R=b;let m,h;e[2]!==u?(m=()=>{var T,U;u&&((U=(T=S.current)==null?void 0:T.scrollIntoView)==null||U.call(T,{block:"nearest"}))},h=[u],e[2]=u,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);const N=u||void 0,j=u?"secondary":"ghost";let k;e[5]!==c?(k=Se(c,!1),e[5]=c,e[6]=k):k=e[6];let x;e[7]!==g||e[8]!==r?(x=()=>g(r),e[7]=g,e[8]=r,e[9]=x):x=e[9];let w;e[10]!==R?(w=t.jsx(R,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[10]=R,e[11]=w):w=e[11];const v=f&&f.className;let D;e[12]!==v?(D=ie("min-w-0 flex-1 truncate text-xs",v),e[12]=v,e[13]=D):D=e[13];let L;e[14]!==o||e[15]!==D?(L=t.jsx("span",{className:D,children:o}),e[14]=o,e[15]=D,e[16]=L):L=e[16];let F;e[17]!==f?(F=f&&t.jsx("span",{className:ie("shrink-0 font-mono text-[10px]",f.className),title:f.label,children:f.code}),e[17]=f,e[18]=F):F=e[18];let i;return e[19]!==r||e[20]!==L||e[21]!==F||e[22]!==N||e[23]!==j||e[24]!==k||e[25]!==x||e[26]!==w?(i=t.jsxs(A,{ref:S,"aria-current":N,variant:j,size:"sm",className:ct,style:k,onClick:x,title:r,children:[w,L,F]}),e[19]=r,e[20]=L,e[21]=F,e[22]=N,e[23]=j,e[24]=k,e[25]=x,e[26]=w,e[27]=i):i=e[27],i}const ps={"?":{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 Ie(n){const e=n.workTreeStatus.trim()||n.indexStatus.trim();return ps[e]??{label:"Changed",className:"text-muted-foreground"}}function js(n){return`${n.indexStatus}${n.workTreeStatus}`.trim()||"?"}const gs=new Set([".md",".mdx",".markdown"]);function rt(n){const e=n.lastIndexOf(".");return e!==-1&&gs.has(n.slice(e).toLowerCase())}function ws(n,e,r){if(!n||/^(?:[a-z]+:|\/|#)/i.test(n))return n;const o=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",c=[];for(const f of[...o.split("/"),...n.split("/")])f===".."?c.pop():f&&f!=="."&&c.push(f);const u=e.includes("\\")?"\\":"/";return[e.replace(/[\\/]+$/,""),...c].join(u)}async function pe(n,e){try{const r=await n.json();if(r&&typeof r=="object"&&typeof r.error=="string")return r.error}catch{}return e}function ys(n){return n<1024?`${n} B`:`${(n/1024).toFixed(n<10*1024?1:0)} KB`}function vs(n,e){let r=0;for(let o=1;o<e;o+=1){const c=n.indexOf(`
|
|
2
|
+
`,r);if(c<0)return r;r=c+1}return r}function Rs({cwd:n,onClose:e,onAddToPrompt:r,openRequest:o}){const c=l.useRef(null),u=l.useRef(null),f=l.useRef(null),[g,S]=l.useState(""),[b,R]=l.useState([]),[m,h]=l.useState(!0),[N,j]=l.useState(null),[k,x]=l.useState(0),[w,v]=l.useState(!1),[D,L]=l.useState(0),F=l.useRef(!1),[i,T]=l.useState(null),[U,Ce]=l.useState(!0),[M,J]=l.useState(""),[ft,re]=l.useState(""),[O,oe]=l.useState(null),[ut,Ue]=l.useState(0),[K,Oe]=l.useState(!1),[Z,Pe]=l.useState(!1),[Ge,_]=l.useState(null),[mt,ee]=l.useState(!1),[z,ke]=l.useState("all"),[y,Be]=l.useState(null),[Ke,He]=l.useState(!1),[xt,Ve]=l.useState(null),[C,ce]=l.useState("edit"),[E,we]=l.useState(null),[de,Qe]=l.useState(!1),[Ye,Ee]=l.useState(null),[fe,H]=l.useState(null),[P,ye]=l.useState(null),[ve,Re]=l.useState(""),[B,ue]=l.useState(null),I=i!==null&&M!==ft,$=l.useMemo(()=>new Map(((y==null?void 0:y.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[y==null?void 0:y.files]),te=l.useCallback(async()=>{He(!0),Ve(null);try{const s=await ae(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const a=await s.json();Be(a),a.isRepository||ke("all")}catch(s){Be(null),ke("all"),Ve(s instanceof Error?s.message:"Unable to read git status")}finally{He(!1)}},[n]);l.useEffect(()=>{te()},[te]);const De=z==="all"&&g.trim()==="";l.useEffect(()=>{if(De)return;const s=new AbortController,a=window.setTimeout(async()=>{h(!0),j(null);const d=F.current;F.current=!1;try{const p=await ae(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(g)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!p.ok)throw new Error(await pe(p,"Unable to list project files"));const G=await p.json();if(s.signal.aborted)return;const tt=Ct(G),st=G.totalMatches;R(tt),x(typeof st=="number"?st:tt.length),v(G.scanLimited===!0)}catch(p){s.signal.aborted||(R([]),j(p instanceof Error?p.message:"Unable to list project files"))}finally{s.signal.aborted||h(!1)}},120);return()=>{window.clearTimeout(a),s.abort()}},[n,g,D,De]),l.useEffect(()=>{T(null),J(""),re(""),oe(null),_(null),H(null),ce("edit"),we(null),Ee(null),ue(null)},[n]),l.useEffect(()=>{if(!I)return;const s=a=>a.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[I]);const ht=l.useCallback((s,a)=>{const d=u.current;if(!d)return;if(!a||a<1){d.focus();return}const p=vs(s,a);d.blur(),d.setSelectionRange(p,p),d.focus()},[]);l.useEffect(()=>{const s=f.current;!s||!u.current||(f.current=null,ht(s.text,s.line))});const se=l.useCallback(async(s,a)=>{Oe(!0),_(null),ee(!1),H(null);try{const d=await ae(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const p=await d.json();J(p.content),re(p.content),oe(p.mtimeMs),Ue(p.size),f.current={text:p.content,line:a}}catch(d){J(""),re(""),oe(null),_(d instanceof Error?d.message:"Unable to open file")}finally{Oe(!1)}},[n]),ne=l.useCallback(async(s,a)=>{Qe(!0),Ee(null),we(null);try{const d=a?`&originalPath=${encodeURIComponent(a)}`:"",p=await ae(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!p.ok)throw new Error(await pe(p,"Unable to diff file"));we(await p.json())}catch(d){Ee(d instanceof Error?d.message:"Unable to diff file")}finally{Qe(!1)}},[n]),be=l.useCallback(({path:s,mode:a,line:d})=>{var p;if(T(s),Ce(!1),a==="edit"){ce(rt(s)&&!d?"preview":"edit"),se(s,d);return}ce(a),J(""),re(""),oe(null),_(null),ee(!1),H(null),ne(s,(p=$.get(s))==null?void 0:p.originalPath)},[$,ne,se]),Ne=l.useCallback(s=>{if(I){ue({type:"file",target:s});return}be(s)},[I,be]),Xe=l.useCallback(s=>{if(s===i){Ce(!1);return}const a=z==="changes"&&$.has(s)?"diff":"edit";Ne({path:s,mode:a})},[$,z,Ne,i]),qe=l.useRef(0);l.useEffect(()=>{!o||o.token===qe.current||(qe.current=o.token,Ne({path:o.file,mode:o.mode,line:o.line}))},[o,Ne]);const pt=l.useCallback(()=>{var s;!i||C==="diff"||(ce("diff"),(E==null?void 0:E.path)!==i&&!de&&ne(i,(s=$.get(i))==null?void 0:s.originalPath))},[$,E==null?void 0:E.path,de,ne,i,C]),jt=l.useCallback(s=>{!i||C===s||(ce(s),O===null&&!K&&se(i))},[K,se,O,i,C]),Fe=l.useCallback(()=>{var s;if(i){if(C==="diff"){ne(i,(s=$.get(i))==null?void 0:s.originalPath);return}se(i)}},[$,ne,se,i,C]),gt=l.useCallback(()=>{F.current=!0,L(s=>s+1),te(),C==="diff"&&Fe()},[te,Fe,C]),Le=l.useCallback(async()=>{if(!(!i||O===null||!I||Z)){Pe(!0),_(null),ee(!1);try{const s=await ae("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,path:i,content:M,expectedMtimeMs:O})});if(!s.ok)throw new Error(await pe(s,"Unable to save file"));const a=await s.json();re(M),oe(a.mtimeMs),Ue(a.size),ee(!0),we(null),te()}catch(s){_(s instanceof Error?s.message:"Unable to save file")}finally{Pe(!1)}}},[M,n,I,te,O,Z,i]);l.useEffect(()=>{function s(a){var d;(d=c.current)!=null&&d.contains(document.activeElement)&&Jt("projectFileSave",a)&&(a.preventDefault(),Le())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Le]);const wt=l.useCallback(()=>{if(I){ue({type:"close"});return}e()},[I,e]),yt=l.useCallback(()=>{if(!B)return;const s=B;if(ue(null),s.type==="file"){be(s.target);return}e()},[e,be,B]),vt=l.useCallback(s=>{if(s.key!=="Tab")return;s.preventDefault();const a=s.currentTarget,d=a.selectionStart,p=a.selectionEnd,G=`${M.slice(0,d)} ${M.slice(p)}`;J(G),ee(!1),H(null),requestAnimationFrame(()=>{a.selectionStart=d+2,a.selectionEnd=d+2})},[M]),bt=l.useCallback(s=>{const a=s.currentTarget;if(a.selectionStart===a.selectionEnd){H(null);return}const d=M.slice(a.selectionStart,a.selectionEnd),p=M.slice(0,a.selectionStart).split(`
|
|
3
|
+
`).length,G=p+d.split(`
|
|
4
|
+
`).length-1;H({text:d,startLine:p,endLine:G})},[M]),Te=l.useMemo(()=>(i==null?void 0:i.split("/").at(-1))??null,[i]),me=i?$.get(i):void 0,We=i!==null&&rt(i),Je=l.useCallback(s=>{const a=$.get(s);return a?{code:js(a),...Ie(a)}:null},[$]),Nt=l.useMemo(()=>({...kt,img:s=>t.jsx(Et,{src:ws(s.src,n,i??""),alt:s.alt})}),[n,i]),Me=l.useMemo(()=>E&&!E.binary&&!E.tooLarge?Rt(E.original??"",E.current??""):null,[E]),V=l.useMemo(()=>{if(z==="all")return b;const s=g.trim().toLowerCase();return((y==null?void 0:y.files)??[]).map(a=>a.path).filter((a,d,p)=>p.indexOf(a)===d).filter(a=>!s||a.toLowerCase().includes(s)).sort((a,d)=>a.localeCompare(d))},[z,b,y==null?void 0:y.files,g]),Ze=l.useMemo(()=>i&&!V.includes(i)?[i,...V]:V,[V,i]),St=z==="changes"?Ke:m,_e=z==="changes"?xt:N,et=Ke;return t.jsxs("aside",{ref:c,"aria-label":"Project files",className:"relative flex size-full min-h-0 flex-col bg-background",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx($e,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(A,{variant:"ghost",size:"icon-sm",onClick:wt,"aria-label":"Close project files",children:t.jsx(ss,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(y==null?void 0:y.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(ns,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:y.branch??"Detached HEAD",children:y.branch??"detached HEAD"}),y.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",y.upstream]}),(y.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",y.ahead]}),(y.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",y.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[y.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:ie("min-h-0 shrink-0 flex-col md:flex md:w-56",i&&!U?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(Dt,{className:"min-w-0 flex-1",children:[t.jsx(Ft,{children:t.jsx(ls,{"data-icon":"inline-start"})}),t.jsx(Lt,{"aria-label":"Search project files",value:g,onChange:s=>S(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:et,onClick:gt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(lt,{"data-icon":"inline-start",className:et?"animate-spin":void 0})})]}),(y==null?void 0:y.isRepository)&&t.jsxs(nt,{"aria-label":"File scope",value:[z],onValueChange:s=>{const a=s[0];(a==="all"||a==="changes")&&ke(a)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(he,{value:"all",className:"flex-1",children:"All files"}),t.jsx(he,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Tt,{className:"min-h-0 flex-1",children:De?t.jsx(us,{cwd:n,selectedPath:i,onSelect:Xe,fileStatus:Je,reloadToken:D}):St?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading files…"]}):_e?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(q,{children:"Could not load files"}),t.jsx(W,{children:_e})]})}):Ze.length===0?t.jsx(Q,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx($e,{})}),t.jsx(q,{children:z==="changes"?"No working-tree changes":"No matching files"}),t.jsx(W,{children:z==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[Ze.map(s=>{const a=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",p=Je(s),G=ot(s);return t.jsxs(A,{variant:i===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>Xe(s),title:s,children:[t.jsx(G,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:a}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),p&&t.jsx(le,{variant:"outline",className:ie("font-mono",p.className),title:p.label,children:p.code})]},s)}),z==="all"&&(k>V.length||w)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[k>V.length&&`Showing ${V.length} of ${k} matches. Type to narrow the list. `,w&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical",className:"hidden md:block"}),t.jsx("section",{"aria-label":"File editor",className:ie("min-h-0 min-w-0 flex-1 flex-col md:flex",i&&!U?"flex":"hidden"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center gap-2 px-3 py-1 md:flex-nowrap",children:[t.jsx(A,{variant:"ghost",size:"icon-lg",className:"md:hidden",onClick:()=>Ce(!0),"aria-label":"Back to file browser",children:t.jsx(as,{"data-icon":"inline-start"})}),t.jsxs("div",{className:"min-w-0 flex-1 basis-[calc(100%-3.25rem)] md:basis-auto",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:i,children:Te}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:i})]}),(me||C==="diff"||We)&&t.jsxs(nt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?pt():(s[0]==="edit"||s[0]==="preview")&&jt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(me||C==="diff")&&t.jsx(he,{value:"diff",children:"Diff"}),We&&t.jsx(he,{value:"preview",children:"Preview"}),t.jsx(he,{value:"edit",children:"Edit"})]}),C==="diff"&&me&&t.jsx(le,{variant:"outline",className:Ie(me).className,children:Ie(me).label}),C==="diff"&&Me&&t.jsx(Mt,{add:Me.add,del:Me.del}),C!=="diff"&&I&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!I&&mt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&O!==null&&t.jsx("span",{className:"hidden text-xs text-muted-foreground md:inline",children:ys(ut)}),r&&t.jsxs(A,{variant:"outline",size:"sm",disabled:C==="diff"?de||E===null:K||O===null,onClick:()=>{fe?(Re(""),ye(fe)):r({path:i})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(at,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||Z,onClick:Fe,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(lt,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(A,{size:"sm",disabled:!I||K||Z||O===null,onClick:()=>void Le(),children:[Z?t.jsx(je,{"data-icon":"inline-start"}):t.jsx(is,{"data-icon":"inline-start"}),Z?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Ge&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(ge,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Ge})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading diff…"]}):Ye?t.jsx(Q,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(q,{children:"Could not diff this file"}),t.jsx(W,{children:Ye})]})}):E===null?null:E.binary||E.tooLarge?t.jsx(Q,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:E.binary?"Binary file":"File is too large to diff"}),t.jsx(W,{children:E.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):E.original===E.current?t.jsx(Q,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:"No content changes"}),t.jsx(W,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(zt,{oldString:E.original??"",newString:E.current??"",filePath:i,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Opening file…"]}),!K&&O!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${i}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(rs,{components:Nt,remarkPlugins:It,children:M})}):t.jsx(Zt,{textareaRef:u,ariaLabel:`Editing ${i}`,filePath:i,value:M,readOnly:!1,onChange:s=>{J(s),ee(!1),H(null)},onKeyDown:vt,onSelect:bt}))]})]}):t.jsx(Q,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(X,{variant:"icon",children:t.jsx(ze,{})}),t.jsx(q,{children:"Select a file"}),t.jsx(W,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx($t,{open:P!==null,onOpenChange:s=>{s||ye(null)},children:t.jsxs(At,{children:[t.jsxs(Ut,{children:[t.jsx(Ot,{children:"Comment on selected lines"}),t.jsxs(Pt,{children:["Add a review instruction for ",i," lines ",P==null?void 0:P.startLine,"-",P==null?void 0:P.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const a=ve.trim();!i||!P||!a||!r||(r({path:i,...P,comment:a}),ye(null),Re(""))},children:[t.jsx(Gt,{autoFocus:!0,"aria-label":"Review comment",value:ve,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var a;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&ve.trim()&&(s.preventDefault(),(a=s.currentTarget.form)==null||a.requestSubmit())}}),t.jsxs(Bt,{children:[t.jsx(A,{type:"button",variant:"outline",onClick:()=>ye(null),children:"Cancel"}),t.jsxs(A,{type:"submit",disabled:!ve.trim(),children:[t.jsx(at,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Kt,{open:B!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Ht,{size:"sm",children:[t.jsxs(Vt,{children:[t.jsx(Qt,{children:"Discard unsaved changes?"}),t.jsx(Yt,{children:(B==null?void 0:B.type)==="file"?`Your edits to ${Te??"this file"} will be lost when you open ${B.target.path}.`:`Your edits to ${Te??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(Xt,{children:[t.jsx(qt,{size:"sm",children:"Keep editing"}),t.jsx(Wt,{variant:"destructive",size:"sm",onClick:yt,children:"Discard changes"})]})]})})]})}export{Rs as ProjectFilesPanel};
|
package/dist/web/assets/{ProjectSwitcherModal-lncPQd9P.js → ProjectSwitcherModal-Chi-U3vv.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as U,r as A,j as t}from"./vendor-react-gGw_S5I_.js";import{v as X,w as Y,i as Z,j as _,k as ee,C as te,x as se,E as ae,y as ne,z as ie,G as oe,H as le,J as q,L as re,M as J,N as de,O as ce,h as me,P as he,D as ue,Q as fe,R as xe}from"./index-
|
|
1
|
+
import{c as U,r as A,j as t}from"./vendor-react-gGw_S5I_.js";import{v as X,w as Y,i as Z,j as _,k as ee,C as te,x as se,E as ae,y as ne,z as ie,G as oe,H as le,J as q,L as re,M as J,N as de,O as ce,h as me,P as he,D as ue,Q as fe,R as xe}from"./index-C6wvrmo0.js";import{F as Q,a as pe}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function ve(v){const e=U.c(56),{open:l,onClose:n,onNewSession:c,onNewFolder:H,defaultAgentKind:O,currentProjectDirName:u,currentProjectCwd:m}=v;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[0]=S):S=e[0];const[o,K]=A.useState(S),[r,W]=A.useState("");let P,D;e[1]!==l?(P=()=>{l&&(W(""),Y("/api/projects").then(Ne).then(s=>K(s)).catch(()=>K([])))},D=[l],e[1]=l,e[2]=P,e[3]=D):(P=e[2],D=e[3]),A.useEffect(P,D);let E,F;e[4]!==m||e[5]!==u||e[6]!==n||e[7]!==c||e[8]!==l||e[9]!==o?(E=()=>{if(!l)return;const s=function(h){var y;if(fe("newSession",h)&&u){h.preventDefault();const V=m?xe(o,m,"claude")??((y=o.find(B=>B.path===m))==null?void 0:y.dirName)??u:u;c(V,m??void 0),n()}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},F=[l,o,u,m,c,n],e[4]=m,e[5]=u,e[6]=n,e[7]=c,e[8]=l,e[9]=o,e[10]=E,e[11]=F):(E=e[10],F=e[11]),A.useEffect(E,F);const{names:d}=X();let R;e:{if(!r){R=o;break e}let s;if(e[12]!==r||e[13]!==d||e[14]!==o){const a=r.toLowerCase();s=o.filter(h=>{var y;return h.path.toLowerCase().includes(a)||h.shortName.toLowerCase().includes(a)||h.dirName.toLowerCase().includes(a)||((y=d[h.dirName])==null?void 0:y.toLowerCase().includes(a))}),e[12]=r,e[13]=d,e[14]=o,e[15]=s}else s=e[15];R=s}const T=R;let i,f,b;e[16]!==r?(i=r.trim(),f=i.replace(/[\\/]+$/,"")||i,b=i.startsWith("/")||/^[a-z]:[\\/]/i.test(i)||i.startsWith("\\\\"),e[16]=r,e[17]=i,e[18]=f,e[19]=b):(i=e[17],f=e[18],b=e[19]);const G=b;let L;e[20]!==G||e[21]!==f||e[22]!==o?(L=G&&!o.some(s=>(s.path.replace(/[\\/]+$/,"")||s.path)===f),e[20]=G,e[21]=f,e[22]=o,e[23]=L):L=e[23];const I=L;let k;e[24]!==n||e[25]!==c?(k=s=>{c(s.dirName,s.path),n()},e[24]=n,e[25]=c,e[26]=k):k=e[26];const g=k;let x;e[27]!==n?(x=s=>{s||n()},e[27]=n,e[28]=x):x=e[28];let z;e[29]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsxs(Z,{className:"sr-only",children:[t.jsx(_,{children:"Start a session"}),t.jsx(ee,{children:"Choose a project or enter an absolute folder path."})]}),e[29]=z):z=e[29];let p;e[30]!==r?(p=t.jsx(te,{autoFocus:!0,placeholder:"Search projects or paste an absolute path...",value:r,onValueChange:W}),e[30]=r,e[31]=p):p=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(se,{className:"py-0",children:t.jsx(ae,{className:"border-0 py-8",children:t.jsxs(ne,{children:[t.jsx(ie,{variant:"icon",children:t.jsx(Q,{})}),t.jsx(oe,{children:"No projects found"}),t.jsx(le,{children:"Try another name or paste an absolute path."})]})})}),e[32]=M):M=e[32];let N;e[33]!==I||e[34]!==O||e[35]!==i||e[36]!==n||e[37]!==H?(N=I&&t.jsxs(q,{value:`folder:${i}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>{H(i),n()},children:[t.jsx(pe,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),t.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[i," · ",re(O)]})]})]}),e[33]=I,e[34]=O,e[35]=i,e[36]=n,e[37]=H,e[38]=N):N=e[38];let j;if(e[39]!==T||e[40]!==g||e[41]!==d){let s;e[43]!==g||e[44]!==d?(s=a=>t.jsxs(q,{value:`project:${a.dirName}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>g(a),children:[t.jsx(Q,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium",children:d[a.dirName]||J(a.path)}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[d[a.dirName]&&t.jsx("span",{className:"mr-1.5",children:J(a.path)}),a.sessionCount," session",a.sessionCount!==1?"s":"",a.lastModified&&t.jsxs(t.Fragment,{children:[" · ",new Date(a.lastModified).toLocaleDateString()]})]})]})]},a.dirName),e[43]=g,e[44]=d,e[45]=s):s=e[45],j=T.map(s),e[39]=T,e[40]=g,e[41]=d,e[42]=j}else j=e[42];let w;e[46]!==N||e[47]!==j?(w=t.jsxs(de,{className:"max-h-80 p-1",children:[M,t.jsxs(ce,{className:"p-0",children:[N,j]})]}),e[46]=N,e[47]=j,e[48]=w):w=e[48];let C;e[49]!==p||e[50]!==w?(C=t.jsxs(me,{className:"max-w-md gap-0 overflow-hidden p-0",children:[z,t.jsxs(he,{shouldFilter:!1,className:"rounded-none p-0",children:[p,w]})]}),e[49]=p,e[50]=w,e[51]=C):C=e[51];let $;return e[52]!==l||e[53]!==x||e[54]!==C?($=t.jsx(ue,{open:l,onOpenChange:x,children:C}),e[52]=l,e[53]=x,e[54]=C,e[55]=$):$=e[55],$}function Ne(v){return v.ok?v.json():[]}export{ve as ProjectSwitcherModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{ap as jr,Q as as,B as Gr}from"./index-
|
|
1
|
+
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{ap as jr,Q as as,B as Gr}from"./index-C6wvrmo0.js";import{_ as Jr}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";/**
|
|
2
2
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{aw as W,Z as $,i as K,j as L,k as U,Y as H,h as Z,D as q}from"./index-
|
|
1
|
+
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{aw as W,Z as $,i as K,j as L,k as U,Y as H,h as Z,D as q}from"./index-C6wvrmo0.js";import{J as B,v as Q}from"./vendor-ui-ZKZkD5k3.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",R="medium";function V(){try{const s=localStorage.getItem(Y);if(I.some(e=>e.id===s))return s}catch{}return R}let _=typeof window>"u"?R:V();const M=new Set;function J(s){if(typeof document>"u")return;const e=I.find(t=>t.id===s)??I[1];document.documentElement.style.setProperty("--chat-width",e.css)}J(_);function X(){return _}function ee(s){_=s;try{localStorage.setItem(Y,s)}catch{}J(s),M.forEach(e=>e())}function te(s){return M.add(s),()=>M.delete(s)}function se(){const s=O.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 R}function de(s){const e=O.c(42),{open:t,onClose:r,currentTheme:l,onSelectTheme:k,onPreviewTheme:i}=s,[x,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]!==x?(N=()=>{t&&i(W[x].id)},b=[x,t,i],e[4]=i,e[5]=t,e[6]=x,e[7]=N,e[8]=b):(N=e[7],b=e[8]),g.useEffect(N,b);let S,v;e[9]!==i||e[10]!==t?(S=()=>{t||i(null)},v=[t,i],e[9]=i,e[10]=t,e[11]=S,e[12]=v):(S=e[11],v=e[12]),g.useEffect(S,v);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 C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs(K,{className:"border-b p-4 pr-12",children:[n.jsxs(L,{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(U,{children:"Preview a color theme and set the chat width."})]}),e[18]=C):C=e[18];const G=W[x];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(B,{"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(H,{"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 E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=E):E=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:[E,n.jsx(H,{"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 p;e[35]!==m||e[36]!==h?(p=n.jsxs(Z,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[C,m,h]}),e[35]=m,e[36]=h,e[37]=p):p=e[37];let T;return e[38]!==t||e[39]!==p||e[40]!==o?(T=n.jsx(q,{open:t,onOpenChange:o,children:p}),e[38]=t,e[39]=p,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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as X,j as s,r as C}from"./vendor-react-gGw_S5I_.js";import{_ as le,aN as Me,aO as mt,aD as ft,az as xt,aP as Ve,a4 as pe,aQ as Ke,aR as Qe,am as je,a6 as Se,a7 as Ce,B as ne,a9 as Te,w as Re,aL as Le,aH as De,aI as Fe,l as Ue,aJ as Je,A as Ge,aS as pt,p as Xe,aT as ht,aU as gt,aV as jt,E as ze,y as Ae,G as We,H as Pe,aW as bt,d as Nt,c as wt,S as yt,a as vt,aX as kt,b as St,q as Ct,z as Tt,a5 as Rt}from"./index-C6wvrmo0.js";import{M as It}from"./vendor-markdown-BE1gYnO9.js";import{$ as Ze,a0 as et,a1 as tt,a2 as $t,a3 as Ie,R as _t,J as st,A as lt,a4 as qe,h as zt,a5 as At,a6 as Wt,D as Pt,a7 as He,b as Ot,Y as Et}from"./vendor-ui-ZKZkD5k3.js";import"./vendor-shiki-DOn6sF-i.js";const Mt=new Set(["done","error","skipped"]);function Ye(l){return Mt.has(l)}function Lt(l){return l!=="completed"&&l!=="failed"&&l!=="killed"}function nt(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 Dt(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 Ft(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}const at=["headline","oneLineSell","verdict","summary","name","lens"],Jt=new Set(["title","name"]),Bt=new Set(["headline","oneLineSell","verdict"]);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 Ht(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 Ht(l);if(typeof l=="number"||typeof l=="boolean")return String(l);if(Array.isArray(l))return l.length>0?$e(l[0]):"";if(Me(l))for(const e of at){const t=l[e];if(typeof t=="string"&&t.trim())return t.trim()}return""}function Be(l){if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}function Yt(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(It,{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 Oe(l){const e=X.c(21),{value:t,depth:r}=l,a=r===void 0?0:r;if(!Me(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=Be(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(Qt)){let d;e[7]!==t?(d=t.map(Kt),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(Oe,{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(Vt),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:Bt.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:Yt(u)}),s.jsx("div",{className:"min-w-0 text-sm leading-relaxed",children:s.jsx(Oe,{value:c,depth:a+1})})]},u)})]}),e[18]=a,e[19]=t,e[20]=n}else n=e[20];return n}function Vt(l){const[e,t]=l;return Jt.has(e)&&typeof t=="string"&&t.trim().length>0}function Kt(l,e){return s.jsx("li",{className:"pl-1 text-sm leading-relaxed",children:s.jsx(ot,{value:l})},e)}function Qt(l){return!Me(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(Oe,{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 Gt(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]=Ve();let p,j,b,N,S,w,v,g,T,I,A,H,R,y,k,$,W,_,P,O,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=Dt(t.state);let Ne;e[29]!==t.state?(Ne=!Ye(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 Re(`/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"&&Ye(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,H=ct,N=Le,O="sm",I="motion-card motion-list-item gap-0 py-0",b=De,P="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:Gt(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:Ze,children:[Ke(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:et,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:tt,children:Qe(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,R="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]=I,e[18]=A,e[19]=H,e[20]=R,e[21]=y,e[22]=k,e[23]=$,e[24]=W,e[25]=_,e[26]=P,e[27]=O,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],I=e[17],A=e[18],H=e[19],R=e[20],y=e[21],k=e[22],$=e[23],W=e[24],_=e[25],P=e[26],O=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]!==R||e[80]!==y?(Z=s.jsxs(p,{variant:R,className:y,children:[E,T.label]}),e[76]=p,e[77]=T.label,e[78]=E,e[79]=R,e[80]=y,e[81]=Z):Z=e[81];let Y;e[82]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Ie,{className:"mt-0.5 size-4 text-muted-foreground transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"}),e[82]=Y):Y=e[82];let M;e[83]!==Z||e[84]!==k?(M=s.jsxs("div",{className:k,children:[Z,Y]}),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]!==P?(ee=s.jsx(b,{className:P,children:L}),e[92]=b,e[93]=L,e[94]=P,e[95]=ee):ee=e[95];let V;e[96]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Ue,{}),e[96]=V):V=e[96];let K;e[97]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx("h5",{className:"text-sm font-semibold text-foreground",children:"Response"}),e[97]=K):K=e[97];const te=c.status==="loaded"?"Complete agent response":"Saved response preview";let D;e[98]!==te?(D=s.jsxs("div",{children:[K,s.jsx("p",{className:"text-xs text-muted-foreground",children:te})]}),e[98]=te,e[99]=D):D=e[99];let F;e[100]!==w||e[101]!==v?(F=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]=F):F=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(Be(z)),"aria-label":x?"Response copied":"Copy response",title:x?"Copied":"Copy response",children:x?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})}),e[103]=x,e[104]=h,e[105]=z,e[106]=U):U=e[106];let J;e[107]!==F||e[108]!==U?(J=s.jsxs("div",{className:"flex items-center gap-1",children:[F,U]}),e[107]=F,e[108]=U,e[109]=J):J=e[109];let B;e[110]!==D||e[111]!==J?(B=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[D,J]}),e[110]=D,e[111]=J,e[112]=B):B=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 Q;e[117]!==t.promptPreview||e[118]!==m?(Q=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(Ie,{"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]=Q):Q=e[119];let G;e[120]!==B||e[121]!==q||e[122]!==Q?(G=s.jsxs(Te,{children:[V,s.jsxs(Je,{className:"flex flex-col gap-4 px-4 py-4",children:[B,q,Q]})]}),e[120]=B,e[121]=q,e[122]=Q,e[123]=G):G=e[123];let se;e[124]!==N||e[125]!==I||e[126]!==ee||e[127]!==G||e[128]!==O?(se=s.jsxs(N,{size:O,className:I,children:[ee,G]}),e[124]=N,e[125]=I,e[126]=ee,e[127]=G,e[128]=O,e[129]=se):se=e[129];let be;return e[130]!==S||e[131]!==A||e[132]!==H||e[133]!==se?(be=s.jsx(S,{open:A,onOpenChange:H,children:se}),e[130]=S,e[131]=A,e[132]=H,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=nt(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=Ft(t),I=Ut(t.agentCounts),A=g&&t.controllable!==!1;f="flex flex-col gap-6 pb-6";const H=g&&s.jsx("span",{className:le("size-1.5 rounded-full",w.dot)});let R;e[16]!==w||e[17]!==H?(R=s.jsxs(pe,{variant:"outline",className:w.badge,children:[H,w.label]}),e[16]=w,e[17]=H,e[18]=R):R=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]!==R?(k=s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[R,y]}),e[20]=R,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 P;e[30]!==g||e[31]!==A||e[32]!==i||e[33]!==o||e[34]!==n?(P=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]=P):P=e[35];let O;e[36]!==_||e[37]!==P?(O=s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[_,P]}),e[36]=_,e[37]=P,e[38]=O):O=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 Y;e[41]!==Z?(Y=s.jsx(ge,{icon:Wt,value:Z,label:"Phases"}),e[41]=Z,e[42]=Y):Y=e[42];let M;e[43]!==t.totalTokens?(M=Ke(t.totalTokens),e[43]=t.totalTokens,e[44]=M):M=e[44];let L;e[45]!==M?(L=s.jsx(ge,{icon:Ze,value:M,label:"Tokens"}),e[45]=M,e[46]=L):L=e[46];const ee=String(t.totalToolCalls);let V;e[47]!==ee?(V=s.jsx(ge,{icon:et,value:ee,label:"Tool calls"}),e[47]=ee,e[48]=V):V=e[48];let K;e[49]!==t.durationMs?(K=typeof t.durationMs=="number"?Qe(t.durationMs):"In progress",e[49]=t.durationMs,e[50]=K):K=e[50];let te;e[51]!==K?(te=s.jsx(ge,{icon:tt,value:K,label:"Duration",className:"col-span-2 sm:col-span-1"}),e[51]=K,e[52]=te):te=e[52];let D;e[53]!==E||e[54]!==Y||e[55]!==L||e[56]!==V||e[57]!==te?(D=s.jsxs("div",{className:"grid grid-cols-2 gap-px overflow-hidden rounded-lg border bg-border sm:grid-cols-5",children:[E,Y,L,V,te]}),e[53]=E,e[54]=Y,e[55]=L,e[56]=V,e[57]=te,e[58]=D):D=e[58];let F;e[59]!==I?(F=Math.round(I*100),e[59]=I,e[60]=F):F=e[60];let U;e[61]!==F?(U=s.jsx(jt,{value:F,"aria-label":"Workflow progress",className:"flex-1"}),e[61]=F,e[62]=U):U=e[62];let J;e[63]!==I?(J=Math.round(I*100),e[63]=I,e[64]=J):J=e[64];let B;e[65]!==J?(B=s.jsxs("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[J,"%"]}),e[65]=J,e[66]=B):B=e[66];let q;e[67]!==U||e[68]!==B?(q=s.jsxs("div",{className:"flex items-center gap-3",children:[U,B]}),e[67]=U,e[68]=B,e[69]=q):q=e[69],e[70]!==O||e[71]!==D||e[72]!==q?(x=s.jsxs("section",{className:"flex flex-col gap-4",children:[O,D,q]}),e[70]=O,e[71]=D,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(Xe,{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 Q;e[81]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx("p",{className:"px-2 pb-2 pt-1 text-xs font-medium text-muted-foreground",children:"Run outline"}),e[81]=Q):Q=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:[Q,s.jsx("div",{className:"flex flex-col gap-1",children:T.map(ts)})]}),m="flex min-w-0 flex-col gap-8";let G;e[82]!==t.runId||e[83]!==r||e[84]!==a?(G=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]=G):G=e[85],d=T.map(G),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(Pe,{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]=Ve(),h=l.endsWith("…"),p=i??l,j=C.useCallback(async()=>{d(!0),c(!1);try{const b=await Re(`/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(Le,{className:"motion-enter gap-0 py-0",children:[s.jsxs(De,{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(Ie,{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(Be(p)),"aria-label":f?"Outcome copied":"Copy outcome",title:f?"Copied":"Copy outcome",children:f?s.jsx(st,{"data-icon":"inline-start"}):s.jsx(lt,{"data-icon":"inline-start"})})]})]}),s.jsxs(Te,{children:[s.jsx(Ue,{}),s.jsx(Je,{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(De,{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(Pt,{className:"size-4"}),s.jsx(Fe,{children:"Orchestration script"}),s.jsx(Ie,{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(Ue,{}),e[1]=i):i=e[1];let o;e[2]!==t?(o=s.jsxs(Le,{size:"sm",className:"gap-0 py-0",children:[n,s.jsxs(Te,{children:[i,s.jsx(Je,{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 R;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:((R=a[0])==null?void 0:R.runId)??null,T=C.useCallback(async()=>{const y=++v.current;if(!t||!r||!g){f(null);return}try{const k=await Re(`/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 I=C.useCallback(async()=>{if(!b){N(!0);return}if(!(!r||!g)){j(!0),w(null);try{const k=await(await Re("/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,H=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(He,{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(Ot,{"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(He,{})}),s.jsx(We,{children:"No workflows in this session"}),s.jsx(Pe,{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(Xe,{children:S})}),s.jsx(es,{detail:c,dirName:t??"",sessionId:r??"",stopping:p,confirming:b,onForceStop:I})]}):H?s.jsx(ze,{className:"min-h-[50dvh]",children:s.jsxs(Ae,{children:[s.jsx(We,{children:"Could not load this workflow"}),s.jsx(Pe,{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=nt(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:Rt(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};
|