cogpit 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/cli-runtime.js +329 -265
  2. package/dist/instance-worker.js +3 -1
  3. package/dist/web/assets/{CogpitBlock-BycygJkN.js → CogpitBlock-B7SKhn5k.js} +1 -1
  4. package/dist/web/assets/{CommandPaletteHost-BgKoDHcE.js → CommandPaletteHost-Dig9sRnN.js} +1 -1
  5. package/dist/web/assets/{ConfigBrowser-Bg_4DTXP.js → ConfigBrowser-C_4UyHta.js} +1 -1
  6. package/dist/web/assets/{CrewPanel-zGPJa0nm.js → CrewPanel-CyCZndfq.js} +1 -1
  7. package/dist/web/assets/{HighlightedEditor-C2wqN7Xw.js → HighlightedEditor-YAPOkcjz.js} +1 -1
  8. package/dist/web/assets/{KeyboardShortcutsDialog-CUUxScBc.js → KeyboardShortcutsDialog-CjA8MBfY.js} +1 -1
  9. package/dist/web/assets/{MissionHome-BTxUBbuU.js → MissionHome-CK5zZCld.js} +1 -1
  10. package/dist/web/assets/{MobileFileChanges-BN7bdxse.js → MobileFileChanges-DyjwWXMW.js} +1 -1
  11. package/dist/web/assets/{PluginsDialog-XdukDCaQ.js → PluginsDialog-BHKZ3Esx.js} +1 -1
  12. package/dist/web/assets/{PreviewPanel-u6bXlEMm.js → PreviewPanel-CXOXFWWK.js} +1 -1
  13. package/dist/web/assets/{ProjectFilesPanel-BMSrF4EP.js → ProjectFilesPanel-CwBgFc0T.js} +1 -1
  14. package/dist/web/assets/{ProjectSwitcherModal-Ph5R0C2t.js → ProjectSwitcherModal-DB-xcVjM.js} +1 -1
  15. package/dist/web/assets/{TerminalOutput-w6mgZ5a7.js → TerminalOutput-BA4pFb8E.js} +1 -1
  16. package/dist/web/assets/{ThemeSelectorModal-DB69FVzW.js → ThemeSelectorModal-B8nIlHO2.js} +1 -1
  17. package/dist/web/assets/{WorkflowsPanel-DFIpG32k.js → WorkflowsPanel-BZhR5Ld-.js} +1 -1
  18. package/dist/web/assets/{WorktreePanel-B_9oCuoW.js → WorktreePanel-DYxBPlno.js} +1 -1
  19. package/dist/web/assets/{edition-ui-ZYzlZ7yi.js → edition-ui-CXQDiuhB.js} +1 -1
  20. package/dist/web/assets/{index-CKeIY-uM.js → index-B1Aq64LJ.js} +1 -1
  21. package/dist/web/assets/{index-C1aZnlGg.js → index-C0oae6L9.js} +1 -1
  22. package/dist/web/assets/{index-BYjv05SI.js → index-D3WV64DU.js} +11 -11
  23. package/dist/web/assets/{index-vyOkk7K_.js → index-utwOdTFc.js} +2 -2
  24. package/dist/web/assets/{switch-DkwGVNAF.js → switch-B1AuQGfo.js} +1 -1
  25. package/dist/web/index.html +1 -1
  26. package/package.json +2 -1
@@ -15938,7 +15938,7 @@ import { createInterface as createInterface2 } from "node:readline";
15938
15938
  var package_default = {
15939
15939
  name: "cogpit",
15940
15940
  private: true,
15941
- version: "3.4.0",
15941
+ version: "3.4.1",
15942
15942
  description: "Control center for Claude Code, OpenAI Codex, and GitHub Copilot CLI sessions",
15943
15943
  license: "MIT",
15944
15944
  author: {
@@ -16015,6 +16015,7 @@ var package_default = {
16015
16015
  "node-pty": "^1.1.0",
16016
16016
  "proper-lockfile": "4.1.2",
16017
16017
  semver: "7.8.5",
16018
+ "signal-exit": "3.0.7",
16018
16019
  "smol-toml": "1.9.0",
16019
16020
  "tuf-js": "3.1.0",
16020
16021
  "vscode-jsonrpc": "8.2.1",
@@ -16044,6 +16045,7 @@ var package_default = {
16044
16045
  "@types/react": "^19.0.2",
16045
16046
  "@types/react-dom": "^19.0.2",
16046
16047
  "@types/semver": "7.7.1",
16048
+ "@types/signal-exit": "3.0.4",
16047
16049
  "@types/ws": "^8.18.1",
16048
16050
  "@vitejs/plugin-react": "^4.3.4",
16049
16051
  "@vitest/coverage-v8": "^4.1.12",
@@ -1,4 +1,4 @@
1
- import{c as qe,j as O,r as ge}from"./vendor-react-gGw_S5I_.js";import{aM as si,aN as fi,aO as ai,aP as pi,R as di,J as xe,B as Ue}from"./index-BYjv05SI.js";import{N as Kn,Y as hi}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function mi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var U={},Fe={},te={},gn;function ke(){if(gn)return te;gn=1;function t(s){return typeof s>"u"||s===null}function i(s){return typeof s=="object"&&s!==null}function m(s){return Array.isArray(s)?s:t(s)?[]:[s]}function y(s,c){if(c){const A=Object.keys(c);for(let r=0,f=A.length;r<f;r+=1){const C=A[r];s[C]=c[C]}}return s}function p(s,c){let A="";for(let r=0;r<c;r+=1)A+=s;return A}function h(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return te.isNothing=t,te.isObject=i,te.toArray=m,te.repeat=p,te.isNegativeZero=h,te.extend=y,te}var $e,xn;function Ee(){if(xn)return $e;xn=1;function t(m,y){let p="";const h=m.reason||"(unknown reason)";return m.mark?(m.mark.name&&(p+='in "'+m.mark.name+'" '),p+="("+(m.mark.line+1)+":"+(m.mark.column+1)+")",!y&&m.mark.snippet&&(p+=`
1
+ import{c as qe,j as O,r as ge}from"./vendor-react-gGw_S5I_.js";import{aM as si,aN as fi,aO as ai,aP as pi,R as di,J as xe,B as Ue}from"./index-D3WV64DU.js";import{N as Kn,Y as hi}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function mi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var U={},Fe={},te={},gn;function ke(){if(gn)return te;gn=1;function t(s){return typeof s>"u"||s===null}function i(s){return typeof s=="object"&&s!==null}function m(s){return Array.isArray(s)?s:t(s)?[]:[s]}function y(s,c){if(c){const A=Object.keys(c);for(let r=0,f=A.length;r<f;r+=1){const C=A[r];s[C]=c[C]}}return s}function p(s,c){let A="";for(let r=0;r<c;r+=1)A+=s;return A}function h(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return te.isNothing=t,te.isObject=i,te.toArray=m,te.repeat=p,te.isNegativeZero=h,te.extend=y,te}var $e,xn;function Ee(){if(xn)return $e;xn=1;function t(m,y){let p="";const h=m.reason||"(unknown reason)";return m.mark?(m.mark.name&&(p+='in "'+m.mark.name+'" '),p+="("+(m.mark.line+1)+":"+(m.mark.column+1)+")",!y&&m.mark.snippet&&(p+=`
2
2
 
3
3
  `+m.mark.snippet),h+" "+p):h}function i(m,y){Error.call(this),this.name="YAMLException",this.reason=m,this.mark=y,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,i.prototype.toString=function(y){return this.name+": "+t(this,y)},$e=i,$e}var Ge,An;function gi(){if(An)return Ge;An=1;const t=ke();function i(p,h,s,c,A){let r="",f="";const C=Math.floor(A/2)-1;return c-h>C&&(r=" ... ",h=c-C+r.length),s-c>C&&(f=" ...",s=c+C-f.length),{str:r+p.slice(h,s).replace(/\t/g,"→")+f,pos:c-h+r.length}}function m(p,h){return t.repeat(" ",h-p.length)+p}function y(p,h){if(h=Object.create(h||null),!p.buffer)return null;h.maxLength||(h.maxLength=79),typeof h.indent!="number"&&(h.indent=1),typeof h.linesBefore!="number"&&(h.linesBefore=3),typeof h.linesAfter!="number"&&(h.linesAfter=2);const s=/\r?\n|\r|\0/g,c=[0],A=[];let r,f=-1;for(;r=s.exec(p.buffer);)A.push(r.index),c.push(r.index+r[0].length),p.position<=r.index&&f<0&&(f=c.length-2);f<0&&(f=c.length-1);let C="";const L=Math.min(p.line+h.linesAfter,A.length).toString().length,R=h.maxLength-(h.indent+L+3);for(let F=1;F<=h.linesBefore&&!(f-F<0);F++){const H=i(p.buffer,c[f-F],A[f-F],p.position-(c[f]-c[f-F]),R);C=t.repeat(" ",h.indent)+m((p.line-F+1).toString(),L)+" | "+H.str+`
4
4
  `+C}const V=i(p.buffer,c[f],A[f],p.position,R);C+=t.repeat(" ",h.indent)+m((p.line+1).toString(),L)+" | "+V.str+`
@@ -1 +1 @@
1
- import{c as ie,j as u,r as M}from"./vendor-react-gGw_S5I_.js";import{af as h,ag as Z,ah as ue,ai as he,aj as ge,ak as fe,al as ve,am as we,an as Ce,ao as Se,ap as je,aq as be,ar as ye,as as xe,at as ee,au as _,av as Pe,aw as Te,ax as Oe,ay as ke,az as Ne,aA as Fe,aB as Ee,U as Ie}from"./index-BYjv05SI.js";import{P as $e,l as Ae,m as te,S as Re,L as De,H as Le,n as He,o as Me,c as ne,G as Be,F as qe,p as Ge,q as Ke,r as ze,s as Ue,t as We,u as pe,v as ae,w as _e,x as Ve,y as Je,K as Xe,E as Qe,z as Ye,A as Ze,B as oe,D as et,I as tt,J as nt}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,c,l,m,d){return{id:t,label:e,icon:c,run:l,shortcut:m,description:d,value:`${e} ${s}`}}function V(...t){return t.filter(e=>e!==!1&&e!==void 0)}function at(t){const e=ie.c(40);let s,c,l,m,d,w,C,r,S,g,b,f,y,N,x;if(e[0]!==t){const $=V(a("home","Go to Mission Control","home overview dashboard",Le,t.onGoHome),a("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",De,t.onToggleMissionControl,h("missionControl")),...(t.extraActions??[]).map(ot),a("new-session","Start a new session","project agent chat create",$e,t.onNewSession,h("newSession")),t.onDuplicateSession&&a("duplicate-session","Duplicate this session","copy fork clone branch thread",Ae,t.onDuplicateSession),t.canFocusComposer&&a("focus-composer","Focus message composer","chat prompt input",te,t.onFocusComposer,h("focusComposer")),t.onFindInConversation&&a("find-in-conversation","Find in conversation","search text transcript turns matches",Re,t.onFindInConversation,h("findInConversation"))),F=(t.projects??[]).slice(0,8).map(n=>a(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,He,()=>{var i;return(i=t.onOpenProject)==null?void 0:i.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),E=(t.recentSessions??[]).slice(0,10).map(n=>{const v=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,L=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,v,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,te,()=>{var q;return(q=t.onOpenSession)==null?void 0:q.call(t,n.dirName,n.fileName)},void 0,L)}),A=t.devices??[],I=A.length>1&&t.onSwitchDevice?A.slice(0,Z.length).map((n,i)=>a(`device-${n.id}`,n.isActive?`${n.name} (current)`:`Switch to ${n.name}`,`device machine host remote ${n.id}`,n.isLocal?Me:ne,()=>{var v;return(v=t.onSwitchDevice)==null?void 0:v.call(t,n.id)},h(Z[i]))):[],o=V(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Ue,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",ze,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",Ke,t.onToggleProjectFiles,h("projectFiles")),t.onToggleBrowser&&a("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",Ge,t.onToggleBrowser),t.hasFileChanges&&a("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",qe,t.onToggleFileChanges),t.supportsWorktrees&&t.canOpenTerminal&&a("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Be,t.onToggleWorktrees)),R=V(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",tt,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",et,t.onRevealProject),t.onCopyResumeCommand&&a("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",oe,t.onCopyResumeCommand),t.onCopyProjectPath&&a("copy-project-path","Copy project path","workspace directory clipboard",oe,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",Ye,t.onOpenTerminal,h("systemTerminal")),t.onTogglePreview&&a("preview","Toggle development preview","browser localhost dev server website",Qe,t.onTogglePreview,h("preview")),t.onOpenKeyboardShortcuts&&a("keyboard-shortcuts","Customize keyboard shortcuts","keybindings hotkeys settings",Xe,t.onOpenKeyboardShortcuts),t.onOpenConfig&&a("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",Je,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",Ve,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",_e,t.onOpenTheme,h("themeSelector")),a("expand","Expand all groups","conversation details",ae,t.onExpandAll,h("expandAll")),a("expand-payloads","Expand all tool payloads","raw input result diff conversation details",ae,t.onExpandToolPayloads,h("expandToolPayloads")),a("collapse","Collapse all","conversation groups payloads details",pe,t.onCollapseAll),t.onKillAll&&a("kill-all","Kill all agent processes","stop terminate halt everything runaway",We,t.onKillAll),t.onOpenDevices&&a("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",nt,()=>{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",ne,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),k=[{value:"Navigation",items:$},...E.length>0?[{value:"Recent sessions",items:E}]:[],...F.length>0?[{value:"Projects",items:F}]:[],...I.length>0?[{value:"Devices",items:I}]:[],{value:"View",items:o},{value:"Tools",items:R}],D=function(i){t.onOpenChange(!1),i.run()};l=ve,y=t.open,N=t.onOpenChange,x="Command palette",w="Search for a Cogpit action to run.",C="max-w-xl",c=we,S="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(Ce,{"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(ue,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[17]=t.loadingNavigation,e[18]=f):f=e[18],s=Se,m="max-h-[min(26rem,60vh)]",e[19]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(je,{children:"No matching actions."}),e[19]=d):d=e[19],r=k.map(n=>u.jsx(he,{heading:n.value,children:n.items.map(i=>{const v=i.icon;return u.jsxs(ge,{value:i.value,onSelect:()=>D(i),children:[u.jsx(v,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:i.label}),i.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:i.description})]}),i.shortcut&&u.jsx(fe,{children:i.shortcut})]},i.id)})},n.value)),e[0]=t,e[1]=s,e[2]=c,e[3]=l,e[4]=m,e[5]=d,e[6]=w,e[7]=C,e[8]=r,e[9]=S,e[10]=g,e[11]=b,e[12]=f,e[13]=y,e[14]=N,e[15]=x}else s=e[1],c=e[2],l=e[3],m=e[4],d=e[5],w=e[6],C=e[7],r=e[8],S=e[9],g=e[10],b=e[11],f=e[12],y=e[13],N=e[14],x=e[15];let P;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==r?(P=u.jsxs(s,{className:m,children:[d,r]}),e[20]=s,e[21]=m,e[22]=d,e[23]=r,e[24]=P):P=e[24];let T;e[25]!==c||e[26]!==P||e[27]!==S||e[28]!==g||e[29]!==b||e[30]!==f?(T=u.jsxs(c,{label:S,loop:g,children:[b,f,P]}),e[25]=c,e[26]=P,e[27]=S,e[28]=g,e[29]=b,e[30]=f,e[31]=T):T=e[31];let O;return e[32]!==l||e[33]!==w||e[34]!==C||e[35]!==T||e[36]!==y||e[37]!==N||e[38]!==x?(O=u.jsx(l,{open:y,onOpenChange:N,title:x,description:w,className:C,children:T}),e[32]=l,e[33]=w,e[34]=C,e[35]=T,e[36]=y,e[37]=N,e[38]=x,e[39]=O):O=e[39],O}function ot(t){return a(t.id,t.label,t.keywords,t.icon,t.onSelect)}async function se(t,e){const s=await Ie(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const c=await s.json();return Array.isArray(c)?c:[]}function dt(t){var J;const e=ie.c(51);let s,c,l,m,d,w;e[0]!==t?({open:l,currentProjectDirName:s,projectCwd:d,onProcessStarted:c,launchTerminalRequest:w,...m}=t,e[0]=t,e[1]=s,e[2]=c,e[3]=l,e[4]=m,e[5]=d,e[6]=w):(s=e[1],c=e[2],l=e[3],m=e[4],d=e[5],w=e[6]);const C=w===void 0?0:w,r=be();let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[7]=S):S=e[7];const[g,b]=M.useState(S);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[y,N]=M.useState(f),[x,P]=M.useState(!1),T=M.useRef(0),O=ye();let $,F;e[9]!==O||e[10]!==l?($=()=>{if(!l)return;const j=new AbortController,B=Te();return P(!0),Promise.allSettled([se("/api/projects",j.signal),se(Oe({limit:"12",perProject:"3"},O),j.signal)]).then(me=>{const[X,Q]=me;if(j.signal.aborted)return;const Y=Q.status==="fulfilled"?Q.value:[];ke(Y,B),b(X.status==="fulfilled"?X.value:[]),N(Y),P(!1)}),()=>j.abort()},F=[l,O],e[9]=O,e[10]=l,e[11]=$,e[12]=F):($=e[11],F=e[12]),M.useEffect($,F);let E;e[13]!==g?(E=xe(g),e[13]=g,e[14]=E):E=e[14];const A=E;let I;e:{if(d){I=d;break e}if(!s){I=null;break e}let j;e[15]!==s||e[16]!==g?(j=((J=g.find(B=>B.dirName===s))==null?void 0:J.path)??null,e[15]=s,e[16]=g,e[17]=j):j=e[17],I=j}const o=I;let R;e[18]!==c||e[19]!==r||e[20]!==o?(R=()=>{if(!o)return;const j=r.spawnTerminal({cwd:o}),B=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";c({id:j,name:B,type:"terminal",status:"running",source:o})},e[18]=c,e[19]=r,e[20]=o,e[21]=R):R=e[21];const k=R;let D,n;e[22]!==k||e[23]!==C||e[24]!==r.status||e[25]!==o?(n=()=>{C<=T.current||!o||r.status!=="connected"||(T.current=C,k())},D=[k,C,r.status,o],e[22]=k,e[23]=C,e[24]=r.status,e[25]=o,e[26]=D,e[27]=n):(D=e[26],n=e[27]),M.useEffect(n,D);let i;e[28]!==s||e[29]!==o?(i={path:o,dirName:s},e[28]=s,e[29]=o,e[30]=i):i=e[30];const v=i;let L;e[31]!==v?(L=()=>Ne(v),e[31]=v,e[32]=L):L=e[32];const q=L;let G;e[33]!==v?(G=()=>Fe(v),e[33]=v,e[34]=G):G=e[34];const le=G,ce=!ee()&&_("hostFiles"),re=_("hostFiles")&&(!ee()||Pe());let K;e[35]!==o?(K=()=>{o&&Ee(o)},e[35]=o,e[36]=K):K=e[36];const de=K;let H;e[37]!==k||e[38]!==r.status||e[39]!==o?(H=o&&r.status==="connected"&&_("terminal")?k:void 0,e[37]=k,e[38]=r.status,e[39]=o,e[40]=H):H=e[40];const U=o&&re?q:void 0,W=o&&ce?le:void 0,p=o?de:void 0;let z;return e[41]!==x||e[42]!==l||e[43]!==m||e[44]!==y||e[45]!==A||e[46]!==H||e[47]!==U||e[48]!==W||e[49]!==p?(z=u.jsx(at,{...m,open:l,projects:A,recentSessions:y,loadingNavigation:x,onOpenIntegratedTerminal:H,onOpenProjectInEditor:U,onRevealProject:W,onCopyProjectPath:p}),e[41]=x,e[42]=l,e[43]=m,e[44]=y,e[45]=A,e[46]=H,e[47]=U,e[48]=W,e[49]=p,e[50]=z):z=e[50],z}export{dt as CommandPaletteHost};
1
+ import{c as ie,j as u,r as M}from"./vendor-react-gGw_S5I_.js";import{af as h,ag as Z,ah as ue,ai as he,aj as ge,ak as fe,al as ve,am as we,an as Ce,ao as Se,ap as je,aq as be,ar as ye,as as xe,at as ee,au as _,av as Pe,aw as Te,ax as Oe,ay as ke,az as Ne,aA as Fe,aB as Ee,U as Ie}from"./index-D3WV64DU.js";import{P as $e,l as Ae,m as te,S as Re,L as De,H as Le,n as He,o as Me,c as ne,G as Be,F as qe,p as Ge,q as Ke,r as ze,s as Ue,t as We,u as pe,v as ae,w as _e,x as Ve,y as Je,K as Xe,E as Qe,z as Ye,A as Ze,B as oe,D as et,I as tt,J as nt}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,c,l,m,d){return{id:t,label:e,icon:c,run:l,shortcut:m,description:d,value:`${e} ${s}`}}function V(...t){return t.filter(e=>e!==!1&&e!==void 0)}function at(t){const e=ie.c(40);let s,c,l,m,d,w,C,r,S,g,b,f,y,N,x;if(e[0]!==t){const $=V(a("home","Go to Mission Control","home overview dashboard",Le,t.onGoHome),a("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",De,t.onToggleMissionControl,h("missionControl")),...(t.extraActions??[]).map(ot),a("new-session","Start a new session","project agent chat create",$e,t.onNewSession,h("newSession")),t.onDuplicateSession&&a("duplicate-session","Duplicate this session","copy fork clone branch thread",Ae,t.onDuplicateSession),t.canFocusComposer&&a("focus-composer","Focus message composer","chat prompt input",te,t.onFocusComposer,h("focusComposer")),t.onFindInConversation&&a("find-in-conversation","Find in conversation","search text transcript turns matches",Re,t.onFindInConversation,h("findInConversation"))),F=(t.projects??[]).slice(0,8).map(n=>a(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,He,()=>{var i;return(i=t.onOpenProject)==null?void 0:i.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),E=(t.recentSessions??[]).slice(0,10).map(n=>{const v=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,L=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,v,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,te,()=>{var q;return(q=t.onOpenSession)==null?void 0:q.call(t,n.dirName,n.fileName)},void 0,L)}),A=t.devices??[],I=A.length>1&&t.onSwitchDevice?A.slice(0,Z.length).map((n,i)=>a(`device-${n.id}`,n.isActive?`${n.name} (current)`:`Switch to ${n.name}`,`device machine host remote ${n.id}`,n.isLocal?Me:ne,()=>{var v;return(v=t.onSwitchDevice)==null?void 0:v.call(t,n.id)},h(Z[i]))):[],o=V(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Ue,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",ze,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",Ke,t.onToggleProjectFiles,h("projectFiles")),t.onToggleBrowser&&a("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",Ge,t.onToggleBrowser),t.hasFileChanges&&a("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",qe,t.onToggleFileChanges),t.supportsWorktrees&&t.canOpenTerminal&&a("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Be,t.onToggleWorktrees)),R=V(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",tt,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",et,t.onRevealProject),t.onCopyResumeCommand&&a("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",oe,t.onCopyResumeCommand),t.onCopyProjectPath&&a("copy-project-path","Copy project path","workspace directory clipboard",oe,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",Ye,t.onOpenTerminal,h("systemTerminal")),t.onTogglePreview&&a("preview","Toggle development preview","browser localhost dev server website",Qe,t.onTogglePreview,h("preview")),t.onOpenKeyboardShortcuts&&a("keyboard-shortcuts","Customize keyboard shortcuts","keybindings hotkeys settings",Xe,t.onOpenKeyboardShortcuts),t.onOpenConfig&&a("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",Je,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",Ve,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",_e,t.onOpenTheme,h("themeSelector")),a("expand","Expand all groups","conversation details",ae,t.onExpandAll,h("expandAll")),a("expand-payloads","Expand all tool payloads","raw input result diff conversation details",ae,t.onExpandToolPayloads,h("expandToolPayloads")),a("collapse","Collapse all","conversation groups payloads details",pe,t.onCollapseAll),t.onKillAll&&a("kill-all","Kill all agent processes","stop terminate halt everything runaway",We,t.onKillAll),t.onOpenDevices&&a("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",nt,()=>{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",ne,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),k=[{value:"Navigation",items:$},...E.length>0?[{value:"Recent sessions",items:E}]:[],...F.length>0?[{value:"Projects",items:F}]:[],...I.length>0?[{value:"Devices",items:I}]:[],{value:"View",items:o},{value:"Tools",items:R}],D=function(i){t.onOpenChange(!1),i.run()};l=ve,y=t.open,N=t.onOpenChange,x="Command palette",w="Search for a Cogpit action to run.",C="max-w-xl",c=we,S="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(Ce,{"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(ue,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[17]=t.loadingNavigation,e[18]=f):f=e[18],s=Se,m="max-h-[min(26rem,60vh)]",e[19]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(je,{children:"No matching actions."}),e[19]=d):d=e[19],r=k.map(n=>u.jsx(he,{heading:n.value,children:n.items.map(i=>{const v=i.icon;return u.jsxs(ge,{value:i.value,onSelect:()=>D(i),children:[u.jsx(v,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:i.label}),i.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:i.description})]}),i.shortcut&&u.jsx(fe,{children:i.shortcut})]},i.id)})},n.value)),e[0]=t,e[1]=s,e[2]=c,e[3]=l,e[4]=m,e[5]=d,e[6]=w,e[7]=C,e[8]=r,e[9]=S,e[10]=g,e[11]=b,e[12]=f,e[13]=y,e[14]=N,e[15]=x}else s=e[1],c=e[2],l=e[3],m=e[4],d=e[5],w=e[6],C=e[7],r=e[8],S=e[9],g=e[10],b=e[11],f=e[12],y=e[13],N=e[14],x=e[15];let P;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==r?(P=u.jsxs(s,{className:m,children:[d,r]}),e[20]=s,e[21]=m,e[22]=d,e[23]=r,e[24]=P):P=e[24];let T;e[25]!==c||e[26]!==P||e[27]!==S||e[28]!==g||e[29]!==b||e[30]!==f?(T=u.jsxs(c,{label:S,loop:g,children:[b,f,P]}),e[25]=c,e[26]=P,e[27]=S,e[28]=g,e[29]=b,e[30]=f,e[31]=T):T=e[31];let O;return e[32]!==l||e[33]!==w||e[34]!==C||e[35]!==T||e[36]!==y||e[37]!==N||e[38]!==x?(O=u.jsx(l,{open:y,onOpenChange:N,title:x,description:w,className:C,children:T}),e[32]=l,e[33]=w,e[34]=C,e[35]=T,e[36]=y,e[37]=N,e[38]=x,e[39]=O):O=e[39],O}function ot(t){return a(t.id,t.label,t.keywords,t.icon,t.onSelect)}async function se(t,e){const s=await Ie(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const c=await s.json();return Array.isArray(c)?c:[]}function dt(t){var J;const e=ie.c(51);let s,c,l,m,d,w;e[0]!==t?({open:l,currentProjectDirName:s,projectCwd:d,onProcessStarted:c,launchTerminalRequest:w,...m}=t,e[0]=t,e[1]=s,e[2]=c,e[3]=l,e[4]=m,e[5]=d,e[6]=w):(s=e[1],c=e[2],l=e[3],m=e[4],d=e[5],w=e[6]);const C=w===void 0?0:w,r=be();let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[7]=S):S=e[7];const[g,b]=M.useState(S);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[y,N]=M.useState(f),[x,P]=M.useState(!1),T=M.useRef(0),O=ye();let $,F;e[9]!==O||e[10]!==l?($=()=>{if(!l)return;const j=new AbortController,B=Te();return P(!0),Promise.allSettled([se("/api/projects",j.signal),se(Oe({limit:"12",perProject:"3"},O),j.signal)]).then(me=>{const[X,Q]=me;if(j.signal.aborted)return;const Y=Q.status==="fulfilled"?Q.value:[];ke(Y,B),b(X.status==="fulfilled"?X.value:[]),N(Y),P(!1)}),()=>j.abort()},F=[l,O],e[9]=O,e[10]=l,e[11]=$,e[12]=F):($=e[11],F=e[12]),M.useEffect($,F);let E;e[13]!==g?(E=xe(g),e[13]=g,e[14]=E):E=e[14];const A=E;let I;e:{if(d){I=d;break e}if(!s){I=null;break e}let j;e[15]!==s||e[16]!==g?(j=((J=g.find(B=>B.dirName===s))==null?void 0:J.path)??null,e[15]=s,e[16]=g,e[17]=j):j=e[17],I=j}const o=I;let R;e[18]!==c||e[19]!==r||e[20]!==o?(R=()=>{if(!o)return;const j=r.spawnTerminal({cwd:o}),B=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";c({id:j,name:B,type:"terminal",status:"running",source:o})},e[18]=c,e[19]=r,e[20]=o,e[21]=R):R=e[21];const k=R;let D,n;e[22]!==k||e[23]!==C||e[24]!==r.status||e[25]!==o?(n=()=>{C<=T.current||!o||r.status!=="connected"||(T.current=C,k())},D=[k,C,r.status,o],e[22]=k,e[23]=C,e[24]=r.status,e[25]=o,e[26]=D,e[27]=n):(D=e[26],n=e[27]),M.useEffect(n,D);let i;e[28]!==s||e[29]!==o?(i={path:o,dirName:s},e[28]=s,e[29]=o,e[30]=i):i=e[30];const v=i;let L;e[31]!==v?(L=()=>Ne(v),e[31]=v,e[32]=L):L=e[32];const q=L;let G;e[33]!==v?(G=()=>Fe(v),e[33]=v,e[34]=G):G=e[34];const le=G,ce=!ee()&&_("hostFiles"),re=_("hostFiles")&&(!ee()||Pe());let K;e[35]!==o?(K=()=>{o&&Ee(o)},e[35]=o,e[36]=K):K=e[36];const de=K;let H;e[37]!==k||e[38]!==r.status||e[39]!==o?(H=o&&r.status==="connected"&&_("terminal")?k:void 0,e[37]=k,e[38]=r.status,e[39]=o,e[40]=H):H=e[40];const U=o&&re?q:void 0,W=o&&ce?le:void 0,p=o?de:void 0;let z;return e[41]!==x||e[42]!==l||e[43]!==m||e[44]!==y||e[45]!==A||e[46]!==H||e[47]!==U||e[48]!==W||e[49]!==p?(z=u.jsx(at,{...m,open:l,projects:A,recentSessions:y,loadingNavigation:x,onOpenIntegratedTerminal:H,onOpenProjectInEditor:U,onRevealProject:W,onCopyProjectPath:p}),e[41]=x,e[42]=l,e[43]=m,e[44]=y,e[45]=A,e[46]=H,e[47]=U,e[48]=W,e[49]=p,e[50]=z):z=e[50],z}export{dt as CommandPaletteHost};
@@ -1 +1 @@
1
- import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{bf as ye,c4 as Ce,J as F,z as ke,C as q,b6 as X,T as ve,H as Z,bb as ae,B as O,U as A,bW as Ne,bU as Se,bV as we,c5 as De,c6 as Te,c7 as Ee,c8 as V,c9 as Re,ca as ee,cb as Ie,Z as te,a5 as le,cc as Oe,a6 as ie,a7 as re,a9 as oe,aa as ce,ab as de,ac as ue,ad as me,ah as ze,L as Ae,M as Le,N as Be,O as $e,Q as Fe,Y as Ge,m as Me,I as ne,n as Pe,E as Ue,q as _e,cd as Ve}from"./index-BYjv05SI.js";import{av as He,A as Ke,i as Je,a7 as Qe,aw as We,al as Ye,ax as xe,p as fe,ay as qe,az as Xe,W as H,X as K,P as Ze,aA as he,aB as et,k as tt,a4 as nt,S as st,U as at}from"./vendor-ui-DkzcTXCS.js";import{H as lt}from"./HighlightedEditor-C2wqN7Xw.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:We,color:"text-muted-foreground"},agents:{label:"Agents",icon:Qe,color:"text-muted-foreground"},skills:{label:"Skills",icon:Je,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ke,color:"text-muted-foreground"},settings:{label:"Settings",icon:He,color:"text-muted-foreground"}};function J(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...J(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=J(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(Ye,{"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(qe,{"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(q,{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(q,{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 W,Y;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=>J(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=(W=s.find(a=>a.scope==="global"))==null?void 0:W.baseDir,I=(Y=s.find(a=>a.scope==="project"))==null?void 0:Y.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
+ import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{bf as ye,c4 as Ce,J as F,z as ke,C as q,b6 as X,T as ve,H as Z,bb as ae,B as O,U as A,bW as Ne,bU as Se,bV as we,c5 as De,c6 as Te,c7 as Ee,c8 as V,c9 as Re,ca as ee,cb as Ie,Z as te,a5 as le,cc as Oe,a6 as ie,a7 as re,a9 as oe,aa as ce,ab as de,ac as ue,ad as me,ah as ze,L as Ae,M as Le,N as Be,O as $e,Q as Fe,Y as Ge,m as Me,I as ne,n as Pe,E as Ue,q as _e,cd as Ve}from"./index-D3WV64DU.js";import{av as He,A as Ke,i as Je,a7 as Qe,aw as We,al as Ye,ax as xe,p as fe,ay as qe,az as Xe,W as H,X as K,P as Ze,aA as he,aB as et,k as tt,a4 as nt,S as st,U as at}from"./vendor-ui-DkzcTXCS.js";import{H as lt}from"./HighlightedEditor-YAPOkcjz.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:We,color:"text-muted-foreground"},agents:{label:"Agents",icon:Qe,color:"text-muted-foreground"},skills:{label:"Skills",icon:Je,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ke,color:"text-muted-foreground"},settings:{label:"Settings",icon:He,color:"text-muted-foreground"}};function J(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...J(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=J(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(Ye,{"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(qe,{"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(q,{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(q,{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 W,Y;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=>J(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=(W=s.find(a=>a.scope==="global"))==null?void 0:W.baseDir,I=(Y=s.find(a=>a.scope==="project"))==null?void 0:Y.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 +1 @@
1
- import{r as S,c as re,j as n}from"./vendor-react-gGw_S5I_.js";import{U as ze,bJ as it,bK as be,bL as jt,bM as yt,bN as Nt,B as J,L as rt,M as ct,N as It,O as dt,Q as ut,C as Ze,bO as kt,b6 as Je,z as Qe,bP as Ct,bQ as St,q as ft,aK as Mt,bR as $t,b7 as Rt,bC as Tt,bS as At,aP as Ot,R as Et,D as Lt,h as _t,j as zt,k as Dt,J as se,bT as Pt,bU as Ft,bV as Yt,bW as qt,bX as Ye,$ as qe,bY as Wt,bz as Ht,bZ as Ut,b_ as Bt,b$ as Ae,c0 as Oe,bk as Kt,Z as Gt,c1 as Vt,c2 as Xt,c3 as Zt,bH as Jt}from"./index-BYjv05SI.js";import{S as Qt}from"./switch-DkwGVNAF.js";import{m as es,aq as ts,ak as ss,e as ns,ar as ht,as as pt,P as os,a7 as as,$ as ls,C as et,at as is,au as rs,X as cs}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function Ce(s){if(s.ok)return s;const e=await s.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Ee(s,e){return[...new Map([...s,...e].map(t=>[t.sequence,t])).values()].sort((t,i)=>t.sequence-i.sequence)}function ds(s){const[e,t]=S.useState(null),[i,a]=S.useState([]),[l,c]=S.useState(null),[o,u]=S.useState(!1),[r,d]=S.useState(!1),[m,w]=S.useState(!1),[g,x]=S.useState(new Set),p=S.useRef(0),h=S.useRef(null),v=S.useRef(!1),N=S.useRef(!1),b=S.useRef(new Set),k=S.useRef(!1),C=S.useRef(null),M=S.useCallback(async j=>{const R=++p.current;try{const I=C.current,E=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!j()||R!==p.current)return;t(A=>A&&JSON.stringify(A.members)===JSON.stringify(E.members)?{...E,members:A.members}:E),a(A=>Ee(A,E.messages)),C.current=E.nextCursor,k.current||(k.current=!0,w(E.hasMore)),c(null)}catch(I){j()&&R===p.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[s]);it(M,2e3);const _=S.useCallback(async j=>{var R;if(v.current)return!1;v.current=!0,u(!0),((R=h.current)==null?void 0:R.text)!==j&&(h.current={text:j,id:crypto.randomUUID()});try{const $=await(await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{text:j,commandId:h.current.id}))).json();return p.current++,a(E=>Ee(E,[$.message])),h.current=null,c($.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(I){return c(I instanceof Error?I.message:"Couldn't send the message."),!1}finally{v.current=!1,u(!1)}},[s]),O=S.useCallback(async(j,R)=>{if(!b.current.has(j)){b.current.add(j),x(I=>new Set(I).add(j));try{await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{sessionId:j,listening:R},{method:"PATCH"})),p.current++,t(I=>I&&{...I,members:I.members.map($=>$.sessionId===j?{...$,listening:R}:$)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(j),x(I=>{const $=new Set(I);return $.delete(j),$})}}},[s]),L=S.useCallback(async()=>{if(!(!i.length||N.current)){N.current=!0,d(!0);try{const R=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}?before=${i[0].sequence}`))).json();a(I=>Ee(I,R.messages)),w(R.hasMore)}catch(j){c(j instanceof Error?j.message:"Couldn't load older messages.")}finally{N.current=!1,d(!1)}}},[i,s]);return{page:e,messages:i,error:l,posting:o,busyMembers:g,hasOlder:m,loadingOlder:r,post:_,setListening:O,older:L}}const us=[],fs=new Map;function hs(s){var We,He,Ue,Be,Ke,Ge,Ve;const e=re.c(111),{rootId:t,kinds:i,active:a}=s,l=i===void 0?fs:i,c=a===void 0?!0:a,o=ds(t),[u,r]=S.useState(""),d=S.useRef(null),m=S.useRef(!0);let w;e[0]!==o.messages?(w=(We=o.messages.at(-1))==null?void 0:We.sequence,e[0]=o.messages,e[1]=w):w=e[1];const g=w,x=((He=o.page)==null?void 0:He.members)??us;let p;e[2]!==x?(p=jt(x),e[2]=x,e[3]=p):p=e[3];const h=p;let v;e[4]!==x||e[5]!==t?(v=yt(x,t),e[4]=x,e[5]=t,e[6]=v):v=e[6];const N=v;let b;e[7]!==x?(b=new Map(x.map(ms)),e[7]=x,e[8]=b):b=e[8];const k=b;let C;e[9]!==o.messages||e[10]!==t?(C=Nt(o.messages,t),e[9]=o.messages,e[10]=t,e[11]=C):C=e[11];const M=C;let _;e[12]!==c?(_=()=>{var q,F;c&&m.current&&((F=(q=d.current)==null?void 0:q.scrollIntoView)==null||F.call(q,{block:"end"}))},e[12]=c,e[13]=_):_=e[13];let O;e[14]!==c||e[15]!==g?(O=[c,g],e[14]=c,e[15]=g,e[16]=O):O=e[16],S.useEffect(_,O);let L;e[17]!==o||e[18]!==u?(L=async()=>{const q=u.trim();!q||o.posting||await o.post(q)&&(r(F=>F.trim()===q?"":F),m.current=!0)},e[17]=o,e[18]=u,e[19]=L):L=e[19];const j=L;let R;e[20]!==o.page||e[21]!==x?(R=o.page?`${x.filter(ps).length} listening · Members & mentions`:"Loading chat…",e[20]=o.page,e[21]=x,e[22]=R):R=e[22];let I;e[23]!==R?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:R}),e[23]=R,e[24]=I):I=e[24];let $;if(e[25]!==o||e[26]!==l||e[27]!==x||e[28]!==t||e[29]!==N){let q;e[31]!==o||e[32]!==l||e[33]!==t||e[34]!==N?(q=F=>{var Xe;return n.jsxs(Ze,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(kt,{role:F.sessionId===t?"lead":"agent",sessionId:F.sessionId,kinds:l,tints:N,className:"size-5"}),n.jsxs(Je,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${F.sessionId}`,"aria-label":`Listen for ${F.name}`,children:[n.jsx("span",{className:"truncate",children:F.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",F.handle]})]}),n.jsx(J,{variant:"ghost",size:"icon-xs",disabled:!((Xe=o.page)!=null&&Xe.canPost)||!F.canInteract,onClick:()=>r(je=>`${je}${je&&!/\s$/.test(je)?" ":""}@${F.handle} `),"aria-label":`Mention ${F.name}`,title:`Mention @${F.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${F.sessionId}`,size:"sm",checked:F.listening,disabled:!F.canInteract||o.busyMembers.has(F.sessionId),onCheckedChange:je=>void o.setListening(F.sessionId,je)})]},F.sessionId)},e[31]=o,e[32]=l,e[33]=t,e[34]=N,e[35]=q):q=e[35],$=x.map(q),e[25]=o,e[26]=l,e[27]=x,e[28]=t,e[29]=N,e[30]=$}else $=e[30];let E;e[36]!==$?(E=n.jsx(Qe,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:$}),e[36]=$,e[37]=E):E=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=A):A=e[38];let z;e[39]!==I||e[40]!==E?(z=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,E,A]}),e[39]=I,e[40]=E,e[41]=z):z=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=q=>{const F=q.target;m.current=F.scrollHeight-F.scrollTop-F.clientHeight<80},e[42]=D):D=e[42];let W;e[43]!==o?(W=o.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(J,{variant:"ghost",size:"xs",disabled:o.loadingOlder,onClick:()=>void o.older(),children:o.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=o,e[44]=W):W=e[44];let P;e[45]!==o.messages.length||e[46]!==o.page?(P=o.page&&o.messages.length===0&&n.jsx(rt,{children:n.jsxs(ct,{children:[n.jsx(It,{variant:"icon",children:n.jsx(es,{})}),n.jsx(dt,{children:"Talk to the crew"}),n.jsx(ut,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=o.messages.length,e[46]=o.page,e[47]=P):P=e[47];let Y;if(e[48]!==k||e[49]!==h||e[50]!==l||e[51]!==t||e[52]!==M||e[53]!==N){let q;e[55]!==k||e[56]!==h||e[57]!==l||e[58]!==t||e[59]!==N?(q=F=>n.jsxs(S.Fragment,{children:[F.day!==void 0&&n.jsx(Ct,{day:F.day}),n.jsx(St,{run:F,members:k,handles:h,kinds:l,tints:N,rootId:t})]},F.messages[0].sequence),e[55]=k,e[56]=h,e[57]=l,e[58]=t,e[59]=N,e[60]=q):q=e[60],Y=M.map(q),e[48]=k,e[49]=h,e[50]=l,e[51]=t,e[52]=M,e[53]=N,e[54]=Y}else Y=e[54];let K;e[61]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("div",{ref:d}),e[61]=K):K=e[61];let B;e[62]!==Y?(B=n.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[Y,K]}),e[62]=Y,e[63]=B):B=e[63];let X;e[64]!==W||e[65]!==P||e[66]!==B?(X=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:D,children:[W,P,B]}),e[64]=W,e[65]=P,e[66]=B,e[67]=X):X=e[67];let H;e[68]!==j?(H=q=>{q.preventDefault(),j()},e[68]=j,e[69]=H):H=e[69];const U=!!o.error,G=`crew-chat-${t}`;let f;e[70]!==G?(f=n.jsx(Je,{htmlFor:G,className:"sr-only",children:"Message the crew"}),e[70]=G,e[71]=f):f=e[71];const y=`crew-chat-${t}`,T=!((Ue=o.page)!=null&&Ue.canPost),V=!!o.error;let ee;e[72]===Symbol.for("react.memo_cache_sentinel")?(ee=q=>r(q.target.value),e[72]=ee):ee=e[72];let Z;e[73]!==j?(Z=q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&!q.nativeEvent.isComposing&&(q.preventDefault(),j())},e[73]=j,e[74]=Z):Z=e[74];let te;e[75]!==u||e[76]!==y||e[77]!==T||e[78]!==V||e[79]!==Z?(te=n.jsx(Mt,{id:y,value:u,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:T,"aria-invalid":V,onChange:ee,onKeyDown:Z}),e[75]=u,e[76]=y,e[77]=T,e[78]=V,e[79]=Z,e[80]=te):te=e[80];let ae;e[81]!==o.error?(ae=o.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o.error}),e[81]=o.error,e[82]=ae):ae=e[82];let ce;e[83]!==U||e[84]!==f||e[85]!==te||e[86]!==ae?(ce=n.jsxs(Ze,{"data-invalid":U,children:[f,te,ae]}),e[83]=U,e[84]=f,e[85]=te,e[86]=ae,e[87]=ce):ce=e[87];const ve=((Be=o.page)==null?void 0:Be.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let le;e[88]!==ve?(le=n.jsx(Rt,{className:"flex-1",children:ve}),e[88]=ve,e[89]=le):le=e[89];let de;e[90]!==((Ke=o.page)==null?void 0:Ke.canPost)||e[91]!==o.posting||e[92]!==u?(de=!((Ge=o.page)!=null&&Ge.canPost)||!u.trim()||o.posting,e[90]=(Ve=o.page)==null?void 0:Ve.canPost,e[91]=o.posting,e[92]=u,e[93]=de):de=e[93];let Ie;e[94]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=Ie):Ie=e[94];const Te=o.posting?"Sending…":"Send";let pe;e[95]!==de||e[96]!==Te?(pe=n.jsxs(J,{type:"submit",size:"sm",disabled:de,children:[Ie,Te]}),e[95]=de,e[96]=Te,e[97]=pe):pe=e[97];let me;e[98]!==le||e[99]!==pe?(me=n.jsxs("div",{className:"flex items-center gap-2",children:[le,pe]}),e[98]=le,e[99]=pe,e[100]=me):me=e[100];let ge;e[101]!==ce||e[102]!==me?(ge=n.jsxs(Qe,{className:"gap-2",children:[ce,me]}),e[101]=ce,e[102]=me,e[103]=ge):ge=e[103];let xe;e[104]!==H||e[105]!==ge?(xe=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:H,children:ge}),e[104]=H,e[105]=ge,e[106]=xe):xe=e[106];let ke;return e[107]!==z||e[108]!==X||e[109]!==xe?(ke=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[z,X,xe]}),e[107]=z,e[108]=X,e[109]=xe,e[110]=ke):ke=e[110],ke}function ps(s){return s.listening}function ms(s){return[s.sessionId,s]}const ue={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function mt(s){const e=new Date(s),t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?t:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${t}`}function fe(s){if(s.status==="deferred")return"needs-you";switch(s.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function tt(s,e){var t,i;return{sessionId:s.sessionId,dirName:((t=s.address)==null?void 0:t.dirName)??"",fileName:((i=s.address)==null?void 0:i.fileName)??"",projectShortName:"",lastModified:s.lastActivityAt??"",lastActivityAt:s.lastActivityAt,size:0,cwd:s.cwd,customTitle:s.customTitle,aiTitle:s.aiTitle,firstUserMessage:s.firstUserMessage,...s.parentId&&{crew:{rootId:e,parentId:s.parentId,startedAt:s.startedAt??0,...s.name&&{name:s.name}}}}}function gs(s,e,t){var o;const i=((o=[...e.values()].find(u=>u.parentId===null))==null?void 0:o.sessionId)??s.sessionId,a=t[s.sessionId],l=tt(s,i);if(!s.parentId)return Tt(l,a);const c=e.get(s.parentId);return At(l,{customName:a,parent:c&&tt(c,i)})}function xs(s){const e=new Map;for(const l of s.members){if(!l.parentId)continue;const c=e.get(l.parentId);c?c.push(l):e.set(l.parentId,[l])}const t=[],i=new Set,a=(l,c)=>{var u;const o=[...e.get(l)??[]].sort((r,d)=>(r.startedAt??0)-(d.startedAt??0));for(const r of o)i.has(r.sessionId)||(i.add(r.sessionId),t.push({member:r,depth:c,children:((u=e.get(r.sessionId))==null?void 0:u.length)??0}),a(r.sessionId,c+1))};a(s.rootId,0);for(const l of s.members)l.parentId&&!i.has(l.sessionId)&&(i.add(l.sessionId),t.push({member:l,depth:0,children:0}));return t}function ws(s){const e=({member:t,pending:i})=>i.askedAt??(Date.parse(t.lastActivityAt??"")||0);return s.members.flatMap(t=>t.waiting.map(i=>({member:t,pending:i}))).sort((t,i)=>e(t)-e(i))}function bs(s){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const t of s.members){if(!t.parentId)continue;e.size++;const i=fe(t);i==="working"?e.working++:i==="needs-you"?e.needsYou++:i==="failed"?e.failed++:i==="unreachable"?e.unreachable++:e.done++,Re(t)&&e.unreadResults++}return e}function Re(s){return!!(s.result&&s.result.state!=="running"&&!s.result.acknowledged)}function Ne(s){const[e]=s.waiting;switch(fe(s)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":!e&&s.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return s.status==="tool_use"&&s.toolName?s.toolName:s.status==="thinking"?"Thinking":s.status==="compacting"?"Compacting":s.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return s.error?`Failed · ${s.error}`:"Failed";case"unreachable":return s.device?`${s.device.name} is not answering`:"Not found";default:return Re(s)?"Finished · result unread":"Finished"}}const ne=196,Q=86,ie=40,we=12,vs=28,Me=6,st=8,he=10,js=6,$e=28,De=36;function gt(s){const e=fe(s);return e==="working"||e==="needs-you"}function ys(s){const e={all:s.members.length,active:0,working:0,needsYou:0};for(const t of s.members){const i=fe(t);i==="working"?e.working++:i==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(s,e)=>(s.startedAt??0)-(e.startedAt??0)||s.sessionId.localeCompare(e.sessionId);function xt(s){const e=new Map(s.members.map(a=>[a.sessionId,a])),t=new Map,i=[];for(const a of s.members){const l=a.parentId&&a.sessionId!==s.rootId?e.get(a.parentId):void 0;if(!l){i.push(a);continue}const c=t.get(l.sessionId);c?c.push(a):t.set(l.sessionId,[a])}for(const a of t.values())a.sort(nt);return i.sort((a,l)=>+(l.sessionId===s.rootId)-+(a.sessionId===s.rootId)||nt(a,l)),{roots:i,childrenOf:t}}function Ns(s,e){if(e==="all")return new Set(s.members.map(a=>a.sessionId));const t=new Map(s.members.map(a=>[a.sessionId,a])),i=new Set;for(const a of s.members){if(!gt(a))continue;let l=a;for(;l&&!i.has(l.sessionId);)i.add(l.sessionId),l=l.sessionId===s.rootId||!l.parentId?void 0:t.get(l.parentId)}return i}function Is(s){const{roots:e,childrenOf:t}=xt(s),i=new Set;let a=0;const l=e.map(c=>({member:c,depth:0}));for(;l.length>0;){const{member:c,depth:o}=l.pop();if(!i.has(c.sessionId)){i.add(c.sessionId),a=Math.max(a,o);for(const u of t.get(c.sessionId)??[])l.push({member:u,depth:o+1})}}return a}function ks(s){return(s+1)*ne+s*ie}function Cs(s,e,t,{group:i=!1,stacked:a}={}){const{roots:l,childrenOf:c}=xt(s),o=Ns(s,e),u=C=>(c.get(C)??[]).filter(M=>o.has(M.sessionId)),r=(a==null?void 0:a.cardWidth)??ne,d=[],m=[],w=[],g=new Set;let x=0,p=0;const h=C=>{const M={count:0,working:0,needsYou:0},_=new Set(g),O=[...u(C)];for(;O.length>0;){const L=O.pop();if(_.has(L.sessionId))continue;_.add(L.sessionId),M.count++;const j=fe(L);j==="working"?M.working++:j==="needs-you"&&M.needsYou++,O.push(...u(L.sessionId))}return M},v=C=>u(C).filter(M=>!g.has(M.sessionId)),N=C=>v(C.sessionId).length===0||t.has(C.sessionId),b=(C,M,_)=>{g.add(C.sessionId);const O=v(C.sessionId),L=O.length>0&&t.has(C.sessionId),j=L?[]:O,R=i&&!a&&j.length>=st?j.filter(N):[],I=R.length>=st?R:[],$=new Set(I),E=j.filter(D=>!$.has(D)),A={member:C,depth:M,x:(_==null?void 0:_.x)??M*(a?$e:ne+ie),y:(_==null?void 0:_.y)??x+(E.length===0&&I.length>0?he:0),childCount:O.length,collapsed:L,hidden:L?h(C.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!gt(C),grouped:!!_};if(d.push(A),p=Math.max(p,A.x+r+(a&&O.length>0?De:0)),a){x+=Q+we;const D=j.map(W=>b(W,M+1));return D.length>0&&m.push({parentId:C.sessionId,path:Ms(A.x,A.y,D)}),A.y}if(L){const D=A.y+Q/2;m.push({parentId:C.sessionId,path:`M${A.x+ne} ${D}H${A.x+ne+ie/2}`})}if(_)return A.y;if(j.length===0)return x+=Q+we,A.y;const z=E.map(D=>b(D,M+1));return I.length>0&&z.push(k(C.sessionId,I,M+1)+he),m.push({parentId:C.sessionId,path:Ss(A.x+ne,A.y,z)}),A.y},k=(C,M,_)=>{const O=Math.min(js,Math.max(2,Math.ceil(Math.sqrt(M.length/1.5)))),L=Math.ceil(M.length/O),j={parentId:C,x:_*(ne+ie),y:x,width:O*ne+(O-1)*ie+2*he,height:L*Q+(L-1)*we+2*he};return w.push(j),M.forEach((R,I)=>b(R,_,{x:j.x+he+I%O*(ne+ie),y:j.y+he+Math.floor(I/O)*(Q+we)})),p=Math.max(p,j.x+j.width),x+=j.height+we,j.y};for(const C of l)!o.has(C.sessionId)||g.has(C.sessionId)||(d.length>0&&(x+=vs),b(C,0));return{orientation:a?"stacked":"across",cardWidth:r,nodes:d,edges:m,groups:w,width:p,height:Math.max(0,x-we)}}function Ss(s,e,t){const i=e+Q/2,a=[`M${s} ${i}H${s+ie}`];for(const l of t)l!==e&&a.push(wt(s,i,l+Q/2));return a.join("")}function wt(s,e,t){const i=s+ie/2;return`M${i} ${e}V${t-Me}Q${i} ${t} ${i+Me} ${t}H${s+ie}`}function Ms(s,e,t){return t.map(i=>bt(s,e,i)).join("")}function bt(s,e,t){const i=s+$e/2,a=t+Q/2;return`M${i} ${e+Q}V${a-Me}Q${i} ${a} ${i+Me} ${a}H${s+$e}`}function $s(s,e){const t=new Map(s.nodes.map(c=>[c.member.sessionId,c])),i=new Map(s.groups.map(c=>[c.parentId,c]));let a=e?t.get(e):void 0;const l=[];for(;a!=null&&a.member.parentId;){const c=a.member.parentId,o=t.get(c);if(!o||o.depth!==a.depth-1)break;if(s.orientation==="stacked"){l.unshift(bt(o.x,o.y,a.y)),a=o;continue}const u=o.x+ne,r=o.y+Q/2,d=a.grouped?i.get(c):void 0,m=(d?d.y+he:a.y)+Q/2;l.unshift(m===r?`M${u} ${r}H${u+ie}`:`M${u} ${r}H${u+ie/2}${wt(u,r,m)}`),a=o}return l.length>0?l.join(""):null}const oe=14,Pe=.25,ot=1.5,Rs=.7,Se=1.2,Ts=56,As=900,Os=.85,Es=320,Le={all:new Set,active:new Set};function Ls(s){const[e,t]=Ot(Et("crew-map-filter"),"all"),i=e==="active"?"active":"all",[a,l]=S.useState({rootId:s,folds:Le}),c=S.useRef(new Map),o=a.rootId===s?a.folds:Le,u=S.useCallback(d=>l(m=>{const w=m.rootId===s?m.folds:Le,g=new Set(w[i]);return g.delete(d)||g.add(d),{rootId:s,folds:{...w,[i]:g}}}),[i,s]),r=S.useMemo(()=>({get current(){return c.current.get(s)??null},set current(d){c.current.set(s,d)}}),[s]);return{filter:i,setFilter:t,collapsed:o[i],toggle:u,viewport:r}}function _s(s){const e=re.c(86),{crew:t,hereId:i,controls:a,kinds:l,nameOf:c,onOpen:o}=s,[u,r]=S.useState(!1),{filter:d,collapsed:m,toggle:w}=a;let g,x,p,h,v,N,b,k,C,M,_,O,L,j,R,I;if(e[0]!==m||e[1]!==a||e[2]!==t||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==l||e[7]!==c||e[8]!==o||e[9]!==w){let B;e[26]!==t.rootId?(B=y=>y.sessionId===t.rootId,e[26]=t.rootId,e[27]=B):B=e[27];const X=t.members.find(B);let H;e[28]!==m||e[29]!==a||e[30]!==t||e[31]!==d||e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==w?(H=(y,T)=>n.jsx(Fs,{crew:t,collapsed:m,groups:!y,filter:d,hereId:i,kinds:l,nameOf:c,memory:y,onOpen:T,onToggle:w,onShowAll:()=>a.setFilter("all")}),e[28]=m,e[29]=a,e[30]=t,e[31]=d,e[32]=i,e[33]=l,e[34]=c,e[35]=w,e[36]=H):H=e[36],p=H,N="flex h-full min-h-0 flex-col";let U;e[37]!==a||e[38]!==t?(U=n.jsx(at,{crew:t,controls:a}),e[37]=a,e[38]=t,e[39]=U):U=e[39];let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("span",{className:"flex-1"}),e[40]=G):G=e[40];let f;e[41]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>r(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=f):f=e[41],e[42]!==U?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[U,G,f]}),e[42]=U,e[43]=b):b=e[43],e[44]!==p||e[45]!==a.viewport||e[46]!==o?(k=p(a.viewport,o),e[44]=p,e[45]=a.viewport,e[46]=o,e[47]=k):k=e[47],x=Lt,I=u,v=r,g=_t,O=!0,L="flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden p-0 sm:h-[calc(100dvh-4rem)] sm:w-[calc(100vw-4rem)] sm:max-w-none",e[48]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(zt,{className:"sr-only",children:"Crew map"}),R=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=j,e[49]=R):(j=e[48],R=e[49]),M="flex h-12 shrink-0 items-center gap-3 pl-4 pr-14",e[50]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),e[50]=_):_=e[50],h="min-w-0 truncate text-sm font-medium",C=X?c(X):"Crew",e[0]=m,e[1]=a,e[2]=t,e[3]=u,e[4]=d,e[5]=i,e[6]=l,e[7]=c,e[8]=o,e[9]=w,e[10]=g,e[11]=x,e[12]=p,e[13]=h,e[14]=v,e[15]=N,e[16]=b,e[17]=k,e[18]=C,e[19]=M,e[20]=_,e[21]=O,e[22]=L,e[23]=j,e[24]=R,e[25]=I}else g=e[10],x=e[11],p=e[12],h=e[13],v=e[14],N=e[15],b=e[16],k=e[17],C=e[18],M=e[19],_=e[20],O=e[21],L=e[22],j=e[23],R=e[24],I=e[25];let $;e[51]!==h||e[52]!==C?($=n.jsx("span",{className:h,children:C}),e[51]=h,e[52]=C,e[53]=$):$=e[53];let E;e[54]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("span",{className:"flex-1"}),e[54]=E):E=e[54];let A;e[55]!==a||e[56]!==t?(A=n.jsx(at,{crew:t,controls:a}),e[55]=a,e[56]=t,e[57]=A):A=e[57];let z;e[58]!==$||e[59]!==A||e[60]!==M||e[61]!==_?(z=n.jsxs("header",{className:M,children:[_,$,E,A]}),e[58]=$,e[59]=A,e[60]=M,e[61]=_,e[62]=z):z=e[62];let D;e[63]!==o?(D=B=>{r(!1),o(B)},e[63]=o,e[64]=D):D=e[64];let W;e[65]!==p||e[66]!==D?(W=p(null,D),e[65]=p,e[66]=D,e[67]=W):W=e[67];let P;e[68]!==g||e[69]!==z||e[70]!==W||e[71]!==O||e[72]!==L||e[73]!==j||e[74]!==R?(P=n.jsxs(g,{showCloseButton:O,className:L,children:[j,R,z,W]}),e[68]=g,e[69]=z,e[70]=W,e[71]=O,e[72]=L,e[73]=j,e[74]=R,e[75]=P):P=e[75];let Y;e[76]!==x||e[77]!==v||e[78]!==P||e[79]!==I?(Y=n.jsx(x,{open:I,onOpenChange:v,children:P}),e[76]=x,e[77]=v,e[78]=P,e[79]=I,e[80]=Y):Y=e[80];let K;return e[81]!==N||e[82]!==b||e[83]!==k||e[84]!==Y?(K=n.jsxs("div",{className:N,children:[b,k,Y]}),e[81]=N,e[82]=b,e[83]=k,e[84]=Y,e[85]=K):K=e[85],K}function at(s){const e=re.c(3),{crew:t,controls:i}=s;let a;if(e[0]!==i||e[1]!==t){const l=ys(t),c=[{id:"all",label:"All",count:l.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:l.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];a=n.jsx("div",{role:"radiogroup","aria-label":"Show on the map",className:"flex shrink-0 gap-0.5 rounded-full border bg-background p-0.5",children:c.map(o=>{const{id:u,label:r,count:d,hint:m}=o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":i.filter===u,"aria-label":`${r}, ${vt(d)}`,title:m,onClick:()=>i.setFilter(u),className:se("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",i.filter===u&&"bg-accent text-foreground"),children:[r,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:d})]},u)})}),e[0]=i,e[1]=t,e[2]=a}else a=e[2];return a}function vt(s){return`${s} ${s===1?"session":"sessions"}`}function _e(s,e,t){return s.orientation==="stacked"?{scale:e,left:oe,top:oe}:{scale:e,left:Math.max(oe,(t.width-s.width*e)/2),top:Math.max(oe,Math.min((t.height-s.height*e)/2,t.height*.12))}}function zs(s,e,t){return{width:Math.max(t.width,e.left+s.width*e.scale+oe),height:Math.max(t.height,e.top+s.height*e.scale+Ts)}}function lt(s,e,{widthOnly:t=!1}={}){if(s.width===0||e.width===0)return 1;const i=(e.width-2*oe)/s.width,a=t?i:Math.min(i,(e.height-2*oe)/s.height);return Fe(a,Pe,1)}const Fe=(s,e,t)=>Math.min(t,Math.max(e,s));function Ds(s,e,t,i,a){var w;const l=new Map(e.layout.nodes.map(g=>[g.member.sessionId,g])),c=new Map(t.nodes.map(g=>[g.member.sessionId,g]));if(e.frame===i&&l.size===c.size&&t.nodes.every(g=>{const x=l.get(g.member.sessionId);return x!==void 0&&x.x===g.x&&x.y===g.y}))return null;const u=g=>({x:e.frame.left+g.x*e.frame.scale-s.left,y:e.frame.top+g.y*e.frame.scale-s.top}),r=a&&l.has(a)&&c.has(a)?a:(w=e.layout.nodes.filter(g=>c.has(g.member.sessionId)).map(g=>({node:g,screen:u(g)})).filter(({screen:g})=>g.y+Q*e.frame.scale>0&&g.x+e.layout.cardWidth*e.frame.scale>0).sort((g,x)=>g.screen.y-x.screen.y||g.screen.x-x.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!r)return null;const d=u(l.get(r)),m=c.get(r);return{left:i.left+m.x*i.scale-d.x,top:i.top+m.y*i.scale-d.y}}function Ps(s,e,t,i){const a=new Map(s.nodes.map(x=>[x.member.sessionId,x])),l=e?a.get(e):void 0;if(!l)return{left:0,top:0};const{scale:c}=t,o=t.left+l.x*c,u=t.top+l.y*c,r=o+s.cardWidth*c,d=u+Q*c;if(r<=i.clientWidth&&d<=i.clientHeight)return{left:0,top:0};const m=l.member.parentId&&a.get(l.member.parentId)||l;let w=t.left+Math.min(m.x,l.x)*c-oe,g=t.top+Math.min(m.y,l.y)*c-oe;return r-w>i.clientWidth&&(w=o-oe),d-g>i.clientHeight&&(g=u-i.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,g)}}function Fs({crew:s,collapsed:e,groups:t,filter:i,hereId:a,kinds:l,nameOf:c,memory:o,onOpen:u,onToggle:r,onShowAll:d}){const m=S.useRef(null),[w,g]=S.useState({width:0,height:0}),x=t&&w.width>=As,p=S.useMemo(()=>Is(s),[s]),h=w.width-2*oe,v=!t&&w.width>0&&ks(p)*Os>h,N=v?Fe(h-p*$e-De,ne,Es):ne,b=S.useMemo(()=>Cs(s,i,e,{group:x,...v&&{stacked:{cardWidth:N}}}),[s,i,e,x,v,N]),[k,C]=S.useState(()=>{var f;return((f=o==null?void 0:o.current)==null?void 0:f.frame)??{scale:1,left:oe,top:oe}}),[M,_]=S.useState(!1),O=S.useRef(null),L=S.useRef(null),j=S.useRef({left:0,top:0}),R=S.useRef(null),I=S.useRef(null),$=zs(b,k,w),{scale:E}=k;S.useLayoutEffect(()=>{const f=m.current;if(!f)return;const y=()=>g(V=>V.width===f.clientWidth&&V.height===f.clientHeight?V:{width:f.clientWidth,height:f.clientHeight});y();const T=new ResizeObserver(y);return T.observe(f),()=>T.disconnect()},[]);const A=S.useCallback(f=>{const y=m.current;o&&y&&(o.current={frame:f,left:y.scrollLeft,top:y.scrollTop})},[o]),z=S.useCallback((f,y)=>{O.current={frame:f,scroll:y},C(f)},[]),D=S.useCallback(f=>{const y=_e(f,Math.max(lt(f,w,{widthOnly:!0}),Rs),w);z(y,()=>{const T=m.current;return T?Ps(f,a,y,T):{left:0,top:0}})},[z,a,w]);S.useLayoutEffect(()=>{const f=m.current;if(w.width===0||!f)return;const y=R.current;if(y){if(y.filter!==i||y.layout.orientation!==b.orientation)D(b);else if(y.layout!==b){const T=Ds(j.current,y,b,k,L.current);T&&(f.scrollLeft=T.left,f.scrollTop=T.top,j.current={left:f.scrollLeft,top:f.scrollTop})}}else{const T=o==null?void 0:o.current;T?z(T.frame,()=>({left:T.left,top:T.top})):D(b)}L.current=null,R.current={layout:b,filter:i,frame:k}}),S.useLayoutEffect(()=>{const f=O.current,y=m.current;if(!f||!y||f.frame!==k)return;O.current=null;const{left:T,top:V}=f.scroll();y.scrollLeft=T,y.scrollTop=V,j.current={left:y.scrollLeft,top:y.scrollTop},A(k)});const W=S.useRef(a);S.useEffect(()=>{var f,y;W.current!==a&&(W.current=a,a&&((y=(f=m.current)==null?void 0:f.querySelector(`[data-crew-map-card="${CSS.escape(a)}"]`))==null||y.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[a]);const P=S.useCallback((f,y)=>{var de;const T=m.current,V=((de=O.current)==null?void 0:de.frame.scale)??E,ee=Fe(V*f,Pe,ot);if(!T||ee===V)return;const Z=T.getBoundingClientRect(),te=y?y.clientX-Z.left:T.clientWidth/2,ae=y?y.clientY-Z.top:T.clientHeight/2,ce=(T.scrollLeft+te-k.left)/E,ve=(T.scrollTop+ae-k.top)/E,le=_e(b,ee,w);z(le,()=>({left:le.left+ce*le.scale-te,top:le.top+ve*le.scale-ae}))},[z,k.left,k.top,b,E,w]),Y=S.useRef(P);S.useLayoutEffect(()=>{Y.current=P}),S.useEffect(()=>{const f=m.current;if(!f)return;const y=T=>{!T.ctrlKey&&!T.metaKey||(T.preventDefault(),Y.current(Math.exp(-T.deltaY*.01),T))};return f.addEventListener("wheel",y,{passive:!1}),()=>f.removeEventListener("wheel",y)},[]);const K=f=>{const y=m.current;!y||f.pointerType!=="mouse"||f.button!==0||f.target.closest("button")||(I.current={pointerId:f.pointerId,x:f.clientX,y:f.clientY,left:y.scrollLeft,top:y.scrollTop},y.setPointerCapture(f.pointerId),_(!0))},B=f=>{const y=I.current,T=m.current;!y||!T||y.pointerId!==f.pointerId||(T.scrollLeft=y.left-(f.clientX-y.x),T.scrollTop=y.top-(f.clientY-y.y))},X=f=>{var y,T;((y=I.current)==null?void 0:y.pointerId)===f.pointerId&&(I.current=null,(T=m.current)==null||T.releasePointerCapture(f.pointerId),_(!1))},H=S.useMemo(()=>$s(b,a),[b,a]),U=b.nodes.length===0,G=b.orientation==="stacked"?b.cardWidth+De/2:ne+ie/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:m,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:f=>{j.current={left:f.currentTarget.scrollLeft,top:f.currentTarget.scrollTop},O.current||A(k)},onPointerDown:K,onPointerMove:B,onPointerUp:X,onPointerCancel:X,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="+"||f.key==="="?P(Se):f.key==="-"&&P(1/Se))},tabIndex:-1,className:se("absolute inset-0 overflow-auto overscroll-contain outline-none [touch-action:pan-x_pan-y]","bg-muted/30 bg-local bg-[radial-gradient(circle,var(--border)_1px,transparent_1px)] bg-size-[18px_18px]",M?"cursor-grabbing select-none":"cursor-grab"),children:U?n.jsxs(rt,{className:"h-full",children:[n.jsxs(ct,{children:[n.jsx(dt,{children:"Nothing is active"}),n.jsx(ut,{className:"text-xs",children:"No session in this crew is working or waiting on you."})]}),n.jsx(J,{variant:"outline",size:"xs",onClick:d,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:$.width,height:$.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:k.left,top:k.top,width:b.width,height:b.height,transform:`scale(${E})`},children:[b.groups.map(f=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:f.x,top:f.y,width:f.width,height:f.height}},f.parentId)),n.jsxs("svg",{"aria-hidden":"true",width:b.width,height:b.height,className:"pointer-events-none absolute inset-0 overflow-visible",fill:"none",children:[b.edges.map(f=>n.jsx("path",{d:f.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},f.parentId)),H&&n.jsx("path",{d:H,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(f=>n.jsx(Hs,{node:f,width:b.cardWidth,toggleLeft:G,here:f.member.sessionId===a,kind:l.get(f.member.sessionId),name:c(f.member),onOpen:u,onToggle:y=>{L.current=y,r(y)}},f.member.sessionId))})]})})}),!U&&n.jsxs("div",{className:"absolute bottom-2.5 right-2.5 flex items-center gap-0.5 rounded-lg border bg-popover p-0.5 shadow-sm",children:[n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:E<=Pe,onClick:()=>P(1/Se),children:n.jsx(pt,{"data-icon":"inline-start"})}),n.jsxs(J,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>P(1/E),children:[Math.round(E*100),"%"]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:E>=ot,onClick:()=>P(Se),children:n.jsx(os,{"data-icon":"inline-start"})}),n.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":"true"}),n.jsx(J,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>z(_e(b,lt(b,w),w),()=>({left:0,top:0})),children:"Fit"})]})]})}const Ys={"needs-you":"border-warning/60 bg-[color-mix(in_oklch,var(--warning)_7%,var(--card))]",failed:"border-destructive/45",unreachable:"border-dashed"},qs={"needs-you":"text-warning",failed:"text-destructive"};function Ws(s){var t,i;const e=(t=s.pullRequests)==null?void 0:t.at(-1);return[s.model&&Ye(s.model),(i=s.device)==null?void 0:i.name,e&&`#${e.number}`,s.lastActivityAt&&qe(s.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(s){const e=re.c(75),{node:t,width:i,toggleLeft:a,here:l,kind:c,name:o,onOpen:u,onToggle:r}=s,{member:d}=t;let m;e[0]!==d?(m=fe(d),e[0]=d,e[1]=m):m=e[1];const w=m;let g;e[2]!==d?(g=Ne(d),e[2]=d,e[3]=g):g=e[3];const x=g;let p;e[4]!==c?(p=c?Pt(c):as,e[4]=c,e[5]=p):p=e[5];const h=p;let v;e[6]!==d?(v=Ws(d),e[6]=d,e[7]=v):v=e[7];const N=v,b=t.context&&"shown because a session it started is active";let k;e[8]!==x||e[9]!==o||e[10]!==b?(k=[o,x,b].filter(Boolean),e[8]=x,e[9]=o,e[10]=b,e[11]=k):k=e[11];const C=k.join(", ");let M;e[12]!==t.x||e[13]!==t.y||e[14]!==i?(M={left:t.x,top:t.y,width:i,height:Q},e[12]=t.x,e[13]=t.y,e[14]=i,e[15]=M):M=e[15];const _=d.sessionId,O=l?"true":void 0;let L;e[16]!==d||e[17]!==u?(L=()=>u(d),e[16]=d,e[17]=u,e[18]=L):L=e[18];const j=Ys[w],R=l&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=t.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let $;e[19]!==j||e[20]!==R||e[21]!==I?($=se("flex size-full cursor-pointer flex-col justify-center gap-1 rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs outline-none","transition-[border-color,opacity,box-shadow] hover:border-foreground/25 hover:shadow-sm focus-visible:ring-2 focus-visible:ring-ring",j,R,I),e[19]=j,e[20]=R,e[21]=I,e[22]=$):$=e[22];let E;e[23]!==C||e[24]!==d.sessionId||e[25]!==w||e[26]!==L||e[27]!==$||e[28]!==O?(E=n.jsx("button",{type:"button","data-crew-map-card":_,"data-crew-map-state":w,"aria-current":O,"aria-label":C,onClick:L,className:$}),e[23]=C,e[24]=d.sessionId,e[25]=w,e[26]=L,e[27]=$,e[28]=O,e[29]=E):E=e[29];let A;e[30]!==h?(A=n.jsx(h,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=h,e[31]=A):A=e[31];let z;e[32]!==o?(z=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:o}),e[32]=o,e[33]=z):z=e[33];let D;e[34]!==A||e[35]!==z?(D=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[A,z]}),e[34]=A,e[35]=z,e[36]=D):D=e[36];const W=ue[w];let P;e[37]!==W?(P=se("size-1.5 shrink-0 rounded-full",W),e[37]=W,e[38]=P):P=e[38];let Y;e[39]!==P?(Y=n.jsx("span",{className:P,"aria-hidden":"true"}),e[39]=P,e[40]=Y):Y=e[40];let K;e[41]!==d||e[42]!==w?(K=Re(d)?"text-warning":qs[w],e[41]=d,e[42]=w,e[43]=K):K=e[43];let B;e[44]!==K?(B=se("min-w-0 truncate text-muted-foreground",K),e[44]=K,e[45]=B):B=e[45];let X;e[46]!==x||e[47]!==B?(X=n.jsx("span",{className:B,children:x}),e[46]=x,e[47]=B,e[48]=X):X=e[48];let H;e[49]!==Y||e[50]!==X?(H=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[Y,X]}),e[49]=Y,e[50]=X,e[51]=H):H=e[51];let U;e[52]!==l||e[53]!==N?(U=(N||l)&&n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11.5px] tabular-nums text-muted-foreground/75",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:N}),l&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=l,e[53]=N,e[54]=U):U=e[54];let G;e[55]!==E||e[56]!==D||e[57]!==H||e[58]!==U?(G=n.jsxs(Ft,{delay:700,render:E,children:[D,H,U]}),e[55]=E,e[56]=D,e[57]=H,e[58]=U,e[59]=G):G=e[59];let f;e[60]!==d||e[61]!==o?(f=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Bs,{member:d,name:o})}),e[60]=d,e[61]=o,e[62]=f):f=e[62];let y;e[63]!==G||e[64]!==f?(y=n.jsxs(qt,{children:[G,f]}),e[63]=G,e[64]=f,e[65]=y):y=e[65];let T;e[66]!==o||e[67]!==t||e[68]!==r||e[69]!==a?(T=t.childCount>0&&n.jsx(Us,{node:t,name:o,left:a,onToggle:r}),e[66]=o,e[67]=t,e[68]=r,e[69]=a,e[70]=T):T=e[70];let V;return e[71]!==y||e[72]!==T||e[73]!==M?(V=n.jsxs("li",{className:"group/node absolute",style:M,children:[y,T]}),e[71]=y,e[72]=T,e[73]=M,e[74]=V):V=e[74],V}function Us(s){const e=re.c(25),{node:t,name:i,left:a,onToggle:l}=s,{collapsed:c,hidden:o}=t;let u=null;o.needsYou>0?u="needs-you":o.working>0&&(u="working");let r;e[0]!==c||e[1]!==o.count||e[2]!==o.needsYou||e[3]!==o.working||e[4]!==i?(r=c?[`Show the ${vt(o.count)} under ${i}`,o.needsYou>0&&`${o.needsYou} waiting on you`,o.working>0&&`${o.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${i}`,e[0]=c,e[1]=o.count,e[2]=o.needsYou,e[3]=o.working,e[4]=i,e[5]=r):r=e[5];const d=r,m=!c,w=c?void 0:"Fold";let g;e[6]!==t.member.sessionId||e[7]!==l?(g=()=>l(t.member.sessionId),e[6]=t.member.sessionId,e[7]=l,e[8]=g):g=e[8];const x=!c&&"opacity-0 group-hover/node:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100";let p;e[9]!==x?(p=se("absolute z-10 flex h-5 min-w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center gap-1 rounded-full border bg-card px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground shadow-xs outline-none","transition-opacity hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",x),e[9]=x,e[10]=p):p=e[10];let h;e[11]!==a?(h={left:a,top:Q/2},e[11]=a,e[12]=h):h=e[12];let v;e[13]!==u||e[14]!==c||e[15]!==o.count?(v=c?n.jsxs(n.Fragment,{children:[u&&n.jsx("span",{className:se("size-1.5 rounded-full",ue[u]),"aria-hidden":"true"}),"+",o.count]}):n.jsx(pt,{"aria-hidden":"true",className:"size-3"}),e[13]=u,e[14]=c,e[15]=o.count,e[16]=v):v=e[16];let N;return e[17]!==d||e[18]!==m||e[19]!==w||e[20]!==g||e[21]!==p||e[22]!==h||e[23]!==v?(N=n.jsx("button",{type:"button","aria-expanded":m,"aria-label":d,title:w,onClick:g,className:p,style:h,children:v}),e[17]=d,e[18]=m,e[19]=w,e[20]=g,e[21]=p,e[22]=h,e[23]=v,e[24]=N):N=e[24],N}function Bs(s){var g,x;const e=re.c(35),{member:t,name:i}=s;let a;e[0]!==t.firstUserMessage?(a=(g=t.firstUserMessage)==null?void 0:g.replace(/\s+/g," ").trim(),e[0]=t.firstUserMessage,e[1]=a):a=e[1];const l=a;let c;e[2]!==t.cwd?(c=(x=t.cwd)==null?void 0:x.split(/[\\/]/).filter(Boolean).at(-1),e[2]=t.cwd,e[3]=c):c=e[3];const o=c;let u;if(e[4]!==o||e[5]!==t.device||e[6]!==t.model||e[7]!==t.startedAt||e[8]!==t.turnCount){if(u=[],t.model){let p;e[10]!==t.model?(p=Ye(t.model),e[10]=t.model,e[11]=p):p=e[11];let h;e[12]!==p?(h=["Model",p],e[12]=p,e[13]=h):h=e[13],u.push(h)}if(t.device){let p;e[14]!==t.device.name?(p=["Device",t.device.name],e[14]=t.device.name,e[15]=p):p=e[15],u.push(p)}if(o){let p;e[16]!==o?(p=["Folder",o],e[16]=o,e[17]=p):p=e[17],u.push(p)}if(t.startedAt){let p;e[18]!==t.startedAt?(p=mt(t.startedAt),e[18]=t.startedAt,e[19]=p):p=e[19];let h;e[20]!==p?(h=["Started",p],e[20]=p,e[21]=h):h=e[21],u.push(h)}if(t.turnCount){const p=String(t.turnCount);let h;e[22]!==p?(h=["Turns",p],e[22]=p,e[23]=h):h=e[23],u.push(h)}e[4]=o,e[5]=t.device,e[6]=t.model,e[7]=t.startedAt,e[8]=t.turnCount,e[9]=u}else u=e[9];let r;e[24]!==i?(r=n.jsx("p",{className:"font-medium",children:i}),e[24]=i,e[25]=r):r=e[25];let d;e[26]!==i||e[27]!==l?(d=l&&l!==i&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:l}),e[26]=i,e[27]=l,e[28]=d):d=e[28];let m;e[29]!==u?(m=u.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:u.map(Ks)}),e[29]=u,e[30]=m):m=e[30];let w;return e[31]!==r||e[32]!==d||e[33]!==m?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[r,d,m]}),e[31]=r,e[32]=d,e[33]=m,e[34]=w):w=e[34],w}function Ks(s){const[e,t]=s;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:t})]},e)}const Gs=4e3;function Vs(s){var p;const[e,t]=S.useState(null),[i,a]=S.useState(null),[l,c]=S.useState(new Set),o=(p=Wt())==null?void 0:p.refresh,u=S.useRef(s),r=S.useRef(new Set);S.useLayoutEffect(()=>(u.current=s,()=>{u.current=null}),[s]);const d=S.useCallback(async h=>{if(s)try{const v=await ze(`/api/session-crew/${encodeURIComponent(s)}`);if(!h())return;if(!v.ok){a(v.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const N=await v.json();if(!h())return;t(b=>JSON.stringify(b)===JSON.stringify(N)?b:N),a(null)}catch{h()&&a("Couldn't load the crew.")}},[s]);it(s?d:null,Gs),S.useEffect(()=>{t(h=>h!=null&&h.members.some(v=>v.sessionId===s)?h:null),a(null),c(new Set)},[s]);const m=S.useCallback(async(h,v,N)=>{const b=`${s}:${h}`;if(r.current.has(b))return;const k=()=>u.current===s;r.current.add(b),c(C=>new Set(C).add(h));try{const C=await v();if(!k())return;if(!C.ok&&C.status!==404){a(N);return}o==null||o(),await d(k)}catch{k()&&a(N)}finally{r.current.delete(b),k()&&c(C=>{const M=new Set(C);return M.delete(h),M})}},[d,o,s]),w=S.useCallback((h,v,N)=>m(v,()=>be("/api/session-respond",{sessionId:h,requestId:v,...N}),"Couldn't send the answer."),[m]),g=S.useCallback((h,v)=>m(v,()=>be("/api/delegated-tasks",{sessionId:h,taskId:v,action:"ack"}),"Couldn't mark the result read."),[m]),x=S.useCallback(h=>m(h.sessionId,()=>{var v;return((v=h.result)==null?void 0:v.state)==="running"&&h.parentId?be("/api/delegated-tasks",{sessionId:h.parentId,taskId:h.result.taskId,action:"cancel"}):be("/api/stop-session",{sessionId:h.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[m]);return{crew:e,error:i,busy:l,respond:w,markRead:g,stop:x}}const Xs=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}],Zs={working:"bg-success shadow-[0_0_0_2px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40",failed:"bg-destructive",unreachable:"border border-muted-foreground/50"};function fn(s){var A;const e=re.c(34),{context:t,closePanel:i}=s,a=((A=t.session)==null?void 0:A.sessionId)??null,{crew:l,error:c,busy:o,respond:u,markRead:r,stop:d}=Vs(a),{names:m}=Ht(),[w,g]=S.useState("overview"),x=Ls((l==null?void 0:l.rootId)??"");let p;e[0]!==(l==null?void 0:l.members)?(p=new Map(((l==null?void 0:l.members)??[]).map(Qs)),e[0]=l==null?void 0:l.members,e[1]=p):p=e[1];const h=p;let v;e[2]!==(l==null?void 0:l.members)?(v=new Map(((l==null?void 0:l.members)??[]).flatMap(Js)),e[2]=l==null?void 0:l.members,e[3]=v):v=e[3];const N=v;let b;e[4]!==h||e[5]!==m?(b=z=>gs(z,h,m),e[4]=h,e[5]=m,e[6]=b):b=e[6];const k=b;let C;e[7]!==t?(C=z=>{z.address&&z.device?Xt(Zt(z.address.dirName,z.address.fileName,z.device.id)):z.address&&t.openSession?t.openSession(z.address.dirName,z.address.fileName):Jt(z.sessionId)},e[7]=t,e[8]=C):C=e[8];const M=C;let _,O,L;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),O=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),L=n.jsx("div",{className:"flex-1"}),e[9]=_,e[10]=O,e[11]=L):(_=e[9],O=e[10],L=e[11]);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(cs,{"data-icon":"inline-start"}),e[12]=j):j=e[12];let R;e[13]!==i?(R=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[_,O,L,n.jsx(J,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close crew",children:j})]}),e[13]=i,e[14]=R):R=e[14];let I;e[15]!==c?(I=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[15]=c,e[16]=I):I=e[16];let $;e[17]!==o||e[18]!==l||e[19]!==c||e[20]!==N||e[21]!==x||e[22]!==r||e[23]!==k||e[24]!==M||e[25]!==u||e[26]!==a||e[27]!==d||e[28]!==w?($=l?n.jsxs(Ut,{value:w,onValueChange:g,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[n.jsxs(Bt,{variant:"line",className:"mx-3 mb-1",children:[n.jsx(Ae,{value:"overview",children:"Overview"}),n.jsx(Ae,{value:"map",children:"Map"}),n.jsx(Ae,{value:"chat",children:"Chat"})]}),n.jsx(Oe,{value:"overview",className:"min-h-0",children:n.jsxs(ft,{className:"h-full min-h-0",children:[n.jsx(en,{crew:l,hereId:a,nameOf:k,onOpen:M}),n.jsx(sn,{crew:l,busy:o,nameOf:k,onOpen:M,onRespond:u}),n.jsx(nn,{crew:l,hereId:a,busy:o,nameOf:k,onOpen:M,onMarkRead:r,onStop:d})]})}),n.jsx(Oe,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:l,hereId:a,controls:x,kinds:N,nameOf:k,onOpen:M})}),n.jsx(Oe,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:l.rootId,kinds:N,active:w==="chat"},l.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[17]=o,e[18]=l,e[19]=c,e[20]=N,e[21]=x,e[22]=r,e[23]=k,e[24]=M,e[25]=u,e[26]=a,e[27]=d,e[28]=w,e[29]=$):$=e[29];let E;return e[30]!==I||e[31]!==$||e[32]!==R?(E=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[R,I,$]}),e[30]=I,e[31]=$,e[32]=R,e[33]=E):E=e[33],E}function Js(s){return s.address?[[s.sessionId,Kt(s.address.dirName)]]:[]}function Qs(s){return[s.sessionId,s]}function en(s){var b;const e=re.c(45),{crew:t,hereId:i,nameOf:a,onOpen:l}=s;let c,o,u,r,d;if(e[0]!==t||e[1]!==i||e[2]!==a||e[3]!==l){let k;e[9]!==t.rootId?(k=$=>$.sessionId===t.rootId,e[9]=t.rootId,e[10]=k):k=e[10];const C=t.members.find(k),M=t.members.filter(tn);let _;e[11]!==t?(_=bs(t),e[11]=t,e[12]=_):_=e[12],d=_;const O=(b=M[0])==null?void 0:b.startedAt;c="Crew summary",o="border-b px-3 pb-3 pt-1";const L=C&&n.jsx("button",{type:"button",onClick:()=>l(C),"aria-current":C.sessionId===i?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:a(C)}),j=d.size===1?"session":"sessions",R=O?` · since ${mt(O)}`:"";let I;e[13]!==j||e[14]!==R||e[15]!==d.size?(I=n.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[d.size," ",j,R]}),e[13]=j,e[14]=R,e[15]=d.size,e[16]=I):I=e[16],e[17]!==I||e[18]!==L?(u=n.jsxs("div",{className:"flex items-baseline gap-2",children:[L,I]}),e[17]=I,e[18]=L,e[19]=u):u=e[19],r=M.length>0&&n.jsx("div",{"data-crew-strip":!0,className:"mt-2.5 grid grid-cols-[repeat(auto-fit,minmax(6px,1fr))] gap-[3px]",role:"list","aria-label":"One cell per session, in the order they were started",children:M.map($=>{const E=fe($);return n.jsx("button",{type:"button",role:"listitem","data-crew-cell":E,title:`${a($)}: ${Ne($)}`,"aria-label":`${a($)}: ${Ne($)}`,onClick:()=>{var A;return(A=document.querySelector(`[data-crew-row="${$.sessionId}"]`))==null?void 0:A.scrollIntoView({block:"nearest",behavior:"smooth"})},className:se("h-2.5 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",Zs[E],$.sessionId===i&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},$.sessionId)})}),e[0]=t,e[1]=i,e[2]=a,e[3]=l,e[4]=c,e[5]=o,e[6]=u,e[7]=r,e[8]=d}else c=e[4],o=e[5],u=e[6],r=e[7],d=e[8];let m;e[20]!==d.working?(m=d.working>0&&n.jsx(ye,{dot:ue.working,value:d.working,label:"working"}),e[20]=d.working,e[21]=m):m=e[21];let w;e[22]!==d.needsYou?(w=d.needsYou>0&&n.jsx(ye,{dot:ue["needs-you"],value:d.needsYou,label:d.needsYou===1?"needs you":"need you"}),e[22]=d.needsYou,e[23]=w):w=e[23];let g;e[24]!==d.done?(g=d.done>0&&n.jsx(ye,{dot:ue.done,value:d.done,label:"done"}),e[24]=d.done,e[25]=g):g=e[25];let x;e[26]!==d.failed?(x=d.failed>0&&n.jsx(ye,{dot:ue.failed,value:d.failed,label:"failed"}),e[26]=d.failed,e[27]=x):x=e[27];let p;e[28]!==d.unreachable?(p=d.unreachable>0&&n.jsx(ye,{dot:ue.unreachable,value:d.unreachable,label:"away"}),e[28]=d.unreachable,e[29]=p):p=e[29];let h;e[30]!==d.unreadResults?(h=d.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:d.unreadResults})," ",d.unreadResults===1?"result":"results"," unread"]}),e[30]=d.unreadResults,e[31]=h):h=e[31];let v;e[32]!==h||e[33]!==m||e[34]!==w||e[35]!==g||e[36]!==x||e[37]!==p?(v=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[m,w,g,x,p,h]}),e[32]=h,e[33]=m,e[34]=w,e[35]=g,e[36]=x,e[37]=p,e[38]=v):v=e[38];let N;return e[39]!==c||e[40]!==v||e[41]!==o||e[42]!==u||e[43]!==r?(N=n.jsxs("section",{"aria-label":c,className:o,children:[u,r,v]}),e[39]=c,e[40]=v,e[41]=o,e[42]=u,e[43]=r,e[44]=N):N=e[44],N}function tn(s){return s.parentId!==null}function ye(s){const e=re.c(10),{dot:t,value:i,label:a}=s;let l;e[0]!==t?(l=se("size-1.5 rounded-full",t),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==l?(c=n.jsx("span",{className:l,"aria-hidden":"true"}),e[2]=l,e[3]=c):c=e[3];let o;e[4]!==i?(o=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:i}),e[4]=i,e[5]=o):o=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==o?(u=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,o," ",a]}),e[6]=a,e[7]=c,e[8]=o,e[9]=u):u=e[9],u}function sn(s){const e=re.c(6),{crew:t,busy:i,nameOf:a,onOpen:l,onRespond:c}=s,o=ws(t),[u,r]=S.useState(0);if(o.length===0)return null;const d=Math.min(u,o.length-1),{member:m,pending:w}=o[d],g=o[d+1];let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=x):x=e[0];let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"flex-1"}),e[1]=p):p=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:se("size-1.5 shrink-0 rounded-full",ue["needs-you"]),"aria-hidden":"true"}),e[2]=h):h=e[2];const v=w.askedAt?`waiting ${qe(new Date(w.askedAt).toISOString())}`:"waiting";let N;e[3]!==v?(N=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:v}),e[3]=v,e[4]=N):N=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(et,{"data-icon":"inline-end"}),e[5]=b):b=e[5],n.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[x,n.jsx("span",{className:"tabular-nums",children:o.length}),p,o.length>1&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"tabular-nums",children:[d+1," of ",o.length]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:d===0,onClick:()=>r(d-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:d===o.length-1,onClick:()=>r(d+1),children:n.jsx(et,{"data-icon":"inline-start"})})]})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[h,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:a(m)}),m.device&&n.jsx(Gt,{variant:"outline",children:m.device.name}),N]}),n.jsx(Vt,{sessionId:m.sessionId,pending:w,queued:0,responding:i.has(w.requestId),onRespond:(k,C)=>void c(m.sessionId,k,C),onOpen:()=>l(m)},w.requestId),n.jsxs(J,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>l(m),children:["Open session",b]})]}),g&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:a(g.member)})," ",Ne(g.member).toLowerCase()]})]})}function nn(s){const e=re.c(17),{crew:t,hereId:i,busy:a,nameOf:l,onOpen:c,onMarkRead:o,onStop:u}=s,[r,d]=S.useState("all");let m;if(e[0]!==a||e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==l||e[5]!==o||e[6]!==c||e[7]!==u){let w;e[9]!==r?(w=N=>{const{member:b}=N;if(r==="all")return!0;const k=fe(b);return r==="done"?k!=="working"&&k!=="needs-you":k===r},e[9]=r,e[10]=w):w=e[10];const g=xs(t).filter(w);let x,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),p=n.jsx("span",{className:"flex-1"}),e[11]=x,e[12]=p):(x=e[11],p=e[12]);let h;e[13]!==r?(h=Xs.map(N=>{const{id:b,label:k}=N;return n.jsx("button",{type:"button",role:"radio","aria-checked":r===b,onClick:()=>d(b),className:se("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",r===b&&"bg-accent text-foreground"),children:k},b)}),e[13]=r,e[14]=h):h=e[14];let v;e[15]!==h?(v=n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[x,p,n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:h})]}),e[15]=h,e[16]=v):v=e[16],m=n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[v,g.length===0?n.jsx("p",{className:"px-1.5 py-4 text-center text-xs text-muted-foreground",children:"No sessions here."}):n.jsx("ul",{className:"flex flex-col",children:g.map(N=>n.jsx(on,{row:N,here:N.member.sessionId===i,busy:a,name:l(N.member),onOpen:c,onMarkRead:o,onStop:u},N.member.sessionId))})]}),e[0]=a,e[1]=t,e[2]=r,e[3]=i,e[4]=l,e[5]=o,e[6]=c,e[7]=u,e[8]=m}else m=e[8];return m}function on(s){var ae,ce;const e=re.c(73),{row:t,here:i,busy:a,name:l,onOpen:c,onMarkRead:o,onStop:u}=s,{member:r,depth:d,children:m}=t;let w;e[0]!==r?(w=fe(r),e[0]=r,e[1]=w):w=e[1];const g=w;let x;e[2]!==r?(x=Ne(r),e[2]=r,e[3]=x):x=e[3];const p=x;let h;e[4]!==r.pullRequests?(h=(ae=r.pullRequests)==null?void 0:ae.at(-1),e[4]=r.pullRequests,e[5]=h):h=e[5];const v=h;let N;e[6]!==r?(N=Re(r)&&r.result&&r.parentId,e[6]=r,e[7]=N):N=e[7];const b=N,k=(g==="working"||g==="needs-you")&&(!r.device||((ce=r.result)==null?void 0:ce.state)==="running"&&r.parentId!==null),C=r.sessionId,M=i?"bg-accent":"hover:bg-accent/60",_=d>0&&"border-l border-border/70";let O;e[8]!==M||e[9]!==_?(O=se("group/crew relative rounded-md",M,_),e[8]=M,e[9]=_,e[10]=O):O=e[10];const L=d>0?6+(d-1)*14:0;let j;e[11]!==L?(j={marginLeft:L},e[11]=L,e[12]=j):j=e[12];let R;e[13]!==r||e[14]!==c?(R=()=>c(r),e[13]=r,e[14]=c,e[15]=R):R=e[15];const I=i?"true":void 0,$=`${l}, ${p}`,E=ue[g];let A;e[16]!==E?(A=se("size-1.5 justify-self-center rounded-full",E),e[16]=E,e[17]=A):A=e[17];let z;e[18]!==A?(z=n.jsx("span",{className:A,"aria-hidden":"true"}),e[18]=A,e[19]=z):z=e[19];let D;e[20]!==l?(D=n.jsx("span",{className:"truncate",children:l}),e[20]=l,e[21]=D):D=e[21];let W;e[22]!==i?(W=i&&n.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[22]=i,e[23]=W):W=e[23];let P;e[24]!==D||e[25]!==W?(P=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[D,W]}),e[24]=D,e[25]=W,e[26]=P):P=e[26];let Y;e[27]!==r.lastActivityAt?(Y=r.lastActivityAt?qe(r.lastActivityAt):"",e[27]=r.lastActivityAt,e[28]=Y):Y=e[28];let K;e[29]!==Y?(K=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:Y}),e[29]=Y,e[30]=K):K=e[30];const B=(g==="needs-you"||b)&&"text-warning",X=g==="failed"&&"text-destructive";let H;e[31]!==B||e[32]!==X?(H=se("min-w-0 flex-1 truncate",B,X),e[31]=B,e[32]=X,e[33]=H):H=e[33];let U;e[34]!==p||e[35]!==H?(U=n.jsx("span",{className:H,children:p}),e[34]=p,e[35]=H,e[36]=U):U=e[36];let G;e[37]!==v?(G=v&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",v.number]}),e[37]=v,e[38]=G):G=e[38];let f;e[39]!==r.device?(f=r.device&&n.jsx("span",{className:"shrink-0",children:r.device.name}),e[39]=r.device,e[40]=f):f=e[40];let y;e[41]!==m?(y=m>0&&n.jsxs("span",{className:"shrink-0",children:[m," ",m===1?"session":"sessions"]}),e[41]=m,e[42]=y):y=e[42];let T;e[43]!==r.model?(T=r.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:Ye(r.model)}),e[43]=r.model,e[44]=T):T=e[44];let V;e[45]!==U||e[46]!==G||e[47]!==f||e[48]!==y||e[49]!==T?(V=n.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[U,G,f,y,T]}),e[45]=U,e[46]=G,e[47]=f,e[48]=y,e[49]=T,e[50]=V):V=e[50];let ee;e[51]!==R||e[52]!==I||e[53]!==$||e[54]!==z||e[55]!==P||e[56]!==K||e[57]!==V?(ee=n.jsxs("button",{type:"button",onClick:R,"aria-current":I,"aria-label":$,className:"grid w-full grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[z,P,K,V]}),e[51]=R,e[52]=I,e[53]=$,e[54]=z,e[55]=P,e[56]=K,e[57]=V,e[58]=ee):ee=e[58];let Z;e[59]!==a||e[60]!==k||e[61]!==r||e[62]!==l||e[63]!==o||e[64]!==u||e[65]!==b?(Z=(b||k)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[b&&r.result&&r.parentId&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${l}'s result read`,title:"Mark the result read",disabled:a.has(r.result.taskId),onClick:()=>void o(r.parentId,r.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),k&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${l}`,title:"Stop this session",disabled:a.has(r.sessionId),onClick:()=>void u(r),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[59]=a,e[60]=k,e[61]=r,e[62]=l,e[63]=o,e[64]=u,e[65]=b,e[66]=Z):Z=e[66];let te;return e[67]!==r.sessionId||e[68]!==j||e[69]!==ee||e[70]!==Z||e[71]!==O?(te=n.jsxs("li",{"data-crew-row":C,className:O,style:j,children:[ee,Z]}),e[67]=r.sessionId,e[68]=j,e[69]=ee,e[70]=Z,e[71]=O,e[72]=te):te=e[72],te}export{fn as CrewPanel};
1
+ import{r as S,c as re,j as n}from"./vendor-react-gGw_S5I_.js";import{U as ze,bJ as it,bK as be,bL as jt,bM as yt,bN as Nt,B as J,L as rt,M as ct,N as It,O as dt,Q as ut,C as Ze,bO as kt,b6 as Je,z as Qe,bP as Ct,bQ as St,q as ft,aK as Mt,bR as $t,b7 as Rt,bC as Tt,bS as At,aP as Ot,R as Et,D as Lt,h as _t,j as zt,k as Dt,J as se,bT as Pt,bU as Ft,bV as Yt,bW as qt,bX as Ye,$ as qe,bY as Wt,bz as Ht,bZ as Ut,b_ as Bt,b$ as Ae,c0 as Oe,bk as Kt,Z as Gt,c1 as Vt,c2 as Xt,c3 as Zt,bH as Jt}from"./index-D3WV64DU.js";import{S as Qt}from"./switch-B1AuQGfo.js";import{m as es,aq as ts,ak as ss,e as ns,ar as ht,as as pt,P as os,a7 as as,$ as ls,C as et,at as is,au as rs,X as cs}from"./vendor-ui-DkzcTXCS.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";async function Ce(s){if(s.ok)return s;const e=await s.json().catch(()=>null);throw new Error((e==null?void 0:e.error)||"Couldn't update crew chat.")}function Ee(s,e){return[...new Map([...s,...e].map(t=>[t.sequence,t])).values()].sort((t,i)=>t.sequence-i.sequence)}function ds(s){const[e,t]=S.useState(null),[i,a]=S.useState([]),[l,c]=S.useState(null),[o,u]=S.useState(!1),[r,d]=S.useState(!1),[m,w]=S.useState(!1),[g,x]=S.useState(new Set),p=S.useRef(0),h=S.useRef(null),v=S.useRef(!1),N=S.useRef(!1),b=S.useRef(new Set),k=S.useRef(!1),C=S.useRef(null),M=S.useCallback(async j=>{const R=++p.current;try{const I=C.current,E=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}${I===null?"":`?after=${I}&limit=100`}`))).json();if(!j()||R!==p.current)return;t(A=>A&&JSON.stringify(A.members)===JSON.stringify(E.members)?{...E,members:A.members}:E),a(A=>Ee(A,E.messages)),C.current=E.nextCursor,k.current||(k.current=!0,w(E.hasMore)),c(null)}catch(I){j()&&R===p.current&&c(I instanceof Error?I.message:"Couldn't load crew chat.")}},[s]);it(M,2e3);const _=S.useCallback(async j=>{var R;if(v.current)return!1;v.current=!0,u(!0),((R=h.current)==null?void 0:R.text)!==j&&(h.current={text:j,id:crypto.randomUUID()});try{const $=await(await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{text:j,commandId:h.current.id}))).json();return p.current++,a(E=>Ee(E,[$.message])),h.current=null,c($.pending.length?"Message saved. Some members are unavailable; delivery will retry.":null),!0}catch(I){return c(I instanceof Error?I.message:"Couldn't send the message."),!1}finally{v.current=!1,u(!1)}},[s]),O=S.useCallback(async(j,R)=>{if(!b.current.has(j)){b.current.add(j),x(I=>new Set(I).add(j));try{await Ce(await be(`/api/crew-chat/${encodeURIComponent(s)}`,{sessionId:j,listening:R},{method:"PATCH"})),p.current++,t(I=>I&&{...I,members:I.members.map($=>$.sessionId===j?{...$,listening:R}:$)}),c(null)}catch(I){c(I instanceof Error?I.message:"Couldn't change listening.")}finally{b.current.delete(j),x(I=>{const $=new Set(I);return $.delete(j),$})}}},[s]),L=S.useCallback(async()=>{if(!(!i.length||N.current)){N.current=!0,d(!0);try{const R=await(await Ce(await ze(`/api/crew-chat/${encodeURIComponent(s)}?before=${i[0].sequence}`))).json();a(I=>Ee(I,R.messages)),w(R.hasMore)}catch(j){c(j instanceof Error?j.message:"Couldn't load older messages.")}finally{N.current=!1,d(!1)}}},[i,s]);return{page:e,messages:i,error:l,posting:o,busyMembers:g,hasOlder:m,loadingOlder:r,post:_,setListening:O,older:L}}const us=[],fs=new Map;function hs(s){var We,He,Ue,Be,Ke,Ge,Ve;const e=re.c(111),{rootId:t,kinds:i,active:a}=s,l=i===void 0?fs:i,c=a===void 0?!0:a,o=ds(t),[u,r]=S.useState(""),d=S.useRef(null),m=S.useRef(!0);let w;e[0]!==o.messages?(w=(We=o.messages.at(-1))==null?void 0:We.sequence,e[0]=o.messages,e[1]=w):w=e[1];const g=w,x=((He=o.page)==null?void 0:He.members)??us;let p;e[2]!==x?(p=jt(x),e[2]=x,e[3]=p):p=e[3];const h=p;let v;e[4]!==x||e[5]!==t?(v=yt(x,t),e[4]=x,e[5]=t,e[6]=v):v=e[6];const N=v;let b;e[7]!==x?(b=new Map(x.map(ms)),e[7]=x,e[8]=b):b=e[8];const k=b;let C;e[9]!==o.messages||e[10]!==t?(C=Nt(o.messages,t),e[9]=o.messages,e[10]=t,e[11]=C):C=e[11];const M=C;let _;e[12]!==c?(_=()=>{var q,F;c&&m.current&&((F=(q=d.current)==null?void 0:q.scrollIntoView)==null||F.call(q,{block:"end"}))},e[12]=c,e[13]=_):_=e[13];let O;e[14]!==c||e[15]!==g?(O=[c,g],e[14]=c,e[15]=g,e[16]=O):O=e[16],S.useEffect(_,O);let L;e[17]!==o||e[18]!==u?(L=async()=>{const q=u.trim();!q||o.posting||await o.post(q)&&(r(F=>F.trim()===q?"":F),m.current=!0)},e[17]=o,e[18]=u,e[19]=L):L=e[19];const j=L;let R;e[20]!==o.page||e[21]!==x?(R=o.page?`${x.filter(ps).length} listening · Members & mentions`:"Loading chat…",e[20]=o.page,e[21]=x,e[22]=R):R=e[22];let I;e[23]!==R?(I=n.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:R}),e[23]=R,e[24]=I):I=e[24];let $;if(e[25]!==o||e[26]!==l||e[27]!==x||e[28]!==t||e[29]!==N){let q;e[31]!==o||e[32]!==l||e[33]!==t||e[34]!==N?(q=F=>{var Xe;return n.jsxs(Ze,{orientation:"horizontal",className:"items-center gap-2",children:[n.jsx(kt,{role:F.sessionId===t?"lead":"agent",sessionId:F.sessionId,kinds:l,tints:N,className:"size-5"}),n.jsxs(Je,{className:"min-w-0 flex-1 items-baseline gap-1.5",htmlFor:`listen-${F.sessionId}`,"aria-label":`Listen for ${F.name}`,children:[n.jsx("span",{className:"truncate",children:F.name}),n.jsxs("span",{className:"truncate text-xs font-normal text-muted-foreground",children:["@",F.handle]})]}),n.jsx(J,{variant:"ghost",size:"icon-xs",disabled:!((Xe=o.page)!=null&&Xe.canPost)||!F.canInteract,onClick:()=>r(je=>`${je}${je&&!/\s$/.test(je)?" ":""}@${F.handle} `),"aria-label":`Mention ${F.name}`,title:`Mention @${F.handle}`,className:"text-muted-foreground",children:n.jsx(ts,{"data-icon":"inline-start"})}),n.jsx(Qt,{id:`listen-${F.sessionId}`,size:"sm",checked:F.listening,disabled:!F.canInteract||o.busyMembers.has(F.sessionId),onCheckedChange:je=>void o.setListening(F.sessionId,je)})]},F.sessionId)},e[31]=o,e[32]=l,e[33]=t,e[34]=N,e[35]=q):q=e[35],$=x.map(q),e[25]=o,e[26]=l,e[27]=x,e[28]=t,e[29]=N,e[30]=$}else $=e[30];let E;e[36]!==$?(E=n.jsx(Qe,{className:"max-h-48 gap-2 overflow-y-auto py-2",children:$}),e[36]=$,e[37]=E):E=e[37];let A;e[38]===Symbol.for("react.memo_cache_sentinel")?(A=n.jsx("p",{className:"pb-1 text-xs text-muted-foreground",children:"Listening sends short notices while an agent works. @mentions send the full message, even when listening is off."}),e[38]=A):A=e[38];let z;e[39]!==I||e[40]!==E?(z=n.jsxs("details",{className:"shrink-0 border-b px-3 py-2",children:[I,E,A]}),e[39]=I,e[40]=E,e[41]=z):z=e[41];let D;e[42]===Symbol.for("react.memo_cache_sentinel")?(D=q=>{const F=q.target;m.current=F.scrollHeight-F.scrollTop-F.clientHeight<80},e[42]=D):D=e[42];let W;e[43]!==o?(W=o.hasOlder&&n.jsx("div",{className:"flex justify-center py-2",children:n.jsx(J,{variant:"ghost",size:"xs",disabled:o.loadingOlder,onClick:()=>void o.older(),children:o.loadingOlder?"Loading…":"Load earlier messages"})}),e[43]=o,e[44]=W):W=e[44];let P;e[45]!==o.messages.length||e[46]!==o.page?(P=o.page&&o.messages.length===0&&n.jsx(rt,{children:n.jsxs(ct,{children:[n.jsx(It,{variant:"icon",children:n.jsx(es,{})}),n.jsx(dt,{children:"Talk to the crew"}),n.jsx(ut,{children:"Share a discovery, ask a question, or tag someone for their input."})]})}),e[45]=o.messages.length,e[46]=o.page,e[47]=P):P=e[47];let Y;if(e[48]!==k||e[49]!==h||e[50]!==l||e[51]!==t||e[52]!==M||e[53]!==N){let q;e[55]!==k||e[56]!==h||e[57]!==l||e[58]!==t||e[59]!==N?(q=F=>n.jsxs(S.Fragment,{children:[F.day!==void 0&&n.jsx(Ct,{day:F.day}),n.jsx(St,{run:F,members:k,handles:h,kinds:l,tints:N,rootId:t})]},F.messages[0].sequence),e[55]=k,e[56]=h,e[57]=l,e[58]=t,e[59]=N,e[60]=q):q=e[60],Y=M.map(q),e[48]=k,e[49]=h,e[50]=l,e[51]=t,e[52]=M,e[53]=N,e[54]=Y}else Y=e[54];let K;e[61]===Symbol.for("react.memo_cache_sentinel")?(K=n.jsx("div",{ref:d}),e[61]=K):K=e[61];let B;e[62]!==Y?(B=n.jsxs("div",{role:"log","aria-label":"Shared messages","aria-live":"polite","aria-relevant":"additions",className:"flex flex-col gap-4 px-3 py-3",children:[Y,K]}),e[62]=Y,e[63]=B):B=e[63];let X;e[64]!==W||e[65]!==P||e[66]!==B?(X=n.jsxs(ft,{className:"min-h-0 flex-1",onScrollCapture:D,children:[W,P,B]}),e[64]=W,e[65]=P,e[66]=B,e[67]=X):X=e[67];let H;e[68]!==j?(H=q=>{q.preventDefault(),j()},e[68]=j,e[69]=H):H=e[69];const U=!!o.error,G=`crew-chat-${t}`;let f;e[70]!==G?(f=n.jsx(Je,{htmlFor:G,className:"sr-only",children:"Message the crew"}),e[70]=G,e[71]=f):f=e[71];const y=`crew-chat-${t}`,T=!((Ue=o.page)!=null&&Ue.canPost),V=!!o.error;let ee;e[72]===Symbol.for("react.memo_cache_sentinel")?(ee=q=>r(q.target.value),e[72]=ee):ee=e[72];let Z;e[73]!==j?(Z=q=>{q.key==="Enter"&&(q.metaKey||q.ctrlKey)&&!q.nativeEvent.isComposing&&(q.preventDefault(),j())},e[73]=j,e[74]=Z):Z=e[74];let te;e[75]!==u||e[76]!==y||e[77]!==T||e[78]!==V||e[79]!==Z?(te=n.jsx(Mt,{id:y,value:u,rows:3,maxLength:$t,placeholder:"Message the crew… use @ to tag an agent",disabled:T,"aria-invalid":V,onChange:ee,onKeyDown:Z}),e[75]=u,e[76]=y,e[77]=T,e[78]=V,e[79]=Z,e[80]=te):te=e[80];let ae;e[81]!==o.error?(ae=o.error&&n.jsx("p",{role:"alert",className:"text-xs text-destructive",children:o.error}),e[81]=o.error,e[82]=ae):ae=e[82];let ce;e[83]!==U||e[84]!==f||e[85]!==te||e[86]!==ae?(ce=n.jsxs(Ze,{"data-invalid":U,children:[f,te,ae]}),e[83]=U,e[84]=f,e[85]=te,e[86]=ae,e[87]=ce):ce=e[87];const ve=((Be=o.page)==null?void 0:Be.canPost)===!1?"You have read access to this crew.":"⌘ / Ctrl + Enter to send";let le;e[88]!==ve?(le=n.jsx(Rt,{className:"flex-1",children:ve}),e[88]=ve,e[89]=le):le=e[89];let de;e[90]!==((Ke=o.page)==null?void 0:Ke.canPost)||e[91]!==o.posting||e[92]!==u?(de=!((Ge=o.page)!=null&&Ge.canPost)||!u.trim()||o.posting,e[90]=(Ve=o.page)==null?void 0:Ve.canPost,e[91]=o.posting,e[92]=u,e[93]=de):de=e[93];let Ie;e[94]===Symbol.for("react.memo_cache_sentinel")?(Ie=n.jsx(ss,{"data-icon":"inline-start"}),e[94]=Ie):Ie=e[94];const Te=o.posting?"Sending…":"Send";let pe;e[95]!==de||e[96]!==Te?(pe=n.jsxs(J,{type:"submit",size:"sm",disabled:de,children:[Ie,Te]}),e[95]=de,e[96]=Te,e[97]=pe):pe=e[97];let me;e[98]!==le||e[99]!==pe?(me=n.jsxs("div",{className:"flex items-center gap-2",children:[le,pe]}),e[98]=le,e[99]=pe,e[100]=me):me=e[100];let ge;e[101]!==ce||e[102]!==me?(ge=n.jsxs(Qe,{className:"gap-2",children:[ce,me]}),e[101]=ce,e[102]=me,e[103]=ge):ge=e[103];let xe;e[104]!==H||e[105]!==ge?(xe=n.jsx("form",{className:"shrink-0 border-t p-3",onSubmit:H,children:ge}),e[104]=H,e[105]=ge,e[106]=xe):xe=e[106];let ke;return e[107]!==z||e[108]!==X||e[109]!==xe?(ke=n.jsxs("section",{"aria-label":"Crew chat",className:"flex h-full min-h-0 flex-col",children:[z,X,xe]}),e[107]=z,e[108]=X,e[109]=xe,e[110]=ke):ke=e[110],ke}function ps(s){return s.listening}function ms(s){return[s.sessionId,s]}const ue={working:"bg-success ring-2 ring-success/30","needs-you":"bg-warning",done:"bg-muted-foreground/50",failed:"bg-destructive",unreachable:"border border-muted-foreground/60"};function mt(s){const e=new Date(s),t=e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.toDateString()===new Date().toDateString()?t:`${e.toLocaleDateString([],{month:"short",day:"numeric"})}, ${t}`}function fe(s){if(s.status==="deferred")return"needs-you";switch(s.outcome){case"needs_input":return"needs-you";case"running":return"working";case"error":return"failed";case"unreachable":case"not_found":return"unreachable";default:return"done"}}function tt(s,e){var t,i;return{sessionId:s.sessionId,dirName:((t=s.address)==null?void 0:t.dirName)??"",fileName:((i=s.address)==null?void 0:i.fileName)??"",projectShortName:"",lastModified:s.lastActivityAt??"",lastActivityAt:s.lastActivityAt,size:0,cwd:s.cwd,customTitle:s.customTitle,aiTitle:s.aiTitle,firstUserMessage:s.firstUserMessage,...s.parentId&&{crew:{rootId:e,parentId:s.parentId,startedAt:s.startedAt??0,...s.name&&{name:s.name}}}}}function gs(s,e,t){var o;const i=((o=[...e.values()].find(u=>u.parentId===null))==null?void 0:o.sessionId)??s.sessionId,a=t[s.sessionId],l=tt(s,i);if(!s.parentId)return Tt(l,a);const c=e.get(s.parentId);return At(l,{customName:a,parent:c&&tt(c,i)})}function xs(s){const e=new Map;for(const l of s.members){if(!l.parentId)continue;const c=e.get(l.parentId);c?c.push(l):e.set(l.parentId,[l])}const t=[],i=new Set,a=(l,c)=>{var u;const o=[...e.get(l)??[]].sort((r,d)=>(r.startedAt??0)-(d.startedAt??0));for(const r of o)i.has(r.sessionId)||(i.add(r.sessionId),t.push({member:r,depth:c,children:((u=e.get(r.sessionId))==null?void 0:u.length)??0}),a(r.sessionId,c+1))};a(s.rootId,0);for(const l of s.members)l.parentId&&!i.has(l.sessionId)&&(i.add(l.sessionId),t.push({member:l,depth:0,children:0}));return t}function ws(s){const e=({member:t,pending:i})=>i.askedAt??(Date.parse(t.lastActivityAt??"")||0);return s.members.flatMap(t=>t.waiting.map(i=>({member:t,pending:i}))).sort((t,i)=>e(t)-e(i))}function bs(s){const e={size:0,working:0,needsYou:0,done:0,failed:0,unreachable:0,unreadResults:0};for(const t of s.members){if(!t.parentId)continue;e.size++;const i=fe(t);i==="working"?e.working++:i==="needs-you"?e.needsYou++:i==="failed"?e.failed++:i==="unreachable"?e.unreachable++:e.done++,Re(t)&&e.unreadResults++}return e}function Re(s){return!!(s.result&&s.result.state!=="running"&&!s.result.acknowledged)}function Ne(s){const[e]=s.waiting;switch(fe(s)){case"needs-you":return(e==null?void 0:e.kind)==="permission"?`Waiting on a permission · ${e.toolName}`:(e==null?void 0:e.kind)==="question"?"Asked a question":!e&&s.status==="deferred"?"Awaiting permission review":"Plan to review";case"working":return s.status==="tool_use"&&s.toolName?s.toolName:s.status==="thinking"?"Thinking":s.status==="compacting"?"Compacting":s.status==="awaiting_agents"?"Waiting on its agents":"Working";case"failed":return s.error?`Failed · ${s.error}`:"Failed";case"unreachable":return s.device?`${s.device.name} is not answering`:"Not found";default:return Re(s)?"Finished · result unread":"Finished"}}const ne=196,Q=86,ie=40,we=12,vs=28,Me=6,st=8,he=10,js=6,$e=28,De=36;function gt(s){const e=fe(s);return e==="working"||e==="needs-you"}function ys(s){const e={all:s.members.length,active:0,working:0,needsYou:0};for(const t of s.members){const i=fe(t);i==="working"?e.working++:i==="needs-you"&&e.needsYou++}return e.active=e.working+e.needsYou,e}const nt=(s,e)=>(s.startedAt??0)-(e.startedAt??0)||s.sessionId.localeCompare(e.sessionId);function xt(s){const e=new Map(s.members.map(a=>[a.sessionId,a])),t=new Map,i=[];for(const a of s.members){const l=a.parentId&&a.sessionId!==s.rootId?e.get(a.parentId):void 0;if(!l){i.push(a);continue}const c=t.get(l.sessionId);c?c.push(a):t.set(l.sessionId,[a])}for(const a of t.values())a.sort(nt);return i.sort((a,l)=>+(l.sessionId===s.rootId)-+(a.sessionId===s.rootId)||nt(a,l)),{roots:i,childrenOf:t}}function Ns(s,e){if(e==="all")return new Set(s.members.map(a=>a.sessionId));const t=new Map(s.members.map(a=>[a.sessionId,a])),i=new Set;for(const a of s.members){if(!gt(a))continue;let l=a;for(;l&&!i.has(l.sessionId);)i.add(l.sessionId),l=l.sessionId===s.rootId||!l.parentId?void 0:t.get(l.parentId)}return i}function Is(s){const{roots:e,childrenOf:t}=xt(s),i=new Set;let a=0;const l=e.map(c=>({member:c,depth:0}));for(;l.length>0;){const{member:c,depth:o}=l.pop();if(!i.has(c.sessionId)){i.add(c.sessionId),a=Math.max(a,o);for(const u of t.get(c.sessionId)??[])l.push({member:u,depth:o+1})}}return a}function ks(s){return(s+1)*ne+s*ie}function Cs(s,e,t,{group:i=!1,stacked:a}={}){const{roots:l,childrenOf:c}=xt(s),o=Ns(s,e),u=C=>(c.get(C)??[]).filter(M=>o.has(M.sessionId)),r=(a==null?void 0:a.cardWidth)??ne,d=[],m=[],w=[],g=new Set;let x=0,p=0;const h=C=>{const M={count:0,working:0,needsYou:0},_=new Set(g),O=[...u(C)];for(;O.length>0;){const L=O.pop();if(_.has(L.sessionId))continue;_.add(L.sessionId),M.count++;const j=fe(L);j==="working"?M.working++:j==="needs-you"&&M.needsYou++,O.push(...u(L.sessionId))}return M},v=C=>u(C).filter(M=>!g.has(M.sessionId)),N=C=>v(C.sessionId).length===0||t.has(C.sessionId),b=(C,M,_)=>{g.add(C.sessionId);const O=v(C.sessionId),L=O.length>0&&t.has(C.sessionId),j=L?[]:O,R=i&&!a&&j.length>=st?j.filter(N):[],I=R.length>=st?R:[],$=new Set(I),E=j.filter(D=>!$.has(D)),A={member:C,depth:M,x:(_==null?void 0:_.x)??M*(a?$e:ne+ie),y:(_==null?void 0:_.y)??x+(E.length===0&&I.length>0?he:0),childCount:O.length,collapsed:L,hidden:L?h(C.sessionId):{count:0,working:0,needsYou:0},context:e==="active"&&!gt(C),grouped:!!_};if(d.push(A),p=Math.max(p,A.x+r+(a&&O.length>0?De:0)),a){x+=Q+we;const D=j.map(W=>b(W,M+1));return D.length>0&&m.push({parentId:C.sessionId,path:Ms(A.x,A.y,D)}),A.y}if(L){const D=A.y+Q/2;m.push({parentId:C.sessionId,path:`M${A.x+ne} ${D}H${A.x+ne+ie/2}`})}if(_)return A.y;if(j.length===0)return x+=Q+we,A.y;const z=E.map(D=>b(D,M+1));return I.length>0&&z.push(k(C.sessionId,I,M+1)+he),m.push({parentId:C.sessionId,path:Ss(A.x+ne,A.y,z)}),A.y},k=(C,M,_)=>{const O=Math.min(js,Math.max(2,Math.ceil(Math.sqrt(M.length/1.5)))),L=Math.ceil(M.length/O),j={parentId:C,x:_*(ne+ie),y:x,width:O*ne+(O-1)*ie+2*he,height:L*Q+(L-1)*we+2*he};return w.push(j),M.forEach((R,I)=>b(R,_,{x:j.x+he+I%O*(ne+ie),y:j.y+he+Math.floor(I/O)*(Q+we)})),p=Math.max(p,j.x+j.width),x+=j.height+we,j.y};for(const C of l)!o.has(C.sessionId)||g.has(C.sessionId)||(d.length>0&&(x+=vs),b(C,0));return{orientation:a?"stacked":"across",cardWidth:r,nodes:d,edges:m,groups:w,width:p,height:Math.max(0,x-we)}}function Ss(s,e,t){const i=e+Q/2,a=[`M${s} ${i}H${s+ie}`];for(const l of t)l!==e&&a.push(wt(s,i,l+Q/2));return a.join("")}function wt(s,e,t){const i=s+ie/2;return`M${i} ${e}V${t-Me}Q${i} ${t} ${i+Me} ${t}H${s+ie}`}function Ms(s,e,t){return t.map(i=>bt(s,e,i)).join("")}function bt(s,e,t){const i=s+$e/2,a=t+Q/2;return`M${i} ${e+Q}V${a-Me}Q${i} ${a} ${i+Me} ${a}H${s+$e}`}function $s(s,e){const t=new Map(s.nodes.map(c=>[c.member.sessionId,c])),i=new Map(s.groups.map(c=>[c.parentId,c]));let a=e?t.get(e):void 0;const l=[];for(;a!=null&&a.member.parentId;){const c=a.member.parentId,o=t.get(c);if(!o||o.depth!==a.depth-1)break;if(s.orientation==="stacked"){l.unshift(bt(o.x,o.y,a.y)),a=o;continue}const u=o.x+ne,r=o.y+Q/2,d=a.grouped?i.get(c):void 0,m=(d?d.y+he:a.y)+Q/2;l.unshift(m===r?`M${u} ${r}H${u+ie}`:`M${u} ${r}H${u+ie/2}${wt(u,r,m)}`),a=o}return l.length>0?l.join(""):null}const oe=14,Pe=.25,ot=1.5,Rs=.7,Se=1.2,Ts=56,As=900,Os=.85,Es=320,Le={all:new Set,active:new Set};function Ls(s){const[e,t]=Ot(Et("crew-map-filter"),"all"),i=e==="active"?"active":"all",[a,l]=S.useState({rootId:s,folds:Le}),c=S.useRef(new Map),o=a.rootId===s?a.folds:Le,u=S.useCallback(d=>l(m=>{const w=m.rootId===s?m.folds:Le,g=new Set(w[i]);return g.delete(d)||g.add(d),{rootId:s,folds:{...w,[i]:g}}}),[i,s]),r=S.useMemo(()=>({get current(){return c.current.get(s)??null},set current(d){c.current.set(s,d)}}),[s]);return{filter:i,setFilter:t,collapsed:o[i],toggle:u,viewport:r}}function _s(s){const e=re.c(86),{crew:t,hereId:i,controls:a,kinds:l,nameOf:c,onOpen:o}=s,[u,r]=S.useState(!1),{filter:d,collapsed:m,toggle:w}=a;let g,x,p,h,v,N,b,k,C,M,_,O,L,j,R,I;if(e[0]!==m||e[1]!==a||e[2]!==t||e[3]!==u||e[4]!==d||e[5]!==i||e[6]!==l||e[7]!==c||e[8]!==o||e[9]!==w){let B;e[26]!==t.rootId?(B=y=>y.sessionId===t.rootId,e[26]=t.rootId,e[27]=B):B=e[27];const X=t.members.find(B);let H;e[28]!==m||e[29]!==a||e[30]!==t||e[31]!==d||e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==w?(H=(y,T)=>n.jsx(Fs,{crew:t,collapsed:m,groups:!y,filter:d,hereId:i,kinds:l,nameOf:c,memory:y,onOpen:T,onToggle:w,onShowAll:()=>a.setFilter("all")}),e[28]=m,e[29]=a,e[30]=t,e[31]=d,e[32]=i,e[33]=l,e[34]=c,e[35]=w,e[36]=H):H=e[36],p=H,N="flex h-full min-h-0 flex-col";let U;e[37]!==a||e[38]!==t?(U=n.jsx(at,{crew:t,controls:a}),e[37]=a,e[38]=t,e[39]=U):U=e[39];let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=n.jsx("span",{className:"flex-1"}),e[40]=G):G=e[40];let f;e[41]===Symbol.for("react.memo_cache_sentinel")?(f=n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Expand the map",title:"Expand the map",onClick:()=>r(!0),children:n.jsx(ns,{"data-icon":"inline-start"})}),e[41]=f):f=e[41],e[42]!==U?(b=n.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[U,G,f]}),e[42]=U,e[43]=b):b=e[43],e[44]!==p||e[45]!==a.viewport||e[46]!==o?(k=p(a.viewport,o),e[44]=p,e[45]=a.viewport,e[46]=o,e[47]=k):k=e[47],x=Lt,I=u,v=r,g=_t,O=!0,L="flex h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-none flex-col gap-0 overflow-hidden p-0 sm:h-[calc(100dvh-4rem)] sm:w-[calc(100vw-4rem)] sm:max-w-none",e[48]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(zt,{className:"sr-only",children:"Crew map"}),R=n.jsx(Dt,{className:"sr-only",children:"Every session in this crew, from the one that started it."}),e[48]=j,e[49]=R):(j=e[48],R=e[49]),M="flex h-12 shrink-0 items-center gap-3 pl-4 pr-14",e[50]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"}),e[50]=_):_=e[50],h="min-w-0 truncate text-sm font-medium",C=X?c(X):"Crew",e[0]=m,e[1]=a,e[2]=t,e[3]=u,e[4]=d,e[5]=i,e[6]=l,e[7]=c,e[8]=o,e[9]=w,e[10]=g,e[11]=x,e[12]=p,e[13]=h,e[14]=v,e[15]=N,e[16]=b,e[17]=k,e[18]=C,e[19]=M,e[20]=_,e[21]=O,e[22]=L,e[23]=j,e[24]=R,e[25]=I}else g=e[10],x=e[11],p=e[12],h=e[13],v=e[14],N=e[15],b=e[16],k=e[17],C=e[18],M=e[19],_=e[20],O=e[21],L=e[22],j=e[23],R=e[24],I=e[25];let $;e[51]!==h||e[52]!==C?($=n.jsx("span",{className:h,children:C}),e[51]=h,e[52]=C,e[53]=$):$=e[53];let E;e[54]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsx("span",{className:"flex-1"}),e[54]=E):E=e[54];let A;e[55]!==a||e[56]!==t?(A=n.jsx(at,{crew:t,controls:a}),e[55]=a,e[56]=t,e[57]=A):A=e[57];let z;e[58]!==$||e[59]!==A||e[60]!==M||e[61]!==_?(z=n.jsxs("header",{className:M,children:[_,$,E,A]}),e[58]=$,e[59]=A,e[60]=M,e[61]=_,e[62]=z):z=e[62];let D;e[63]!==o?(D=B=>{r(!1),o(B)},e[63]=o,e[64]=D):D=e[64];let W;e[65]!==p||e[66]!==D?(W=p(null,D),e[65]=p,e[66]=D,e[67]=W):W=e[67];let P;e[68]!==g||e[69]!==z||e[70]!==W||e[71]!==O||e[72]!==L||e[73]!==j||e[74]!==R?(P=n.jsxs(g,{showCloseButton:O,className:L,children:[j,R,z,W]}),e[68]=g,e[69]=z,e[70]=W,e[71]=O,e[72]=L,e[73]=j,e[74]=R,e[75]=P):P=e[75];let Y;e[76]!==x||e[77]!==v||e[78]!==P||e[79]!==I?(Y=n.jsx(x,{open:I,onOpenChange:v,children:P}),e[76]=x,e[77]=v,e[78]=P,e[79]=I,e[80]=Y):Y=e[80];let K;return e[81]!==N||e[82]!==b||e[83]!==k||e[84]!==Y?(K=n.jsxs("div",{className:N,children:[b,k,Y]}),e[81]=N,e[82]=b,e[83]=k,e[84]=Y,e[85]=K):K=e[85],K}function at(s){const e=re.c(3),{crew:t,controls:i}=s;let a;if(e[0]!==i||e[1]!==t){const l=ys(t),c=[{id:"all",label:"All",count:l.all,hint:"Every session in the crew"},{id:"active",label:"Active",count:l.active,hint:"Sessions working or waiting on you, and the sessions that started them"}];a=n.jsx("div",{role:"radiogroup","aria-label":"Show on the map",className:"flex shrink-0 gap-0.5 rounded-full border bg-background p-0.5",children:c.map(o=>{const{id:u,label:r,count:d,hint:m}=o;return n.jsxs("button",{type:"button",role:"radio","aria-checked":i.filter===u,"aria-label":`${r}, ${vt(d)}`,title:m,onClick:()=>i.setFilter(u),className:se("inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",i.filter===u&&"bg-accent text-foreground"),children:[r,n.jsx("span",{className:"tabular-nums text-muted-foreground",children:d})]},u)})}),e[0]=i,e[1]=t,e[2]=a}else a=e[2];return a}function vt(s){return`${s} ${s===1?"session":"sessions"}`}function _e(s,e,t){return s.orientation==="stacked"?{scale:e,left:oe,top:oe}:{scale:e,left:Math.max(oe,(t.width-s.width*e)/2),top:Math.max(oe,Math.min((t.height-s.height*e)/2,t.height*.12))}}function zs(s,e,t){return{width:Math.max(t.width,e.left+s.width*e.scale+oe),height:Math.max(t.height,e.top+s.height*e.scale+Ts)}}function lt(s,e,{widthOnly:t=!1}={}){if(s.width===0||e.width===0)return 1;const i=(e.width-2*oe)/s.width,a=t?i:Math.min(i,(e.height-2*oe)/s.height);return Fe(a,Pe,1)}const Fe=(s,e,t)=>Math.min(t,Math.max(e,s));function Ds(s,e,t,i,a){var w;const l=new Map(e.layout.nodes.map(g=>[g.member.sessionId,g])),c=new Map(t.nodes.map(g=>[g.member.sessionId,g]));if(e.frame===i&&l.size===c.size&&t.nodes.every(g=>{const x=l.get(g.member.sessionId);return x!==void 0&&x.x===g.x&&x.y===g.y}))return null;const u=g=>({x:e.frame.left+g.x*e.frame.scale-s.left,y:e.frame.top+g.y*e.frame.scale-s.top}),r=a&&l.has(a)&&c.has(a)?a:(w=e.layout.nodes.filter(g=>c.has(g.member.sessionId)).map(g=>({node:g,screen:u(g)})).filter(({screen:g})=>g.y+Q*e.frame.scale>0&&g.x+e.layout.cardWidth*e.frame.scale>0).sort((g,x)=>g.screen.y-x.screen.y||g.screen.x-x.screen.x)[0])==null?void 0:w.node.member.sessionId;if(!r)return null;const d=u(l.get(r)),m=c.get(r);return{left:i.left+m.x*i.scale-d.x,top:i.top+m.y*i.scale-d.y}}function Ps(s,e,t,i){const a=new Map(s.nodes.map(x=>[x.member.sessionId,x])),l=e?a.get(e):void 0;if(!l)return{left:0,top:0};const{scale:c}=t,o=t.left+l.x*c,u=t.top+l.y*c,r=o+s.cardWidth*c,d=u+Q*c;if(r<=i.clientWidth&&d<=i.clientHeight)return{left:0,top:0};const m=l.member.parentId&&a.get(l.member.parentId)||l;let w=t.left+Math.min(m.x,l.x)*c-oe,g=t.top+Math.min(m.y,l.y)*c-oe;return r-w>i.clientWidth&&(w=o-oe),d-g>i.clientHeight&&(g=u-i.clientHeight/3),{left:Math.max(0,w),top:Math.max(0,g)}}function Fs({crew:s,collapsed:e,groups:t,filter:i,hereId:a,kinds:l,nameOf:c,memory:o,onOpen:u,onToggle:r,onShowAll:d}){const m=S.useRef(null),[w,g]=S.useState({width:0,height:0}),x=t&&w.width>=As,p=S.useMemo(()=>Is(s),[s]),h=w.width-2*oe,v=!t&&w.width>0&&ks(p)*Os>h,N=v?Fe(h-p*$e-De,ne,Es):ne,b=S.useMemo(()=>Cs(s,i,e,{group:x,...v&&{stacked:{cardWidth:N}}}),[s,i,e,x,v,N]),[k,C]=S.useState(()=>{var f;return((f=o==null?void 0:o.current)==null?void 0:f.frame)??{scale:1,left:oe,top:oe}}),[M,_]=S.useState(!1),O=S.useRef(null),L=S.useRef(null),j=S.useRef({left:0,top:0}),R=S.useRef(null),I=S.useRef(null),$=zs(b,k,w),{scale:E}=k;S.useLayoutEffect(()=>{const f=m.current;if(!f)return;const y=()=>g(V=>V.width===f.clientWidth&&V.height===f.clientHeight?V:{width:f.clientWidth,height:f.clientHeight});y();const T=new ResizeObserver(y);return T.observe(f),()=>T.disconnect()},[]);const A=S.useCallback(f=>{const y=m.current;o&&y&&(o.current={frame:f,left:y.scrollLeft,top:y.scrollTop})},[o]),z=S.useCallback((f,y)=>{O.current={frame:f,scroll:y},C(f)},[]),D=S.useCallback(f=>{const y=_e(f,Math.max(lt(f,w,{widthOnly:!0}),Rs),w);z(y,()=>{const T=m.current;return T?Ps(f,a,y,T):{left:0,top:0}})},[z,a,w]);S.useLayoutEffect(()=>{const f=m.current;if(w.width===0||!f)return;const y=R.current;if(y){if(y.filter!==i||y.layout.orientation!==b.orientation)D(b);else if(y.layout!==b){const T=Ds(j.current,y,b,k,L.current);T&&(f.scrollLeft=T.left,f.scrollTop=T.top,j.current={left:f.scrollLeft,top:f.scrollTop})}}else{const T=o==null?void 0:o.current;T?z(T.frame,()=>({left:T.left,top:T.top})):D(b)}L.current=null,R.current={layout:b,filter:i,frame:k}}),S.useLayoutEffect(()=>{const f=O.current,y=m.current;if(!f||!y||f.frame!==k)return;O.current=null;const{left:T,top:V}=f.scroll();y.scrollLeft=T,y.scrollTop=V,j.current={left:y.scrollLeft,top:y.scrollTop},A(k)});const W=S.useRef(a);S.useEffect(()=>{var f,y;W.current!==a&&(W.current=a,a&&((y=(f=m.current)==null?void 0:f.querySelector(`[data-crew-map-card="${CSS.escape(a)}"]`))==null||y.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})))},[a]);const P=S.useCallback((f,y)=>{var de;const T=m.current,V=((de=O.current)==null?void 0:de.frame.scale)??E,ee=Fe(V*f,Pe,ot);if(!T||ee===V)return;const Z=T.getBoundingClientRect(),te=y?y.clientX-Z.left:T.clientWidth/2,ae=y?y.clientY-Z.top:T.clientHeight/2,ce=(T.scrollLeft+te-k.left)/E,ve=(T.scrollTop+ae-k.top)/E,le=_e(b,ee,w);z(le,()=>({left:le.left+ce*le.scale-te,top:le.top+ve*le.scale-ae}))},[z,k.left,k.top,b,E,w]),Y=S.useRef(P);S.useLayoutEffect(()=>{Y.current=P}),S.useEffect(()=>{const f=m.current;if(!f)return;const y=T=>{!T.ctrlKey&&!T.metaKey||(T.preventDefault(),Y.current(Math.exp(-T.deltaY*.01),T))};return f.addEventListener("wheel",y,{passive:!1}),()=>f.removeEventListener("wheel",y)},[]);const K=f=>{const y=m.current;!y||f.pointerType!=="mouse"||f.button!==0||f.target.closest("button")||(I.current={pointerId:f.pointerId,x:f.clientX,y:f.clientY,left:y.scrollLeft,top:y.scrollTop},y.setPointerCapture(f.pointerId),_(!0))},B=f=>{const y=I.current,T=m.current;!y||!T||y.pointerId!==f.pointerId||(T.scrollLeft=y.left-(f.clientX-y.x),T.scrollTop=y.top-(f.clientY-y.y))},X=f=>{var y,T;((y=I.current)==null?void 0:y.pointerId)===f.pointerId&&(I.current=null,(T=m.current)==null||T.releasePointerCapture(f.pointerId),_(!1))},H=S.useMemo(()=>$s(b,a),[b,a]),U=b.nodes.length===0,G=b.orientation==="stacked"?b.cardWidth+De/2:ne+ie/2;return n.jsxs("div",{className:"relative min-h-0 flex-1 border-t",children:[n.jsx("div",{ref:m,role:"region","aria-label":"Crew map","data-crew-map-layout":b.orientation,onScroll:f=>{j.current={left:f.currentTarget.scrollLeft,top:f.currentTarget.scrollTop},O.current||A(k)},onPointerDown:K,onPointerMove:B,onPointerUp:X,onPointerCancel:X,onKeyDown:f=>{f.target===f.currentTarget&&(f.key==="+"||f.key==="="?P(Se):f.key==="-"&&P(1/Se))},tabIndex:-1,className:se("absolute inset-0 overflow-auto overscroll-contain outline-none [touch-action:pan-x_pan-y]","bg-muted/30 bg-local bg-[radial-gradient(circle,var(--border)_1px,transparent_1px)] bg-size-[18px_18px]",M?"cursor-grabbing select-none":"cursor-grab"),children:U?n.jsxs(rt,{className:"h-full",children:[n.jsxs(ct,{children:[n.jsx(dt,{children:"Nothing is active"}),n.jsx(ut,{className:"text-xs",children:"No session in this crew is working or waiting on you."})]}),n.jsx(J,{variant:"outline",size:"xs",onClick:d,children:"Show all sessions"})]}):n.jsx("div",{className:"relative",style:{width:$.width,height:$.height},children:n.jsxs("div",{className:"absolute origin-top-left",style:{left:k.left,top:k.top,width:b.width,height:b.height,transform:`scale(${E})`},children:[b.groups.map(f=>n.jsx("div",{"aria-hidden":"true",className:"absolute rounded-xl border border-dashed border-muted-foreground/25 bg-muted/25",style:{left:f.x,top:f.y,width:f.width,height:f.height}},f.parentId)),n.jsxs("svg",{"aria-hidden":"true",width:b.width,height:b.height,className:"pointer-events-none absolute inset-0 overflow-visible",fill:"none",children:[b.edges.map(f=>n.jsx("path",{d:f.path,className:"stroke-muted-foreground/35",strokeWidth:1.25},f.parentId)),H&&n.jsx("path",{d:H,className:"stroke-foreground/55",strokeWidth:1.5})]}),n.jsx("ul",{"aria-label":"Sessions",className:"absolute inset-0",children:b.nodes.map(f=>n.jsx(Hs,{node:f,width:b.cardWidth,toggleLeft:G,here:f.member.sessionId===a,kind:l.get(f.member.sessionId),name:c(f.member),onOpen:u,onToggle:y=>{L.current=y,r(y)}},f.member.sessionId))})]})})}),!U&&n.jsxs("div",{className:"absolute bottom-2.5 right-2.5 flex items-center gap-0.5 rounded-lg border bg-popover p-0.5 shadow-sm",children:[n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom out",title:"Zoom out",disabled:E<=Pe,onClick:()=>P(1/Se),children:n.jsx(pt,{"data-icon":"inline-start"})}),n.jsxs(J,{variant:"ghost",size:"xs","aria-label":"Actual size",title:"Actual size",className:"min-w-11 px-1 tabular-nums text-muted-foreground",onClick:()=>P(1/E),children:[Math.round(E*100),"%"]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Zoom in",title:"Zoom in",disabled:E>=ot,onClick:()=>P(Se),children:n.jsx(os,{"data-icon":"inline-start"})}),n.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":"true"}),n.jsx(J,{variant:"ghost",size:"xs",title:"Fit the whole crew on screen",className:"px-1.5 text-muted-foreground",onClick:()=>z(_e(b,lt(b,w),w),()=>({left:0,top:0})),children:"Fit"})]})]})}const Ys={"needs-you":"border-warning/60 bg-[color-mix(in_oklch,var(--warning)_7%,var(--card))]",failed:"border-destructive/45",unreachable:"border-dashed"},qs={"needs-you":"text-warning",failed:"text-destructive"};function Ws(s){var t,i;const e=(t=s.pullRequests)==null?void 0:t.at(-1);return[s.model&&Ye(s.model),(i=s.device)==null?void 0:i.name,e&&`#${e.number}`,s.lastActivityAt&&qe(s.lastActivityAt)].filter(Boolean).join(" · ")}function Hs(s){const e=re.c(75),{node:t,width:i,toggleLeft:a,here:l,kind:c,name:o,onOpen:u,onToggle:r}=s,{member:d}=t;let m;e[0]!==d?(m=fe(d),e[0]=d,e[1]=m):m=e[1];const w=m;let g;e[2]!==d?(g=Ne(d),e[2]=d,e[3]=g):g=e[3];const x=g;let p;e[4]!==c?(p=c?Pt(c):as,e[4]=c,e[5]=p):p=e[5];const h=p;let v;e[6]!==d?(v=Ws(d),e[6]=d,e[7]=v):v=e[7];const N=v,b=t.context&&"shown because a session it started is active";let k;e[8]!==x||e[9]!==o||e[10]!==b?(k=[o,x,b].filter(Boolean),e[8]=x,e[9]=o,e[10]=b,e[11]=k):k=e[11];const C=k.join(", ");let M;e[12]!==t.x||e[13]!==t.y||e[14]!==i?(M={left:t.x,top:t.y,width:i,height:Q},e[12]=t.x,e[13]=t.y,e[14]=i,e[15]=M):M=e[15];const _=d.sessionId,O=l?"true":void 0;let L;e[16]!==d||e[17]!==u?(L=()=>u(d),e[16]=d,e[17]=u,e[18]=L):L=e[18];const j=Ys[w],R=l&&"outline-solid outline-[1.5px] outline-offset-2 outline-foreground/70",I=t.context&&"opacity-60 hover:opacity-100 focus-visible:opacity-100";let $;e[19]!==j||e[20]!==R||e[21]!==I?($=se("flex size-full cursor-pointer flex-col justify-center gap-1 rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs outline-none","transition-[border-color,opacity,box-shadow] hover:border-foreground/25 hover:shadow-sm focus-visible:ring-2 focus-visible:ring-ring",j,R,I),e[19]=j,e[20]=R,e[21]=I,e[22]=$):$=e[22];let E;e[23]!==C||e[24]!==d.sessionId||e[25]!==w||e[26]!==L||e[27]!==$||e[28]!==O?(E=n.jsx("button",{type:"button","data-crew-map-card":_,"data-crew-map-state":w,"aria-current":O,"aria-label":C,onClick:L,className:$}),e[23]=C,e[24]=d.sessionId,e[25]=w,e[26]=L,e[27]=$,e[28]=O,e[29]=E):E=e[29];let A;e[30]!==h?(A=n.jsx(h,{"aria-hidden":"true",className:"mt-[3px] size-3.5 shrink-0 text-muted-foreground"}),e[30]=h,e[31]=A):A=e[31];let z;e[32]!==o?(z=n.jsx("span",{className:"line-clamp-2 min-w-0 flex-1 text-[13px]/[18px] font-medium",children:o}),e[32]=o,e[33]=z):z=e[33];let D;e[34]!==A||e[35]!==z?(D=n.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[A,z]}),e[34]=A,e[35]=z,e[36]=D):D=e[36];const W=ue[w];let P;e[37]!==W?(P=se("size-1.5 shrink-0 rounded-full",W),e[37]=W,e[38]=P):P=e[38];let Y;e[39]!==P?(Y=n.jsx("span",{className:P,"aria-hidden":"true"}),e[39]=P,e[40]=Y):Y=e[40];let K;e[41]!==d||e[42]!==w?(K=Re(d)?"text-warning":qs[w],e[41]=d,e[42]=w,e[43]=K):K=e[43];let B;e[44]!==K?(B=se("min-w-0 truncate text-muted-foreground",K),e[44]=K,e[45]=B):B=e[45];let X;e[46]!==x||e[47]!==B?(X=n.jsx("span",{className:B,children:x}),e[46]=x,e[47]=B,e[48]=X):X=e[48];let H;e[49]!==Y||e[50]!==X?(H=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[Y,X]}),e[49]=Y,e[50]=X,e[51]=H):H=e[51];let U;e[52]!==l||e[53]!==N?(U=(N||l)&&n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11.5px] tabular-nums text-muted-foreground/75",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate",children:N}),l&&n.jsx("span",{className:"shrink-0 font-medium text-foreground/70",children:"You are here"})]}),e[52]=l,e[53]=N,e[54]=U):U=e[54];let G;e[55]!==E||e[56]!==D||e[57]!==H||e[58]!==U?(G=n.jsxs(Ft,{delay:700,render:E,children:[D,H,U]}),e[55]=E,e[56]=D,e[57]=H,e[58]=U,e[59]=G):G=e[59];let f;e[60]!==d||e[61]!==o?(f=n.jsx(Yt,{side:"left",align:"start",className:"max-w-72",children:n.jsx(Bs,{member:d,name:o})}),e[60]=d,e[61]=o,e[62]=f):f=e[62];let y;e[63]!==G||e[64]!==f?(y=n.jsxs(qt,{children:[G,f]}),e[63]=G,e[64]=f,e[65]=y):y=e[65];let T;e[66]!==o||e[67]!==t||e[68]!==r||e[69]!==a?(T=t.childCount>0&&n.jsx(Us,{node:t,name:o,left:a,onToggle:r}),e[66]=o,e[67]=t,e[68]=r,e[69]=a,e[70]=T):T=e[70];let V;return e[71]!==y||e[72]!==T||e[73]!==M?(V=n.jsxs("li",{className:"group/node absolute",style:M,children:[y,T]}),e[71]=y,e[72]=T,e[73]=M,e[74]=V):V=e[74],V}function Us(s){const e=re.c(25),{node:t,name:i,left:a,onToggle:l}=s,{collapsed:c,hidden:o}=t;let u=null;o.needsYou>0?u="needs-you":o.working>0&&(u="working");let r;e[0]!==c||e[1]!==o.count||e[2]!==o.needsYou||e[3]!==o.working||e[4]!==i?(r=c?[`Show the ${vt(o.count)} under ${i}`,o.needsYou>0&&`${o.needsYou} waiting on you`,o.working>0&&`${o.working} working`].filter(Boolean).join(", "):`Fold the sessions under ${i}`,e[0]=c,e[1]=o.count,e[2]=o.needsYou,e[3]=o.working,e[4]=i,e[5]=r):r=e[5];const d=r,m=!c,w=c?void 0:"Fold";let g;e[6]!==t.member.sessionId||e[7]!==l?(g=()=>l(t.member.sessionId),e[6]=t.member.sessionId,e[7]=l,e[8]=g):g=e[8];const x=!c&&"opacity-0 group-hover/node:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100";let p;e[9]!==x?(p=se("absolute z-10 flex h-5 min-w-5 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center gap-1 rounded-full border bg-card px-1.5 text-[11px] font-medium tabular-nums text-muted-foreground shadow-xs outline-none","transition-opacity hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",x),e[9]=x,e[10]=p):p=e[10];let h;e[11]!==a?(h={left:a,top:Q/2},e[11]=a,e[12]=h):h=e[12];let v;e[13]!==u||e[14]!==c||e[15]!==o.count?(v=c?n.jsxs(n.Fragment,{children:[u&&n.jsx("span",{className:se("size-1.5 rounded-full",ue[u]),"aria-hidden":"true"}),"+",o.count]}):n.jsx(pt,{"aria-hidden":"true",className:"size-3"}),e[13]=u,e[14]=c,e[15]=o.count,e[16]=v):v=e[16];let N;return e[17]!==d||e[18]!==m||e[19]!==w||e[20]!==g||e[21]!==p||e[22]!==h||e[23]!==v?(N=n.jsx("button",{type:"button","aria-expanded":m,"aria-label":d,title:w,onClick:g,className:p,style:h,children:v}),e[17]=d,e[18]=m,e[19]=w,e[20]=g,e[21]=p,e[22]=h,e[23]=v,e[24]=N):N=e[24],N}function Bs(s){var g,x;const e=re.c(35),{member:t,name:i}=s;let a;e[0]!==t.firstUserMessage?(a=(g=t.firstUserMessage)==null?void 0:g.replace(/\s+/g," ").trim(),e[0]=t.firstUserMessage,e[1]=a):a=e[1];const l=a;let c;e[2]!==t.cwd?(c=(x=t.cwd)==null?void 0:x.split(/[\\/]/).filter(Boolean).at(-1),e[2]=t.cwd,e[3]=c):c=e[3];const o=c;let u;if(e[4]!==o||e[5]!==t.device||e[6]!==t.model||e[7]!==t.startedAt||e[8]!==t.turnCount){if(u=[],t.model){let p;e[10]!==t.model?(p=Ye(t.model),e[10]=t.model,e[11]=p):p=e[11];let h;e[12]!==p?(h=["Model",p],e[12]=p,e[13]=h):h=e[13],u.push(h)}if(t.device){let p;e[14]!==t.device.name?(p=["Device",t.device.name],e[14]=t.device.name,e[15]=p):p=e[15],u.push(p)}if(o){let p;e[16]!==o?(p=["Folder",o],e[16]=o,e[17]=p):p=e[17],u.push(p)}if(t.startedAt){let p;e[18]!==t.startedAt?(p=mt(t.startedAt),e[18]=t.startedAt,e[19]=p):p=e[19];let h;e[20]!==p?(h=["Started",p],e[20]=p,e[21]=h):h=e[21],u.push(h)}if(t.turnCount){const p=String(t.turnCount);let h;e[22]!==p?(h=["Turns",p],e[22]=p,e[23]=h):h=e[23],u.push(h)}e[4]=o,e[5]=t.device,e[6]=t.model,e[7]=t.startedAt,e[8]=t.turnCount,e[9]=u}else u=e[9];let r;e[24]!==i?(r=n.jsx("p",{className:"font-medium",children:i}),e[24]=i,e[25]=r):r=e[25];let d;e[26]!==i||e[27]!==l?(d=l&&l!==i&&n.jsx("p",{className:"line-clamp-3 text-muted-foreground",children:l}),e[26]=i,e[27]=l,e[28]=d):d=e[28];let m;e[29]!==u?(m=u.length>0&&n.jsx("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5",children:u.map(Ks)}),e[29]=u,e[30]=m):m=e[30];let w;return e[31]!==r||e[32]!==d||e[33]!==m?(w=n.jsxs("div",{className:"flex flex-col gap-1.5 py-0.5",children:[r,d,m]}),e[31]=r,e[32]=d,e[33]=m,e[34]=w):w=e[34],w}function Ks(s){const[e,t]=s;return n.jsxs("div",{className:"contents",children:[n.jsx("dt",{className:"text-muted-foreground",children:e}),n.jsx("dd",{className:"truncate tabular-nums",children:t})]},e)}const Gs=4e3;function Vs(s){var p;const[e,t]=S.useState(null),[i,a]=S.useState(null),[l,c]=S.useState(new Set),o=(p=Wt())==null?void 0:p.refresh,u=S.useRef(s),r=S.useRef(new Set);S.useLayoutEffect(()=>(u.current=s,()=>{u.current=null}),[s]);const d=S.useCallback(async h=>{if(s)try{const v=await ze(`/api/session-crew/${encodeURIComponent(s)}`);if(!h())return;if(!v.ok){a(v.status===404?"This session is no longer available.":"Couldn't load the crew.");return}const N=await v.json();if(!h())return;t(b=>JSON.stringify(b)===JSON.stringify(N)?b:N),a(null)}catch{h()&&a("Couldn't load the crew.")}},[s]);it(s?d:null,Gs),S.useEffect(()=>{t(h=>h!=null&&h.members.some(v=>v.sessionId===s)?h:null),a(null),c(new Set)},[s]);const m=S.useCallback(async(h,v,N)=>{const b=`${s}:${h}`;if(r.current.has(b))return;const k=()=>u.current===s;r.current.add(b),c(C=>new Set(C).add(h));try{const C=await v();if(!k())return;if(!C.ok&&C.status!==404){a(N);return}o==null||o(),await d(k)}catch{k()&&a(N)}finally{r.current.delete(b),k()&&c(C=>{const M=new Set(C);return M.delete(h),M})}},[d,o,s]),w=S.useCallback((h,v,N)=>m(v,()=>be("/api/session-respond",{sessionId:h,requestId:v,...N}),"Couldn't send the answer."),[m]),g=S.useCallback((h,v)=>m(v,()=>be("/api/delegated-tasks",{sessionId:h,taskId:v,action:"ack"}),"Couldn't mark the result read."),[m]),x=S.useCallback(h=>m(h.sessionId,()=>{var v;return((v=h.result)==null?void 0:v.state)==="running"&&h.parentId?be("/api/delegated-tasks",{sessionId:h.parentId,taskId:h.result.taskId,action:"cancel"}):be("/api/stop-session",{sessionId:h.sessionId,cancelQueued:!0})},"Couldn't stop the session."),[m]);return{crew:e,error:i,busy:l,respond:w,markRead:g,stop:x}}const Xs=[{id:"all",label:"All"},{id:"working",label:"Working"},{id:"needs-you",label:"Need you"},{id:"done",label:"Done"}],Zs={working:"bg-success shadow-[0_0_0_2px_color-mix(in_oklch,var(--success)_25%,transparent)]","needs-you":"bg-warning",done:"bg-muted-foreground/40",failed:"bg-destructive",unreachable:"border border-muted-foreground/50"};function fn(s){var A;const e=re.c(34),{context:t,closePanel:i}=s,a=((A=t.session)==null?void 0:A.sessionId)??null,{crew:l,error:c,busy:o,respond:u,markRead:r,stop:d}=Vs(a),{names:m}=Ht(),[w,g]=S.useState("overview"),x=Ls((l==null?void 0:l.rootId)??"");let p;e[0]!==(l==null?void 0:l.members)?(p=new Map(((l==null?void 0:l.members)??[]).map(Qs)),e[0]=l==null?void 0:l.members,e[1]=p):p=e[1];const h=p;let v;e[2]!==(l==null?void 0:l.members)?(v=new Map(((l==null?void 0:l.members)??[]).flatMap(Js)),e[2]=l==null?void 0:l.members,e[3]=v):v=e[3];const N=v;let b;e[4]!==h||e[5]!==m?(b=z=>gs(z,h,m),e[4]=h,e[5]=m,e[6]=b):b=e[6];const k=b;let C;e[7]!==t?(C=z=>{z.address&&z.device?Xt(Zt(z.address.dirName,z.address.fileName,z.device.id)):z.address&&t.openSession?t.openSession(z.address.dirName,z.address.fileName):Jt(z.sessionId)},e[7]=t,e[8]=C):C=e[8];const M=C;let _,O,L;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=n.jsx(ht,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),O=n.jsx("h2",{className:"text-sm font-medium",children:"Crew"}),L=n.jsx("div",{className:"flex-1"}),e[9]=_,e[10]=O,e[11]=L):(_=e[9],O=e[10],L=e[11]);let j;e[12]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(cs,{"data-icon":"inline-start"}),e[12]=j):j=e[12];let R;e[13]!==i?(R=n.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[_,O,L,n.jsx(J,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close crew",children:j})]}),e[13]=i,e[14]=R):R=e[14];let I;e[15]!==c?(I=c&&n.jsx("p",{role:"alert",className:"px-3 pb-2 text-xs text-destructive",children:c}),e[15]=c,e[16]=I):I=e[16];let $;e[17]!==o||e[18]!==l||e[19]!==c||e[20]!==N||e[21]!==x||e[22]!==r||e[23]!==k||e[24]!==M||e[25]!==u||e[26]!==a||e[27]!==d||e[28]!==w?($=l?n.jsxs(Ut,{value:w,onValueChange:g,className:"min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)]",children:[n.jsxs(Bt,{variant:"line",className:"mx-3 mb-1",children:[n.jsx(Ae,{value:"overview",children:"Overview"}),n.jsx(Ae,{value:"map",children:"Map"}),n.jsx(Ae,{value:"chat",children:"Chat"})]}),n.jsx(Oe,{value:"overview",className:"min-h-0",children:n.jsxs(ft,{className:"h-full min-h-0",children:[n.jsx(en,{crew:l,hereId:a,nameOf:k,onOpen:M}),n.jsx(sn,{crew:l,busy:o,nameOf:k,onOpen:M,onRespond:u}),n.jsx(nn,{crew:l,hereId:a,busy:o,nameOf:k,onOpen:M,onMarkRead:r,onStop:d})]})}),n.jsx(Oe,{value:"map",className:"min-h-0",children:n.jsx(_s,{crew:l,hereId:a,controls:x,kinds:N,nameOf:k,onOpen:M})}),n.jsx(Oe,{value:"chat",keepMounted:!0,className:"min-h-0",children:n.jsx(hs,{rootId:l.rootId,kinds:N,active:w==="chat"},l.rootId)})]}):!c&&n.jsx("p",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"Loading the crew…"}),e[17]=o,e[18]=l,e[19]=c,e[20]=N,e[21]=x,e[22]=r,e[23]=k,e[24]=M,e[25]=u,e[26]=a,e[27]=d,e[28]=w,e[29]=$):$=e[29];let E;return e[30]!==I||e[31]!==$||e[32]!==R?(E=n.jsxs("aside",{"aria-label":"Crew",className:"flex size-full min-h-0 flex-col bg-canvas",children:[R,I,$]}),e[30]=I,e[31]=$,e[32]=R,e[33]=E):E=e[33],E}function Js(s){return s.address?[[s.sessionId,Kt(s.address.dirName)]]:[]}function Qs(s){return[s.sessionId,s]}function en(s){var b;const e=re.c(45),{crew:t,hereId:i,nameOf:a,onOpen:l}=s;let c,o,u,r,d;if(e[0]!==t||e[1]!==i||e[2]!==a||e[3]!==l){let k;e[9]!==t.rootId?(k=$=>$.sessionId===t.rootId,e[9]=t.rootId,e[10]=k):k=e[10];const C=t.members.find(k),M=t.members.filter(tn);let _;e[11]!==t?(_=bs(t),e[11]=t,e[12]=_):_=e[12],d=_;const O=(b=M[0])==null?void 0:b.startedAt;c="Crew summary",o="border-b px-3 pb-3 pt-1";const L=C&&n.jsx("button",{type:"button",onClick:()=>l(C),"aria-current":C.sessionId===i?"true":void 0,className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring",children:a(C)}),j=d.size===1?"session":"sessions",R=O?` · since ${mt(O)}`:"";let I;e[13]!==j||e[14]!==R||e[15]!==d.size?(I=n.jsxs("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[d.size," ",j,R]}),e[13]=j,e[14]=R,e[15]=d.size,e[16]=I):I=e[16],e[17]!==I||e[18]!==L?(u=n.jsxs("div",{className:"flex items-baseline gap-2",children:[L,I]}),e[17]=I,e[18]=L,e[19]=u):u=e[19],r=M.length>0&&n.jsx("div",{"data-crew-strip":!0,className:"mt-2.5 grid grid-cols-[repeat(auto-fit,minmax(6px,1fr))] gap-[3px]",role:"list","aria-label":"One cell per session, in the order they were started",children:M.map($=>{const E=fe($);return n.jsx("button",{type:"button",role:"listitem","data-crew-cell":E,title:`${a($)}: ${Ne($)}`,"aria-label":`${a($)}: ${Ne($)}`,onClick:()=>{var A;return(A=document.querySelector(`[data-crew-row="${$.sessionId}"]`))==null?void 0:A.scrollIntoView({block:"nearest",behavior:"smooth"})},className:se("h-2.5 rounded-[2px] outline-none focus-visible:ring-2 focus-visible:ring-ring",Zs[E],$.sessionId===i&&"outline outline-[1.5px] outline-offset-2 outline-foreground")},$.sessionId)})}),e[0]=t,e[1]=i,e[2]=a,e[3]=l,e[4]=c,e[5]=o,e[6]=u,e[7]=r,e[8]=d}else c=e[4],o=e[5],u=e[6],r=e[7],d=e[8];let m;e[20]!==d.working?(m=d.working>0&&n.jsx(ye,{dot:ue.working,value:d.working,label:"working"}),e[20]=d.working,e[21]=m):m=e[21];let w;e[22]!==d.needsYou?(w=d.needsYou>0&&n.jsx(ye,{dot:ue["needs-you"],value:d.needsYou,label:d.needsYou===1?"needs you":"need you"}),e[22]=d.needsYou,e[23]=w):w=e[23];let g;e[24]!==d.done?(g=d.done>0&&n.jsx(ye,{dot:ue.done,value:d.done,label:"done"}),e[24]=d.done,e[25]=g):g=e[25];let x;e[26]!==d.failed?(x=d.failed>0&&n.jsx(ye,{dot:ue.failed,value:d.failed,label:"failed"}),e[26]=d.failed,e[27]=x):x=e[27];let p;e[28]!==d.unreachable?(p=d.unreachable>0&&n.jsx(ye,{dot:ue.unreachable,value:d.unreachable,label:"away"}),e[28]=d.unreachable,e[29]=p):p=e[29];let h;e[30]!==d.unreadResults?(h=d.unreadResults>0&&n.jsxs("span",{className:"ml-auto text-warning",children:[n.jsx("span",{className:"font-medium tabular-nums",children:d.unreadResults})," ",d.unreadResults===1?"result":"results"," unread"]}),e[30]=d.unreadResults,e[31]=h):h=e[31];let v;e[32]!==h||e[33]!==m||e[34]!==w||e[35]!==g||e[36]!==x||e[37]!==p?(v=n.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-xs text-muted-foreground",children:[m,w,g,x,p,h]}),e[32]=h,e[33]=m,e[34]=w,e[35]=g,e[36]=x,e[37]=p,e[38]=v):v=e[38];let N;return e[39]!==c||e[40]!==v||e[41]!==o||e[42]!==u||e[43]!==r?(N=n.jsxs("section",{"aria-label":c,className:o,children:[u,r,v]}),e[39]=c,e[40]=v,e[41]=o,e[42]=u,e[43]=r,e[44]=N):N=e[44],N}function tn(s){return s.parentId!==null}function ye(s){const e=re.c(10),{dot:t,value:i,label:a}=s;let l;e[0]!==t?(l=se("size-1.5 rounded-full",t),e[0]=t,e[1]=l):l=e[1];let c;e[2]!==l?(c=n.jsx("span",{className:l,"aria-hidden":"true"}),e[2]=l,e[3]=c):c=e[3];let o;e[4]!==i?(o=n.jsx("span",{className:"font-medium tabular-nums text-foreground",children:i}),e[4]=i,e[5]=o):o=e[5];let u;return e[6]!==a||e[7]!==c||e[8]!==o?(u=n.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c,o," ",a]}),e[6]=a,e[7]=c,e[8]=o,e[9]=u):u=e[9],u}function sn(s){const e=re.c(6),{crew:t,busy:i,nameOf:a,onOpen:l,onRespond:c}=s,o=ws(t),[u,r]=S.useState(0);if(o.length===0)return null;const d=Math.min(u,o.length-1),{member:m,pending:w}=o[d],g=o[d+1];let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Needs you"}),e[0]=x):x=e[0];let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx("span",{className:"flex-1"}),e[1]=p):p=e[1];let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx("span",{className:se("size-1.5 shrink-0 rounded-full",ue["needs-you"]),"aria-hidden":"true"}),e[2]=h):h=e[2];const v=w.askedAt?`waiting ${qe(new Date(w.askedAt).toISOString())}`:"waiting";let N;e[3]!==v?(N=n.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-warning",children:v}),e[3]=v,e[4]=N):N=e[4];let b;return e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(et,{"data-icon":"inline-end"}),e[5]=b):b=e[5],n.jsxs("section",{"aria-label":"Needs you",className:"border-b px-3 py-2.5",children:[n.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[x,n.jsx("span",{className:"tabular-nums",children:o.length}),p,o.length>1&&n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"tabular-nums",children:[d+1," of ",o.length]}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Previous request",disabled:d===0,onClick:()=>r(d-1),children:n.jsx(ls,{"data-icon":"inline-start"})}),n.jsx(J,{variant:"ghost",size:"icon-xs","aria-label":"Next request",disabled:d===o.length-1,onClick:()=>r(d+1),children:n.jsx(et,{"data-icon":"inline-start"})})]})]}),n.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.jsxs("div",{className:"flex items-center gap-2 px-0.5 text-xs",children:[h,n.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:a(m)}),m.device&&n.jsx(Gt,{variant:"outline",children:m.device.name}),N]}),n.jsx(Vt,{sessionId:m.sessionId,pending:w,queued:0,responding:i.has(w.requestId),onRespond:(k,C)=>void c(m.sessionId,k,C),onOpen:()=>l(m)},w.requestId),n.jsxs(J,{variant:"ghost",size:"xs",className:"self-end text-muted-foreground",onClick:()=>l(m),children:["Open session",b]})]}),g&&n.jsxs("p",{className:"mt-2 truncate text-xs text-muted-foreground",children:["Next: ",n.jsx("span",{className:"font-medium text-foreground",children:a(g.member)})," ",Ne(g.member).toLowerCase()]})]})}function nn(s){const e=re.c(17),{crew:t,hereId:i,busy:a,nameOf:l,onOpen:c,onMarkRead:o,onStop:u}=s,[r,d]=S.useState("all");let m;if(e[0]!==a||e[1]!==t||e[2]!==r||e[3]!==i||e[4]!==l||e[5]!==o||e[6]!==c||e[7]!==u){let w;e[9]!==r?(w=N=>{const{member:b}=N;if(r==="all")return!0;const k=fe(b);return r==="done"?k!=="working"&&k!=="needs-you":k===r},e[9]=r,e[10]=w):w=e[10];const g=xs(t).filter(w);let x,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx("h3",{className:"text-sm font-medium",children:"Sessions"}),p=n.jsx("span",{className:"flex-1"}),e[11]=x,e[12]=p):(x=e[11],p=e[12]);let h;e[13]!==r?(h=Xs.map(N=>{const{id:b,label:k}=N;return n.jsx("button",{type:"button",role:"radio","aria-checked":r===b,onClick:()=>d(b),className:se("rounded-full px-2 py-0.5 text-[11px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",r===b&&"bg-accent text-foreground"),children:k},b)}),e[13]=r,e[14]=h):h=e[14];let v;e[15]!==h?(v=n.jsxs("div",{className:"mb-1.5 flex items-center gap-2 px-1.5",children:[x,p,n.jsx("div",{role:"radiogroup","aria-label":"Show sessions",className:"flex gap-0.5",children:h})]}),e[15]=h,e[16]=v):v=e[16],m=n.jsxs("section",{"aria-label":"Sessions",className:"px-1.5 py-2.5",children:[v,g.length===0?n.jsx("p",{className:"px-1.5 py-4 text-center text-xs text-muted-foreground",children:"No sessions here."}):n.jsx("ul",{className:"flex flex-col",children:g.map(N=>n.jsx(on,{row:N,here:N.member.sessionId===i,busy:a,name:l(N.member),onOpen:c,onMarkRead:o,onStop:u},N.member.sessionId))})]}),e[0]=a,e[1]=t,e[2]=r,e[3]=i,e[4]=l,e[5]=o,e[6]=c,e[7]=u,e[8]=m}else m=e[8];return m}function on(s){var ae,ce;const e=re.c(73),{row:t,here:i,busy:a,name:l,onOpen:c,onMarkRead:o,onStop:u}=s,{member:r,depth:d,children:m}=t;let w;e[0]!==r?(w=fe(r),e[0]=r,e[1]=w):w=e[1];const g=w;let x;e[2]!==r?(x=Ne(r),e[2]=r,e[3]=x):x=e[3];const p=x;let h;e[4]!==r.pullRequests?(h=(ae=r.pullRequests)==null?void 0:ae.at(-1),e[4]=r.pullRequests,e[5]=h):h=e[5];const v=h;let N;e[6]!==r?(N=Re(r)&&r.result&&r.parentId,e[6]=r,e[7]=N):N=e[7];const b=N,k=(g==="working"||g==="needs-you")&&(!r.device||((ce=r.result)==null?void 0:ce.state)==="running"&&r.parentId!==null),C=r.sessionId,M=i?"bg-accent":"hover:bg-accent/60",_=d>0&&"border-l border-border/70";let O;e[8]!==M||e[9]!==_?(O=se("group/crew relative rounded-md",M,_),e[8]=M,e[9]=_,e[10]=O):O=e[10];const L=d>0?6+(d-1)*14:0;let j;e[11]!==L?(j={marginLeft:L},e[11]=L,e[12]=j):j=e[12];let R;e[13]!==r||e[14]!==c?(R=()=>c(r),e[13]=r,e[14]=c,e[15]=R):R=e[15];const I=i?"true":void 0,$=`${l}, ${p}`,E=ue[g];let A;e[16]!==E?(A=se("size-1.5 justify-self-center rounded-full",E),e[16]=E,e[17]=A):A=e[17];let z;e[18]!==A?(z=n.jsx("span",{className:A,"aria-hidden":"true"}),e[18]=A,e[19]=z):z=e[19];let D;e[20]!==l?(D=n.jsx("span",{className:"truncate",children:l}),e[20]=l,e[21]=D):D=e[21];let W;e[22]!==i?(W=i&&n.jsx("span",{className:"shrink-0 rounded-full border px-1.5 text-[10.5px] font-normal text-muted-foreground",children:"you are here"}),e[22]=i,e[23]=W):W=e[23];let P;e[24]!==D||e[25]!==W?(P=n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12.5px] font-medium",children:[D,W]}),e[24]=D,e[25]=W,e[26]=P):P=e[26];let Y;e[27]!==r.lastActivityAt?(Y=r.lastActivityAt?qe(r.lastActivityAt):"",e[27]=r.lastActivityAt,e[28]=Y):Y=e[28];let K;e[29]!==Y?(K=n.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground/80",children:Y}),e[29]=Y,e[30]=K):K=e[30];const B=(g==="needs-you"||b)&&"text-warning",X=g==="failed"&&"text-destructive";let H;e[31]!==B||e[32]!==X?(H=se("min-w-0 flex-1 truncate",B,X),e[31]=B,e[32]=X,e[33]=H):H=e[33];let U;e[34]!==p||e[35]!==H?(U=n.jsx("span",{className:H,children:p}),e[34]=p,e[35]=H,e[36]=U):U=e[36];let G;e[37]!==v?(G=v&&n.jsxs("span",{className:"shrink-0 rounded-full border px-1.5 text-[11px]",children:["#",v.number]}),e[37]=v,e[38]=G):G=e[38];let f;e[39]!==r.device?(f=r.device&&n.jsx("span",{className:"shrink-0",children:r.device.name}),e[39]=r.device,e[40]=f):f=e[40];let y;e[41]!==m?(y=m>0&&n.jsxs("span",{className:"shrink-0",children:[m," ",m===1?"session":"sessions"]}),e[41]=m,e[42]=y):y=e[42];let T;e[43]!==r.model?(T=r.model&&n.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:Ye(r.model)}),e[43]=r.model,e[44]=T):T=e[44];let V;e[45]!==U||e[46]!==G||e[47]!==f||e[48]!==y||e[49]!==T?(V=n.jsxs("span",{className:"col-start-2 col-end-4 flex min-w-0 items-center gap-2 text-[11.5px] text-muted-foreground",children:[U,G,f,y,T]}),e[45]=U,e[46]=G,e[47]=f,e[48]=y,e[49]=T,e[50]=V):V=e[50];let ee;e[51]!==R||e[52]!==I||e[53]!==$||e[54]!==z||e[55]!==P||e[56]!==K||e[57]!==V?(ee=n.jsxs("button",{type:"button",onClick:R,"aria-current":I,"aria-label":$,className:"grid w-full grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[z,P,K,V]}),e[51]=R,e[52]=I,e[53]=$,e[54]=z,e[55]=P,e[56]=K,e[57]=V,e[58]=ee):ee=e[58];let Z;e[59]!==a||e[60]!==k||e[61]!==r||e[62]!==l||e[63]!==o||e[64]!==u||e[65]!==b?(Z=(b||k)&&n.jsxs("div",{className:"absolute right-1.5 top-1 hidden gap-1 group-focus-within/crew:flex group-hover/crew:flex",children:[b&&r.result&&r.parentId&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover","aria-label":`Mark ${l}'s result read`,title:"Mark the result read",disabled:a.has(r.result.taskId),onClick:()=>void o(r.parentId,r.result.taskId),children:n.jsx(is,{"data-icon":"inline-start"})}),k&&n.jsx(J,{variant:"outline",size:"icon-xs",className:"bg-popover text-destructive","aria-label":`Stop ${l}`,title:"Stop this session",disabled:a.has(r.sessionId),onClick:()=>void u(r),children:n.jsx(rs,{"data-icon":"inline-start"})})]}),e[59]=a,e[60]=k,e[61]=r,e[62]=l,e[63]=o,e[64]=u,e[65]=b,e[66]=Z):Z=e[66];let te;return e[67]!==r.sessionId||e[68]!==j||e[69]!==ee||e[70]!==Z||e[71]!==O?(te=n.jsxs("li",{"data-crew-row":C,className:O,style:j,children:[ee,Z]}),e[67]=r.sessionId,e[68]=j,e[69]=ee,e[70]=Z,e[71]=O,e[72]=te):te=e[72],te}export{fn as CrewPanel};
@@ -1,2 +1,2 @@
1
- import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-BYjv05SI.js";const F=2e5;function W(l){const e=G.c(32),{value:t,onChange:v,readOnly:f,filePath:E,ariaLabel:L,textareaRef:u,onKeyDown:S,onSelect:_}=l,p=M(),[h,N]=H.useState(null),d=H.useRef(null),m=H.useRef(null);let x;e[0]!==E?(x=P(E)??"markdown",e[0]=E,e[1]=x):x=e[1];const g=x,b=t.length>F;let j,k;e[2]!==p||e[3]!==g||e[4]!==b||e[5]!==t?(j=()=>{if(b){N(null);return}let r=!1;const I=setTimeout(()=>{z(t,g,p).then(A=>{r||N(A)})},80);return()=>{r=!0,clearTimeout(I)}},k=[t,g,p,b],e[2]=p,e[3]=g,e[4]=b,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]),H.useEffect(j,k);let R;e[8]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{d.current&&m.current&&(m.current.scrollTop=d.current.scrollTop,m.current.scrollLeft=d.current.scrollLeft)},e[8]=R):R=e[8];const D=R;let T;e[9]!==u?(T=r=>{d.current=r,u&&(u.current=r)},e[9]=u,e[10]=T):T=e[10];const y=T;let n;e[11]!==h||e[12]!==t?(n=h?h.map(J):i.jsx("code",{className:"text-foreground",children:t}),e[11]=h,e[12]=t,e[13]=n):n=e[13];let s;e[14]!==n?(s=i.jsx("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",children:n}),e[14]=n,e[15]=s):s=e[15];let o;e[16]!==v?(o=r=>v(r.target.value),e[16]=v,e[17]=o):o=e[17];const C=f&&"cursor-default";let a;e[18]!==C?(a=X("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-selection","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",C),e[18]=C,e[19]=a):a=e[19];let c;e[20]!==L||e[21]!==y||e[22]!==S||e[23]!==_||e[24]!==f||e[25]!==a||e[26]!==o||e[27]!==t?(c=i.jsx("textarea",{ref:y,"aria-label":L,value:t,onChange:o,onScroll:D,onKeyDown:S,onSelect:_,readOnly:f,spellCheck:!1,className:a,placeholder:"Empty file"}),e[20]=L,e[21]=y,e[22]=S,e[23]=_,e[24]=f,e[25]=a,e[26]=o,e[27]=t,e[28]=c):c=e[28];let w;return e[29]!==c||e[30]!==s?(w=i.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[s,c]}),e[29]=c,e[30]=s,e[31]=w):w=e[31],w}function J(l,e){return i.jsxs("span",{children:[l.map(K),`
1
+ import{c as G,r as H,j as i}from"./vendor-react-gGw_S5I_.js";import{V as M,W as P,J as X,X as z}from"./index-D3WV64DU.js";const F=2e5;function W(l){const e=G.c(32),{value:t,onChange:v,readOnly:f,filePath:E,ariaLabel:L,textareaRef:u,onKeyDown:S,onSelect:_}=l,p=M(),[h,N]=H.useState(null),d=H.useRef(null),m=H.useRef(null);let x;e[0]!==E?(x=P(E)??"markdown",e[0]=E,e[1]=x):x=e[1];const g=x,b=t.length>F;let j,k;e[2]!==p||e[3]!==g||e[4]!==b||e[5]!==t?(j=()=>{if(b){N(null);return}let r=!1;const I=setTimeout(()=>{z(t,g,p).then(A=>{r||N(A)})},80);return()=>{r=!0,clearTimeout(I)}},k=[t,g,p,b],e[2]=p,e[3]=g,e[4]=b,e[5]=t,e[6]=j,e[7]=k):(j=e[6],k=e[7]),H.useEffect(j,k);let R;e[8]===Symbol.for("react.memo_cache_sentinel")?(R=()=>{d.current&&m.current&&(m.current.scrollTop=d.current.scrollTop,m.current.scrollLeft=d.current.scrollLeft)},e[8]=R):R=e[8];const D=R;let T;e[9]!==u?(T=r=>{d.current=r,u&&(u.current=r)},e[9]=u,e[10]=T):T=e[10];const y=T;let n;e[11]!==h||e[12]!==t?(n=h?h.map(J):i.jsx("code",{className:"text-foreground",children:t}),e[11]=h,e[12]=t,e[13]=n):n=e[13];let s;e[14]!==n?(s=i.jsx("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 overflow-hidden font-mono text-[13px] leading-relaxed p-4 m-0 pointer-events-none whitespace-pre-wrap break-words",children:n}),e[14]=n,e[15]=s):s=e[15];let o;e[16]!==v?(o=r=>v(r.target.value),e[16]=v,e[17]=o):o=e[17];const C=f&&"cursor-default";let a;e[18]!==C?(a=X("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-selection","scrollbar-thin scrollbar-track-transparent scrollbar-thumb-border",C),e[18]=C,e[19]=a):a=e[19];let c;e[20]!==L||e[21]!==y||e[22]!==S||e[23]!==_||e[24]!==f||e[25]!==a||e[26]!==o||e[27]!==t?(c=i.jsx("textarea",{ref:y,"aria-label":L,value:t,onChange:o,onScroll:D,onKeyDown:S,onSelect:_,readOnly:f,spellCheck:!1,className:a,placeholder:"Empty file"}),e[20]=L,e[21]=y,e[22]=S,e[23]=_,e[24]=f,e[25]=a,e[26]=o,e[27]=t,e[28]=c):c=e[28];let w;return e[29]!==c||e[30]!==s?(w=i.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[s,c]}),e[29]=c,e[30]=s,e[31]=w):w=e[31],w}function J(l,e){return i.jsxs("span",{children:[l.map(K),`
2
2
  `]},e)}function K(l,e){return i.jsx("span",{style:{color:l.color},children:l.content},e)}export{W as H};
@@ -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-BYjv05SI.js";import{R as O,K as oe,S as ce}from"./vendor-ui-DkzcTXCS.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
+ 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-D3WV64DU.js";import{R as O,K as oe,S as ce}from"./vendor-ui-DkzcTXCS.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};