@siteboon/claude-code-ui 1.19.0 → 1.19.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.
|
@@ -581,7 +581,7 @@ import{j as i,_ as H5,a as q5,S as bi,F as Qo,T as C4,P as A4,E as Hr,V as Jo,b
|
|
|
581
581
|
.xterm-screen:focus {
|
|
582
582
|
outline: none !important;
|
|
583
583
|
}
|
|
584
|
-
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=t_,document.head.appendChild(e)}function r_(e){if(!e||typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(t)}return r}const Tb="https://auth.openai.com/codex/device";function Nb(e){return typeof e=="string"&&/\bcodex\s+login\b/i.test(e)}function Mf({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n=!1,onProcessComplete:a,minimal:s=!1,autoConnect:o=!1}){const{t:l}=Nt("chat"),c=x.useRef(null),u=x.useRef(null),d=x.useRef(null),p=x.useRef(null),[m,h]=x.useState(!1),[f,g]=x.useState(!1),[v,E]=x.useState(!1),[w,k]=x.useState(null),[C,A]=x.useState(!1),[T,I]=x.useState(""),[j,L]=x.useState("idle"),[_,M]=x.useState(!1),P=x.useRef(e),$=x.useRef(t),F=x.useRef(r),X=x.useRef(n),B=x.useRef(a),W=x.useRef("");x.useEffect(()=>{P.current=e,$.current=t,F.current=r,X.current=n,B.current=a});const V=x.useCallback((Q=W.current)=>{if(!Q)return!1;const ne=window.open(Q,"_blank","noopener,noreferrer");if(ne){try{ne.opener=null}catch{}return!0}return!1},[]),le=x.useCallback(async(Q=W.current)=>{if(!Q)return!1;let ne=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(Q),ne=!0)}catch{ne=!1}return ne||(ne=r_(Q)),ne},[]),R=x.useCallback(async()=>{if(!(C||m))try{let Q;if(!iA){const ne=localStorage.getItem("auth-token");if(!ne){console.error("No authentication token found for Shell WebSocket connection");return}Q=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ne)}`}p.current=new WebSocket(Q),p.current.onopen=()=>{h(!0),A(!1),W.current="",I(""),L("idle"),M(!1),setTimeout(()=>{d.current&&u.current&&(d.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:P.current.fullPath||P.current.path,sessionId:X.current?null:$.current?.id,hasSession:X.current?!1:!!$.current,provider:X.current?"plain-shell":$.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:F.current,isPlainShell:X.current})))},100)},p.current.onmessage=ne=>{try{const he=JSON.parse(ne.data);if(he.type==="output"){let se=he.data;if(X.current&&B.current){const pe=se.replace(/\x1b\[[0-9;]*m/g,"");if(pe.includes("Process exited with code 0"))B.current(0);else if(pe.match(/Process exited with code (\d+)/)){const Ae=parseInt(pe.match(/Process exited with code (\d+)/)[1]);Ae!==0&&B.current(Ae)}}u.current&&u.current.write(se)}else(he.type==="auth_url"&&he.url||he.type==="url_open"&&he.url)&&(W.current=he.url,I(he.url),L("idle"),M(!1))}catch(he){console.error("[Shell] Error handling WebSocket message:",he,ne.data)}},p.current.onclose=ne=>{h(!1),A(!1),L("idle"),M(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=ne=>{h(!1),A(!1)}}catch{h(!1),A(!1)}},[C,m,V]),Z=x.useCallback(()=>{!f||m||C||(A(!0),R())},[f,m,C,R]),H=x.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),h(!1),A(!1),W.current="",I(""),L("idle"),M(!1)},[]),N=x.useMemo(()=>t?t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session":null,[t]),q=x.useMemo(()=>N?N.slice(0,30):null,[N]),ie=x.useMemo(()=>N?N.slice(0,50):null,[N]),J=()=>{E(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,d.current=null),h(!1),g(!1),W.current="",I(""),L("idle"),M(!1),setTimeout(()=>{E(!1)},200)};if(x.useEffect(()=>{const Q=t?.id||null;w!==null&&w!==Q&&f&&H(),k(Q)},[t?.id,f,H]),x.useEffect(()=>{if(!c.current||!e||v||u.current)return;u.current=new XI.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),d.current=new ZI.FitAddon;const Q=new QI.WebglAddon,ne=new e_.WebLinksAddon;u.current.loadAddon(d.current),s||u.current.loadAddon(ne);try{u.current.loadAddon(Q)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(c.current),u.current.attachCustomKeyEventHandler(se=>{const pe=Nb(F.current)?Tb:W.current;return se.type==="keydown"&&s&&X.current&&pe&&!se.ctrlKey&&!se.metaKey&&!se.altKey&&se.key?.toLowerCase()==="c"&&le(pe).catch(()=>{}),se.type==="keydown"&&(se.ctrlKey||se.metaKey)&&se.key?.toLowerCase()==="c"&&u.current.hasSelection()?(se.preventDefault(),se.stopPropagation(),document.execCommand("copy"),!1):se.type==="keydown"&&(se.ctrlKey||se.metaKey)&&se.key?.toLowerCase()==="v"?(se.preventDefault(),se.stopPropagation(),navigator.clipboard.readText().then(Ae=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Ae}))}).catch(()=>{}),!1):!0}),setTimeout(()=>{d.current&&(d.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),g(!0),u.current.onData(se=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:se}))});const he=new ResizeObserver(()=>{d.current&&u.current&&setTimeout(()=>{d.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return c.current&&he.observe(c.current),()=>{he.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,v,s,le]),x.useEffect(()=>{!o||!f||C||m||Z()},[o,f,C,m,Z]),!e)return i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),i.jsx("h3",{className:"text-lg font-semibold mb-2",children:l("shell.selectProject.title")}),i.jsx("p",{children:l("shell.selectProject.description")})]})});if(s){const Q=Nb(r)?Tb:T,ne=!!Q,he=ne&&!_,se=ne&&_;return i.jsxs("div",{className:"h-full w-full bg-gray-900 relative",children:[i.jsx("div",{ref:c,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),he&&i.jsx("div",{className:"absolute inset-x-0 bottom-14 z-20 border-t border-gray-700/80 bg-gray-900/95 p-3 backdrop-blur-sm md:hidden",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),i.jsx("button",{type:"button",onClick:()=>M(!0),className:"rounded bg-gray-700 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-gray-100 hover:bg-gray-600",children:"Hide"})]}),i.jsx("input",{type:"text",value:Q,readOnly:!0,onClick:pe=>pe.currentTarget.select(),className:"w-full rounded border border-gray-600 bg-gray-800 px-2 py-1 text-xs text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500","aria-label":"Authentication URL"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>{V(Q)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),i.jsx("button",{type:"button",onClick:async()=>{const pe=await le(Q);L(pe?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:j==="copied"?"Copied":"Copy URL"})]})]})}),se&&i.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:i.jsx("button",{type:"button",onClick:()=>M(!1),className:"rounded bg-gray-800/95 px-3 py-2 text-xs font-medium text-gray-100 shadow-lg backdrop-blur-sm hover:bg-gray-700",children:"Show login URL"})})]})}return i.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[i.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-green-500":"bg-red-500"}`}),t&&i.jsxs("span",{className:"text-xs text-blue-300",children:["(",q,"...)"]}),!t&&i.jsx("span",{className:"text-xs text-gray-400",children:l("shell.status.newSession")}),!f&&i.jsx("span",{className:"text-xs text-yellow-400",children:l("shell.status.initializing")}),v&&i.jsx("span",{className:"text-xs text-blue-400",children:l("shell.status.restarting")})]}),i.jsxs("div",{className:"flex items-center space-x-3",children:[m&&i.jsxs("button",{onClick:H,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:l("shell.actions.disconnectTitle"),children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),i.jsx("span",{children:l("shell.actions.disconnect")})]}),i.jsxs("button",{onClick:J,disabled:v||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:l("shell.actions.restartTitle"),children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),i.jsx("span",{children:l("shell.actions.restart")})]})]})]})}),i.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[i.jsx("div",{ref:c,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!f&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:i.jsx("div",{className:"text-white",children:l("shell.loading")})}),f&&!m&&!C&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:i.jsxs("div",{className:"text-center max-w-sm w-full",children:[i.jsxs("button",{onClick:Z,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:l("shell.actions.connectTitle"),children:[i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),i.jsx("span",{children:l("shell.actions.connect")})]}),i.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:n?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):t?l("shell.resumeSession",{displayName:ie}):l("shell.startSession")})]})}),C&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:i.jsxs("div",{className:"text-center max-w-sm w-full",children:[i.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[i.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),i.jsx("span",{className:"text-base font-medium",children:l("shell.connecting")})]}),i.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:n?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):l("shell.startCli",{projectName:e.displayName})})]})})]})]})}function oS({project:e,session:t=null,command:r=null,isPlainShell:n=null,autoConnect:a=!0,onComplete:s=null,onClose:o=null,title:l=null,className:c="",showHeader:u=!0,compact:d=!1,minimal:p=!1}){const[m,h]=x.useState(!1),f=n!==null?n:r!==null,g=x.useCallback(v=>{h(!0),s&&s(v)},[s]);return e?i.jsxs("div",{className:`h-full w-full flex flex-col ${c}`,children:[!p&&u&&l&&i.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:l}),m&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),o&&i.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),i.jsx("div",{className:"flex-1 w-full min-h-0",children:i.jsx(Mf,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:f,onProcessComplete:g,minimal:p,autoConnect:p?!0:a})})]}):i.jsx("div",{className:`h-full flex items-center justify-center ${c}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function lS({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:a,customCommand:s,isAuthenticated:o=!1,isOnboarding:l=!1}){if(!e)return null;const c=()=>{if(s)return s;switch(r){case"claude":return o?"claude setup-token --dangerously-skip-permissions":l?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return"codex login";default:return o?"claude setup-token --dangerously-skip-permissions":l?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions"}},u=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},d=p=>{a&&a(p)};return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u()}),i.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:i.jsx(_t,{className:"w-6 h-6"})})]}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(oS,{project:n,command:c(),onComplete:d,minimal:!0})})]})})}const n_=({onComplete:e})=>{const[t,r]=x.useState(0),[n,a]=x.useState(""),[s,o]=x.useState(""),[l,c]=x.useState(!1),[u,d]=x.useState(""),[p,m]=x.useState(null),[h]=x.useState({name:"default",fullPath:""}),[f,g]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[v,E]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[w,k]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:C}=ps(),A=x.useRef(void 0);x.useEffect(()=>{T()},[]);const T=async()=>{try{const R=await _e("/api/user/git-config");if(R.ok){const Z=await R.json();Z.gitName&&a(Z.gitName),Z.gitEmail&&o(Z.gitEmail)}}catch(R){console.error("Error loading git config:",R)}};x.useEffect(()=>{const R=A.current;A.current=p,(R===void 0||R!==null&&p===null)&&(I(),j(),L())},[p]);const I=async()=>{try{const R=await _e("/api/cli/claude/status");if(R.ok){const Z=await R.json();g({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else g({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Claude auth status:",R),g({authenticated:!1,email:null,loading:!1,error:R.message})}},j=async()=>{try{const R=await _e("/api/cli/cursor/status");if(R.ok){const Z=await R.json();E({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else E({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Cursor auth status:",R),E({authenticated:!1,email:null,loading:!1,error:R.message})}},L=async()=>{try{const R=await _e("/api/cli/codex/status");if(R.ok){const Z=await R.json();k({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else k({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Codex auth status:",R),k({authenticated:!1,email:null,loading:!1,error:R.message})}},_=()=>m("claude"),M=()=>m("cursor"),P=()=>m("codex"),$=R=>{R===0&&(p==="claude"?I():p==="cursor"?j():p==="codex"&&L())},F=async()=>{if(d(""),t===0){if(!n.trim()||!s.trim()){d("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)){d("Please enter a valid email address");return}c(!0);try{const Z=await _e("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!Z.ok){const H=await Z.json();throw new Error(H.error||"Failed to save git configuration")}r(t+1)}catch(Z){d(Z.message)}finally{c(!1)}return}r(t+1)},X=()=>{d(""),r(t-1)},B=async()=>{c(!0),d("");try{const R=await _e("/api/user/complete-onboarding",{method:"POST"});if(!R.ok){const Z=await R.json();throw new Error(Z.error||"Failed to complete onboarding")}e&&e()}catch(R){d(R.message)}finally{c(!1)}},W=[{title:"Git Configuration",description:"Set up your git identity for commits",icon:fn,required:!0},{title:"Connect Agents",description:"Connect your AI coding assistants",icon:tS,required:!1}],V=()=>{switch(t){case 0:return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(fn,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for your commits"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[i.jsx(qI,{className:"w-4 h-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:n,onChange:R=>a(R.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"John Doe",required:!0,disabled:l}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.name"})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[i.jsx(K6,{className:"w-4 h-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:s,onChange:R=>o(R.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"john@example.com",required:!0,disabled:l}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.email"})]})]})]});case 1:return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"text-center mb-6",children:[i.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${f.authenticated?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:i.jsx(aS,{size:20})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Claude Code",f.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:f.loading?"Checking...":f.authenticated?f.email||"Connected":"Not connected"})]})]}),!f.authenticated&&!f.loading&&i.jsx("button",{onClick:_,className:"bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${v.authenticated?"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/30 rounded-full flex items-center justify-center",children:i.jsx(sS,{size:20})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Cursor",v.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:v.loading?"Checking...":v.authenticated?v.email||"Connected":"Not connected"})]})]}),!v.authenticated&&!v.loading&&i.jsx("button",{onClick:M,className:"bg-purple-600 hover:bg-purple-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${w.authenticated?"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx(iS,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["OpenAI Codex",w.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:w.loading?"Checking...":w.authenticated?w.email||"Connected":"Not connected"})]})]}),!w.authenticated&&!w.loading&&i.jsx("button",{onClick:P,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})})]}),i.jsx("div",{className:"text-center text-sm text-muted-foreground pt-2",children:i.jsx("p",{children:"You can configure these later in Settings."})})]});default:return null}},le=()=>{switch(t){case 0:return n.trim()&&s.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);case 1:return!0;default:return!1}};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:W.map((R,Z)=>i.jsxs(Xt.Fragment,{children:[i.jsxs("div",{className:"flex flex-col items-center flex-1",children:[i.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center border-2 transition-colors duration-200 ${Z<t?"bg-green-500 border-green-500 text-white":Z===t?"bg-blue-600 border-blue-600 text-white":"bg-background border-border text-muted-foreground"}`,children:Z<t?i.jsx(lr,{className:"w-6 h-6"}):typeof R.icon=="function"?i.jsx(R.icon,{}):i.jsx(R.icon,{className:"w-6 h-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${Z===t?"text-foreground":"text-muted-foreground"}`,children:R.title}),R.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),Z<W.length-1&&i.jsx("div",{className:`flex-1 h-0.5 mx-2 transition-colors duration-200 ${Z<t?"bg-green-500":"bg-border"}`})]},Z))})}),i.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8",children:[V(),u&&i.jsx("div",{className:"mt-6 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-lg",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),i.jsxs("div",{className:"flex items-center justify-between mt-8 pt-6 border-t border-border",children:[i.jsxs("button",{onClick:X,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:[i.jsx(Of,{className:"w-4 h-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<W.length-1?i.jsx("button",{onClick:F,disabled:!le()||l,className:"flex items-center gap-2 px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:l?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(Xr,{className:"w-4 h-4"})]})}):i.jsx("button",{onClick:B,disabled:l,className:"flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 disabled:bg-green-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:l?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(lr,{className:"w-4 h-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(lS,{isOpen:!!p,onClose:()=>m(null),provider:p,project:h,onComplete:$,isOnboarding:!0})]})},a_=()=>i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex justify-center mb-4",children:i.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:i.jsx(nl,{className:"w-8 h-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Claude Code UI"}),i.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce"}),i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),i.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),s_=({children:e})=>{const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=ps();return r?i.jsx(a_,{}):n?i.jsx(mA,{}):t?a?e:i.jsx(n_,{onComplete:s}):i.jsx(KI,{})},Cb=e=>typeof window>"u"?!1:window.innerWidth<e,Ab=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function Pf(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=x.useState(()=>r?Cb(t):!1),[o,l]=x.useState(()=>n?Ab():!1);return x.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(Cb(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),x.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),u=()=>{l(Ab())};return u(),typeof c.addEventListener=="function"?(c.addEventListener("change",u),()=>{c.removeEventListener("change",u)}):(c.addListener(u),()=>{c.removeListener(u)})},[n]),{isMobile:a,isPWA:o}}const Lh="1.18.2",i_=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},cS=(e,t)=>{const[r,n]=x.useState(!1),[a,s]=x.useState(null),[o,l]=x.useState(null);return x.useEffect(()=>{const c=async()=>{try{const p=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`)).json();if(p.tag_name){const m=p.tag_name.replace(/^v/,"");s(m),n(i_(m,Lh)>0),l({title:p.name||p.tag_name,body:p.body||"",htmlUrl:p.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:p.published_at})}else n(!1),s(null),l(null)}catch(d){console.error("Version check failed:",d),n(!1),s(null),l(null)}};c();const u=setInterval(c,300*1e3);return()=>clearInterval(u)},[e,t]),{updateAvailable:r,latestVersion:a,currentVersion:Lh,releaseInfo:o}},xa={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},Ro=Object.keys(xa),o_=new Set(Ro),zl="ui-preferences:sync",Oo=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},l_=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Oo(n,t)}catch{return t}},c_=e=>{if(typeof window>"u")return xa;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return Ro.reduce((a,s)=>(a[s]=Oo(n[s],xa[s]),a),{...xa})}}}catch{}return Ro.reduce((t,r)=>(t[r]=l_(r,xa[r]),t),{...xa})};function u_(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!o_.has(r))return e;const a=Oo(n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of Ro){if(!(s in r))continue;const o=r[s],l=Oo(o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...xa,...t.value||{}};default:return e}}function Ff(e="uiPreferences"){const t=x.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=x.useReducer(u_,e,c_);return x.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(zl,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),x.useEffect(()=>{if(typeof window>"u")return;const l=d=>{!d||typeof d!="object"||Array.isArray(d)||n({type:"set_many",value:d})},c=d=>{if(!(d.key!==e||d.newValue===null))try{const p=JSON.parse(d.newValue);l(p)}catch{}},u=d=>{const m=d.detail;!m||m.storageKey!==e||m.sourceId===t.current||l(m.value)};return window.addEventListener("storage",c),window.addEventListener(zl,u),()=>{window.removeEventListener("storage",c),window.removeEventListener(zl,u)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const d_=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},p_=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},m_=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Lo=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||0),h_=(e,t)=>e.__provider==="cursor"?e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.summary||t("projects.newSession"),f_=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||""),g_=(e,t,r)=>{const n=Lo(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isActive:a<10,sessionName:h_(e,r),sessionTime:f_(e),messageCount:Number(e.messageCount||0)}},uS=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(s=>({...s,__provider:"claude"})),n=(e.cursorSessions||[]).map(s=>({...s,__provider:"cursor"})),a=(e.codexSessions||[]).map(s=>({...s,__provider:"codex"}));return[...r,...n,...a].sort((s,o)=>Lo(o).getTime()-Lo(s).getTime())},Ib=(e,t)=>{const r=uS(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=Lo(a);return s>n?s:n},new Date(0))},b_=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?Ib(o,n).getTime()-Ib(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},x_=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},y_=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},v_=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function k_({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:u,onProjectDelete:d,setCurrentProject:p,setSidebarVisible:m,sidebarVisible:h}){const[f,g]=x.useState(new Set),[v,E]=x.useState(null),[w,k]=x.useState(!1),[C,A]=x.useState(""),[T,I]=x.useState({}),[j,L]=x.useState({}),[_,M]=x.useState(new Set),[P,$]=x.useState(new Date),[F,X]=x.useState("name"),[B,W]=x.useState(!1),[V,le]=x.useState({}),[R,Z]=x.useState(null),[H,N]=x.useState(""),[q,ie]=x.useState(""),[J,Q]=x.useState(new Set),[ne,he]=x.useState(null),[se,pe]=x.useState(null),[Ae,Re]=x.useState(!1),[Ye,Ze]=x.useState(()=>p_()),at=!a&&!h;x.useEffect(()=>{const ye=setInterval(()=>{$(new Date)},6e4);return()=>clearInterval(ye)},[]),x.useEffect(()=>{L({}),M(new Set),le({})},[e]),x.useEffect(()=>{t&&g(ye=>{if(ye.has(t.name))return ye;const Ie=new Set(ye);return Ie.add(t.name),Ie})},[r,t]),x.useEffect(()=>{if(e.length>0&&!n){const ye=new Set;e.forEach(Ie=>{Ie.sessions&&Ie.sessions.length>=0&&ye.add(Ie.name)}),M(ye)}},[e,n]),x.useEffect(()=>{const ye=()=>{X(d_())};ye();const Ie=yt=>{yt.key==="claude-settings"&&ye()};window.addEventListener("storage",Ie);const pt=setInterval(()=>{document.hasFocus()&&ye()},1e3);return()=>{window.removeEventListener("storage",Ie),clearInterval(pt)}},[]);const st=x.useCallback(ye=>Ie=>{const pt=Ie.target;pt.closest(".overflow-y-auto")||pt.closest("[data-scroll-container]")||(Ie.preventDefault(),Ie.stopPropagation(),ye())},[]),Qe=x.useCallback(ye=>{g(Ie=>{const pt=new Set;return Ie.has(ye)||pt.add(ye),pt})},[]),Be=x.useCallback((ye,Ie)=>{c({...ye,__projectName:Ie})},[c]),tt=x.useCallback(ye=>{Ze(Ie=>{const pt=new Set(Ie);return pt.has(ye)?pt.delete(ye):pt.add(ye),m_(pt),pt})},[]),xt=x.useCallback(ye=>Ye.has(ye),[Ye]),ge=x.useCallback(ye=>uS(ye,j),[j]),rt=x.useMemo(()=>e.map(ye=>{const Ie=V[ye.name];return Ie===void 0?ye:{...ye,sessionMeta:{...ye.sessionMeta,hasMore:Ie}}}),[V,e]),de=x.useMemo(()=>b_(rt,F,Ye,j),[j,F,rt,Ye]),Te=x.useMemo(()=>x_(de,q),[q,de]),re=x.useCallback(ye=>{E(ye.name),A(ye.displayName)},[]),ue=x.useCallback(()=>{E(null),A("")},[]),ve=x.useCallback(async ye=>{try{(await bt.renameProject(ye,C)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ie){console.error("Error renaming project:",Ie)}finally{E(null),A("")}},[C]),Me=x.useCallback((ye,Ie,pt,yt="claude")=>{pe({projectName:ye,sessionId:Ie,sessionTitle:pt,provider:yt})},[]),qe=x.useCallback(async()=>{if(!se)return;const{projectName:ye,sessionId:Ie,provider:pt}=se;pe(null);try{const yt=pt==="codex"?await bt.deleteCodexSession(Ie):await bt.deleteSession(ye,Ie);if(yt.ok)u?.(Ie);else{const qt=await yt.text();console.error("[Sidebar] Failed to delete session:",{status:yt.status,error:qt}),alert(s("messages.deleteSessionFailed"))}}catch(yt){console.error("[Sidebar] Error deleting session:",yt),alert(s("messages.deleteSessionError"))}},[u,se,s]),kt=x.useCallback(ye=>{he({project:ye,sessionCount:ge(ye).length})},[ge]),ht=x.useCallback(async()=>{if(!ne)return;const{project:ye,sessionCount:Ie}=ne,pt=Ie===0;he(null),Q(yt=>new Set([...yt,ye.name]));try{const yt=await bt.deleteProject(ye.name,!pt);if(yt.ok)d?.(ye.name);else{const qt=await yt.json();alert(qt.error||s("messages.deleteProjectFailed"))}}catch(yt){console.error("Error deleting project:",yt),alert(s("messages.deleteProjectError"))}finally{Q(yt=>{const qt=new Set(yt);return qt.delete(ye.name),qt})}},[ne,d,s]),Oe=x.useCallback(async ye=>{const Ie=V[ye.name];if(!(!(Ie!==void 0?Ie:ye.sessionMeta?.hasMore===!0)||T[ye.name])){I(yt=>({...yt,[ye.name]:!0}));try{const yt=(ye.sessions?.length||0)+(j[ye.name]?.length||0),qt=await bt.sessions(ye.name,5,yt);if(!qt.ok)return;const wr=await qt.json();L(pr=>({...pr,[ye.name]:[...pr[ye.name]||[],...wr.sessions||[]]})),wr.hasMore===!1&&le(pr=>({...pr,[ye.name]:!1}))}catch(yt){console.error("Error loading more sessions:",yt)}finally{I(yt=>({...yt,[ye.name]:!1}))}}},[j,T,V]),Xe=x.useCallback(ye=>{l(ye),p(ye)},[l,p]),ze=x.useCallback(async()=>{W(!0);try{await o()}finally{W(!1)}},[o]),Ke=x.useCallback(async(ye,Ie,pt)=>{Z(null),N("")},[]),lt=x.useCallback(()=>{m(!1)},[m]),et=x.useCallback(()=>{m(!0)},[m]);return{isSidebarCollapsed:at,expandedProjects:f,editingProject:v,showNewProject:w,editingName:C,loadingSessions:T,additionalSessions:j,initialSessionsLoaded:_,currentTime:P,projectSortOrder:F,isRefreshing:B,editingSession:R,editingSessionName:H,searchFilter:q,deletingProjects:J,deleteConfirmation:ne,sessionDeleteConfirmation:se,showVersionModal:Ae,starredProjects:Ye,filteredProjects:Te,handleTouchClick:st,toggleProject:Qe,handleSessionClick:Be,toggleStarProject:tt,isProjectStarred:xt,getProjectSessions:ge,startEditing:re,cancelEditing:ue,saveProjectName:ve,showDeleteSessionConfirmation:Me,confirmDeleteSession:qe,requestProjectDelete:kt,confirmDeleteProject:ht,loadMoreSessions:Oe,handleProjectSelect:Xe,refreshProjects:ze,updateSessionSummary:Ke,collapseSidebar:lt,expandSidebar:et,setShowNewProject:k,setEditingName:A,setEditingSession:Z,setEditingSessionName:N,setSearchFilter:ie,setDeleteConfirmation:he,setSessionDeleteConfirmation:pe,setShowVersionModal:Re}}function w_({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){return i.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[i.jsx("button",{onClick:e,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:i.jsx(dI,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),i.jsx("div",{className:"nav-divider w-6 my-1"}),i.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":a("actions.settings"),title:a("actions.settings"),children:i.jsx(Rt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),r&&i.jsxs("button",{onClick:n,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[i.jsx(_n,{className:"w-4 h-4 text-blue-500"}),i.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function dS(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=dS(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function pS(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=dS(e))&&(n&&(n+=" "),n+=t);return n}const Bf="-",E_=e=>{const t=T_(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(Bf);return l[0]===""&&l.length!==1&&l.shift(),mS(l,t)||S_(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},mS=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?mS(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Bf);return t.validators.find(({validator:o})=>o(s))?.classGroupId},_b=/^\[(.+)\]$/,S_=e=>{if(_b.test(e)){const t=_b.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},T_=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)Dh(r[a],n,a,t);return n},Dh=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:Rb(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(N_(a)){Dh(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{Dh(o,Rb(t,s),r,n)})})},Rb=(e,t)=>{let r=e;return t.split(Bf).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},N_=e=>e.isThemeGetter,C_=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},jh="!",Mh=":",A_=Mh.length,I_=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let o=0,l=0,c=0,u;for(let f=0;f<a.length;f++){let g=a[f];if(o===0&&l===0){if(g===Mh){s.push(a.slice(c,f)),c=f+A_;continue}if(g==="/"){u=f;continue}}g==="["?o++:g==="]"?o--:g==="("?l++:g===")"&&l--}const d=s.length===0?a:a.substring(c),p=__(d),m=p!==d,h=u&&u>c?u-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+Mh,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},__=e=>e.endsWith(jh)?e.substring(0,e.length-1):e.startsWith(jh)?e.substring(1):e,R_=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},O_=e=>({cache:C_(e.cacheSize),parseClassName:I_(e),sortModifiers:R_(e),...E_(e)}),L_=/\s+/,D_=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(L_);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:g}=r(d);if(p){c=d+(c.length>0?" "+c:c);continue}let v=!!g,E=n(v?f.substring(0,g):f);if(!E){if(!v){c=d+(c.length>0?" "+c:c);continue}if(E=n(f),!E){c=d+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),k=h?w+jh:w,C=k+E;if(o.includes(C))continue;o.push(C);const A=a(E,v);for(let T=0;T<A.length;++T){const I=A[T];o.push(k+I)}c=d+(c.length>0?" "+c:c)}return c};function j_(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=hS(t))&&(n&&(n+=" "),n+=r);return n}const hS=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=hS(e[n]))&&(r&&(r+=" "),r+=t);return r};function M_(e,...t){let r,n,a,s=o;function o(c){const u=t.reduce((d,p)=>p(d),e());return r=O_(u),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const u=n(c);if(u)return u;const d=D_(c,r);return a(c,d),d}return function(){return s(j_.apply(null,arguments))}}const Qt=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},fS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,gS=/^\((?:(\w[\w-]*):)?(.+)\)$/i,P_=/^\d+\/\d+$/,F_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,B_=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,U_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,z_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ua=e=>P_.test(e),vt=e=>!!e&&!Number.isNaN(Number(e)),Wn=e=>!!e&&Number.isInteger(Number(e)),Hl=e=>e.endsWith("%")&&vt(e.slice(0,-1)),Sn=e=>F_.test(e),H_=()=>!0,q_=e=>B_.test(e)&&!U_.test(e),bS=()=>!1,G_=e=>$_.test(e),W_=e=>z_.test(e),V_=e=>!Ge(e)&&!We(e),Y_=e=>hs(e,vS,bS),Ge=e=>fS.test(e),ha=e=>hs(e,kS,q_),ql=e=>hs(e,J_,vt),Ob=e=>hs(e,xS,bS),K_=e=>hs(e,yS,W_),$i=e=>hs(e,wS,G_),We=e=>gS.test(e),Os=e=>fs(e,kS),X_=e=>fs(e,e8),Lb=e=>fs(e,xS),Z_=e=>fs(e,vS),Q_=e=>fs(e,yS),zi=e=>fs(e,wS,!0),hs=(e,t,r)=>{const n=fS.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},fs=(e,t,r=!1)=>{const n=gS.exec(e);return n?n[1]?t(n[1]):r:!1},xS=e=>e==="position"||e==="percentage",yS=e=>e==="image"||e==="url",vS=e=>e==="length"||e==="size"||e==="bg-size",kS=e=>e==="length",J_=e=>e==="number",e8=e=>e==="family-name",wS=e=>e==="shadow",t8=()=>{const e=Qt("color"),t=Qt("font"),r=Qt("text"),n=Qt("font-weight"),a=Qt("tracking"),s=Qt("leading"),o=Qt("breakpoint"),l=Qt("container"),c=Qt("spacing"),u=Qt("radius"),d=Qt("shadow"),p=Qt("inset-shadow"),m=Qt("text-shadow"),h=Qt("drop-shadow"),f=Qt("blur"),g=Qt("perspective"),v=Qt("aspect"),E=Qt("ease"),w=Qt("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...C(),We,Ge],T=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],j=()=>[We,Ge,c],L=()=>[Ua,"full","auto",...j()],_=()=>[Wn,"none","subgrid",We,Ge],M=()=>["auto",{span:["full",Wn,We,Ge]},Wn,We,Ge],P=()=>[Wn,"auto",We,Ge],$=()=>["auto","min","max","fr",We,Ge],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...j()],W=()=>[Ua,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],V=()=>[e,We,Ge],le=()=>[...C(),Lb,Ob,{position:[We,Ge]}],R=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Z_,Y_,{size:[We,Ge]}],H=()=>[Hl,Os,ha],N=()=>["","none","full",u,We,Ge],q=()=>["",vt,Os,ha],ie=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[vt,Hl,Lb,Ob],ne=()=>["","none",f,We,Ge],he=()=>["none",vt,We,Ge],se=()=>["none",vt,We,Ge],pe=()=>[vt,We,Ge],Ae=()=>[Ua,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sn],breakpoint:[Sn],color:[H_],container:[Sn],"drop-shadow":[Sn],ease:["in","out","in-out"],font:[V_],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sn],shadow:[Sn],spacing:["px",vt],text:[Sn],"text-shadow":[Sn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ua,Ge,We,v]}],container:["container"],columns:[{columns:[vt,Ge,We,l]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Wn,"auto",We,Ge]}],basis:[{basis:[Ua,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[vt,Ua,"auto","initial","none",Ge]}],grow:[{grow:["",vt,We,Ge]}],shrink:[{shrink:["",vt,We,Ge]}],order:[{order:[Wn,"first","last","none",We,Ge]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:M()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":$()}],"auto-rows":[{"auto-rows":$()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:W()}],w:[{w:[l,"screen",...W()]}],"min-w":[{"min-w":[l,"screen","none",...W()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...W()]}],h:[{h:["screen","lh",...W()]}],"min-h":[{"min-h":["screen","lh","none",...W()]}],"max-h":[{"max-h":["screen","lh",...W()]}],"font-size":[{text:["base",r,Os,ha]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,We,ql]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Hl,Ge]}],"font-family":[{font:[X_,Ge,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,We,Ge]}],"line-clamp":[{"line-clamp":[vt,"none",We,ql]}],leading:[{leading:[s,...j()]}],"list-image":[{"list-image":["none",We,Ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",We,Ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:[vt,"from-font","auto",We,ha]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[vt,"auto",We,Ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",We,Ge]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",We,Ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Wn,We,Ge],radial:["",We,Ge],conic:[Wn,We,Ge]},Q_,K_]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:q()}],"border-w-x":[{"border-x":q()}],"border-w-y":[{"border-y":q()}],"border-w-s":[{"border-s":q()}],"border-w-e":[{"border-e":q()}],"border-w-t":[{"border-t":q()}],"border-w-r":[{"border-r":q()}],"border-w-b":[{"border-b":q()}],"border-w-l":[{"border-l":q()}],"divide-x":[{"divide-x":q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ie(),"hidden","none"]}],"divide-style":[{divide:[...ie(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ie(),"none","hidden"]}],"outline-offset":[{"outline-offset":[vt,We,Ge]}],"outline-w":[{outline:["",vt,Os,ha]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",d,zi,$i]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",p,zi,$i]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[vt,ha]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":q()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",m,zi,$i]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[vt,We,Ge]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[We,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",We,Ge]}],filter:[{filter:["","none",We,Ge]}],blur:[{blur:ne()}],brightness:[{brightness:[vt,We,Ge]}],contrast:[{contrast:[vt,We,Ge]}],"drop-shadow":[{"drop-shadow":["","none",h,zi,$i]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",vt,We,Ge]}],"hue-rotate":[{"hue-rotate":[vt,We,Ge]}],invert:[{invert:["",vt,We,Ge]}],saturate:[{saturate:[vt,We,Ge]}],sepia:[{sepia:["",vt,We,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",We,Ge]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[vt,We,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[vt,We,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",vt,We,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[vt,We,Ge]}],"backdrop-invert":[{"backdrop-invert":["",vt,We,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[vt,We,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[vt,We,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",vt,We,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",We,Ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[vt,"initial",We,Ge]}],ease:[{ease:["linear","initial",E,We,Ge]}],delay:[{delay:[vt,We,Ge]}],animate:[{animate:["none",w,We,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,We,Ge]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:pe()}],"skew-x":[{"skew-x":pe()}],"skew-y":[{"skew-y":pe()}],transform:[{transform:[We,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",We,Ge]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",We,Ge]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[vt,Os,ha,ql]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},r8=M_(t8);function Ve(...e){return r8(pS(e))}function n8(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const Uf=x.forwardRef(({className:e,children:t,...r},n)=>i.jsx("div",{className:Ve(e,"relative overflow-hidden"),...r,children:i.jsx("div",{ref:n,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:t})}));Uf.displayName="ScrollArea";function a8({updateAvailable:e,releaseInfo:t,latestVersion:r,onShowVersionModal:n,onShowSettings:a,t:s}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden md:block px-2 py-1.5",children:i.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:n,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(bb,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:s("version.updateAvailable")})]})]})}),i.jsx("div",{className:"md:hidden px-3 py-2",children:i.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:n,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(bb,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:s("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden md:block px-2 py-1.5",children:i.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:a,children:[i.jsx(Rt,{className:"w-3.5 h-3.5"}),i.jsx("span",{className:"text-sm",children:s("actions.settings")})]})}),i.jsx("div",{className:"md:hidden p-3 pb-20",children:i.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:a,children:[i.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:i.jsx(Rt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:s("actions.settings")})]})})]})}const Db=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jb=pS,ES=(e,t)=>r=>{var n;if(t?.variants==null)return jb(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(u=>{const d=r?.[u],p=s?.[u];if(d===null)return null;const m=Db(d)||Db(p);return a[u][m]}),l=r&&Object.entries(r).reduce((u,d)=>{let[p,m]=d;return m===void 0||(u[p]=m),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:p,className:m,...h}=d;return Object.entries(h).every(f=>{let[g,v]=f;return Array.isArray(v)?v.includes({...s,...l}[g]):{...s,...l}[g]===v})?[...u,p,m]:u},[]);return jb(e,o,c,r?.class,r?.className)},s8=ES("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),$e=x.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:Ve(s8({variant:t,size:r,className:e})),ref:a,...n}));$e.displayName="Button";const Ft=x.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:Ve("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Ft.displayName="Input";function i8({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,t:p}){const m=()=>i.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[i.jsx("div",{className:"w-7 h-7 bg-primary/90 rounded-lg flex items-center justify-center shadow-sm flex-shrink-0",children:i.jsx("svg",{className:"w-3.5 h-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),i.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:p("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(m,{}),i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:l,disabled:c,title:p("tooltips.refresh"),children:i.jsx(Cn,{className:`w-3.5 h-3.5 ${c?"animate-spin":""}`})}),i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:u,title:p("tooltips.createProject"),children:i.jsx(er,{className:"w-3.5 h-3.5"})}),i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:p("tooltips.hideSidebar"),children:i.jsx(cI,{className:"w-3.5 h-3.5"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"relative mt-2.5",children:[i.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),i.jsx(Ft,{type:"text",placeholder:p("projects.searchPlaceholder"),value:a,onChange:h=>s(h.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),a&&i.jsx("button",{onClick:o,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:i.jsx(_t,{className:"w-3 h-3 text-muted-foreground"})})]})]}),i.jsx("div",{className:"hidden md:block nav-divider"}),i.jsxs("div",{className:"md:hidden p-3 pb-2",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(m,{}),i.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[i.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:l,disabled:c,children:i.jsx(Cn,{className:`w-4 h-4 text-muted-foreground ${c?"animate-spin":""}`})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:u,children:i.jsx(fo,{className:"w-4 h-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"relative mt-2.5",children:[i.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),i.jsx(Ft,{type:"text",placeholder:p("projects.searchPlaceholder"),value:a,onChange:h=>s(h.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),a&&i.jsx("button",{onClick:o,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:i.jsx(_t,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),i.jsx("div",{className:"md:hidden nav-divider"})]})}const o8=({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1})=>{const s=(()=>{switch(e){case"fully-configured":return{icon:vi,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Rt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:rl,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:_t,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),o=s.icon,l={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},c={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return n?i.jsxs("div",{className:Ve("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",s.bgColor,s.color,r),title:s.title,children:[i.jsx(o,{className:l[t]}),i.jsx("span",{className:"font-medium",children:s.label})]}):i.jsx("div",{className:Ve("inline-flex items-center justify-center rounded-full transition-colors",s.bgColor,c[t],r),title:s.title,children:i.jsx(o,{className:Ve(l[t],s.color)})})},l8=ES("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Zr({className:e,variant:t,...r}){return i.jsx("div",{className:Ve(l8({variant:t}),e),...r})}const Mb=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),u=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:u===1?r?r("time.oneDayAgo"):"1 day ago":u<7?r?r("time.daysAgo",{count:u}):`${u} days ago`:n.toLocaleDateString()};function Kr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(sS,{className:t}):e==="codex"?i.jsx(iS,{className:t}):i.jsx(aS,{className:t})}function c8({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,onEditingSessionNameChange:o,onStartEditingSession:l,onCancelEditingSession:c,onSaveEditingSession:u,onProjectSelect:d,onSessionSelect:p,onDeleteSession:m,touchHandlerFactory:h,t:f}){const g=g_(t,n,f),v=r?.id===t.id,E=()=>{d(e),p(t,e.name)},w=()=>{u(e.name,t.id,s)},k=()=>{m(e.name,t.id,g.sessionName,t.__provider)};return i.jsxs("div",{className:"group relative",children:[g.isActive&&i.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:i.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:Ve("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",v?"bg-primary/5 border-primary/20":"",!v&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:E,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:Ve("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",v?"bg-primary/10":"bg-muted/50"),children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx(ii,{className:"w-2.5 h-2.5 text-muted-foreground"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:Mb(g.sessionTime,n,f)}),g.messageCount>0&&i.jsx(Zr,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:g.messageCount}),i.jsx("span",{className:"ml-1 opacity-70",children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})})]})]}),!g.isCursorSession&&i.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:C=>{C.stopPropagation(),k()},children:i.jsx(xr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),i.jsxs("div",{className:"hidden md:block",children:[i.jsx($e,{variant:"ghost",className:Ve("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",v&&"bg-accent text-accent-foreground"),onClick:()=>p(t,e.name),children:i.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx(ii,{className:"w-2.5 h-2.5 text-muted-foreground"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:Mb(g.sessionTime,n,f)}),g.messageCount>0&&i.jsx(Zr,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:g.messageCount}),i.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})})]})]})]})}),!g.isCursorSession&&i.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:a===t.id&&!g.isCodexSession?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:C=>o(C.target.value),onKeyDown:C=>{C.stopPropagation(),C.key==="Enter"?w():C.key==="Escape"&&c()},onClick:C=>C.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),i.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),w()},title:f("tooltips.save"),children:i.jsx(lr,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),i.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),c()},title:f("tooltips.cancel"),children:i.jsx(_t,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):i.jsxs(i.Fragment,{children:[!g.isCodexSession&&i.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),l(t.id,t.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:i.jsx(fI,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),i.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),k()},title:f("tooltips.deleteSession"),children:i.jsx(xr,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function u8(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"p-2 rounded-md",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},t))})}function d8({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,onEditingSessionNameChange:u,onStartEditingSession:d,onCancelEditingSession:p,onSaveEditingSession:m,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,onLoadMoreSessions:v,onNewSession:E,touchHandlerFactory:w,t:k}){if(!t)return null;const C=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[a?!C&&!s?i.jsx("div",{className:"py-2 px-3 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:k("sessions.noSessions")})}):r.map(T=>i.jsx(c8,{project:e,session:T,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,onEditingSessionNameChange:u,onStartEditingSession:d,onCancelEditingSession:p,onSaveEditingSession:m,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,touchHandlerFactory:w,t:k},T.id)):i.jsx(u8,{}),C&&A&&i.jsx($e,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),k("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Mr,{className:"w-3 h-3"}),k("sessions.showMore")]})}),i.jsx("div",{className:"md:hidden px-3 pb-2",children:i.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{h(e),E(e)},children:[i.jsx(er,{className:"w-3 h-3"}),k("sessions.newSession")]})}),i.jsxs($e,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>E(e),children:[i.jsx(er,{className:"w-3 h-3"}),k("sessions.newSession")]})]})}const p8=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function m8({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:m,editingSessionName:h,tasksEnabled:f,mcpServerStatus:g,onEditingNameChange:v,onToggleProject:E,onProjectSelect:w,onToggleStarProject:k,onStartEditingProject:C,onCancelEditingProject:A,onSaveProjectName:T,onDeleteProject:I,onSessionSelect:j,onDeleteSession:L,onLoadMoreSessions:_,onNewSession:M,onEditingSessionNameChange:P,onStartEditingSession:$,onCancelEditingSession:F,onSaveEditingSession:X,touchHandlerFactory:B,t:W}){const V=t?.name===e.name,le=o===e.name,R=e.sessionMeta?.hasMore===!0,Z=p8(c,R),H=`${Z} session${c.length===1?"":"s"}`,N=y_(e,g),q=()=>E(e.name),ie=()=>k(e.name),J=()=>{T(e.name)},Q=()=>{t?.name!==e.name&&w(e),q()};return i.jsxs("div",{className:Ve("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"group md:group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:Ve("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",V&&"bg-primary/5 border-primary/20",s&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:q,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:Ve("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx(na,{className:"w-4 h-4 text-primary"}):i.jsx(aa,{className:"w-4 h-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:le?i.jsx("input",{type:"text",value:l,onChange:ne=>v(ne.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:W("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ne=>ne.stopPropagation(),onKeyDown:ne=>{ne.key==="Enter"&&J(),ne.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[i.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:e.displayName}),f&&i.jsx(o8,{status:N,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:H})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:le?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:ne=>{ne.stopPropagation(),J()},children:i.jsx(lr,{className:"w-4 h-4 text-white"})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:ne=>{ne.stopPropagation(),A()},children:i.jsx(_t,{className:"w-4 h-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Ve("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:ne=>{ne.stopPropagation(),ie()},title:W(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(wb,{className:Ve("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:ne=>{ne.stopPropagation(),I(e)},children:i.jsx(xr,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:ne=>{ne.stopPropagation(),C(e)},children:i.jsx(li,{className:"w-4 h-4 text-primary"})}),i.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:n?i.jsx(Mr,{className:"w-3 h-3 text-muted-foreground"}):i.jsx(Xr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),i.jsxs($e,{variant:"ghost",className:Ve("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",V&&"bg-accent text-accent-foreground",s&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:Q,children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[n?i.jsx(na,{className:"w-4 h-4 text-primary flex-shrink-0"}):i.jsx(aa,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:le?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:ne=>v(ne.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:W("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ne=>{ne.key==="Enter"&&J(),ne.key==="Escape"&&A()}}),i.jsx("div",{className:"text-xs text-muted-foreground truncate",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[Z,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:le?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:ne=>{ne.stopPropagation(),J()},children:i.jsx(lr,{className:"w-3 h-3"})}),i.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:ne=>{ne.stopPropagation(),A()},children:i.jsx(_t,{className:"w-3 h-3"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:Ve("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",s?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:ne=>{ne.stopPropagation(),ie()},title:W(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(wb,{className:Ve("w-3 h-3 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),i.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:ne=>{ne.stopPropagation(),C(e)},title:W("tooltips.renameProject"),children:i.jsx(li,{className:"w-3 h-3"})}),i.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:ne=>{ne.stopPropagation(),I(e)},title:W("tooltips.deleteProject"),children:i.jsx(xr,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),n?i.jsx(Mr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):i.jsx(Xr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),i.jsx(d8,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:m,editingSessionName:h,onEditingSessionNameChange:P,onStartEditingSession:$,onCancelEditingSession:F,onSaveEditingSession:X,onProjectSelect:w,onSessionSelect:j,onDeleteSession:L,onLoadMoreSessions:_,onNewSession:M,touchHandlerFactory:B,t:W})]})}function h8({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:i.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx(aa,{className:"w-6 h-6 text-muted-foreground"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx(Ta,{className:"w-6 h-6 text-muted-foreground"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function f8({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:u,initialSessionsLoaded:d,currentTime:p,editingSession:m,editingSessionName:h,deletingProjects:f,tasksEnabled:g,mcpServerStatus:v,getProjectSessions:E,isProjectStarred:w,onEditingNameChange:k,onToggleProject:C,onProjectSelect:A,onToggleStarProject:T,onStartEditingProject:I,onCancelEditingProject:j,onSaveProjectName:L,onDeleteProject:_,onSessionSelect:M,onDeleteSession:P,onLoadMoreSessions:$,onNewSession:F,onEditingSessionNameChange:X,onStartEditingSession:B,onCancelEditingSession:W,onSaveEditingSession:V,touchHandlerFactory:le,t:R}){const Z=i.jsx(h8,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:R}),H=!a&&e.length>0&&t.length>0;return i.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:H?t.map(N=>i.jsx(m8,{project:N,selectedProject:r,selectedSession:n,isExpanded:o.has(N.name),isDeleting:f.has(N.name),isStarred:w(N.name),editingProject:l,editingName:c,sessions:E(N),initialSessionsLoaded:d.has(N.name),isLoadingSessions:!!u[N.name],currentTime:p,editingSession:m,editingSessionName:h,tasksEnabled:g,mcpServerStatus:v,onEditingNameChange:k,onToggleProject:C,onProjectSelect:A,onToggleStarProject:T,onStartEditingProject:I,onCancelEditingProject:j,onSaveProjectName:L,onDeleteProject:_,onSessionSelect:M,onDeleteSession:P,onLoadMoreSessions:$,onNewSession:F,onEditingSessionNameChange:X,onStartEditingSession:B,onCancelEditingSession:W,onSaveEditingSession:V,touchHandlerFactory:le,t:R},N.name)):Z})}function g8({isPWA:e,isMobile:t,isLoading:r,projects:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,updateAvailable:p,releaseInfo:m,latestVersion:h,onShowVersionModal:f,onShowSettings:g,projectListProps:v,t:E}){return i.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[i.jsx(i8,{isPWA:e,isMobile:t,isLoading:r,projectsCount:n.length,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,t:E}),i.jsx(Uf,{className:"flex-1 md:px-1.5 md:py-2 overflow-y-auto overscroll-contain",children:i.jsx(f8,{...v})}),i.jsx(a8,{updateAvailable:p,releaseInfo:m,latestVersion:h,onShowVersionModal:f,onShowSettings:g,t:E})]})}const b8=({onClose:e,onProjectCreated:t})=>{const{t:r}=Nt(),[n,a]=x.useState(1),[s,o]=x.useState("existing"),[l,c]=x.useState(""),[u,d]=x.useState(""),[p,m]=x.useState(""),[h,f]=x.useState("stored"),[g,v]=x.useState(""),[E,w]=x.useState(!1),[k,C]=x.useState(null),[A,T]=x.useState([]),[I,j]=x.useState(!1),[L,_]=x.useState([]),[M,P]=x.useState(!1),[$,F]=x.useState(!1),[X,B]=x.useState("~"),[W,V]=x.useState([]),[le,R]=x.useState(!1),[Z,H]=x.useState(!1),[N,q]=x.useState(!1),[ie,J]=x.useState(""),[Q,ne]=x.useState(!1),[he,se]=x.useState("");x.useEffect(()=>{n===2&&s==="new"&&u&&pe()},[n,s,u]),x.useEffect(()=>{l.length>2?Ae(l):(_([]),P(!1))},[l]);const pe=async()=>{try{j(!0);const de=((await(await bt.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(Te=>Te.is_active);T(de),de.length>0&&!p&&m(de[0].id.toString())}catch(ge){console.error("Error loading GitHub tokens:",ge)}finally{j(!1)}},Ae=async ge=>{try{const rt=ge.lastIndexOf("/"),de=rt>0?ge.substring(0,rt):"~",re=await(await bt.browseFilesystem(de)).json();if(re.suggestions){const ue=re.suggestions.filter(ve=>ve.path.toLowerCase().startsWith(ge.toLowerCase())&&ve.path.toLowerCase()!==ge.toLowerCase());_(ue.slice(0,5)),P(ue.length>0)}}catch(rt){console.error("Error loading path suggestions:",rt)}},Re=()=>{if(C(null),n===1){if(!s){C(r("projectWizard.errors.selectType"));return}a(2)}else if(n===2){if(!l.trim()){C(r("projectWizard.errors.providePath"));return}a(3)}},Ye=()=>{C(null),a(n-1)},Ze=async()=>{w(!0),C(null),se("");try{if(s==="new"&&u){const Te=new URLSearchParams({path:l.trim(),githubUrl:u.trim()});h==="stored"&&p?Te.append("githubTokenId",p):h==="new"&&g&&Te.append("newGithubToken",g.trim());const re=localStorage.getItem("auth-token"),ue=`/api/projects/clone-progress?${Te}${re?`&token=${re}`:""}`;await new Promise((ve,Me)=>{const qe=new EventSource(ue);qe.onmessage=kt=>{try{const ht=JSON.parse(kt.data);ht.type==="progress"?se(ht.message):ht.type==="complete"?(qe.close(),t&&t(ht.project),e(),ve()):ht.type==="error"&&(qe.close(),Me(new Error(ht.message)))}catch(ht){console.error("Error parsing SSE event:",ht)}},qe.onerror=()=>{qe.close(),Me(new Error("Connection lost during clone"))}});return}const ge={workspaceType:s,path:l.trim()},rt=await bt.createWorkspace(ge),de=await rt.json();if(!rt.ok)throw new Error(de.details||de.error||r("projectWizard.errors.failedToCreate"));t&&t(de.project),e()}catch(ge){console.error("Error creating workspace:",ge),C(ge.message||r("projectWizard.errors.failedToCreate"))}finally{w(!1)}},at=ge=>{c(ge.path),P(!1)},st=async()=>{F(!0),await Qe("~")},Qe=async ge=>{try{R(!0);const de=await(await bt.browseFilesystem(ge)).json();B(de.path||ge),V(de.suggestions||[])}catch(rt){console.error("Error loading folders:",rt)}finally{R(!1)}},Be=(ge,rt=!1)=>{c(ge),F(!1),rt&&a(3)},tt=async ge=>{await Qe(ge)},xt=async()=>{if(ie.trim()){ne(!0),C(null);try{const ge=X.includes("\\")?"\\":"/",rt=`${X}${ge}${ie.trim()}`,de=await bt.createFolder(rt),Te=await de.json();if(!de.ok)throw new Error(Te.error||r("projectWizard.errors.failedToCreateFolder","Failed to create folder"));J(""),q(!1),await Qe(Te.path||rt)}catch(ge){console.error("Error creating folder:",ge),C(ge.message||r("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{ne(!1)}}};return i.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(fo,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.title")})]}),i.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:E,children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"px-6 pt-4 pb-2",children:i.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(ge=>i.jsxs(Xt.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${ge<n?"bg-green-500 text-white":ge===n?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:ge<n?i.jsx(lr,{className:"w-4 h-4"}):ge}),i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:r(ge===1?"projectWizard.steps.type":ge===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),ge<3&&i.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${ge<n?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},ge))})}),i.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[k&&i.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[i.jsx(rl,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),i.jsx("div",{className:"flex-1",children:i.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:k})})]}),n===1&&i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:r("projectWizard.step1.question")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx("button",{onClick:()=>o("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${s==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:i.jsx(fo,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.existing.title")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.existing.description")})]})]})}),i.jsx("button",{onClick:()=>o("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${s==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:i.jsx(fn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.new.title")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.new.description")})]})]})})]})]})}),n===2&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r(s==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),i.jsxs("div",{className:"relative flex gap-2",children:[i.jsxs("div",{className:"flex-1 relative",children:[i.jsx(Ft,{type:"text",value:l,onChange:ge=>c(ge.target.value),placeholder:s==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),M&&L.length>0&&i.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:L.map((ge,rt)=>i.jsxs("button",{onClick:()=>at(ge),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[i.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:ge.name}),i.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:ge.path})]},rt))})]}),i.jsx($e,{type:"button",variant:"outline",onClick:st,className:"px-3",title:"Browse folders",children:i.jsx(na,{className:"w-4 h-4"})})]}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r(s==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),s==="new"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.githubUrl")}),i.jsx(Ft,{type:"text",value:u,onChange:ge=>d(ge.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.githubHelp")})]}),u&&!u.startsWith("git@")&&!u.startsWith("ssh://")&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[i.jsx(Lf,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:r("projectWizard.step2.githubAuth")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step2.githubAuthHelp")})]})]}),I?i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),r("projectWizard.step2.loadingTokens")]}):A.length>0?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[i.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.storedToken")}),i.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.newToken")}),i.jsx("button",{onClick:()=>{f("none"),m(""),v("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.nonePublic")})]}),h==="stored"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.selectToken")}),i.jsxs("select",{value:p,onChange:ge=>m(ge.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[i.jsx("option",{value:"",children:r("projectWizard.step2.selectTokenPlaceholder")}),A.map(ge=>i.jsx("option",{value:ge.id,children:ge.credential_name},ge.id))]})]}):h==="new"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.newToken")}),i.jsx(Ft,{type:"password",value:g,onChange:ge=>v(ge.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.tokenHelp")})]}):null]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:i.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:r("projectWizard.step2.publicRepoInfo")})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.optionalTokenPublic")}),i.jsx(Ft,{type:"password",value:g,onChange:ge=>v(ge.target.value),placeholder:r("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),n===3&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[i.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:r("projectWizard.step3.reviewConfig")}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.workspaceType")}),i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r(s==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.path")}),i.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:l})]}),s==="new"&&u&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.cloneFrom")}),i.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:u})]}),i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.authentication")}),i.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:h==="stored"&&p?`${r("projectWizard.step3.usingStoredToken")} ${A.find(ge=>ge.id.toString()===p)?.credential_name||"Unknown"}`:h==="new"&&g?r("projectWizard.step3.usingProvidedToken"):u.startsWith("git@")||u.startsWith("ssh://")?r("projectWizard.step3.sshKey","SSH Key"):r("projectWizard.step3.noAuthentication")})]})]})]})]}),i.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:E&&he?i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:r("projectWizard.step3.cloningRepository","Cloning repository...")}),i.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:he})]}):i.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:r(s==="existing"?"projectWizard.step3.existingInfo":u?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[i.jsx($e,{variant:"outline",onClick:n===1?e:Ye,disabled:E,children:n===1?r("projectWizard.buttons.cancel"):i.jsxs(i.Fragment,{children:[i.jsx(Of,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.back")]})}),i.jsx($e,{onClick:n===3?Ze:Re,disabled:E||n===1&&!s,children:E?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 mr-2 animate-spin"}),u?r("projectWizard.buttons.cloning","Cloning..."):r("projectWizard.buttons.creating")]}):n===3?i.jsxs(i.Fragment,{children:[i.jsx(lr,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.createProject")]}):i.jsxs(i.Fragment,{children:[r("projectWizard.buttons.next"),i.jsx(Xr,{className:"w-4 h-4 ml-1"})]})})]})]}),$&&i.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(na,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>H(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:Z?"Hide hidden folders":"Show hidden folders",children:Z?i.jsx(Aa,{className:"w-5 h-5"}):i.jsx(Z4,{className:"w-5 h-5"})}),i.jsx("button",{onClick:()=>q(!N),className:`p-2 rounded-md transition-colors ${N?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:i.jsx(er,{className:"w-5 h-5"})}),i.jsx("button",{onClick:()=>F(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:i.jsx(_t,{className:"w-5 h-5"})})]})]}),N&&i.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ft,{type:"text",value:ie,onChange:ge=>J(ge.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:ge=>{ge.key==="Enter"&&xt(),ge.key==="Escape"&&(q(!1),J(""))},autoFocus:!0}),i.jsx($e,{size:"sm",onClick:xt,disabled:!ie.trim()||Q,children:Q?i.jsx(ka,{className:"w-4 h-4 animate-spin"}):"Create"}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>{q(!1),J("")},children:"Cancel"})]})}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:le?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(ka,{className:"w-6 h-6 animate-spin text-gray-400"})}):i.jsxs("div",{className:"space-y-1",children:[X!=="~"&&X!=="/"&&!/^[A-Za-z]:\\?$/.test(X)&&i.jsxs("button",{onClick:()=>{const ge=Math.max(X.lastIndexOf("/"),X.lastIndexOf("\\"));let rt;ge<=0?rt="/":ge===2&&/^[A-Za-z]:/.test(X)?rt=X.substring(0,3):rt=X.substring(0,ge),tt(rt)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[i.jsx(na,{className:"w-5 h-5 text-gray-400"}),i.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),W.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):W.filter(ge=>Z||!ge.name.startsWith(".")).sort((ge,rt)=>ge.name.toLowerCase().localeCompare(rt.name.toLowerCase())).map((ge,rt)=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{onClick:()=>tt(ge.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[i.jsx(fo,{className:"w-5 h-5 text-blue-500"}),i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ge.name})]}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>Be(ge.path,s==="existing"),className:"text-xs px-3",children:"Select"})]},rt))]})}),i.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),i.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:X})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[i.jsx($e,{variant:"outline",onClick:()=>{F(!1),q(!1),J("")},children:"Cancel"}),i.jsx($e,{variant:"outline",onClick:()=>Be(X,s==="existing"),children:"Use this folder"})]})]})]})})]})};function x8(){const{t:e}=Nt("settings"),[t,r]=x.useState([]),[n,a]=x.useState([]),[s,o]=x.useState(!0),[l,c]=x.useState(!1),[u,d]=x.useState(!1),[p,m]=x.useState(""),[h,f]=x.useState(""),[g,v]=x.useState(""),[E,w]=x.useState(""),[k,C]=x.useState({}),[A,T]=x.useState(null),[I,j]=x.useState(null),{updateAvailable:L,latestVersion:_,releaseInfo:M}=cS("siteboon","claudecodeui");x.useEffect(()=>{P()},[]);const P=async()=>{try{o(!0);const Z=await(await _e("/api/settings/api-keys")).json();r(Z.apiKeys||[]);const N=await(await _e("/api/settings/credentials?type=github_token")).json();a(N.credentials||[])}catch(R){console.error("Error fetching settings:",R)}finally{o(!1)}},$=async()=>{if(p.trim())try{const Z=await(await _e("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();Z.success&&(j(Z.apiKey),m(""),c(!1),P())}catch(R){console.error("Error creating API key:",R)}},F=async R=>{if(confirm(e("apiKeys.confirmDelete")))try{await _e(`/api/settings/api-keys/${R}`,{method:"DELETE"}),P()}catch(Z){console.error("Error deleting API key:",Z)}},X=async(R,Z)=>{try{await _e(`/api/settings/api-keys/${R}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!Z})}),P()}catch(H){console.error("Error toggling API key:",H)}},B=async()=>{if(!(!h.trim()||!g.trim()))try{(await(await _e("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:h,credentialType:"github_token",credentialValue:g,description:E})})).json()).success&&(f(""),v(""),w(""),d(!1),P())}catch(R){console.error("Error creating GitHub credential:",R)}},W=async R=>{if(confirm(e("apiKeys.github.confirmDelete")))try{await _e(`/api/settings/credentials/${R}`,{method:"DELETE"}),P()}catch(Z){console.error("Error deleting GitHub credential:",Z)}},V=async(R,Z)=>{try{await _e(`/api/settings/credentials/${R}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!Z})}),P()}catch(H){console.error("Error toggling GitHub credential:",H)}},le=(R,Z)=>{navigator.clipboard.writeText(R),T(Z),setTimeout(()=>T(null),2e3)};return s?i.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):i.jsxs("div",{className:"space-y-8",children:[I&&i.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[i.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),i.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),i.jsx($e,{size:"sm",variant:"outline",onClick:()=>le(I.apiKey,"new"),children:A==="new"?i.jsx(lr,{className:"h-4 w-4"}):i.jsx(X4,{className:"h-4 w-4"})})]}),i.jsx($e,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>j(null),children:e("apiKeys.newKey.iveSavedIt")})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Lf,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),i.jsxs($e,{size:"sm",onClick:()=>c(!l),children:[i.jsx(er,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),i.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),i.jsx(yb,{className:"h-3 w-3"})]})]}),l&&i.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[i.jsx(Ft,{placeholder:e("apiKeys.form.placeholder"),value:p,onChange:R=>m(R.target.value),className:"mb-2"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx($e,{onClick:$,children:e("apiKeys.form.createButton")}),i.jsx($e,{variant:"outline",onClick:()=>c(!1),children:e("apiKeys.form.cancelButton")})]})]}),i.jsx("div",{className:"space-y-2",children:t.length===0?i.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(R=>i.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium",children:R.key_name}),i.jsx("code",{className:"text-xs text-muted-foreground",children:R.api_key}),i.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(R.created_at).toLocaleDateString(),R.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(R.last_used).toLocaleDateString()}`]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{size:"sm",variant:R.is_active?"outline":"secondary",onClick:()=>X(R.id,R.is_active),children:R.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>F(R.id),children:i.jsx(xr,{className:"h-4 w-4"})})]})]},R.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_6,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.github.title")})]}),i.jsxs($e,{size:"sm",onClick:()=>d(!u),children:[i.jsx(er,{className:"h-4 w-4 mr-1"}),e("apiKeys.github.addButton")]})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("apiKeys.github.descriptionAlt")}),u&&i.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[i.jsx(Ft,{placeholder:e("apiKeys.github.form.namePlaceholder"),value:h,onChange:R=>f(R.target.value)}),i.jsxs("div",{className:"relative",children:[i.jsx(Ft,{type:k.new?"text":"password",placeholder:e("apiKeys.github.form.tokenPlaceholder"),value:g,onChange:R=>v(R.target.value),className:"pr-10"}),i.jsx("button",{type:"button",onClick:()=>C({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?i.jsx(Z4,{className:"h-4 w-4"}):i.jsx(Aa,{className:"h-4 w-4"})})]}),i.jsx(Ft,{placeholder:e("apiKeys.github.form.descriptionPlaceholder"),value:E,onChange:R=>w(R.target.value)}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx($e,{onClick:B,children:e("apiKeys.github.form.addButton")}),i.jsx($e,{variant:"outline",onClick:()=>{d(!1),f(""),v(""),w("")},children:e("apiKeys.github.form.cancelButton")})]}),i.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:e("apiKeys.github.form.howToCreate")})]}),i.jsx("div",{className:"space-y-2",children:n.length===0?i.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.github.empty")}):n.map(R=>i.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium",children:R.credential_name}),R.description&&i.jsx("div",{className:"text-xs text-muted-foreground",children:R.description}),i.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.github.added")," ",new Date(R.created_at).toLocaleDateString()]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{size:"sm",variant:R.is_active?"outline":"secondary",onClick:()=>V(R.id,R.is_active),children:R.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>W(R.id),children:i.jsx(xr,{className:"h-4 w-4"})})]})]},R.id))})]}),i.jsx("div",{className:"pt-6 border-t border-border/50",children:i.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[i.jsxs("a",{href:M?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Lh]}),L&&_&&i.jsxs("a",{href:M?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[i.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:_})}),i.jsx(yb,{className:"h-2.5 w-2.5"})]})]})})]})}function y8(){const{t:e}=Nt("settings"),[t,r]=x.useState(""),[n,a]=x.useState(""),[s,o]=x.useState(!1),[l,c]=x.useState(!1),[u,d]=x.useState(null);x.useEffect(()=>{p()},[]);const p=async()=>{try{o(!0);const h=await _e("/api/user/git-config");if(h.ok){const f=await h.json();r(f.gitName||""),a(f.gitEmail||"")}}catch(h){console.error("Error loading git config:",h)}finally{o(!1)}},m=async()=>{try{c(!0);const h=await _e("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:t,gitEmail:n})});if(h.ok)d("success"),setTimeout(()=>d(null),3e3);else{const f=await h.json();d("error"),console.error("Failed to save git config:",f.error)}}catch(h){console.error("Error saving git config:",h),d("error")}finally{c(!1)}};return i.jsx("div",{className:"space-y-8",children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(fn,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("git.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("git.description")}),i.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:e("git.name.label")}),i.jsx(Ft,{id:"settings-git-name",type:"text",value:t,onChange:h=>r(h.target.value),placeholder:"John Doe",disabled:s,className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.name.help")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:e("git.email.label")}),i.jsx(Ft,{id:"settings-git-email",type:"email",value:n,onChange:h=>a(h.target.value),placeholder:"john@example.com",disabled:s,className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.email.help")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{onClick:m,disabled:l||!t||!n,children:e(l?"git.actions.saving":"git.actions.save")}),u==="success"&&i.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[i.jsx(lr,{className:"w-4 h-4"}),e("git.status.success")]})]})]})]})})}function v8(){const{t:e}=Nt("settings"),{tasksEnabled:t,setTasksEnabled:r,isTaskMasterInstalled:n,isCheckingInstallation:a}=yi();return i.jsx("div",{className:"space-y-8",children:a?i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:e("tasks.checking")})]})}):i.jsxs(i.Fragment,{children:[!n&&i.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:e("tasks.notInstalled.title")}),i.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[i.jsx("p",{children:e("tasks.notInstalled.description")}),i.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:i.jsx("code",{children:e("tasks.notInstalled.installCommand")})}),i.jsx("div",{children:i.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),e("tasks.notInstalled.viewOnGitHub"),i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"font-medium",children:e("tasks.notInstalled.afterInstallation")}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[i.jsx("li",{children:e("tasks.notInstalled.steps.restart")}),i.jsx("li",{children:e("tasks.notInstalled.steps.autoAvailable")}),i.jsx("li",{children:e("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),n&&i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:e("tasks.settings.enableLabel")}),i.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:e("tasks.settings.enableDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t,onChange:s=>r(s.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const k8={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},w8={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function $a({agentId:e,authStatus:t,isSelected:r,onClick:n,isMobile:a=!1}){const{t:s}=Nt("settings"),o=k8[e],l=w8[o.color];return a?i.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${l.borderBottom} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsx(Kr,{provider:e,className:"w-5 h-5"}),i.jsx("span",{className:"text-xs font-medium text-foreground",children:o.name}),t?.authenticated&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`})]})}):i.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${l.border} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Kr,{provider:e,className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:o.name})]}),i.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?i.jsx("span",{className:"text-gray-400",children:s("agents.authStatus.checking")}):t?.authenticated?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`}),i.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||s("agents.authStatus.connected")})]}):i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{children:s("agents.authStatus.notConnected")})]})})]})}const E8={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function S8({agent:e,authStatus:t,onLogin:r}){const{t:n}=Nt("settings"),a=E8[e];return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx(Kr,{provider:e,className:"w-6 h-6"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a.name}),i.jsx("p",{className:"text-sm text-muted-foreground",children:n(`agents.account.${e}.description`)})]})]}),i.jsx("div",{className:`${a.bgClass} border ${a.borderClass} rounded-lg p-4`,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:`font-medium ${a.textClass}`,children:n("agents.connectionStatus")}),i.jsx("div",{className:`text-sm ${a.subtextClass}`,children:t?.loading?n("agents.authStatus.checkingAuth"):t?.authenticated?n("agents.authStatus.loggedInAs",{email:t.email||n("agents.authStatus.authenticatedUser")}):n("agents.authStatus.notConnected")})]}),i.jsx("div",{children:t?.loading?i.jsx(Zr,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:n("agents.authStatus.checking")}):t?.authenticated?i.jsx(Zr,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:n("agents.authStatus.connected")}):i.jsx(Zr,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:n("agents.authStatus.disconnected")})})]}),i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:`font-medium ${a.textClass}`,children:t?.authenticated?n("agents.login.reAuthenticate"):n("agents.login.title")}),i.jsx("div",{className:`text-sm ${a.subtextClass}`,children:t?.authenticated?n("agents.login.reAuthDescription"):n("agents.login.description",{agent:a.name})})]}),i.jsxs($e,{onClick:r,className:`${a.buttonClass} text-white`,size:"sm",children:[i.jsx(tS,{className:"w-4 h-4 mr-2"}),t?.authenticated?n("agents.login.reLoginButton"):n("agents.login.button")]})]})}),t?.error&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:n("agents.error",{error:t.error})})})]})})]})}const T8=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],N8=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function C8({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:a,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const{t:d}=Nt("settings"),p=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},m=g=>{n(r.filter(v=>v!==g))},h=g=>{g&&!a.includes(g)&&(s([...a,g]),u(""))},f=g=>{s(a.filter(v=>v!==g))};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-orange-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.title")})]}),i.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("label",{className:"flex items-center gap-3",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:d("permissions.skipPermissions.label")}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:d("permissions.skipPermissions.claudeDescription")})]})]})})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.allowedTools.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.allowedTools.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:o,onChange:g=>l(g.target.value),placeholder:d("permissions.allowedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(o))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>p(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:d("permissions.allowedTools.quickAdd")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:T8.map(g=>i.jsx($e,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),i.jsxs("div",{className:"space-y-2",children:[r.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>m(g),className:"text-green-600 hover:text-green-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),r.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.allowedTools.empty")})]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-red-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.blockedTools.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.blockedTools.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:c,onChange:g=>u(g.target.value),placeholder:d("permissions.blockedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(c))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>h(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[a.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),a.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.blockedTools.empty")})]})]}),i.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:d("permissions.toolExamples.title")}),i.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",d("permissions.toolExamples.bashGitLog")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",d("permissions.toolExamples.bashGitDiff")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",d("permissions.toolExamples.write")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",d("permissions.toolExamples.bashRm")]})]})]})]})}function A8({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:a,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const{t:d}=Nt("settings"),p=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},m=g=>{n(r.filter(v=>v!==g))},h=g=>{g&&!a.includes(g)&&(s([...a,g]),u(""))},f=g=>{s(a.filter(v=>v!==g))};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-orange-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.title")})]}),i.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("label",{className:"flex items-center gap-3",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:d("permissions.skipPermissions.label")}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:d("permissions.skipPermissions.cursorDescription")})]})]})})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.allowedCommands.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.allowedCommands.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:o,onChange:g=>l(g.target.value),placeholder:d("permissions.allowedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(o))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>p(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:d("permissions.allowedCommands.quickAdd")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N8.map(g=>i.jsx($e,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),i.jsxs("div",{className:"space-y-2",children:[r.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>m(g),className:"text-green-600 hover:text-green-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),r.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.allowedCommands.empty")})]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-red-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.blockedCommands.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.blockedCommands.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:c,onChange:g=>u(g.target.value),placeholder:d("permissions.blockedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(c))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>h(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[a.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),a.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.blockedCommands.empty")})]})]}),i.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:d("permissions.shellExamples.title")}),i.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",d("permissions.shellExamples.ls")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",d("permissions.shellExamples.gitStatus")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",d("permissions.shellExamples.npmInstall")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",d("permissions.shellExamples.rmRf")]})]})]})]})}function I8({permissionMode:e,setPermissionMode:t}){const{t:r}=Nt("settings");return i.jsx("div",{className:"space-y-6",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:r("permissions.codex.permissionMode")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:r("permissions.codex.description")}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("default"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:r("permissions.codex.modes.default.title")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:r("permissions.codex.modes.default.description")})]})]})}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("acceptEdits"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:r("permissions.codex.modes.acceptEdits.title")}),i.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:r("permissions.codex.modes.acceptEdits.description")})]})]})}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("bypassPermissions"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[r("permissions.codex.modes.bypassPermissions.title"),i.jsx(Ln,{className:"w-4 h-4"})]}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:r("permissions.codex.modes.bypassPermissions.description")})]})]})}),i.jsxs("details",{className:"text-sm",children:[i.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:r("permissions.codex.technicalDetails")}),i.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.default.title"),":"]})," ",r("permissions.codex.technicalInfo.default")]}),i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.acceptEdits.title"),":"]})," ",r("permissions.codex.technicalInfo.acceptEdits")]}),i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.bypassPermissions.title"),":"]})," ",r("permissions.codex.technicalInfo.bypassPermissions")]}),i.jsx("p",{className:"text-xs opacity-75",children:r("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Gl({agent:e,...t}){return e==="claude"?i.jsx(C8,{...t}):e==="cursor"?i.jsx(A8,{...t}):e==="codex"?i.jsx(I8,{...t}):null}const _8=e=>{switch(e){case"stdio":return i.jsx(ir,{className:"w-4 h-4"});case"sse":return i.jsx(jf,{className:"w-4 h-4"});case"http":return i.jsx(oi,{className:"w-4 h-4"});default:return i.jsx(al,{className:"w-4 h-4"})}};function R8({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:a,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){const{t:u}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-purple-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:u("mcpServers.description.claude")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),u("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(d=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[_8(d.type),i.jsx("span",{className:"font-medium text-foreground",children:d.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:d.type}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:d.scope==="local"?u("mcpServers.scope.local"):d.scope==="user"?u("mcpServers.scope.user"):d.scope})]}),i.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[d.type==="stdio"&&d.config?.command&&i.jsxs("div",{children:[u("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.command})]}),(d.type==="sse"||d.type==="http")&&d.config?.url&&i.jsxs("div",{children:[u("mcpServers.config.url"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.url})]}),d.config?.args&&d.config.args.length>0&&i.jsxs("div",{children:[u("mcpServers.config.args"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.args.join(" ")})]})]}),o?.[d.id]&&i.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[d.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:i.jsx("div",{className:"font-medium",children:o[d.id].message})}),l?.[d.id]&&l[d.id].tools?.length>0&&i.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[i.jsxs("div",{className:"font-medium",children:[u("mcpServers.tools.title")," ",u("mcpServers.tools.count",{count:l[d.id].tools.length})]}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[d.id].tools.slice(0,5).map((p,m)=>i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:p.name},m)),l[d.id].tools.length>5&&i.jsx("span",{className:"text-xs opacity-75",children:u("mcpServers.tools.more",{count:l[d.id].tools.length-5})})]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(d),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:u("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(d.id,d.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:u("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},d.id)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:u("mcpServers.empty")})]})]})}function O8({servers:e,onAdd:t,onEdit:r,onDelete:n}){const{t:a}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-purple-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("mcpServers.description.cursor")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),a("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(s=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ir,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:s.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),i.jsx("div",{className:"text-sm text-muted-foreground",children:s.config?.command&&i.jsxs("div",{children:[a("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.command})]})})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(s),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:a("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(s.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:a("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},s.name||s.id)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:a("mcpServers.empty")})]})]})}function L8({servers:e,onAdd:t,onEdit:r,onDelete:n}){const{t:a}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("mcpServers.description.codex")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),a("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(s=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ir,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:s.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),i.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[s.config?.command&&i.jsxs("div",{children:[a("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.command})]}),s.config?.args&&s.config.args.length>0&&i.jsxs("div",{children:[a("mcpServers.config.args"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.args.join(" ")})]}),s.config?.env&&Object.keys(s.config.env).length>0&&i.jsxs("div",{children:[a("mcpServers.config.environment"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(s.config.env).map(([o,l])=>`${o}=${l}`).join(", ")})]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(s),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:a("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(s.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:a("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},s.name)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:a("mcpServers.empty")})]}),i.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:a("mcpServers.help.title")}),i.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("mcpServers.help.description")})]})]})}function Wl({agent:e,...t}){return e==="claude"?i.jsx(R8,{...t}):e==="cursor"?i.jsx(O8,{...t}):e==="codex"?i.jsx(L8,{...t}):null}const Ph=[{value:"en",label:"English",nativeName:"English"},{value:"ko",label:"Korean",nativeName:"한국어"},{value:"zh-CN",label:"Simplified Chinese",nativeName:"简体中文"},{value:"ja",label:"Japanese",nativeName:"日本語"}];function SS({compact:e=!1}){const{i18n:t,t:r}=Nt("settings"),n=a=>{const s=a.target.value;t.changeLanguage(s)};return e?i.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[i.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[i.jsx(eS,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),r("account.language")]}),i.jsx("select",{value:t.language,onChange:n,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Ph.map(a=>i.jsx("option",{value:a.value,children:a.nativeName},a.value))})]}):i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:r("account.languageLabel")}),i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("account.languageDescription")})]}),i.jsx("select",{value:t.language,onChange:n,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Ph.map(a=>i.jsx("option",{value:a.value,children:a.nativeName},a.value))})]})})}function D8({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:a,toggleDarkMode:s}=xi(),{t:o}=Nt("settings"),[l,c]=x.useState([]),[u,d]=x.useState([]),[p,m]=x.useState(""),[h,f]=x.useState(""),[g,v]=x.useState(!1),[E,w]=x.useState(!1),[k,C]=x.useState(null),[A,T]=x.useState("name"),[I,j]=x.useState([]),[L,_]=x.useState(!1),[M,P]=x.useState(null),[$,F]=x.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[X,B]=x.useState(!1),[W,V]=x.useState({}),[le,R]=x.useState({}),[Z,H]=x.useState({}),[N,q]=x.useState(n),[ie,J]=x.useState(""),[Q,ne]=x.useState("claude"),[he,se]=x.useState("account"),[pe,Ae]=x.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Re,Ye]=x.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ze,at]=x.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[st,Qe]=x.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Be,tt]=x.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[xt,ge]=x.useState([]),[rt,de]=x.useState([]),[Te,re]=x.useState(!1),[ue,ve]=x.useState(""),[Me,qe]=x.useState(""),[kt,ht]=x.useState([]),[Oe,Xe]=x.useState([]),[ze,Ke]=x.useState("default"),[lt,et]=x.useState(!1),[ye,Ie]=x.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[pt,yt]=x.useState(null),[qt,wr]=x.useState(!1),[pr,Er]=x.useState(!1),[mr,kn]=x.useState(""),[Pe,nt]=x.useState(null),[De,te]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[fe,He]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[St,It]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),Gt=async()=>{try{const ae=await _e("/api/cursor/mcp");if(ae.ok){const be=await ae.json();ht(be.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(ae){console.error("Error fetching Cursor MCP servers:",ae)}},wn=async()=>{try{const ae=await _e("/api/codex/mcp/config/read");if(ae.ok){const je=await ae.json();if(je.success&&je.servers){Xe(je.servers);return}}const be=await _e("/api/codex/mcp/cli/list");if(be.ok){const je=await be.json();if(je.success&&je.servers){const mt=je.servers.map(hr=>({id:hr.name,name:hr.name,type:hr.type||"stdio",scope:"user",config:{command:hr.command||"",args:hr.args||[],env:hr.env||{}}}));Xe(mt)}}}catch(ae){console.error("Error fetching Codex MCP servers:",ae)}},en=async()=>{try{const ae=await _e("/api/mcp/config/read");if(ae.ok){const mt=await ae.json();if(mt.success&&mt.servers){j(mt.servers);return}}const be=await _e("/api/mcp/cli/list");if(be.ok){const mt=await be.json();if(mt.success&&mt.servers){const hr=mt.servers.map(qn=>({id:qn.name,name:qn.name,type:qn.type,scope:"user",config:{command:qn.command||"",args:qn.args||[],env:qn.env||{},url:qn.url||"",headers:qn.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));j(hr);return}}const je=await _e("/api/mcp/servers?scope=user");if(je.ok){const mt=await je.json();j(mt.servers||[])}else console.error("Failed to fetch MCP servers")}catch(ae){console.error("Error fetching MCP servers:",ae)}},tn=async ae=>{try{M&&await rr(M.id,"user");const be=await _e("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:ae.name,type:ae.type,scope:ae.scope,projectPath:ae.projectPath,command:ae.config?.command,args:ae.config?.args||[],url:ae.config?.url,headers:ae.config?.headers||{},env:ae.config?.env||{}})});if(be.ok){const je=await be.json();if(je.success)return await en(),!0;throw new Error(je.error||"Failed to save server via Claude CLI")}else{const je=await be.json();throw new Error(je.error||"Failed to save server")}}catch(be){throw console.error("Error saving MCP server:",be),be}},rr=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/cli/remove/${ae}?scope=${be}`,{method:"DELETE"});if(je.ok){const mt=await je.json();if(mt.success)return await en(),!0;throw new Error(mt.error||"Failed to delete server via Claude CLI")}else{const mt=await je.json();throw new Error(mt.error||"Failed to delete server")}}catch(je){throw console.error("Error deleting MCP server:",je),je}},sr=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/servers/${ae}/test?scope=${be}`,{method:"POST"});if(je.ok)return(await je.json()).testResult;{const mt=await je.json();throw new Error(mt.error||"Failed to test server")}}catch(je){throw console.error("Error testing MCP server:",je),je}},En=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/servers/${ae}/tools?scope=${be}`,{method:"POST"});if(je.ok)return(await je.json()).toolsResult;{const mt=await je.json();throw new Error(mt.error||"Failed to discover tools")}}catch(je){throw console.error("Error discovering MCP tools:",je),je}},pa=async ae=>{try{pt&&await Ss(pt.id);const be=await _e("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:ae.name,command:ae.config?.command,args:ae.config?.args||[],env:ae.config?.env||{}})});if(be.ok){const je=await be.json();if(je.success)return await wn(),!0;throw new Error(je.error||"Failed to save Codex MCP server")}else{const je=await be.json();throw new Error(je.error||"Failed to save server")}}catch(be){throw console.error("Error saving Codex MCP server:",be),be}},Ss=async ae=>{try{const be=await _e(`/api/codex/mcp/cli/remove/${ae}`,{method:"DELETE"});if(be.ok){const je=await be.json();if(je.success)return await wn(),!0;throw new Error(je.error||"Failed to delete Codex MCP server")}else{const je=await be.json();throw new Error(je.error||"Failed to delete server")}}catch(be){throw console.error("Error deleting Codex MCP server:",be),be}},ja=()=>{Ie({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),yt(null),et(!1)},Oi=(ae=null)=>{ae?(yt(ae),Ie({name:ae.name,type:ae.type||"stdio",config:{command:ae.config?.command||"",args:ae.config?.args||[],env:ae.config?.env||{}}})):ja(),et(!0)},Cl=async ae=>{ae.preventDefault(),wr(!0);try{pt&&await Ss(pt.name),await pa(ye),ja(),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}finally{wr(!1)}},Al=async ae=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Ss(ae),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}};x.useEffect(()=>{e&&(Il(),Li(),Di(),ji(),q(n))},[e,n]),x.useEffect(()=>{localStorage.setItem("codeEditorTheme",pe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[pe]),x.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Re.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Re]),x.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ze.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]),x.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",st.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[st]),x.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Be),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Be]);const Il=async()=>{try{const ae=localStorage.getItem("claude-settings");if(ae){const mt=JSON.parse(ae);c(mt.allowedTools||[]),d(mt.disallowedTools||[]),v(mt.skipPermissions||!1),T(mt.projectSortOrder||"name")}else c([]),d([]),v(!1),T("name");const be=localStorage.getItem("cursor-tools-settings");if(be){const mt=JSON.parse(be);ge(mt.allowedCommands||[]),de(mt.disallowedCommands||[]),re(mt.skipPermissions||!1)}else ge([]),de([]),re(!1);const je=localStorage.getItem("codex-settings");if(je){const mt=JSON.parse(je);Ke(mt.permissionMode||"default")}else Ke("default");await en(),await Gt(),await wn()}catch(ae){console.error("Error loading tool settings:",ae),c([]),d([]),v(!1),T("name")}},Li=async()=>{try{const ae=await _e("/api/cli/claude/status");if(ae.ok){const be=await ae.json();te({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else te({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Claude auth status:",ae),te({authenticated:!1,email:null,loading:!1,error:ae.message})}},Di=async()=>{try{const ae=await _e("/api/cli/cursor/status");if(ae.ok){const be=await ae.json();He({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else He({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Cursor auth status:",ae),He({authenticated:!1,email:null,loading:!1,error:ae.message})}},ji=async()=>{try{const ae=await _e("/api/cli/codex/status");if(ae.ok){const be=await ae.json();It({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else It({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Codex auth status:",ae),It({authenticated:!1,email:null,loading:!1,error:ae.message})}},_l=()=>{kn("claude"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Rl=()=>{kn("cursor"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Ts=()=>{kn("codex"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Ol=ae=>{ae===0&&(C("success"),mr==="claude"?Li():mr==="cursor"?Di():mr==="codex"&&ji())},Ll=()=>{w(!0),C(null);try{const ae={allowedTools:l,disallowedTools:u,skipPermissions:g,projectSortOrder:A,lastUpdated:new Date().toISOString()},be={allowedCommands:xt,disallowedCommands:rt,skipPermissions:Te,lastUpdated:new Date().toISOString()},je={permissionMode:ze,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(ae)),localStorage.setItem("cursor-tools-settings",JSON.stringify(be)),localStorage.setItem("codex-settings",JSON.stringify(je)),C("success"),setTimeout(()=>{t()},1e3)}catch(ae){console.error("Error saving tool settings:",ae),C("error")}finally{w(!1)}},zn=()=>{F({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),P(null),_(!1),J("")},Mi=(ae=null)=>{ae?(P(ae),F({name:ae.name,type:ae.type,scope:ae.scope,projectPath:ae.projectPath||"",config:{...ae.config},raw:ae.raw,importMode:"form",jsonInput:""})):zn(),_(!0)},Dl=async ae=>{ae.preventDefault(),B(!0);try{if($.importMode==="json"){const be=await _e("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:$.name,jsonConfig:$.jsonInput,scope:$.scope,projectPath:$.projectPath})});if(be.ok){const je=await be.json();if(je.success)await en(),zn(),C("success");else throw new Error(je.error||"Failed to add server via JSON")}else{const je=await be.json();throw new Error(je.error||"Failed to add server")}}else await tn($),zn(),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}finally{B(!1)}},Or=async(ae,be)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await rr(ae,be),C("success")}catch(je){alert(`Error: ${je.message}`),C("error")}},Hn=async(ae,be)=>{try{V({...W,[ae]:{loading:!0}});const je=await sr(ae,be);V({...W,[ae]:je})}catch(je){V({...W,[ae]:{success:!1,message:je.message,details:[]}})}},Kg=async(ae,be)=>{try{H({...Z,[ae]:!0});const je=await En(ae,be);R({...le,[ae]:je})}catch{R({...le,[ae]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{H({...Z,[ae]:!1})}},ma=(ae,be)=>{F(je=>({...je,config:{...je.config,[ae]:be}}))};return e?i.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[i.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Rt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),i.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:o("title")})]}),i.jsx($e,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.jsx("div",{className:"border-b border-border",children:i.jsxs("div",{className:"flex px-4 md:px-6",children:[i.jsx("button",{onClick:()=>q("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.agents")}),i.jsx("button",{onClick:()=>q("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.appearance")}),i.jsxs("button",{onClick:()=>q("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[i.jsx(fn,{className:"w-4 h-4 inline mr-2"}),o("mainTabs.git")]}),i.jsxs("button",{onClick:()=>q("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[i.jsx(Lf,{className:"w-4 h-4 inline mr-2"}),o("mainTabs.apiTokens")]}),i.jsx("button",{onClick:()=>q("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.tasks")})]})}),i.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[N==="appearance"&&i.jsx("div",{className:"space-y-6 md:space-y-8",children:N==="appearance"&&i.jsxs("div",{className:"space-y-6 md:space-y-8",children:[i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.darkMode.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.darkMode.description")})]}),i.jsxs("button",{onClick:s,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":a,"aria-label":"Toggle dark mode",children:[i.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),i.jsx("span",{className:`${a?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:a?i.jsx(_h,{className:"w-3.5 h-3.5 text-gray-700"}):i.jsx(Oh,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),i.jsx("div",{className:"space-y-4",children:i.jsx(SS,{})}),i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.projectSorting.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.projectSorting.description")})]}),i.jsxs("select",{value:A,onChange:ae=>T(ae.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[i.jsx("option",{value:"name",children:o("appearanceSettings.projectSorting.alphabetical")}),i.jsx("option",{value:"date",children:o("appearanceSettings.projectSorting.recentActivity")})]})]})})}),i.jsxs("div",{className:"space-y-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o("appearanceSettings.codeEditor.title")}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.theme.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.theme.description")})]}),i.jsxs("button",{onClick:()=>Ae(pe==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":pe==="dark","aria-label":"Toggle editor theme",children:[i.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),i.jsx("span",{className:`${pe==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:pe==="dark"?i.jsx(_h,{className:"w-3.5 h-3.5 text-gray-700"}):i.jsx(Oh,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.wordWrap.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.wordWrap.description")})]}),i.jsxs("button",{onClick:()=>Ye(!Re),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Re,"aria-label":"Toggle word wrap",children:[i.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),i.jsx("span",{className:`${Re?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.showMinimap.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.showMinimap.description")})]}),i.jsxs("button",{onClick:()=>at(!Ze),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ze,"aria-label":"Toggle minimap",children:[i.jsx("span",{className:"sr-only",children:"Toggle minimap"}),i.jsx("span",{className:`${Ze?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.lineNumbers.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.lineNumbers.description")})]}),i.jsxs("button",{onClick:()=>Qe(!st),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":st,"aria-label":"Toggle line numbers",children:[i.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),i.jsx("span",{className:`${st?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.fontSize.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.fontSize.description")})]}),i.jsxs("select",{value:Be,onChange:ae=>tt(ae.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[i.jsx("option",{value:"10",children:"10px"}),i.jsx("option",{value:"11",children:"11px"}),i.jsx("option",{value:"12",children:"12px"}),i.jsx("option",{value:"13",children:"13px"}),i.jsx("option",{value:"14",children:"14px"}),i.jsx("option",{value:"15",children:"15px"}),i.jsx("option",{value:"16",children:"16px"}),i.jsx("option",{value:"18",children:"18px"}),i.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),N==="git"&&i.jsx(y8,{}),N==="agents"&&i.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[i.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"flex",children:[i.jsx($a,{agentId:"claude",authStatus:De,isSelected:Q==="claude",onClick:()=>ne("claude"),isMobile:!0}),i.jsx($a,{agentId:"cursor",authStatus:fe,isSelected:Q==="cursor",onClick:()=>ne("cursor"),isMobile:!0}),i.jsx($a,{agentId:"codex",authStatus:St,isSelected:Q==="codex",onClick:()=>ne("codex"),isMobile:!0})]})}),i.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"p-2",children:[i.jsx($a,{agentId:"claude",authStatus:De,isSelected:Q==="claude",onClick:()=>ne("claude")}),i.jsx($a,{agentId:"cursor",authStatus:fe,isSelected:Q==="cursor",onClick:()=>ne("cursor")}),i.jsx($a,{agentId:"codex",authStatus:St,isSelected:Q==="codex",onClick:()=>ne("codex")})]})}),i.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[i.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[i.jsx("button",{onClick:()=>se("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.account")}),i.jsx("button",{onClick:()=>se("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.permissions")}),i.jsx("button",{onClick:()=>se("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.mcpServers")})]})}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[he==="account"&&i.jsx(S8,{agent:Q,authStatus:Q==="claude"?De:Q==="cursor"?fe:St,onLogin:Q==="claude"?_l:Q==="cursor"?Rl:Ts}),he==="permissions"&&Q==="claude"&&i.jsx(Gl,{agent:"claude",skipPermissions:g,setSkipPermissions:v,allowedTools:l,setAllowedTools:c,disallowedTools:u,setDisallowedTools:d,newAllowedTool:p,setNewAllowedTool:m,newDisallowedTool:h,setNewDisallowedTool:f}),he==="permissions"&&Q==="cursor"&&i.jsx(Gl,{agent:"cursor",skipPermissions:Te,setSkipPermissions:re,allowedCommands:xt,setAllowedCommands:ge,disallowedCommands:rt,setDisallowedCommands:de,newAllowedCommand:ue,setNewAllowedCommand:ve,newDisallowedCommand:Me,setNewDisallowedCommand:qe}),he==="permissions"&&Q==="codex"&&i.jsx(Gl,{agent:"codex",permissionMode:ze,setPermissionMode:Ke}),he==="mcp"&&Q==="claude"&&i.jsx(Wl,{agent:"claude",servers:I,onAdd:()=>Mi(),onEdit:ae=>Mi(ae),onDelete:(ae,be)=>Or(ae,be),onTest:(ae,be)=>Hn(ae,be),onDiscoverTools:(ae,be)=>Kg(ae,be),testResults:W,serverTools:le,toolsLoading:Z}),he==="mcp"&&Q==="cursor"&&i.jsx(Wl,{agent:"cursor",servers:kt,onAdd:()=>{},onEdit:ae=>{},onDelete:ae=>{}}),he==="mcp"&&Q==="codex"&&i.jsx(Wl,{agent:"codex",servers:Oe,onAdd:()=>Oi(),onEdit:ae=>Oi(ae),onDelete:ae=>Al(ae)})]})]})]}),L&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:i.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[i.jsx("h3",{className:"text-lg font-medium text-foreground",children:o(M?"mcpForm.title.edit":"mcpForm.title.add")}),i.jsx($e,{variant:"ghost",size:"sm",onClick:zn,children:i.jsx(_t,{className:"w-4 h-4"})})]}),i.jsxs("form",{onSubmit:Dl,className:"p-4 space-y-4",children:[!M&&i.jsxs("div",{className:"flex gap-2 mb-4",children:[i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${$.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:o("mcpForm.importMode.form")}),i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${$.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:o("mcpForm.importMode.json")})]}),$.importMode==="form"&&M&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[i.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:o("mcpForm.scope.label")}),i.jsxs("div",{className:"flex items-center gap-2",children:[$.scope==="user"?i.jsx(oi,{className:"w-4 h-4"}):i.jsx(na,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm",children:$.scope==="user"?o("mcpForm.scope.userGlobal"):o("mcpForm.scope.projectLocal")}),$.scope==="local"&&$.projectPath&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",$.projectPath]})]}),i.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:o("mcpForm.scope.cannotChange")})]}),$.importMode==="form"&&!M&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.scope.label")," *"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${$.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(oi,{className:"w-4 h-4"}),i.jsx("span",{children:o("mcpForm.scope.userGlobal")})]})}),i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${$.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(na,{className:"w-4 h-4"}),i.jsx("span",{children:o("mcpForm.scope.projectLocal")})]})})]}),i.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:$.scope==="user"?o("mcpForm.scope.userDescription"):o("mcpForm.scope.projectDescription")})]}),$.scope==="local"&&!M&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.selectProject")," *"]}),i.jsxs("select",{value:$.projectPath,onChange:ae=>F(be=>({...be,projectPath:ae.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:$.scope==="local",children:[i.jsxs("option",{value:"",children:[o("mcpForm.fields.selectProject"),"..."]}),r.map(ae=>i.jsx("option",{value:ae.path||ae.fullPath,children:ae.displayName||ae.name},ae.name))]}),$.projectPath&&i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o("mcpForm.projectPath",{path:$.projectPath})})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:$.importMode==="json"?"md:col-span-2":"",children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.serverName")," *"]}),i.jsx(Ft,{value:$.name,onChange:ae=>{F(be=>({...be,name:ae.target.value}))},placeholder:o("mcpForm.placeholders.serverName"),required:!0})]}),$.importMode==="form"&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.transportType")," *"]}),i.jsxs("select",{value:$.type,onChange:ae=>{F(be=>({...be,type:ae.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[i.jsx("option",{value:"stdio",children:"stdio"}),i.jsx("option",{value:"sse",children:"SSE"}),i.jsx("option",{value:"http",children:"HTTP"})]})]})]}),M&&$.raw&&$.importMode==="form"&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:o("mcpForm.configDetails",{configFile:M.scope==="global"?"~/.claude.json":"project config"})}),i.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify($.raw,null,2)})]}),$.importMode==="json"&&i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.jsonConfig")," *"]}),i.jsx("textarea",{value:$.jsonInput,onChange:ae=>{F(be=>({...be,jsonInput:ae.target.value}));try{if(ae.target.value.trim()){const be=JSON.parse(ae.target.value);be.type?be.type==="stdio"&&!be.command?J(o("mcpForm.validation.stdioRequiresCommand")):(be.type==="http"||be.type==="sse")&&!be.url?J(o("mcpForm.validation.httpRequiresUrl",{type:be.type})):J(""):J(o("mcpForm.validation.missingType"))}}catch{ae.target.value.trim()?J(o("mcpForm.validation.invalidJson")):J("")}},className:`w-full px-3 py-2 border ${ie?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
|
|
584
|
+
`;if(typeof document<"u"){const e=document.createElement("style");e.type="text/css",e.innerText=t_,document.head.appendChild(e)}function r_(e){if(!e||typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();let r=!1;try{r=document.execCommand("copy")}catch{r=!1}finally{document.body.removeChild(t)}return r}const Tb="https://auth.openai.com/codex/device";function Nb(e){return typeof e=="string"&&/\bcodex\s+login\b/i.test(e)}function Mf({selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:n=!1,onProcessComplete:a,minimal:s=!1,autoConnect:o=!1}){const{t:l}=Nt("chat"),c=x.useRef(null),u=x.useRef(null),d=x.useRef(null),p=x.useRef(null),[m,h]=x.useState(!1),[f,g]=x.useState(!1),[v,E]=x.useState(!1),[w,k]=x.useState(null),[C,A]=x.useState(!1),[T,I]=x.useState(""),[j,L]=x.useState("idle"),[_,M]=x.useState(!1),P=x.useRef(e),$=x.useRef(t),F=x.useRef(r),X=x.useRef(n),B=x.useRef(a),W=x.useRef("");x.useEffect(()=>{P.current=e,$.current=t,F.current=r,X.current=n,B.current=a});const V=x.useCallback((Q=W.current)=>{if(!Q)return!1;const ne=window.open(Q,"_blank","noopener,noreferrer");if(ne){try{ne.opener=null}catch{}return!0}return!1},[]),le=x.useCallback(async(Q=W.current)=>{if(!Q)return!1;let ne=!1;try{typeof navigator<"u"&&navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(Q),ne=!0)}catch{ne=!1}return ne||(ne=r_(Q)),ne},[]),R=x.useCallback(async()=>{if(!(C||m))try{let Q;if(!iA){const ne=localStorage.getItem("auth-token");if(!ne){console.error("No authentication token found for Shell WebSocket connection");return}Q=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ne)}`}p.current=new WebSocket(Q),p.current.onopen=()=>{h(!0),A(!1),W.current="",I(""),L("idle"),M(!1),setTimeout(()=>{d.current&&u.current&&(d.current.fit(),p.current.send(JSON.stringify({type:"init",projectPath:P.current.fullPath||P.current.path,sessionId:X.current?null:$.current?.id,hasSession:X.current?!1:!!$.current,provider:X.current?"plain-shell":$.current?.__provider||"claude",cols:u.current.cols,rows:u.current.rows,initialCommand:F.current,isPlainShell:X.current})))},100)},p.current.onmessage=ne=>{try{const he=JSON.parse(ne.data);if(he.type==="output"){let se=he.data;if(X.current&&B.current){const pe=se.replace(/\x1b\[[0-9;]*m/g,"");if(pe.includes("Process exited with code 0"))B.current(0);else if(pe.match(/Process exited with code (\d+)/)){const Ae=parseInt(pe.match(/Process exited with code (\d+)/)[1]);Ae!==0&&B.current(Ae)}}u.current&&u.current.write(se)}else(he.type==="auth_url"&&he.url||he.type==="url_open"&&he.url)&&(W.current=he.url,I(he.url),L("idle"),M(!1))}catch(he){console.error("[Shell] Error handling WebSocket message:",he,ne.data)}},p.current.onclose=ne=>{h(!1),A(!1),L("idle"),M(!1),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H"))},p.current.onerror=ne=>{h(!1),A(!1)}}catch{h(!1),A(!1)}},[C,m,V]),Z=x.useCallback(()=>{!f||m||C||(A(!0),R())},[f,m,C,R]),H=x.useCallback(()=>{p.current&&(p.current.close(),p.current=null),u.current&&(u.current.clear(),u.current.write("\x1B[2J\x1B[H")),h(!1),A(!1),W.current="",I(""),L("idle"),M(!1)},[]),N=x.useMemo(()=>t?t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session":null,[t]),q=x.useMemo(()=>N?N.slice(0,30):null,[N]),ie=x.useMemo(()=>N?N.slice(0,50):null,[N]),J=()=>{E(!0),p.current&&(p.current.close(),p.current=null),u.current&&(u.current.dispose(),u.current=null,d.current=null),h(!1),g(!1),W.current="",I(""),L("idle"),M(!1),setTimeout(()=>{E(!1)},200)};if(x.useEffect(()=>{const Q=t?.id||null;w!==null&&w!==Q&&f&&H(),k(Q)},[t?.id,f,H]),x.useEffect(()=>{if(!c.current||!e||v||u.current)return;u.current=new XI.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),d.current=new ZI.FitAddon;const Q=new QI.WebglAddon,ne=new e_.WebLinksAddon;u.current.loadAddon(d.current),s||u.current.loadAddon(ne);try{u.current.loadAddon(Q)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}u.current.open(c.current),u.current.attachCustomKeyEventHandler(se=>{const pe=Nb(F.current)?Tb:W.current;return se.type==="keydown"&&s&&X.current&&pe&&!se.ctrlKey&&!se.metaKey&&!se.altKey&&se.key?.toLowerCase()==="c"&&le(pe).catch(()=>{}),se.type==="keydown"&&(se.ctrlKey||se.metaKey)&&se.key?.toLowerCase()==="c"&&u.current.hasSelection()?(se.preventDefault(),se.stopPropagation(),document.execCommand("copy"),!1):se.type==="keydown"&&(se.ctrlKey||se.metaKey)&&se.key?.toLowerCase()==="v"?(se.preventDefault(),se.stopPropagation(),navigator.clipboard.readText().then(Ae=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:Ae}))}).catch(()=>{}),!1):!0}),setTimeout(()=>{d.current&&(d.current.fit(),u.current&&p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows})))},100),g(!0),u.current.onData(se=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"input",data:se}))});const he=new ResizeObserver(()=>{d.current&&u.current&&setTimeout(()=>{d.current.fit(),p.current&&p.current.readyState===WebSocket.OPEN&&p.current.send(JSON.stringify({type:"resize",cols:u.current.cols,rows:u.current.rows}))},50)});return c.current&&he.observe(c.current),()=>{he.disconnect(),p.current&&(p.current.readyState===WebSocket.OPEN||p.current.readyState===WebSocket.CONNECTING)&&p.current.close(),p.current=null,u.current&&(u.current.dispose(),u.current=null)}},[e?.path||e?.fullPath,v,s,le]),x.useEffect(()=>{!o||!f||C||m||Z()},[o,f,C,m,Z]),!e)return i.jsx("div",{className:"h-full flex items-center justify-center",children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),i.jsx("h3",{className:"text-lg font-semibold mb-2",children:l("shell.selectProject.title")}),i.jsx("p",{children:l("shell.selectProject.description")})]})});if(s){const Q=Nb(r)?Tb:T,ne=!!Q,he=ne&&!_,se=ne&&_;return i.jsxs("div",{className:"h-full w-full bg-gray-900 relative",children:[i.jsx("div",{ref:c,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),he&&i.jsx("div",{className:"absolute inset-x-0 bottom-14 z-20 border-t border-gray-700/80 bg-gray-900/95 p-3 backdrop-blur-sm md:hidden",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),i.jsx("button",{type:"button",onClick:()=>M(!0),className:"rounded bg-gray-700 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-gray-100 hover:bg-gray-600",children:"Hide"})]}),i.jsx("input",{type:"text",value:Q,readOnly:!0,onClick:pe=>pe.currentTarget.select(),className:"w-full rounded border border-gray-600 bg-gray-800 px-2 py-1 text-xs text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500","aria-label":"Authentication URL"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>{V(Q)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),i.jsx("button",{type:"button",onClick:async()=>{const pe=await le(Q);L(pe?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:j==="copied"?"Copied":"Copy URL"})]})]})}),se&&i.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:i.jsx("button",{type:"button",onClick:()=>M(!1),className:"rounded bg-gray-800/95 px-3 py-2 text-xs font-medium text-gray-100 shadow-lg backdrop-blur-sm hover:bg-gray-700",children:"Show login URL"})})]})}return i.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[i.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-green-500":"bg-red-500"}`}),t&&i.jsxs("span",{className:"text-xs text-blue-300",children:["(",q,"...)"]}),!t&&i.jsx("span",{className:"text-xs text-gray-400",children:l("shell.status.newSession")}),!f&&i.jsx("span",{className:"text-xs text-yellow-400",children:l("shell.status.initializing")}),v&&i.jsx("span",{className:"text-xs text-blue-400",children:l("shell.status.restarting")})]}),i.jsxs("div",{className:"flex items-center space-x-3",children:[m&&i.jsxs("button",{onClick:H,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:l("shell.actions.disconnectTitle"),children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),i.jsx("span",{children:l("shell.actions.disconnect")})]}),i.jsxs("button",{onClick:J,disabled:v||m,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:l("shell.actions.restartTitle"),children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),i.jsx("span",{children:l("shell.actions.restart")})]})]})]})}),i.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[i.jsx("div",{ref:c,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!f&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:i.jsx("div",{className:"text-white",children:l("shell.loading")})}),f&&!m&&!C&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:i.jsxs("div",{className:"text-center max-w-sm w-full",children:[i.jsxs("button",{onClick:Z,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:l("shell.actions.connectTitle"),children:[i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),i.jsx("span",{children:l("shell.actions.connect")})]}),i.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:n?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):t?l("shell.resumeSession",{displayName:ie}):l("shell.startSession")})]})}),C&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:i.jsxs("div",{className:"text-center max-w-sm w-full",children:[i.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[i.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),i.jsx("span",{className:"text-base font-medium",children:l("shell.connecting")})]}),i.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:n?l("shell.runCommand",{command:r||l("shell.defaultCommand"),projectName:e.displayName}):l("shell.startCli",{projectName:e.displayName})})]})})]})]})}function oS({project:e,session:t=null,command:r=null,isPlainShell:n=null,autoConnect:a=!0,onComplete:s=null,onClose:o=null,title:l=null,className:c="",showHeader:u=!0,compact:d=!1,minimal:p=!1}){const[m,h]=x.useState(!1),f=n!==null?n:r!==null,g=x.useCallback(v=>{h(!0),s&&s(v)},[s]);return e?i.jsxs("div",{className:`h-full w-full flex flex-col ${c}`,children:[!p&&u&&l&&i.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center space-x-2",children:[i.jsx("h3",{className:"text-sm font-medium text-gray-200",children:l}),m&&i.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),o&&i.jsx("button",{onClick:o,className:"text-gray-400 hover:text-white",title:"Close",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),i.jsx("div",{className:"flex-1 w-full min-h-0",children:i.jsx(Mf,{selectedProject:e,selectedSession:t,initialCommand:r,isPlainShell:f,onProcessComplete:g,minimal:p,autoConnect:p?!0:a})})]}):i.jsx("div",{className:`h-full flex items-center justify-center ${c}`,children:i.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),i.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),i.jsx("p",{children:"A project is required to open a shell"})]})})}function lS({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:a,customCommand:s,isAuthenticated:o=!1,isOnboarding:l=!1}){if(!e)return null;const c=()=>{if(s)return s;switch(r){case"claude":return o?"claude setup-token --dangerously-skip-permissions":l?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return"codex login";default:return o?"claude setup-token --dangerously-skip-permissions":l?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions"}},u=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},d=p=>{a&&a(p)};return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999] max-md:items-stretch max-md:justify-stretch",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-4xl h-3/4 flex flex-col md:max-w-4xl md:h-3/4 md:rounded-lg md:m-4 max-md:max-w-none max-md:h-full max-md:rounded-none max-md:m-0",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:u()}),i.jsx("button",{onClick:t,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:i.jsx(_t,{className:"w-6 h-6"})})]}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(oS,{project:n,command:c(),onComplete:d,minimal:!0})})]})})}const n_=({onComplete:e})=>{const[t,r]=x.useState(0),[n,a]=x.useState(""),[s,o]=x.useState(""),[l,c]=x.useState(!1),[u,d]=x.useState(""),[p,m]=x.useState(null),[h]=x.useState({name:"default",fullPath:""}),[f,g]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[v,E]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[w,k]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:C}=ps(),A=x.useRef(void 0);x.useEffect(()=>{T()},[]);const T=async()=>{try{const R=await _e("/api/user/git-config");if(R.ok){const Z=await R.json();Z.gitName&&a(Z.gitName),Z.gitEmail&&o(Z.gitEmail)}}catch(R){console.error("Error loading git config:",R)}};x.useEffect(()=>{const R=A.current;A.current=p,(R===void 0||R!==null&&p===null)&&(I(),j(),L())},[p]);const I=async()=>{try{const R=await _e("/api/cli/claude/status");if(R.ok){const Z=await R.json();g({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else g({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Claude auth status:",R),g({authenticated:!1,email:null,loading:!1,error:R.message})}},j=async()=>{try{const R=await _e("/api/cli/cursor/status");if(R.ok){const Z=await R.json();E({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else E({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Cursor auth status:",R),E({authenticated:!1,email:null,loading:!1,error:R.message})}},L=async()=>{try{const R=await _e("/api/cli/codex/status");if(R.ok){const Z=await R.json();k({authenticated:Z.authenticated,email:Z.email,loading:!1,error:Z.error||null})}else k({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(R){console.error("Error checking Codex auth status:",R),k({authenticated:!1,email:null,loading:!1,error:R.message})}},_=()=>m("claude"),M=()=>m("cursor"),P=()=>m("codex"),$=R=>{R===0&&(p==="claude"?I():p==="cursor"?j():p==="codex"&&L())},F=async()=>{if(d(""),t===0){if(!n.trim()||!s.trim()){d("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)){d("Please enter a valid email address");return}c(!0);try{const Z=await _e("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:n,gitEmail:s})});if(!Z.ok){const H=await Z.json();throw new Error(H.error||"Failed to save git configuration")}r(t+1)}catch(Z){d(Z.message)}finally{c(!1)}return}r(t+1)},X=()=>{d(""),r(t-1)},B=async()=>{c(!0),d("");try{const R=await _e("/api/user/complete-onboarding",{method:"POST"});if(!R.ok){const Z=await R.json();throw new Error(Z.error||"Failed to complete onboarding")}e&&e()}catch(R){d(R.message)}finally{c(!1)}},W=[{title:"Git Configuration",description:"Set up your git identity for commits",icon:fn,required:!0},{title:"Connect Agents",description:"Connect your AI coding assistants",icon:tS,required:!1}],V=()=>{switch(t){case 0:return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(fn,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),i.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Git Configuration"}),i.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for your commits"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[i.jsx(qI,{className:"w-4 h-4"}),"Git Name ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",id:"gitName",value:n,onChange:R=>a(R.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"John Doe",required:!0,disabled:l}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.name"})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[i.jsx(K6,{className:"w-4 h-4"}),"Git Email ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",id:"gitEmail",value:s,onChange:R=>o(R.target.value),className:"w-full px-4 py-3 border border-border rounded-lg bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"john@example.com",required:!0,disabled:l}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"This will be used as: git config --global user.email"})]})]})]});case 1:return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"text-center mb-6",children:[i.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Connect Your AI Agents"}),i.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${f.authenticated?"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center",children:i.jsx(aS,{size:20})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Claude Code",f.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:f.loading?"Checking...":f.authenticated?f.email||"Connected":"Not connected"})]})]}),!f.authenticated&&!f.loading&&i.jsx("button",{onClick:_,className:"bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${v.authenticated?"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/30 rounded-full flex items-center justify-center",children:i.jsx(sS,{size:20})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["Cursor",v.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:v.loading?"Checking...":v.authenticated?v.email||"Connected":"Not connected"})]})]}),!v.authenticated&&!v.loading&&i.jsx("button",{onClick:M,className:"bg-purple-600 hover:bg-purple-700 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})}),i.jsx("div",{className:`border rounded-lg p-4 transition-colors ${w.authenticated?"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600":"border-border bg-card"}`,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:i.jsx(iS,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-foreground flex items-center gap-2",children:["OpenAI Codex",w.authenticated&&i.jsx(lr,{className:"w-4 h-4 text-green-500"})]}),i.jsx("div",{className:"text-xs text-muted-foreground",children:w.loading?"Checking...":w.authenticated?w.email||"Connected":"Not connected"})]})]}),!w.authenticated&&!w.loading&&i.jsx("button",{onClick:P,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white text-sm font-medium py-2 px-4 rounded-lg transition-colors",children:"Login"})]})})]}),i.jsx("div",{className:"text-center text-sm text-muted-foreground pt-2",children:i.jsx("p",{children:"You can configure these later in Settings."})})]});default:return null}},le=()=>{switch(t){case 0:return n.trim()&&s.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);case 1:return!0;default:return!1}};return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-2xl",children:[i.jsx("div",{className:"mb-8",children:i.jsx("div",{className:"flex items-center justify-between",children:W.map((R,Z)=>i.jsxs(Xt.Fragment,{children:[i.jsxs("div",{className:"flex flex-col items-center flex-1",children:[i.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center border-2 transition-colors duration-200 ${Z<t?"bg-green-500 border-green-500 text-white":Z===t?"bg-blue-600 border-blue-600 text-white":"bg-background border-border text-muted-foreground"}`,children:Z<t?i.jsx(lr,{className:"w-6 h-6"}):typeof R.icon=="function"?i.jsx(R.icon,{}):i.jsx(R.icon,{className:"w-6 h-6"})}),i.jsxs("div",{className:"mt-2 text-center",children:[i.jsx("p",{className:`text-sm font-medium ${Z===t?"text-foreground":"text-muted-foreground"}`,children:R.title}),R.required&&i.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),Z<W.length-1&&i.jsx("div",{className:`flex-1 h-0.5 mx-2 transition-colors duration-200 ${Z<t?"bg-green-500":"bg-border"}`})]},Z))})}),i.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8",children:[V(),u&&i.jsx("div",{className:"mt-6 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-lg",children:i.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),i.jsxs("div",{className:"flex items-center justify-between mt-8 pt-6 border-t border-border",children:[i.jsxs("button",{onClick:X,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",children:[i.jsx(Of,{className:"w-4 h-4"}),"Previous"]}),i.jsx("div",{className:"flex items-center gap-3",children:t<W.length-1?i.jsx("button",{onClick:F,disabled:!le()||l,className:"flex items-center gap-2 px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:l?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):i.jsxs(i.Fragment,{children:["Next",i.jsx(Xr,{className:"w-4 h-4"})]})}):i.jsx("button",{onClick:B,disabled:l,className:"flex items-center gap-2 px-6 py-3 bg-green-600 hover:bg-green-700 disabled:bg-green-400 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors duration-200",children:l?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),"Completing..."]}):i.jsxs(i.Fragment,{children:[i.jsx(lr,{className:"w-4 h-4"}),"Complete Setup"]})})})]})]})]})}),p&&i.jsx(lS,{isOpen:!!p,onClose:()=>m(null),provider:p,project:h,onComplete:$,isOnboarding:!0})]})},a_=()=>i.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex justify-center mb-4",children:i.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:i.jsx(nl,{className:"w-8 h-8 text-primary-foreground"})})}),i.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"Claude Code UI"}),i.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce"}),i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),i.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),i.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}),s_=({children:e})=>{const{user:t,isLoading:r,needsSetup:n,hasCompletedOnboarding:a,refreshOnboardingStatus:s}=ps();return r?i.jsx(a_,{}):n?i.jsx(mA,{}):t?a?e:i.jsx(n_,{onComplete:s}):i.jsx(KI,{})},Cb=e=>typeof window>"u"?!1:window.innerWidth<e,Ab=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function Pf(e={}){const{mobileBreakpoint:t=768,trackMobile:r=!0,trackPWA:n=!0}=e,[a,s]=x.useState(()=>r?Cb(t):!1),[o,l]=x.useState(()=>n?Ab():!1);return x.useEffect(()=>{if(!r||typeof window>"u")return;const c=()=>{s(Cb(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,r]),x.useEffect(()=>{if(!n||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),u=()=>{l(Ab())};return u(),typeof c.addEventListener=="function"?(c.addEventListener("change",u),()=>{c.removeEventListener("change",u)}):(c.addListener(u),()=>{c.removeListener(u)})},[n]),{isMobile:a,isPWA:o}}const Lh="1.19.1",i_=(e,t)=>{const r=e.split(".").map(Number),n=t.split(".").map(Number);for(let a=0;a<Math.max(r.length,n.length);a++){const s=r[a]||0,o=n[a]||0;if(s!==o)return s-o}return 0},cS=(e,t)=>{const[r,n]=x.useState(!1),[a,s]=x.useState(null),[o,l]=x.useState(null);return x.useEffect(()=>{const c=async()=>{try{const p=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`)).json();if(p.tag_name){const m=p.tag_name.replace(/^v/,"");s(m),n(i_(m,Lh)>0),l({title:p.name||p.tag_name,body:p.body||"",htmlUrl:p.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:p.published_at})}else n(!1),s(null),l(null)}catch(d){console.error("Version check failed:",d),n(!1),s(null),l(null)}};c();const u=setInterval(c,300*1e3);return()=>clearInterval(u)},[e,t]),{updateAvailable:r,latestVersion:a,currentVersion:Lh,releaseInfo:o}},xa={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},Ro=Object.keys(xa),o_=new Set(Ro),zl="ui-preferences:sync",Oo=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},l_=(e,t)=>{try{const r=localStorage.getItem(e);if(r===null)return t;const n=JSON.parse(r);return Oo(n,t)}catch{return t}},c_=e=>{if(typeof window>"u")return xa;try{const t=localStorage.getItem(e);if(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r)){const n=r;return Ro.reduce((a,s)=>(a[s]=Oo(n[s],xa[s]),a),{...xa})}}}catch{}return Ro.reduce((t,r)=>(t[r]=l_(r,xa[r]),t),{...xa})};function u_(e,t){switch(t.type){case"set":{const{key:r,value:n}=t;if(!o_.has(r))return e;const a=Oo(n,e[r]);return e[r]===a?e:{...e,[r]:a}}case"set_many":{const r=t.value||{};let n=!1;const a={...e};for(const s of Ro){if(!(s in r))continue;const o=r[s],l=Oo(o,e[s]);a[s]!==l&&(a[s]=l,n=!0)}return n?a:e}case"reset":return{...xa,...t.value||{}};default:return e}}function Ff(e="uiPreferences"){const t=x.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[r,n]=x.useReducer(u_,e,c_);return x.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(zl,{detail:{storageKey:e,sourceId:t.current,value:r}})))},[r,e]),x.useEffect(()=>{if(typeof window>"u")return;const l=d=>{!d||typeof d!="object"||Array.isArray(d)||n({type:"set_many",value:d})},c=d=>{if(!(d.key!==e||d.newValue===null))try{const p=JSON.parse(d.newValue);l(p)}catch{}},u=d=>{const m=d.detail;!m||m.storageKey!==e||m.sourceId===t.current||l(m.value)};return window.addEventListener("storage",c),window.addEventListener(zl,u),()=>{window.removeEventListener("storage",c),window.removeEventListener(zl,u)}},[e]),{preferences:r,setPreference:(l,c)=>{n({type:"set",key:l,value:c})},setPreferences:l=>{n({type:"set_many",value:l})},resetPreferences:l=>{n({type:"reset",value:l})},dispatch:n}}const d_=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},p_=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},m_=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Lo=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||0),h_=(e,t)=>e.__provider==="cursor"?e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.summary||t("projects.newSession"),f_=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||""),g_=(e,t,r)=>{const n=Lo(e),a=Math.floor((t.getTime()-n.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isActive:a<10,sessionName:h_(e,r),sessionTime:f_(e),messageCount:Number(e.messageCount||0)}},uS=(e,t)=>{const r=[...e.sessions||[],...t[e.name]||[]].map(s=>({...s,__provider:"claude"})),n=(e.cursorSessions||[]).map(s=>({...s,__provider:"cursor"})),a=(e.codexSessions||[]).map(s=>({...s,__provider:"codex"}));return[...r,...n,...a].sort((s,o)=>Lo(o).getTime()-Lo(s).getTime())},Ib=(e,t)=>{const r=uS(e,t);return r.length===0?new Date(0):r.reduce((n,a)=>{const s=Lo(a);return s>n?s:n},new Date(0))},b_=(e,t,r,n)=>{const a=[...e];return a.sort((s,o)=>{const l=r.has(s.name),c=r.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?Ib(o,n).getTime()-Ib(s,n).getTime():(s.displayName||s.name).localeCompare(o.displayName||o.name)}),a},x_=(e,t)=>{const r=t.trim().toLowerCase();return r?e.filter(n=>{const a=(n.displayName||n.name).toLowerCase(),s=n.name.toLowerCase();return a.includes(r)||s.includes(r)}):e},y_=(e,t)=>{const r=!!e.taskmaster?.hasTaskmaster,n=!!(t?.hasMCPServer&&t?.isConfigured);return r&&n?"fully-configured":r?"taskmaster-only":n?"mcp-only":"not-configured"},v_=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function k_({projects:e,selectedProject:t,selectedSession:r,isLoading:n,isMobile:a,t:s,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:u,onProjectDelete:d,setCurrentProject:p,setSidebarVisible:m,sidebarVisible:h}){const[f,g]=x.useState(new Set),[v,E]=x.useState(null),[w,k]=x.useState(!1),[C,A]=x.useState(""),[T,I]=x.useState({}),[j,L]=x.useState({}),[_,M]=x.useState(new Set),[P,$]=x.useState(new Date),[F,X]=x.useState("name"),[B,W]=x.useState(!1),[V,le]=x.useState({}),[R,Z]=x.useState(null),[H,N]=x.useState(""),[q,ie]=x.useState(""),[J,Q]=x.useState(new Set),[ne,he]=x.useState(null),[se,pe]=x.useState(null),[Ae,Re]=x.useState(!1),[Ye,Ze]=x.useState(()=>p_()),at=!a&&!h;x.useEffect(()=>{const ye=setInterval(()=>{$(new Date)},6e4);return()=>clearInterval(ye)},[]),x.useEffect(()=>{L({}),M(new Set),le({})},[e]),x.useEffect(()=>{t&&g(ye=>{if(ye.has(t.name))return ye;const Ie=new Set(ye);return Ie.add(t.name),Ie})},[r,t]),x.useEffect(()=>{if(e.length>0&&!n){const ye=new Set;e.forEach(Ie=>{Ie.sessions&&Ie.sessions.length>=0&&ye.add(Ie.name)}),M(ye)}},[e,n]),x.useEffect(()=>{const ye=()=>{X(d_())};ye();const Ie=yt=>{yt.key==="claude-settings"&&ye()};window.addEventListener("storage",Ie);const pt=setInterval(()=>{document.hasFocus()&&ye()},1e3);return()=>{window.removeEventListener("storage",Ie),clearInterval(pt)}},[]);const st=x.useCallback(ye=>Ie=>{const pt=Ie.target;pt.closest(".overflow-y-auto")||pt.closest("[data-scroll-container]")||(Ie.preventDefault(),Ie.stopPropagation(),ye())},[]),Qe=x.useCallback(ye=>{g(Ie=>{const pt=new Set;return Ie.has(ye)||pt.add(ye),pt})},[]),Be=x.useCallback((ye,Ie)=>{c({...ye,__projectName:Ie})},[c]),tt=x.useCallback(ye=>{Ze(Ie=>{const pt=new Set(Ie);return pt.has(ye)?pt.delete(ye):pt.add(ye),m_(pt),pt})},[]),xt=x.useCallback(ye=>Ye.has(ye),[Ye]),ge=x.useCallback(ye=>uS(ye,j),[j]),rt=x.useMemo(()=>e.map(ye=>{const Ie=V[ye.name];return Ie===void 0?ye:{...ye,sessionMeta:{...ye.sessionMeta,hasMore:Ie}}}),[V,e]),de=x.useMemo(()=>b_(rt,F,Ye,j),[j,F,rt,Ye]),Te=x.useMemo(()=>x_(de,q),[q,de]),re=x.useCallback(ye=>{E(ye.name),A(ye.displayName)},[]),ue=x.useCallback(()=>{E(null),A("")},[]),ve=x.useCallback(async ye=>{try{(await bt.renameProject(ye,C)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Ie){console.error("Error renaming project:",Ie)}finally{E(null),A("")}},[C]),Me=x.useCallback((ye,Ie,pt,yt="claude")=>{pe({projectName:ye,sessionId:Ie,sessionTitle:pt,provider:yt})},[]),qe=x.useCallback(async()=>{if(!se)return;const{projectName:ye,sessionId:Ie,provider:pt}=se;pe(null);try{const yt=pt==="codex"?await bt.deleteCodexSession(Ie):await bt.deleteSession(ye,Ie);if(yt.ok)u?.(Ie);else{const qt=await yt.text();console.error("[Sidebar] Failed to delete session:",{status:yt.status,error:qt}),alert(s("messages.deleteSessionFailed"))}}catch(yt){console.error("[Sidebar] Error deleting session:",yt),alert(s("messages.deleteSessionError"))}},[u,se,s]),kt=x.useCallback(ye=>{he({project:ye,sessionCount:ge(ye).length})},[ge]),ht=x.useCallback(async()=>{if(!ne)return;const{project:ye,sessionCount:Ie}=ne,pt=Ie===0;he(null),Q(yt=>new Set([...yt,ye.name]));try{const yt=await bt.deleteProject(ye.name,!pt);if(yt.ok)d?.(ye.name);else{const qt=await yt.json();alert(qt.error||s("messages.deleteProjectFailed"))}}catch(yt){console.error("Error deleting project:",yt),alert(s("messages.deleteProjectError"))}finally{Q(yt=>{const qt=new Set(yt);return qt.delete(ye.name),qt})}},[ne,d,s]),Oe=x.useCallback(async ye=>{const Ie=V[ye.name];if(!(!(Ie!==void 0?Ie:ye.sessionMeta?.hasMore===!0)||T[ye.name])){I(yt=>({...yt,[ye.name]:!0}));try{const yt=(ye.sessions?.length||0)+(j[ye.name]?.length||0),qt=await bt.sessions(ye.name,5,yt);if(!qt.ok)return;const wr=await qt.json();L(pr=>({...pr,[ye.name]:[...pr[ye.name]||[],...wr.sessions||[]]})),wr.hasMore===!1&&le(pr=>({...pr,[ye.name]:!1}))}catch(yt){console.error("Error loading more sessions:",yt)}finally{I(yt=>({...yt,[ye.name]:!1}))}}},[j,T,V]),Xe=x.useCallback(ye=>{l(ye),p(ye)},[l,p]),ze=x.useCallback(async()=>{W(!0);try{await o()}finally{W(!1)}},[o]),Ke=x.useCallback(async(ye,Ie,pt)=>{Z(null),N("")},[]),lt=x.useCallback(()=>{m(!1)},[m]),et=x.useCallback(()=>{m(!0)},[m]);return{isSidebarCollapsed:at,expandedProjects:f,editingProject:v,showNewProject:w,editingName:C,loadingSessions:T,additionalSessions:j,initialSessionsLoaded:_,currentTime:P,projectSortOrder:F,isRefreshing:B,editingSession:R,editingSessionName:H,searchFilter:q,deletingProjects:J,deleteConfirmation:ne,sessionDeleteConfirmation:se,showVersionModal:Ae,starredProjects:Ye,filteredProjects:Te,handleTouchClick:st,toggleProject:Qe,handleSessionClick:Be,toggleStarProject:tt,isProjectStarred:xt,getProjectSessions:ge,startEditing:re,cancelEditing:ue,saveProjectName:ve,showDeleteSessionConfirmation:Me,confirmDeleteSession:qe,requestProjectDelete:kt,confirmDeleteProject:ht,loadMoreSessions:Oe,handleProjectSelect:Xe,refreshProjects:ze,updateSessionSummary:Ke,collapseSidebar:lt,expandSidebar:et,setShowNewProject:k,setEditingName:A,setEditingSession:Z,setEditingSessionName:N,setSearchFilter:ie,setDeleteConfirmation:he,setSessionDeleteConfirmation:pe,setShowVersionModal:Re}}function w_({onExpand:e,onShowSettings:t,updateAvailable:r,onShowVersionModal:n,t:a}){return i.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[i.jsx("button",{onClick:e,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:i.jsx(dI,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),i.jsx("div",{className:"nav-divider w-6 my-1"}),i.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":a("actions.settings"),title:a("actions.settings"),children:i.jsx(Rt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),r&&i.jsxs("button",{onClick:n,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[i.jsx(_n,{className:"w-4 h-4 text-blue-500"}),i.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function dS(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=dS(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function pS(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=dS(e))&&(n&&(n+=" "),n+=t);return n}const Bf="-",E_=e=>{const t=T_(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:o=>{const l=o.split(Bf);return l[0]===""&&l.length!==1&&l.shift(),mS(l,t)||S_(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&n[o]?[...c,...n[o]]:c}}},mS=(e,t)=>{if(e.length===0)return t.classGroupId;const r=e[0],n=t.nextPart.get(r),a=n?mS(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const s=e.join(Bf);return t.validators.find(({validator:o})=>o(s))?.classGroupId},_b=/^\[(.+)\]$/,S_=e=>{if(_b.test(e)){const t=_b.exec(e)[1],r=t?.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},T_=e=>{const{theme:t,classGroups:r}=e,n={nextPart:new Map,validators:[]};for(const a in r)Dh(r[a],n,a,t);return n},Dh=(e,t,r,n)=>{e.forEach(a=>{if(typeof a=="string"){const s=a===""?t:Rb(t,a);s.classGroupId=r;return}if(typeof a=="function"){if(N_(a)){Dh(a(n),t,r,n);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([s,o])=>{Dh(o,Rb(t,s),r,n)})})},Rb=(e,t)=>{let r=e;return t.split(Bf).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},N_=e=>e.isThemeGetter,C_=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,n=new Map;const a=(s,o)=>{r.set(s,o),t++,t>e&&(t=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return a(s,o),o},set(s,o){r.has(s)?r.set(s,o):a(s,o)}}},jh="!",Mh=":",A_=Mh.length,I_=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const s=[];let o=0,l=0,c=0,u;for(let f=0;f<a.length;f++){let g=a[f];if(o===0&&l===0){if(g===Mh){s.push(a.slice(c,f)),c=f+A_;continue}if(g==="/"){u=f;continue}}g==="["?o++:g==="]"?o--:g==="("?l++:g===")"&&l--}const d=s.length===0?a:a.substring(c),p=__(d),m=p!==d,h=u&&u>c?u-c:void 0;return{modifiers:s,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:h}};if(t){const a=t+Mh,s=n;n=o=>o.startsWith(a)?s(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(r){const a=n;n=s=>r({className:s,parseClassName:a})}return n},__=e=>e.endsWith(jh)?e.substring(0,e.length-1):e.startsWith(jh)?e.substring(1):e,R_=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const a=[];let s=[];return n.forEach(o=>{o[0]==="["||t[o]?(a.push(...s.sort(),o),s=[]):s.push(o)}),a.push(...s.sort()),a}},O_=e=>({cache:C_(e.cacheSize),parseClassName:I_(e),sortModifiers:R_(e),...E_(e)}),L_=/\s+/,D_=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:s}=t,o=[],l=e.trim().split(L_);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:m,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:g}=r(d);if(p){c=d+(c.length>0?" "+c:c);continue}let v=!!g,E=n(v?f.substring(0,g):f);if(!E){if(!v){c=d+(c.length>0?" "+c:c);continue}if(E=n(f),!E){c=d+(c.length>0?" "+c:c);continue}v=!1}const w=s(m).join(":"),k=h?w+jh:w,C=k+E;if(o.includes(C))continue;o.push(C);const A=a(E,v);for(let T=0;T<A.length;++T){const I=A[T];o.push(k+I)}c=d+(c.length>0?" "+c:c)}return c};function j_(){let e=0,t,r,n="";for(;e<arguments.length;)(t=arguments[e++])&&(r=hS(t))&&(n&&(n+=" "),n+=r);return n}const hS=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=hS(e[n]))&&(r&&(r+=" "),r+=t);return r};function M_(e,...t){let r,n,a,s=o;function o(c){const u=t.reduce((d,p)=>p(d),e());return r=O_(u),n=r.cache.get,a=r.cache.set,s=l,l(c)}function l(c){const u=n(c);if(u)return u;const d=D_(c,r);return a(c,d),d}return function(){return s(j_.apply(null,arguments))}}const Qt=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},fS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,gS=/^\((?:(\w[\w-]*):)?(.+)\)$/i,P_=/^\d+\/\d+$/,F_=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,B_=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,U_=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$_=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,z_=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ua=e=>P_.test(e),vt=e=>!!e&&!Number.isNaN(Number(e)),Wn=e=>!!e&&Number.isInteger(Number(e)),Hl=e=>e.endsWith("%")&&vt(e.slice(0,-1)),Sn=e=>F_.test(e),H_=()=>!0,q_=e=>B_.test(e)&&!U_.test(e),bS=()=>!1,G_=e=>$_.test(e),W_=e=>z_.test(e),V_=e=>!Ge(e)&&!We(e),Y_=e=>hs(e,vS,bS),Ge=e=>fS.test(e),ha=e=>hs(e,kS,q_),ql=e=>hs(e,J_,vt),Ob=e=>hs(e,xS,bS),K_=e=>hs(e,yS,W_),$i=e=>hs(e,wS,G_),We=e=>gS.test(e),Os=e=>fs(e,kS),X_=e=>fs(e,e8),Lb=e=>fs(e,xS),Z_=e=>fs(e,vS),Q_=e=>fs(e,yS),zi=e=>fs(e,wS,!0),hs=(e,t,r)=>{const n=fS.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},fs=(e,t,r=!1)=>{const n=gS.exec(e);return n?n[1]?t(n[1]):r:!1},xS=e=>e==="position"||e==="percentage",yS=e=>e==="image"||e==="url",vS=e=>e==="length"||e==="size"||e==="bg-size",kS=e=>e==="length",J_=e=>e==="number",e8=e=>e==="family-name",wS=e=>e==="shadow",t8=()=>{const e=Qt("color"),t=Qt("font"),r=Qt("text"),n=Qt("font-weight"),a=Qt("tracking"),s=Qt("leading"),o=Qt("breakpoint"),l=Qt("container"),c=Qt("spacing"),u=Qt("radius"),d=Qt("shadow"),p=Qt("inset-shadow"),m=Qt("text-shadow"),h=Qt("drop-shadow"),f=Qt("blur"),g=Qt("perspective"),v=Qt("aspect"),E=Qt("ease"),w=Qt("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],C=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...C(),We,Ge],T=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],j=()=>[We,Ge,c],L=()=>[Ua,"full","auto",...j()],_=()=>[Wn,"none","subgrid",We,Ge],M=()=>["auto",{span:["full",Wn,We,Ge]},Wn,We,Ge],P=()=>[Wn,"auto",We,Ge],$=()=>["auto","min","max","fr",We,Ge],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],X=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...j()],W=()=>[Ua,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...j()],V=()=>[e,We,Ge],le=()=>[...C(),Lb,Ob,{position:[We,Ge]}],R=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Z_,Y_,{size:[We,Ge]}],H=()=>[Hl,Os,ha],N=()=>["","none","full",u,We,Ge],q=()=>["",vt,Os,ha],ie=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[vt,Hl,Lb,Ob],ne=()=>["","none",f,We,Ge],he=()=>["none",vt,We,Ge],se=()=>["none",vt,We,Ge],pe=()=>[vt,We,Ge],Ae=()=>[Ua,"full",...j()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Sn],breakpoint:[Sn],color:[H_],container:[Sn],"drop-shadow":[Sn],ease:["in","out","in-out"],font:[V_],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Sn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Sn],shadow:[Sn],spacing:["px",vt],text:[Sn],"text-shadow":[Sn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ua,Ge,We,v]}],container:["container"],columns:[{columns:[vt,Ge,We,l]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Wn,"auto",We,Ge]}],basis:[{basis:[Ua,"full","auto",l,...j()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[vt,Ua,"auto","initial","none",Ge]}],grow:[{grow:["",vt,We,Ge]}],shrink:[{shrink:["",vt,We,Ge]}],order:[{order:[Wn,"first","last","none",We,Ge]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:M()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":$()}],"auto-rows":[{"auto-rows":$()}],gap:[{gap:j()}],"gap-x":[{"gap-x":j()}],"gap-y":[{"gap-y":j()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...X(),"normal"]}],"justify-self":[{"justify-self":["auto",...X()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...X(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...X(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...X(),"baseline"]}],"place-self":[{"place-self":["auto",...X()]}],p:[{p:j()}],px:[{px:j()}],py:[{py:j()}],ps:[{ps:j()}],pe:[{pe:j()}],pt:[{pt:j()}],pr:[{pr:j()}],pb:[{pb:j()}],pl:[{pl:j()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":j()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":j()}],"space-y-reverse":["space-y-reverse"],size:[{size:W()}],w:[{w:[l,"screen",...W()]}],"min-w":[{"min-w":[l,"screen","none",...W()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...W()]}],h:[{h:["screen","lh",...W()]}],"min-h":[{"min-h":["screen","lh","none",...W()]}],"max-h":[{"max-h":["screen","lh",...W()]}],"font-size":[{text:["base",r,Os,ha]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,We,ql]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Hl,Ge]}],"font-family":[{font:[X_,Ge,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,We,Ge]}],"line-clamp":[{"line-clamp":[vt,"none",We,ql]}],leading:[{leading:[s,...j()]}],"list-image":[{"list-image":["none",We,Ge]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",We,Ge]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:V()}],"text-color":[{text:V()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:[vt,"from-font","auto",We,ha]}],"text-decoration-color":[{decoration:V()}],"underline-offset":[{"underline-offset":[vt,"auto",We,Ge]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",We,Ge]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",We,Ge]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Wn,We,Ge],radial:["",We,Ge],conic:[Wn,We,Ge]},Q_,K_]}],"bg-color":[{bg:V()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:V()}],"gradient-via":[{via:V()}],"gradient-to":[{to:V()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:q()}],"border-w-x":[{"border-x":q()}],"border-w-y":[{"border-y":q()}],"border-w-s":[{"border-s":q()}],"border-w-e":[{"border-e":q()}],"border-w-t":[{"border-t":q()}],"border-w-r":[{"border-r":q()}],"border-w-b":[{"border-b":q()}],"border-w-l":[{"border-l":q()}],"divide-x":[{"divide-x":q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ie(),"hidden","none"]}],"divide-style":[{divide:[...ie(),"hidden","none"]}],"border-color":[{border:V()}],"border-color-x":[{"border-x":V()}],"border-color-y":[{"border-y":V()}],"border-color-s":[{"border-s":V()}],"border-color-e":[{"border-e":V()}],"border-color-t":[{"border-t":V()}],"border-color-r":[{"border-r":V()}],"border-color-b":[{"border-b":V()}],"border-color-l":[{"border-l":V()}],"divide-color":[{divide:V()}],"outline-style":[{outline:[...ie(),"none","hidden"]}],"outline-offset":[{"outline-offset":[vt,We,Ge]}],"outline-w":[{outline:["",vt,Os,ha]}],"outline-color":[{outline:V()}],shadow:[{shadow:["","none",d,zi,$i]}],"shadow-color":[{shadow:V()}],"inset-shadow":[{"inset-shadow":["none",p,zi,$i]}],"inset-shadow-color":[{"inset-shadow":V()}],"ring-w":[{ring:q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:V()}],"ring-offset-w":[{"ring-offset":[vt,ha]}],"ring-offset-color":[{"ring-offset":V()}],"inset-ring-w":[{"inset-ring":q()}],"inset-ring-color":[{"inset-ring":V()}],"text-shadow":[{"text-shadow":["none",m,zi,$i]}],"text-shadow-color":[{"text-shadow":V()}],opacity:[{opacity:[vt,We,Ge]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[vt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":V()}],"mask-image-linear-to-color":[{"mask-linear-to":V()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":V()}],"mask-image-t-to-color":[{"mask-t-to":V()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":V()}],"mask-image-r-to-color":[{"mask-r-to":V()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":V()}],"mask-image-b-to-color":[{"mask-b-to":V()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":V()}],"mask-image-l-to-color":[{"mask-l-to":V()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":V()}],"mask-image-x-to-color":[{"mask-x-to":V()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":V()}],"mask-image-y-to-color":[{"mask-y-to":V()}],"mask-image-radial":[{"mask-radial":[We,Ge]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":V()}],"mask-image-radial-to-color":[{"mask-radial-to":V()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":C()}],"mask-image-conic-pos":[{"mask-conic":[vt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":V()}],"mask-image-conic-to-color":[{"mask-conic-to":V()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",We,Ge]}],filter:[{filter:["","none",We,Ge]}],blur:[{blur:ne()}],brightness:[{brightness:[vt,We,Ge]}],contrast:[{contrast:[vt,We,Ge]}],"drop-shadow":[{"drop-shadow":["","none",h,zi,$i]}],"drop-shadow-color":[{"drop-shadow":V()}],grayscale:[{grayscale:["",vt,We,Ge]}],"hue-rotate":[{"hue-rotate":[vt,We,Ge]}],invert:[{invert:["",vt,We,Ge]}],saturate:[{saturate:[vt,We,Ge]}],sepia:[{sepia:["",vt,We,Ge]}],"backdrop-filter":[{"backdrop-filter":["","none",We,Ge]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[vt,We,Ge]}],"backdrop-contrast":[{"backdrop-contrast":[vt,We,Ge]}],"backdrop-grayscale":[{"backdrop-grayscale":["",vt,We,Ge]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[vt,We,Ge]}],"backdrop-invert":[{"backdrop-invert":["",vt,We,Ge]}],"backdrop-opacity":[{"backdrop-opacity":[vt,We,Ge]}],"backdrop-saturate":[{"backdrop-saturate":[vt,We,Ge]}],"backdrop-sepia":[{"backdrop-sepia":["",vt,We,Ge]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":j()}],"border-spacing-x":[{"border-spacing-x":j()}],"border-spacing-y":[{"border-spacing-y":j()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",We,Ge]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[vt,"initial",We,Ge]}],ease:[{ease:["linear","initial",E,We,Ge]}],delay:[{delay:[vt,We,Ge]}],animate:[{animate:["none",w,We,Ge]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,We,Ge]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:se()}],"scale-x":[{"scale-x":se()}],"scale-y":[{"scale-y":se()}],"scale-z":[{"scale-z":se()}],"scale-3d":["scale-3d"],skew:[{skew:pe()}],"skew-x":[{"skew-x":pe()}],"skew-y":[{"skew-y":pe()}],transform:[{transform:[We,Ge,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:V()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:V()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",We,Ge]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",We,Ge]}],fill:[{fill:["none",...V()]}],"stroke-w":[{stroke:[vt,Os,ha,ql]}],stroke:[{stroke:["none",...V()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},r8=M_(t8);function Ve(...e){return r8(pS(e))}function n8(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const Uf=x.forwardRef(({className:e,children:t,...r},n)=>i.jsx("div",{className:Ve(e,"relative overflow-hidden"),...r,children:i.jsx("div",{ref:n,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:t})}));Uf.displayName="ScrollArea";function a8({updateAvailable:e,releaseInfo:t,latestVersion:r,onShowVersionModal:n,onShowSettings:a,t:s}){return i.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden md:block px-2 py-1.5",children:i.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:n,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(bb,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:s("version.updateAvailable")})]})]})}),i.jsx("div",{className:"md:hidden px-3 py-2",children:i.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:n,children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx(bb,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),i.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),i.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[i.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:t?.title||`v${r}`}),i.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:s("version.updateAvailable")})]})]})})]}),i.jsx("div",{className:"nav-divider"}),i.jsx("div",{className:"hidden md:block px-2 py-1.5",children:i.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:a,children:[i.jsx(Rt,{className:"w-3.5 h-3.5"}),i.jsx("span",{className:"text-sm",children:s("actions.settings")})]})}),i.jsx("div",{className:"md:hidden p-3 pb-20",children:i.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:a,children:[i.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:i.jsx(Rt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),i.jsx("span",{className:"text-base font-medium text-foreground",children:s("actions.settings")})]})})]})}const Db=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jb=pS,ES=(e,t)=>r=>{var n;if(t?.variants==null)return jb(e,r?.class,r?.className);const{variants:a,defaultVariants:s}=t,o=Object.keys(a).map(u=>{const d=r?.[u],p=s?.[u];if(d===null)return null;const m=Db(d)||Db(p);return a[u][m]}),l=r&&Object.entries(r).reduce((u,d)=>{let[p,m]=d;return m===void 0||(u[p]=m),u},{}),c=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:p,className:m,...h}=d;return Object.entries(h).every(f=>{let[g,v]=f;return Array.isArray(v)?v.includes({...s,...l}[g]):{...s,...l}[g]===v})?[...u,p,m]:u},[]);return jb(e,o,c,r?.class,r?.className)},s8=ES("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),$e=x.forwardRef(({className:e,variant:t,size:r,...n},a)=>i.jsx("button",{className:Ve(s8({variant:t,size:r,className:e})),ref:a,...n}));$e.displayName="Button";const Ft=x.forwardRef(({className:e,type:t,...r},n)=>i.jsx("input",{type:t,className:Ve("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...r}));Ft.displayName="Input";function i8({isPWA:e,isMobile:t,isLoading:r,projectsCount:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,t:p}){const m=()=>i.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[i.jsx("div",{className:"w-7 h-7 bg-primary/90 rounded-lg flex items-center justify-center shadow-sm flex-shrink-0",children:i.jsx("svg",{className:"w-3.5 h-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),i.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:p("app.title")})]});return i.jsxs("div",{className:"flex-shrink-0",children:[i.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx(m,{}),i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:l,disabled:c,title:p("tooltips.refresh"),children:i.jsx(Cn,{className:`w-3.5 h-3.5 ${c?"animate-spin":""}`})}),i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:u,title:p("tooltips.createProject"),children:i.jsx(er,{className:"w-3.5 h-3.5"})}),i.jsx($e,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:p("tooltips.hideSidebar"),children:i.jsx(cI,{className:"w-3.5 h-3.5"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"relative mt-2.5",children:[i.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),i.jsx(Ft,{type:"text",placeholder:p("projects.searchPlaceholder"),value:a,onChange:h=>s(h.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),a&&i.jsx("button",{onClick:o,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:i.jsx(_t,{className:"w-3 h-3 text-muted-foreground"})})]})]}),i.jsx("div",{className:"hidden md:block nav-divider"}),i.jsxs("div",{className:"md:hidden p-3 pb-2",style:e&&t?{paddingTop:"16px"}:{},children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx(m,{}),i.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[i.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:l,disabled:c,children:i.jsx(Cn,{className:`w-4 h-4 text-muted-foreground ${c?"animate-spin":""}`})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:u,children:i.jsx(fo,{className:"w-4 h-4"})})]})]}),n>0&&!r&&i.jsxs("div",{className:"relative mt-2.5",children:[i.jsx(Ta,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),i.jsx(Ft,{type:"text",placeholder:p("projects.searchPlaceholder"),value:a,onChange:h=>s(h.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),a&&i.jsx("button",{onClick:o,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:i.jsx(_t,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),i.jsx("div",{className:"md:hidden nav-divider"})]})}const o8=({status:e="not-configured",size:t="sm",className:r="",showLabel:n=!1})=>{const s=(()=>{switch(e){case"fully-configured":return{icon:vi,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Rt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:rl,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:_t,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),o=s.icon,l={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},c={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return n?i.jsxs("div",{className:Ve("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",s.bgColor,s.color,r),title:s.title,children:[i.jsx(o,{className:l[t]}),i.jsx("span",{className:"font-medium",children:s.label})]}):i.jsx("div",{className:Ve("inline-flex items-center justify-center rounded-full transition-colors",s.bgColor,c[t],r),title:s.title,children:i.jsx(o,{className:Ve(l[t],s.color)})})},l8=ES("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Zr({className:e,variant:t,...r}){return i.jsx("div",{className:Ve(l8({variant:t}),e),...r})}const Mb=(e,t,r)=>{const n=new Date(e),a=t;if(isNaN(n.getTime()))return r?r("status.unknown"):"Unknown";const s=a.getTime()-n.getTime(),o=Math.floor(s/1e3),l=Math.floor(s/(1e3*60)),c=Math.floor(s/(1e3*60*60)),u=Math.floor(s/(1e3*60*60*24));return o<60?r?r("time.justNow"):"Just now":l===1?r?r("time.oneMinuteAgo"):"1 min ago":l<60?r?r("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?r?r("time.oneHourAgo"):"1 hour ago":c<24?r?r("time.hoursAgo",{count:c}):`${c} hours ago`:u===1?r?r("time.oneDayAgo"):"1 day ago":u<7?r?r("time.daysAgo",{count:u}):`${u} days ago`:n.toLocaleDateString()};function Kr({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?i.jsx(sS,{className:t}):e==="codex"?i.jsx(iS,{className:t}):i.jsx(aS,{className:t})}function c8({project:e,session:t,selectedSession:r,currentTime:n,editingSession:a,editingSessionName:s,onEditingSessionNameChange:o,onStartEditingSession:l,onCancelEditingSession:c,onSaveEditingSession:u,onProjectSelect:d,onSessionSelect:p,onDeleteSession:m,touchHandlerFactory:h,t:f}){const g=g_(t,n,f),v=r?.id===t.id,E=()=>{d(e),p(t,e.name)},w=()=>{u(e.name,t.id,s)},k=()=>{m(e.name,t.id,g.sessionName,t.__provider)};return i.jsxs("div",{className:"group relative",children:[g.isActive&&i.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:i.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:Ve("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",v?"bg-primary/5 border-primary/20":"",!v&&g.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:E,children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:Ve("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",v?"bg-primary/10":"bg-muted/50"),children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx(ii,{className:"w-2.5 h-2.5 text-muted-foreground"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:Mb(g.sessionTime,n,f)}),g.messageCount>0&&i.jsx(Zr,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:g.messageCount}),i.jsx("span",{className:"ml-1 opacity-70",children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})})]})]}),!g.isCursorSession&&i.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:C=>{C.stopPropagation(),k()},children:i.jsx(xr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),i.jsxs("div",{className:"hidden md:block",children:[i.jsx($e,{variant:"ghost",className:Ve("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",v&&"bg-accent text-accent-foreground"),onClick:()=>p(t,e.name),children:i.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:g.sessionName}),i.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.jsx(ii,{className:"w-2.5 h-2.5 text-muted-foreground"}),i.jsx("span",{className:"text-xs text-muted-foreground",children:Mb(g.sessionTime,n,f)}),g.messageCount>0&&i.jsx(Zr,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:g.messageCount}),i.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:i.jsx(Kr,{provider:t.__provider,className:"w-3 h-3"})})]})]})]})}),!g.isCursorSession&&i.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:a===t.id&&!g.isCodexSession?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"text",value:s,onChange:C=>o(C.target.value),onKeyDown:C=>{C.stopPropagation(),C.key==="Enter"?w():C.key==="Escape"&&c()},onClick:C=>C.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),i.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),w()},title:f("tooltips.save"),children:i.jsx(lr,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),i.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),c()},title:f("tooltips.cancel"),children:i.jsx(_t,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):i.jsxs(i.Fragment,{children:[!g.isCodexSession&&i.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),l(t.id,t.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:i.jsx(fI,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),i.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:C=>{C.stopPropagation(),k()},title:f("tooltips.deleteSession"),children:i.jsx(xr,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function u8(){return i.jsx(i.Fragment,{children:Array.from({length:3}).map((e,t)=>i.jsx("div",{className:"p-2 rounded-md",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),i.jsxs("div",{className:"flex-1 space-y-1",children:[i.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+t*15}%`}}),i.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},t))})}function d8({project:e,isExpanded:t,sessions:r,selectedSession:n,initialSessionsLoaded:a,isLoadingSessions:s,currentTime:o,editingSession:l,editingSessionName:c,onEditingSessionNameChange:u,onStartEditingSession:d,onCancelEditingSession:p,onSaveEditingSession:m,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,onLoadMoreSessions:v,onNewSession:E,touchHandlerFactory:w,t:k}){if(!t)return null;const C=r.length>0,A=e.sessionMeta?.hasMore===!0;return i.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[a?!C&&!s?i.jsx("div",{className:"py-2 px-3 text-left",children:i.jsx("p",{className:"text-xs text-muted-foreground",children:k("sessions.noSessions")})}):r.map(T=>i.jsx(c8,{project:e,session:T,selectedSession:n,currentTime:o,editingSession:l,editingSessionName:c,onEditingSessionNameChange:u,onStartEditingSession:d,onCancelEditingSession:p,onSaveEditingSession:m,onProjectSelect:h,onSessionSelect:f,onDeleteSession:g,touchHandlerFactory:w,t:k},T.id)):i.jsx(u8,{}),C&&A&&i.jsx($e,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>v(e),disabled:s,children:s?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),k("sessions.loading")]}):i.jsxs(i.Fragment,{children:[i.jsx(Mr,{className:"w-3 h-3"}),k("sessions.showMore")]})}),i.jsx("div",{className:"md:hidden px-3 pb-2",children:i.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{h(e),E(e)},children:[i.jsx(er,{className:"w-3 h-3"}),k("sessions.newSession")]})}),i.jsxs($e,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>E(e),children:[i.jsx(er,{className:"w-3 h-3"}),k("sessions.newSession")]})]})}const p8=(e,t)=>{const r=e.length;return t&&r>=5?`${r}+`:`${r}`};function m8({project:e,selectedProject:t,selectedSession:r,isExpanded:n,isDeleting:a,isStarred:s,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:m,editingSessionName:h,tasksEnabled:f,mcpServerStatus:g,onEditingNameChange:v,onToggleProject:E,onProjectSelect:w,onToggleStarProject:k,onStartEditingProject:C,onCancelEditingProject:A,onSaveProjectName:T,onDeleteProject:I,onSessionSelect:j,onDeleteSession:L,onLoadMoreSessions:_,onNewSession:M,onEditingSessionNameChange:P,onStartEditingSession:$,onCancelEditingSession:F,onSaveEditingSession:X,touchHandlerFactory:B,t:W}){const V=t?.name===e.name,le=o===e.name,R=e.sessionMeta?.hasMore===!0,Z=p8(c,R),H=`${Z} session${c.length===1?"":"s"}`,N=y_(e,g),q=()=>E(e.name),ie=()=>k(e.name),J=()=>{T(e.name)},Q=()=>{t?.name!==e.name&&w(e),q()};return i.jsxs("div",{className:Ve("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[i.jsxs("div",{className:"group md:group",children:[i.jsx("div",{className:"md:hidden",children:i.jsx("div",{className:Ve("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",V&&"bg-primary/5 border-primary/20",s&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:q,children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx("div",{className:Ve("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",n?"bg-primary/10":"bg-muted"),children:n?i.jsx(na,{className:"w-4 h-4 text-primary"}):i.jsx(aa,{className:"w-4 h-4 text-muted-foreground"})}),i.jsx("div",{className:"min-w-0 flex-1",children:le?i.jsx("input",{type:"text",value:l,onChange:ne=>v(ne.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:W("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:ne=>ne.stopPropagation(),onKeyDown:ne=>{ne.key==="Enter"&&J(),ne.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[i.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:e.displayName}),f&&i.jsx(o8,{status:N,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),i.jsx("p",{className:"text-xs text-muted-foreground",children:H})]})})]}),i.jsx("div",{className:"flex items-center gap-1",children:le?i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:ne=>{ne.stopPropagation(),J()},children:i.jsx(lr,{className:"w-4 h-4 text-white"})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:ne=>{ne.stopPropagation(),A()},children:i.jsx(_t,{className:"w-4 h-4 text-white"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{className:Ve("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",s?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:ne=>{ne.stopPropagation(),ie()},title:W(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(wb,{className:Ve("w-4 h-4 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:ne=>{ne.stopPropagation(),I(e)},children:i.jsx(xr,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),i.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:ne=>{ne.stopPropagation(),C(e)},children:i.jsx(li,{className:"w-4 h-4 text-primary"})}),i.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:n?i.jsx(Mr,{className:"w-3 h-3 text-muted-foreground"}):i.jsx(Xr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),i.jsxs($e,{variant:"ghost",className:Ve("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",V&&"bg-accent text-accent-foreground",s&&!V&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:Q,children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[n?i.jsx(na,{className:"w-4 h-4 text-primary flex-shrink-0"}):i.jsx(aa,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),i.jsx("div",{className:"min-w-0 flex-1 text-left",children:le?i.jsxs("div",{className:"space-y-1",children:[i.jsx("input",{type:"text",value:l,onChange:ne=>v(ne.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:W("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:ne=>{ne.key==="Enter"&&J(),ne.key==="Escape"&&A()}}),i.jsx("div",{className:"text-xs text-muted-foreground truncate",title:e.fullPath,children:e.fullPath})]}):i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:e.displayName,children:e.displayName}),i.jsxs("div",{className:"text-xs text-muted-foreground",children:[Z,e.fullPath!==e.displayName&&i.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),i.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:le?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:ne=>{ne.stopPropagation(),J()},children:i.jsx(lr,{className:"w-3 h-3"})}),i.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:ne=>{ne.stopPropagation(),A()},children:i.jsx(_t,{className:"w-3 h-3"})})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:Ve("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",s?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:ne=>{ne.stopPropagation(),ie()},title:W(s?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:i.jsx(wb,{className:Ve("w-3 h-3 transition-colors",s?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),i.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:ne=>{ne.stopPropagation(),C(e)},title:W("tooltips.renameProject"),children:i.jsx(li,{className:"w-3 h-3"})}),i.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:ne=>{ne.stopPropagation(),I(e)},title:W("tooltips.deleteProject"),children:i.jsx(xr,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),n?i.jsx(Mr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):i.jsx(Xr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),i.jsx(d8,{project:e,isExpanded:n,sessions:c,selectedSession:r,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:m,editingSessionName:h,onEditingSessionNameChange:P,onStartEditingSession:$,onCancelEditingSession:F,onSaveEditingSession:X,onProjectSelect:w,onSessionSelect:j,onDeleteSession:L,onLoadMoreSessions:_,onNewSession:M,touchHandlerFactory:B,t:W})]})}function h8({isLoading:e,loadingProgress:t,projectsCount:r,filteredProjectsCount:n,t:a}){return e?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:i.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),i.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&i.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):r===0?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx(aa,{className:"w-6 h-6 text-muted-foreground"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.noProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):n===0?i.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[i.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:i.jsx(Ta,{className:"w-6 h-6 text-muted-foreground"})}),i.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:a("projects.noMatchingProjects")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function f8({projects:e,filteredProjects:t,selectedProject:r,selectedSession:n,isLoading:a,loadingProgress:s,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:u,initialSessionsLoaded:d,currentTime:p,editingSession:m,editingSessionName:h,deletingProjects:f,tasksEnabled:g,mcpServerStatus:v,getProjectSessions:E,isProjectStarred:w,onEditingNameChange:k,onToggleProject:C,onProjectSelect:A,onToggleStarProject:T,onStartEditingProject:I,onCancelEditingProject:j,onSaveProjectName:L,onDeleteProject:_,onSessionSelect:M,onDeleteSession:P,onLoadMoreSessions:$,onNewSession:F,onEditingSessionNameChange:X,onStartEditingSession:B,onCancelEditingSession:W,onSaveEditingSession:V,touchHandlerFactory:le,t:R}){const Z=i.jsx(h8,{isLoading:a,loadingProgress:s,projectsCount:e.length,filteredProjectsCount:t.length,t:R}),H=!a&&e.length>0&&t.length>0;return i.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:H?t.map(N=>i.jsx(m8,{project:N,selectedProject:r,selectedSession:n,isExpanded:o.has(N.name),isDeleting:f.has(N.name),isStarred:w(N.name),editingProject:l,editingName:c,sessions:E(N),initialSessionsLoaded:d.has(N.name),isLoadingSessions:!!u[N.name],currentTime:p,editingSession:m,editingSessionName:h,tasksEnabled:g,mcpServerStatus:v,onEditingNameChange:k,onToggleProject:C,onProjectSelect:A,onToggleStarProject:T,onStartEditingProject:I,onCancelEditingProject:j,onSaveProjectName:L,onDeleteProject:_,onSessionSelect:M,onDeleteSession:P,onLoadMoreSessions:$,onNewSession:F,onEditingSessionNameChange:X,onStartEditingSession:B,onCancelEditingSession:W,onSaveEditingSession:V,touchHandlerFactory:le,t:R},N.name)):Z})}function g8({isPWA:e,isMobile:t,isLoading:r,projects:n,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,updateAvailable:p,releaseInfo:m,latestVersion:h,onShowVersionModal:f,onShowSettings:g,projectListProps:v,t:E}){return i.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[i.jsx(i8,{isPWA:e,isMobile:t,isLoading:r,projectsCount:n.length,searchFilter:a,onSearchFilterChange:s,onClearSearchFilter:o,onRefresh:l,isRefreshing:c,onCreateProject:u,onCollapseSidebar:d,t:E}),i.jsx(Uf,{className:"flex-1 md:px-1.5 md:py-2 overflow-y-auto overscroll-contain",children:i.jsx(f8,{...v})}),i.jsx(a8,{updateAvailable:p,releaseInfo:m,latestVersion:h,onShowVersionModal:f,onShowSettings:g,t:E})]})}const b8=({onClose:e,onProjectCreated:t})=>{const{t:r}=Nt(),[n,a]=x.useState(1),[s,o]=x.useState("existing"),[l,c]=x.useState(""),[u,d]=x.useState(""),[p,m]=x.useState(""),[h,f]=x.useState("stored"),[g,v]=x.useState(""),[E,w]=x.useState(!1),[k,C]=x.useState(null),[A,T]=x.useState([]),[I,j]=x.useState(!1),[L,_]=x.useState([]),[M,P]=x.useState(!1),[$,F]=x.useState(!1),[X,B]=x.useState("~"),[W,V]=x.useState([]),[le,R]=x.useState(!1),[Z,H]=x.useState(!1),[N,q]=x.useState(!1),[ie,J]=x.useState(""),[Q,ne]=x.useState(!1),[he,se]=x.useState("");x.useEffect(()=>{n===2&&s==="new"&&u&&pe()},[n,s,u]),x.useEffect(()=>{l.length>2?Ae(l):(_([]),P(!1))},[l]);const pe=async()=>{try{j(!0);const de=((await(await bt.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(Te=>Te.is_active);T(de),de.length>0&&!p&&m(de[0].id.toString())}catch(ge){console.error("Error loading GitHub tokens:",ge)}finally{j(!1)}},Ae=async ge=>{try{const rt=ge.lastIndexOf("/"),de=rt>0?ge.substring(0,rt):"~",re=await(await bt.browseFilesystem(de)).json();if(re.suggestions){const ue=re.suggestions.filter(ve=>ve.path.toLowerCase().startsWith(ge.toLowerCase())&&ve.path.toLowerCase()!==ge.toLowerCase());_(ue.slice(0,5)),P(ue.length>0)}}catch(rt){console.error("Error loading path suggestions:",rt)}},Re=()=>{if(C(null),n===1){if(!s){C(r("projectWizard.errors.selectType"));return}a(2)}else if(n===2){if(!l.trim()){C(r("projectWizard.errors.providePath"));return}a(3)}},Ye=()=>{C(null),a(n-1)},Ze=async()=>{w(!0),C(null),se("");try{if(s==="new"&&u){const Te=new URLSearchParams({path:l.trim(),githubUrl:u.trim()});h==="stored"&&p?Te.append("githubTokenId",p):h==="new"&&g&&Te.append("newGithubToken",g.trim());const re=localStorage.getItem("auth-token"),ue=`/api/projects/clone-progress?${Te}${re?`&token=${re}`:""}`;await new Promise((ve,Me)=>{const qe=new EventSource(ue);qe.onmessage=kt=>{try{const ht=JSON.parse(kt.data);ht.type==="progress"?se(ht.message):ht.type==="complete"?(qe.close(),t&&t(ht.project),e(),ve()):ht.type==="error"&&(qe.close(),Me(new Error(ht.message)))}catch(ht){console.error("Error parsing SSE event:",ht)}},qe.onerror=()=>{qe.close(),Me(new Error("Connection lost during clone"))}});return}const ge={workspaceType:s,path:l.trim()},rt=await bt.createWorkspace(ge),de=await rt.json();if(!rt.ok)throw new Error(de.details||de.error||r("projectWizard.errors.failedToCreate"));t&&t(de.project),e()}catch(ge){console.error("Error creating workspace:",ge),C(ge.message||r("projectWizard.errors.failedToCreate"))}finally{w(!1)}},at=ge=>{c(ge.path),P(!1)},st=async()=>{F(!0),await Qe("~")},Qe=async ge=>{try{R(!0);const de=await(await bt.browseFilesystem(ge)).json();B(de.path||ge),V(de.suggestions||[])}catch(rt){console.error("Error loading folders:",rt)}finally{R(!1)}},Be=(ge,rt=!1)=>{c(ge),F(!1),rt&&a(3)},tt=async ge=>{await Qe(ge)},xt=async()=>{if(ie.trim()){ne(!0),C(null);try{const ge=X.includes("\\")?"\\":"/",rt=`${X}${ge}${ie.trim()}`,de=await bt.createFolder(rt),Te=await de.json();if(!de.ok)throw new Error(Te.error||r("projectWizard.errors.failedToCreateFolder","Failed to create folder"));J(""),q(!1),await Qe(Te.path||rt)}catch(ge){console.error("Error creating folder:",ge),C(ge.message||r("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{ne(!1)}}};return i.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(fo,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r("projectWizard.title")})]}),i.jsx("button",{onClick:e,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:E,children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"px-6 pt-4 pb-2",children:i.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(ge=>i.jsxs(Xt.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${ge<n?"bg-green-500 text-white":ge===n?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:ge<n?i.jsx(lr,{className:"w-4 h-4"}):ge}),i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:r(ge===1?"projectWizard.steps.type":ge===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),ge<3&&i.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${ge<n?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},ge))})}),i.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[k&&i.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[i.jsx(rl,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),i.jsx("div",{className:"flex-1",children:i.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:k})})]}),n===1&&i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:r("projectWizard.step1.question")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx("button",{onClick:()=>o("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${s==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:i.jsx(fo,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.existing.title")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.existing.description")})]})]})}),i.jsx("button",{onClick:()=>o("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${s==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:i.jsx(fn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:r("projectWizard.step1.new.title")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step1.new.description")})]})]})})]})]})}),n===2&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r(s==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),i.jsxs("div",{className:"relative flex gap-2",children:[i.jsxs("div",{className:"flex-1 relative",children:[i.jsx(Ft,{type:"text",value:l,onChange:ge=>c(ge.target.value),placeholder:s==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),M&&L.length>0&&i.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:L.map((ge,rt)=>i.jsxs("button",{onClick:()=>at(ge),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[i.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:ge.name}),i.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:ge.path})]},rt))})]}),i.jsx($e,{type:"button",variant:"outline",onClick:st,className:"px-3",title:"Browse folders",children:i.jsx(na,{className:"w-4 h-4"})})]}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r(s==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),s==="new"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.githubUrl")}),i.jsx(Ft,{type:"text",value:u,onChange:ge=>d(ge.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.githubHelp")})]}),u&&!u.startsWith("git@")&&!u.startsWith("ssh://")&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[i.jsx(Lf,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:r("projectWizard.step2.githubAuth")}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("projectWizard.step2.githubAuthHelp")})]})]}),I?i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[i.jsx(ka,{className:"w-4 h-4 animate-spin"}),r("projectWizard.step2.loadingTokens")]}):A.length>0?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[i.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.storedToken")}),i.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.newToken")}),i.jsx("button",{onClick:()=>{f("none"),m(""),v("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${h==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:r("projectWizard.step2.nonePublic")})]}),h==="stored"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.selectToken")}),i.jsxs("select",{value:p,onChange:ge=>m(ge.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[i.jsx("option",{value:"",children:r("projectWizard.step2.selectTokenPlaceholder")}),A.map(ge=>i.jsx("option",{value:ge.id,children:ge.credential_name},ge.id))]})]}):h==="new"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.newToken")}),i.jsx(Ft,{type:"password",value:g,onChange:ge=>v(ge.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.tokenHelp")})]}):null]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:i.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:r("projectWizard.step2.publicRepoInfo")})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("projectWizard.step2.optionalTokenPublic")}),i.jsx(Ft,{type:"password",value:g,onChange:ge=>v(ge.target.value),placeholder:r("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:r("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),n===3&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[i.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:r("projectWizard.step3.reviewConfig")}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.workspaceType")}),i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r(s==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.path")}),i.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:l})]}),s==="new"&&u&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.cloneFrom")}),i.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:u})]}),i.jsxs("div",{className:"flex justify-between text-sm",children:[i.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:r("projectWizard.step3.authentication")}),i.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:h==="stored"&&p?`${r("projectWizard.step3.usingStoredToken")} ${A.find(ge=>ge.id.toString()===p)?.credential_name||"Unknown"}`:h==="new"&&g?r("projectWizard.step3.usingProvidedToken"):u.startsWith("git@")||u.startsWith("ssh://")?r("projectWizard.step3.sshKey","SSH Key"):r("projectWizard.step3.noAuthentication")})]})]})]})]}),i.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:E&&he?i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:r("projectWizard.step3.cloningRepository","Cloning repository...")}),i.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:he})]}):i.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:r(s==="existing"?"projectWizard.step3.existingInfo":u?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[i.jsx($e,{variant:"outline",onClick:n===1?e:Ye,disabled:E,children:n===1?r("projectWizard.buttons.cancel"):i.jsxs(i.Fragment,{children:[i.jsx(Of,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.back")]})}),i.jsx($e,{onClick:n===3?Ze:Re,disabled:E||n===1&&!s,children:E?i.jsxs(i.Fragment,{children:[i.jsx(ka,{className:"w-4 h-4 mr-2 animate-spin"}),u?r("projectWizard.buttons.cloning","Cloning..."):r("projectWizard.buttons.creating")]}):n===3?i.jsxs(i.Fragment,{children:[i.jsx(lr,{className:"w-4 h-4 mr-1"}),r("projectWizard.buttons.createProject")]}):i.jsxs(i.Fragment,{children:[r("projectWizard.buttons.next"),i.jsx(Xr,{className:"w-4 h-4 ml-1"})]})})]})]}),$&&i.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(na,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>H(!Z),className:`p-2 rounded-md transition-colors ${Z?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:Z?"Hide hidden folders":"Show hidden folders",children:Z?i.jsx(Aa,{className:"w-5 h-5"}):i.jsx(Z4,{className:"w-5 h-5"})}),i.jsx("button",{onClick:()=>q(!N),className:`p-2 rounded-md transition-colors ${N?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:i.jsx(er,{className:"w-5 h-5"})}),i.jsx("button",{onClick:()=>F(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:i.jsx(_t,{className:"w-5 h-5"})})]})]}),N&&i.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Ft,{type:"text",value:ie,onChange:ge=>J(ge.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:ge=>{ge.key==="Enter"&&xt(),ge.key==="Escape"&&(q(!1),J(""))},autoFocus:!0}),i.jsx($e,{size:"sm",onClick:xt,disabled:!ie.trim()||Q,children:Q?i.jsx(ka,{className:"w-4 h-4 animate-spin"}):"Create"}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>{q(!1),J("")},children:"Cancel"})]})}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:le?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(ka,{className:"w-6 h-6 animate-spin text-gray-400"})}):i.jsxs("div",{className:"space-y-1",children:[X!=="~"&&X!=="/"&&!/^[A-Za-z]:\\?$/.test(X)&&i.jsxs("button",{onClick:()=>{const ge=Math.max(X.lastIndexOf("/"),X.lastIndexOf("\\"));let rt;ge<=0?rt="/":ge===2&&/^[A-Za-z]:/.test(X)?rt=X.substring(0,3):rt=X.substring(0,ge),tt(rt)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[i.jsx(na,{className:"w-5 h-5 text-gray-400"}),i.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),W.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):W.filter(ge=>Z||!ge.name.startsWith(".")).sort((ge,rt)=>ge.name.toLowerCase().localeCompare(rt.name.toLowerCase())).map((ge,rt)=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{onClick:()=>tt(ge.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[i.jsx(fo,{className:"w-5 h-5 text-blue-500"}),i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ge.name})]}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>Be(ge.path,s==="existing"),className:"text-xs px-3",children:"Select"})]},rt))]})}),i.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),i.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:X})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[i.jsx($e,{variant:"outline",onClick:()=>{F(!1),q(!1),J("")},children:"Cancel"}),i.jsx($e,{variant:"outline",onClick:()=>Be(X,s==="existing"),children:"Use this folder"})]})]})]})})]})};function x8(){const{t:e}=Nt("settings"),[t,r]=x.useState([]),[n,a]=x.useState([]),[s,o]=x.useState(!0),[l,c]=x.useState(!1),[u,d]=x.useState(!1),[p,m]=x.useState(""),[h,f]=x.useState(""),[g,v]=x.useState(""),[E,w]=x.useState(""),[k,C]=x.useState({}),[A,T]=x.useState(null),[I,j]=x.useState(null),{updateAvailable:L,latestVersion:_,releaseInfo:M}=cS("siteboon","claudecodeui");x.useEffect(()=>{P()},[]);const P=async()=>{try{o(!0);const Z=await(await _e("/api/settings/api-keys")).json();r(Z.apiKeys||[]);const N=await(await _e("/api/settings/credentials?type=github_token")).json();a(N.credentials||[])}catch(R){console.error("Error fetching settings:",R)}finally{o(!1)}},$=async()=>{if(p.trim())try{const Z=await(await _e("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:p})})).json();Z.success&&(j(Z.apiKey),m(""),c(!1),P())}catch(R){console.error("Error creating API key:",R)}},F=async R=>{if(confirm(e("apiKeys.confirmDelete")))try{await _e(`/api/settings/api-keys/${R}`,{method:"DELETE"}),P()}catch(Z){console.error("Error deleting API key:",Z)}},X=async(R,Z)=>{try{await _e(`/api/settings/api-keys/${R}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!Z})}),P()}catch(H){console.error("Error toggling API key:",H)}},B=async()=>{if(!(!h.trim()||!g.trim()))try{(await(await _e("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:h,credentialType:"github_token",credentialValue:g,description:E})})).json()).success&&(f(""),v(""),w(""),d(!1),P())}catch(R){console.error("Error creating GitHub credential:",R)}},W=async R=>{if(confirm(e("apiKeys.github.confirmDelete")))try{await _e(`/api/settings/credentials/${R}`,{method:"DELETE"}),P()}catch(Z){console.error("Error deleting GitHub credential:",Z)}},V=async(R,Z)=>{try{await _e(`/api/settings/credentials/${R}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!Z})}),P()}catch(H){console.error("Error toggling GitHub credential:",H)}},le=(R,Z)=>{navigator.clipboard.writeText(R),T(Z),setTimeout(()=>T(null),2e3)};return s?i.jsx("div",{className:"text-muted-foreground",children:e("apiKeys.loading")}):i.jsxs("div",{className:"space-y-8",children:[I&&i.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[i.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:e("apiKeys.newKey.alertTitle")}),i.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e("apiKeys.newKey.alertMessage")}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:I.apiKey}),i.jsx($e,{size:"sm",variant:"outline",onClick:()=>le(I.apiKey,"new"),children:A==="new"?i.jsx(lr,{className:"h-4 w-4"}):i.jsx(X4,{className:"h-4 w-4"})})]}),i.jsx($e,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>j(null),children:e("apiKeys.newKey.iveSavedIt")})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Lf,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.title")})]}),i.jsxs($e,{size:"sm",onClick:()=>c(!l),children:[i.jsx(er,{className:"h-4 w-4 mr-1"}),e("apiKeys.newButton")]})]}),i.jsxs("div",{className:"mb-4",children:[i.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e("apiKeys.description")}),i.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[e("apiKeys.apiDocsLink"),i.jsx(yb,{className:"h-3 w-3"})]})]}),l&&i.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[i.jsx(Ft,{placeholder:e("apiKeys.form.placeholder"),value:p,onChange:R=>m(R.target.value),className:"mb-2"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx($e,{onClick:$,children:e("apiKeys.form.createButton")}),i.jsx($e,{variant:"outline",onClick:()=>c(!1),children:e("apiKeys.form.cancelButton")})]})]}),i.jsx("div",{className:"space-y-2",children:t.length===0?i.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.empty")}):t.map(R=>i.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium",children:R.key_name}),i.jsx("code",{className:"text-xs text-muted-foreground",children:R.api_key}),i.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.list.created")," ",new Date(R.created_at).toLocaleDateString(),R.last_used&&` • ${e("apiKeys.list.lastUsed")} ${new Date(R.last_used).toLocaleDateString()}`]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{size:"sm",variant:R.is_active?"outline":"secondary",onClick:()=>X(R.id,R.is_active),children:R.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>F(R.id),children:i.jsx(xr,{className:"h-4 w-4"})})]})]},R.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(_6,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("apiKeys.github.title")})]}),i.jsxs($e,{size:"sm",onClick:()=>d(!u),children:[i.jsx(er,{className:"h-4 w-4 mr-1"}),e("apiKeys.github.addButton")]})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("apiKeys.github.descriptionAlt")}),u&&i.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[i.jsx(Ft,{placeholder:e("apiKeys.github.form.namePlaceholder"),value:h,onChange:R=>f(R.target.value)}),i.jsxs("div",{className:"relative",children:[i.jsx(Ft,{type:k.new?"text":"password",placeholder:e("apiKeys.github.form.tokenPlaceholder"),value:g,onChange:R=>v(R.target.value),className:"pr-10"}),i.jsx("button",{type:"button",onClick:()=>C({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?i.jsx(Z4,{className:"h-4 w-4"}):i.jsx(Aa,{className:"h-4 w-4"})})]}),i.jsx(Ft,{placeholder:e("apiKeys.github.form.descriptionPlaceholder"),value:E,onChange:R=>w(R.target.value)}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx($e,{onClick:B,children:e("apiKeys.github.form.addButton")}),i.jsx($e,{variant:"outline",onClick:()=>{d(!1),f(""),v(""),w("")},children:e("apiKeys.github.form.cancelButton")})]}),i.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:e("apiKeys.github.form.howToCreate")})]}),i.jsx("div",{className:"space-y-2",children:n.length===0?i.jsx("p",{className:"text-sm text-muted-foreground italic",children:e("apiKeys.github.empty")}):n.map(R=>i.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium",children:R.credential_name}),R.description&&i.jsx("div",{className:"text-xs text-muted-foreground",children:R.description}),i.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[e("apiKeys.github.added")," ",new Date(R.created_at).toLocaleDateString()]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{size:"sm",variant:R.is_active?"outline":"secondary",onClick:()=>V(R.id,R.is_active),children:R.is_active?e("apiKeys.status.active"):e("apiKeys.status.inactive")}),i.jsx($e,{size:"sm",variant:"ghost",onClick:()=>W(R.id),children:i.jsx(xr,{className:"h-4 w-4"})})]})]},R.id))})]}),i.jsx("div",{className:"pt-6 border-t border-border/50",children:i.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[i.jsxs("a",{href:M?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Lh]}),L&&_&&i.jsxs("a",{href:M?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[i.jsx("span",{className:"text-[10px]",children:e("apiKeys.version.updateAvailable",{version:_})}),i.jsx(yb,{className:"h-2.5 w-2.5"})]})]})})]})}function y8(){const{t:e}=Nt("settings"),[t,r]=x.useState(""),[n,a]=x.useState(""),[s,o]=x.useState(!1),[l,c]=x.useState(!1),[u,d]=x.useState(null);x.useEffect(()=>{p()},[]);const p=async()=>{try{o(!0);const h=await _e("/api/user/git-config");if(h.ok){const f=await h.json();r(f.gitName||""),a(f.gitEmail||"")}}catch(h){console.error("Error loading git config:",h)}finally{o(!1)}},m=async()=>{try{c(!0);const h=await _e("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:t,gitEmail:n})});if(h.ok)d("success"),setTimeout(()=>d(null),3e3);else{const f=await h.json();d("error"),console.error("Failed to save git config:",f.error)}}catch(h){console.error("Error saving git config:",h),d("error")}finally{c(!1)}};return i.jsx("div",{className:"space-y-8",children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(fn,{className:"h-5 w-5"}),i.jsx("h3",{className:"text-lg font-semibold",children:e("git.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:e("git.description")}),i.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:e("git.name.label")}),i.jsx(Ft,{id:"settings-git-name",type:"text",value:t,onChange:h=>r(h.target.value),placeholder:"John Doe",disabled:s,className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.name.help")})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:e("git.email.label")}),i.jsx(Ft,{id:"settings-git-email",type:"email",value:n,onChange:h=>a(h.target.value),placeholder:"john@example.com",disabled:s,className:"w-full"}),i.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e("git.email.help")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx($e,{onClick:m,disabled:l||!t||!n,children:e(l?"git.actions.saving":"git.actions.save")}),u==="success"&&i.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[i.jsx(lr,{className:"w-4 h-4"}),e("git.status.success")]})]})]})]})})}function v8(){const{t:e}=Nt("settings"),{tasksEnabled:t,setTasksEnabled:r,isTaskMasterInstalled:n,isCheckingInstallation:a}=yi();return i.jsx("div",{className:"space-y-8",children:a?i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),i.jsx("span",{className:"text-sm text-muted-foreground",children:e("tasks.checking")})]})}):i.jsxs(i.Fragment,{children:[!n&&i.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:e("tasks.notInstalled.title")}),i.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[i.jsx("p",{children:e("tasks.notInstalled.description")}),i.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:i.jsx("code",{children:e("tasks.notInstalled.installCommand")})}),i.jsx("div",{children:i.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),e("tasks.notInstalled.viewOnGitHub"),i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"font-medium",children:e("tasks.notInstalled.afterInstallation")}),i.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[i.jsx("li",{children:e("tasks.notInstalled.steps.restart")}),i.jsx("li",{children:e("tasks.notInstalled.steps.autoAvailable")}),i.jsx("li",{children:e("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),n&&i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:e("tasks.settings.enableLabel")}),i.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:e("tasks.settings.enableDescription")})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:t,onChange:s=>r(s.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const k8={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},w8={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function $a({agentId:e,authStatus:t,isSelected:r,onClick:n,isMobile:a=!1}){const{t:s}=Nt("settings"),o=k8[e],l=w8[o.color];return a?i.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${l.borderBottom} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:i.jsxs("div",{className:"flex flex-col items-center gap-1",children:[i.jsx(Kr,{provider:e,className:"w-5 h-5"}),i.jsx("span",{className:"text-xs font-medium text-foreground",children:o.name}),t?.authenticated&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`})]})}):i.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${l.border} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Kr,{provider:e,className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:o.name})]}),i.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?i.jsx("span",{className:"text-gray-400",children:s("agents.authStatus.checking")}):t?.authenticated?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`}),i.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||s("agents.authStatus.connected")})]}):i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),i.jsx("span",{children:s("agents.authStatus.notConnected")})]})})]})}const E8={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function S8({agent:e,authStatus:t,onLogin:r}){const{t:n}=Nt("settings"),a=E8[e];return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx(Kr,{provider:e,className:"w-6 h-6"}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a.name}),i.jsx("p",{className:"text-sm text-muted-foreground",children:n(`agents.account.${e}.description`)})]})]}),i.jsx("div",{className:`${a.bgClass} border ${a.borderClass} rounded-lg p-4`,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("div",{className:`font-medium ${a.textClass}`,children:n("agents.connectionStatus")}),i.jsx("div",{className:`text-sm ${a.subtextClass}`,children:t?.loading?n("agents.authStatus.checkingAuth"):t?.authenticated?n("agents.authStatus.loggedInAs",{email:t.email||n("agents.authStatus.authenticatedUser")}):n("agents.authStatus.notConnected")})]}),i.jsx("div",{children:t?.loading?i.jsx(Zr,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:n("agents.authStatus.checking")}):t?.authenticated?i.jsx(Zr,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:n("agents.authStatus.connected")}):i.jsx(Zr,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:n("agents.authStatus.disconnected")})})]}),i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:`font-medium ${a.textClass}`,children:t?.authenticated?n("agents.login.reAuthenticate"):n("agents.login.title")}),i.jsx("div",{className:`text-sm ${a.subtextClass}`,children:t?.authenticated?n("agents.login.reAuthDescription"):n("agents.login.description",{agent:a.name})})]}),i.jsxs($e,{onClick:r,className:`${a.buttonClass} text-white`,size:"sm",children:[i.jsx(tS,{className:"w-4 h-4 mr-2"}),t?.authenticated?n("agents.login.reLoginButton"):n("agents.login.button")]})]})}),t?.error&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:n("agents.error",{error:t.error})})})]})})]})}const T8=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],N8=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function C8({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:a,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const{t:d}=Nt("settings"),p=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},m=g=>{n(r.filter(v=>v!==g))},h=g=>{g&&!a.includes(g)&&(s([...a,g]),u(""))},f=g=>{s(a.filter(v=>v!==g))};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-orange-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.title")})]}),i.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("label",{className:"flex items-center gap-3",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:d("permissions.skipPermissions.label")}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:d("permissions.skipPermissions.claudeDescription")})]})]})})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.allowedTools.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.allowedTools.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:o,onChange:g=>l(g.target.value),placeholder:d("permissions.allowedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(o))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>p(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:d("permissions.allowedTools.quickAdd")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:T8.map(g=>i.jsx($e,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),i.jsxs("div",{className:"space-y-2",children:[r.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>m(g),className:"text-green-600 hover:text-green-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),r.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.allowedTools.empty")})]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-red-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.blockedTools.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.blockedTools.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:c,onChange:g=>u(g.target.value),placeholder:d("permissions.blockedTools.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(c))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>h(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[a.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),a.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.blockedTools.empty")})]})]}),i.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:d("permissions.toolExamples.title")}),i.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",d("permissions.toolExamples.bashGitLog")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",d("permissions.toolExamples.bashGitDiff")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",d("permissions.toolExamples.write")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",d("permissions.toolExamples.bashRm")]})]})]})]})}function A8({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:a,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const{t:d}=Nt("settings"),p=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},m=g=>{n(r.filter(v=>v!==g))},h=g=>{g&&!a.includes(g)&&(s([...a,g]),u(""))},f=g=>{s(a.filter(v=>v!==g))};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-orange-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.title")})]}),i.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:i.jsxs("label",{className:"flex items-center gap-3",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:g=>t(g.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:d("permissions.skipPermissions.label")}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:d("permissions.skipPermissions.cursorDescription")})]})]})})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.allowedCommands.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.allowedCommands.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:o,onChange:g=>l(g.target.value),placeholder:d("permissions.allowedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),p(o))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>p(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:d("permissions.allowedCommands.quickAdd")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N8.map(g=>i.jsx($e,{variant:"outline",size:"sm",onClick:()=>p(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),i.jsxs("div",{className:"space-y-2",children:[r.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>m(g),className:"text-green-600 hover:text-green-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),r.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.allowedCommands.empty")})]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ln,{className:"w-5 h-5 text-red-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("permissions.blockedCommands.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:d("permissions.blockedCommands.description")}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[i.jsx(Ft,{value:c,onChange:g=>u(g.target.value),placeholder:d("permissions.blockedCommands.placeholder"),onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),h(c))},className:"flex-1 h-10"}),i.jsxs($e,{onClick:()=>h(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[i.jsx(er,{className:"w-4 h-4 mr-2 sm:mr-0"}),i.jsx("span",{className:"sm:hidden",children:d("permissions.actions.add")})]})]}),i.jsxs("div",{className:"space-y-2",children:[a.map(g=>i.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[i.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),i.jsx($e,{variant:"ghost",size:"sm",onClick:()=>f(g),className:"text-red-600 hover:text-red-700",children:i.jsx(_t,{className:"w-4 h-4"})})]},g)),a.length===0&&i.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:d("permissions.blockedCommands.empty")})]})]}),i.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:d("permissions.shellExamples.title")}),i.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",d("permissions.shellExamples.ls")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",d("permissions.shellExamples.gitStatus")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",d("permissions.shellExamples.npmInstall")]}),i.jsxs("li",{children:[i.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",d("permissions.shellExamples.rmRf")]})]})]})]})}function I8({permissionMode:e,setPermissionMode:t}){const{t:r}=Nt("settings");return i.jsx("div",{className:"space-y-6",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"w-5 h-5 text-green-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:r("permissions.codex.permissionMode")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:r("permissions.codex.description")}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("default"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:r("permissions.codex.modes.default.title")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:r("permissions.codex.modes.default.description")})]})]})}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("acceptEdits"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:r("permissions.codex.modes.acceptEdits.title")}),i.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:r("permissions.codex.modes.acceptEdits.description")})]})]})}),i.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${e==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>t("bypassPermissions"),children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[r("permissions.codex.modes.bypassPermissions.title"),i.jsx(Ln,{className:"w-4 h-4"})]}),i.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:r("permissions.codex.modes.bypassPermissions.description")})]})]})}),i.jsxs("details",{className:"text-sm",children:[i.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:r("permissions.codex.technicalDetails")}),i.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.default.title"),":"]})," ",r("permissions.codex.technicalInfo.default")]}),i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.acceptEdits.title"),":"]})," ",r("permissions.codex.technicalInfo.acceptEdits")]}),i.jsxs("p",{children:[i.jsxs("strong",{children:[r("permissions.codex.modes.bypassPermissions.title"),":"]})," ",r("permissions.codex.technicalInfo.bypassPermissions")]}),i.jsx("p",{className:"text-xs opacity-75",children:r("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Gl({agent:e,...t}){return e==="claude"?i.jsx(C8,{...t}):e==="cursor"?i.jsx(A8,{...t}):e==="codex"?i.jsx(I8,{...t}):null}const _8=e=>{switch(e){case"stdio":return i.jsx(ir,{className:"w-4 h-4"});case"sse":return i.jsx(jf,{className:"w-4 h-4"});case"http":return i.jsx(oi,{className:"w-4 h-4"});default:return i.jsx(al,{className:"w-4 h-4"})}};function R8({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:a,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){const{t:u}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-purple-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:u("mcpServers.description.claude")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),u("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(d=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[_8(d.type),i.jsx("span",{className:"font-medium text-foreground",children:d.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:d.type}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:d.scope==="local"?u("mcpServers.scope.local"):d.scope==="user"?u("mcpServers.scope.user"):d.scope})]}),i.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[d.type==="stdio"&&d.config?.command&&i.jsxs("div",{children:[u("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.command})]}),(d.type==="sse"||d.type==="http")&&d.config?.url&&i.jsxs("div",{children:[u("mcpServers.config.url"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.url})]}),d.config?.args&&d.config.args.length>0&&i.jsxs("div",{children:[u("mcpServers.config.args"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:d.config.args.join(" ")})]})]}),o?.[d.id]&&i.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[d.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:i.jsx("div",{className:"font-medium",children:o[d.id].message})}),l?.[d.id]&&l[d.id].tools?.length>0&&i.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[i.jsxs("div",{className:"font-medium",children:[u("mcpServers.tools.title")," ",u("mcpServers.tools.count",{count:l[d.id].tools.length})]}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[d.id].tools.slice(0,5).map((p,m)=>i.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:p.name},m)),l[d.id].tools.length>5&&i.jsx("span",{className:"text-xs opacity-75",children:u("mcpServers.tools.more",{count:l[d.id].tools.length-5})})]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(d),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:u("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(d.id,d.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:u("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},d.id)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:u("mcpServers.empty")})]})]})}function O8({servers:e,onAdd:t,onEdit:r,onDelete:n}){const{t:a}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-purple-500"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("mcpServers.description.cursor")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),a("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(s=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ir,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:s.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),i.jsx("div",{className:"text-sm text-muted-foreground",children:s.config?.command&&i.jsxs("div",{children:[a("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.command})]})})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(s),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:a("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(s.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:a("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},s.name||s.id)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:a("mcpServers.empty")})]})]})}function L8({servers:e,onAdd:t,onEdit:r,onDelete:n}){const{t:a}=Nt("settings");return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(al,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),i.jsx("h3",{className:"text-lg font-medium text-foreground",children:a("mcpServers.title")})]}),i.jsx("p",{className:"text-sm text-muted-foreground",children:a("mcpServers.description.codex")}),i.jsx("div",{className:"flex justify-between items-center",children:i.jsxs($e,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[i.jsx(er,{className:"w-4 h-4 mr-2"}),a("mcpServers.addButton")]})}),i.jsxs("div",{className:"space-y-2",children:[e.map(s=>i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(ir,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium text-foreground",children:s.name}),i.jsx(Zr,{variant:"outline",className:"text-xs",children:"stdio"})]}),i.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[s.config?.command&&i.jsxs("div",{children:[a("mcpServers.config.command"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.command})]}),s.config?.args&&s.config.args.length>0&&i.jsxs("div",{children:[a("mcpServers.config.args"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:s.config.args.join(" ")})]}),s.config?.env&&Object.keys(s.config.env).length>0&&i.jsxs("div",{children:[a("mcpServers.config.environment"),": ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(s.config.env).map(([o,l])=>`${o}=${l}`).join(", ")})]})]})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx($e,{onClick:()=>r(s),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:a("mcpServers.actions.edit"),children:i.jsx(li,{className:"w-4 h-4"})}),i.jsx($e,{onClick:()=>n(s.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:a("mcpServers.actions.delete"),children:i.jsx(xr,{className:"w-4 h-4"})})]})]})},s.name)),e.length===0&&i.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:a("mcpServers.empty")})]}),i.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:a("mcpServers.help.title")}),i.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:a("mcpServers.help.description")})]})]})}function Wl({agent:e,...t}){return e==="claude"?i.jsx(R8,{...t}):e==="cursor"?i.jsx(O8,{...t}):e==="codex"?i.jsx(L8,{...t}):null}const Ph=[{value:"en",label:"English",nativeName:"English"},{value:"ko",label:"Korean",nativeName:"한국어"},{value:"zh-CN",label:"Simplified Chinese",nativeName:"简体中文"},{value:"ja",label:"Japanese",nativeName:"日本語"}];function SS({compact:e=!1}){const{i18n:t,t:r}=Nt("settings"),n=a=>{const s=a.target.value;t.changeLanguage(s)};return e?i.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[i.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[i.jsx(eS,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),r("account.language")]}),i.jsx("select",{value:t.language,onChange:n,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Ph.map(a=>i.jsx("option",{value:a.value,children:a.nativeName},a.value))})]}):i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:r("account.languageLabel")}),i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("account.languageDescription")})]}),i.jsx("select",{value:t.language,onChange:n,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Ph.map(a=>i.jsx("option",{value:a.value,children:a.nativeName},a.value))})]})})}function D8({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:a,toggleDarkMode:s}=xi(),{t:o}=Nt("settings"),[l,c]=x.useState([]),[u,d]=x.useState([]),[p,m]=x.useState(""),[h,f]=x.useState(""),[g,v]=x.useState(!1),[E,w]=x.useState(!1),[k,C]=x.useState(null),[A,T]=x.useState("name"),[I,j]=x.useState([]),[L,_]=x.useState(!1),[M,P]=x.useState(null),[$,F]=x.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[X,B]=x.useState(!1),[W,V]=x.useState({}),[le,R]=x.useState({}),[Z,H]=x.useState({}),[N,q]=x.useState(n),[ie,J]=x.useState(""),[Q,ne]=x.useState("claude"),[he,se]=x.useState("account"),[pe,Ae]=x.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[Re,Ye]=x.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Ze,at]=x.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[st,Qe]=x.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Be,tt]=x.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[xt,ge]=x.useState([]),[rt,de]=x.useState([]),[Te,re]=x.useState(!1),[ue,ve]=x.useState(""),[Me,qe]=x.useState(""),[kt,ht]=x.useState([]),[Oe,Xe]=x.useState([]),[ze,Ke]=x.useState("default"),[lt,et]=x.useState(!1),[ye,Ie]=x.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[pt,yt]=x.useState(null),[qt,wr]=x.useState(!1),[pr,Er]=x.useState(!1),[mr,kn]=x.useState(""),[Pe,nt]=x.useState(null),[De,te]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[fe,He]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),[St,It]=x.useState({authenticated:!1,email:null,loading:!0,error:null}),Gt=async()=>{try{const ae=await _e("/api/cursor/mcp");if(ae.ok){const be=await ae.json();ht(be.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(ae){console.error("Error fetching Cursor MCP servers:",ae)}},wn=async()=>{try{const ae=await _e("/api/codex/mcp/config/read");if(ae.ok){const je=await ae.json();if(je.success&&je.servers){Xe(je.servers);return}}const be=await _e("/api/codex/mcp/cli/list");if(be.ok){const je=await be.json();if(je.success&&je.servers){const mt=je.servers.map(hr=>({id:hr.name,name:hr.name,type:hr.type||"stdio",scope:"user",config:{command:hr.command||"",args:hr.args||[],env:hr.env||{}}}));Xe(mt)}}}catch(ae){console.error("Error fetching Codex MCP servers:",ae)}},en=async()=>{try{const ae=await _e("/api/mcp/config/read");if(ae.ok){const mt=await ae.json();if(mt.success&&mt.servers){j(mt.servers);return}}const be=await _e("/api/mcp/cli/list");if(be.ok){const mt=await be.json();if(mt.success&&mt.servers){const hr=mt.servers.map(qn=>({id:qn.name,name:qn.name,type:qn.type,scope:"user",config:{command:qn.command||"",args:qn.args||[],env:qn.env||{},url:qn.url||"",headers:qn.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));j(hr);return}}const je=await _e("/api/mcp/servers?scope=user");if(je.ok){const mt=await je.json();j(mt.servers||[])}else console.error("Failed to fetch MCP servers")}catch(ae){console.error("Error fetching MCP servers:",ae)}},tn=async ae=>{try{M&&await rr(M.id,"user");const be=await _e("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:ae.name,type:ae.type,scope:ae.scope,projectPath:ae.projectPath,command:ae.config?.command,args:ae.config?.args||[],url:ae.config?.url,headers:ae.config?.headers||{},env:ae.config?.env||{}})});if(be.ok){const je=await be.json();if(je.success)return await en(),!0;throw new Error(je.error||"Failed to save server via Claude CLI")}else{const je=await be.json();throw new Error(je.error||"Failed to save server")}}catch(be){throw console.error("Error saving MCP server:",be),be}},rr=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/cli/remove/${ae}?scope=${be}`,{method:"DELETE"});if(je.ok){const mt=await je.json();if(mt.success)return await en(),!0;throw new Error(mt.error||"Failed to delete server via Claude CLI")}else{const mt=await je.json();throw new Error(mt.error||"Failed to delete server")}}catch(je){throw console.error("Error deleting MCP server:",je),je}},sr=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/servers/${ae}/test?scope=${be}`,{method:"POST"});if(je.ok)return(await je.json()).testResult;{const mt=await je.json();throw new Error(mt.error||"Failed to test server")}}catch(je){throw console.error("Error testing MCP server:",je),je}},En=async(ae,be="user")=>{try{const je=await _e(`/api/mcp/servers/${ae}/tools?scope=${be}`,{method:"POST"});if(je.ok)return(await je.json()).toolsResult;{const mt=await je.json();throw new Error(mt.error||"Failed to discover tools")}}catch(je){throw console.error("Error discovering MCP tools:",je),je}},pa=async ae=>{try{pt&&await Ss(pt.id);const be=await _e("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:ae.name,command:ae.config?.command,args:ae.config?.args||[],env:ae.config?.env||{}})});if(be.ok){const je=await be.json();if(je.success)return await wn(),!0;throw new Error(je.error||"Failed to save Codex MCP server")}else{const je=await be.json();throw new Error(je.error||"Failed to save server")}}catch(be){throw console.error("Error saving Codex MCP server:",be),be}},Ss=async ae=>{try{const be=await _e(`/api/codex/mcp/cli/remove/${ae}`,{method:"DELETE"});if(be.ok){const je=await be.json();if(je.success)return await wn(),!0;throw new Error(je.error||"Failed to delete Codex MCP server")}else{const je=await be.json();throw new Error(je.error||"Failed to delete server")}}catch(be){throw console.error("Error deleting Codex MCP server:",be),be}},ja=()=>{Ie({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),yt(null),et(!1)},Oi=(ae=null)=>{ae?(yt(ae),Ie({name:ae.name,type:ae.type||"stdio",config:{command:ae.config?.command||"",args:ae.config?.args||[],env:ae.config?.env||{}}})):ja(),et(!0)},Cl=async ae=>{ae.preventDefault(),wr(!0);try{pt&&await Ss(pt.name),await pa(ye),ja(),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}finally{wr(!1)}},Al=async ae=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Ss(ae),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}};x.useEffect(()=>{e&&(Il(),Li(),Di(),ji(),q(n))},[e,n]),x.useEffect(()=>{localStorage.setItem("codeEditorTheme",pe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[pe]),x.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",Re.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Re]),x.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Ze.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Ze]),x.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",st.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[st]),x.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Be),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Be]);const Il=async()=>{try{const ae=localStorage.getItem("claude-settings");if(ae){const mt=JSON.parse(ae);c(mt.allowedTools||[]),d(mt.disallowedTools||[]),v(mt.skipPermissions||!1),T(mt.projectSortOrder||"name")}else c([]),d([]),v(!1),T("name");const be=localStorage.getItem("cursor-tools-settings");if(be){const mt=JSON.parse(be);ge(mt.allowedCommands||[]),de(mt.disallowedCommands||[]),re(mt.skipPermissions||!1)}else ge([]),de([]),re(!1);const je=localStorage.getItem("codex-settings");if(je){const mt=JSON.parse(je);Ke(mt.permissionMode||"default")}else Ke("default");await en(),await Gt(),await wn()}catch(ae){console.error("Error loading tool settings:",ae),c([]),d([]),v(!1),T("name")}},Li=async()=>{try{const ae=await _e("/api/cli/claude/status");if(ae.ok){const be=await ae.json();te({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else te({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Claude auth status:",ae),te({authenticated:!1,email:null,loading:!1,error:ae.message})}},Di=async()=>{try{const ae=await _e("/api/cli/cursor/status");if(ae.ok){const be=await ae.json();He({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else He({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Cursor auth status:",ae),He({authenticated:!1,email:null,loading:!1,error:ae.message})}},ji=async()=>{try{const ae=await _e("/api/cli/codex/status");if(ae.ok){const be=await ae.json();It({authenticated:be.authenticated,email:be.email,loading:!1,error:be.error||null})}else It({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(ae){console.error("Error checking Codex auth status:",ae),It({authenticated:!1,email:null,loading:!1,error:ae.message})}},_l=()=>{kn("claude"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Rl=()=>{kn("cursor"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Ts=()=>{kn("codex"),nt(r?.[0]||{name:"default",fullPath:process.cwd()}),Er(!0)},Ol=ae=>{ae===0&&(C("success"),mr==="claude"?Li():mr==="cursor"?Di():mr==="codex"&&ji())},Ll=()=>{w(!0),C(null);try{const ae={allowedTools:l,disallowedTools:u,skipPermissions:g,projectSortOrder:A,lastUpdated:new Date().toISOString()},be={allowedCommands:xt,disallowedCommands:rt,skipPermissions:Te,lastUpdated:new Date().toISOString()},je={permissionMode:ze,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(ae)),localStorage.setItem("cursor-tools-settings",JSON.stringify(be)),localStorage.setItem("codex-settings",JSON.stringify(je)),C("success"),setTimeout(()=>{t()},1e3)}catch(ae){console.error("Error saving tool settings:",ae),C("error")}finally{w(!1)}},zn=()=>{F({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),P(null),_(!1),J("")},Mi=(ae=null)=>{ae?(P(ae),F({name:ae.name,type:ae.type,scope:ae.scope,projectPath:ae.projectPath||"",config:{...ae.config},raw:ae.raw,importMode:"form",jsonInput:""})):zn(),_(!0)},Dl=async ae=>{ae.preventDefault(),B(!0);try{if($.importMode==="json"){const be=await _e("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:$.name,jsonConfig:$.jsonInput,scope:$.scope,projectPath:$.projectPath})});if(be.ok){const je=await be.json();if(je.success)await en(),zn(),C("success");else throw new Error(je.error||"Failed to add server via JSON")}else{const je=await be.json();throw new Error(je.error||"Failed to add server")}}else await tn($),zn(),C("success")}catch(be){alert(`Error: ${be.message}`),C("error")}finally{B(!1)}},Or=async(ae,be)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await rr(ae,be),C("success")}catch(je){alert(`Error: ${je.message}`),C("error")}},Hn=async(ae,be)=>{try{V({...W,[ae]:{loading:!0}});const je=await sr(ae,be);V({...W,[ae]:je})}catch(je){V({...W,[ae]:{success:!1,message:je.message,details:[]}})}},Kg=async(ae,be)=>{try{H({...Z,[ae]:!0});const je=await En(ae,be);R({...le,[ae]:je})}catch{R({...le,[ae]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{H({...Z,[ae]:!1})}},ma=(ae,be)=>{F(je=>({...je,config:{...je.config,[ae]:be}}))};return e?i.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[i.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Rt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),i.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:o("title")})]}),i.jsx($e,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i.jsx("div",{className:"border-b border-border",children:i.jsxs("div",{className:"flex px-4 md:px-6",children:[i.jsx("button",{onClick:()=>q("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.agents")}),i.jsx("button",{onClick:()=>q("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.appearance")}),i.jsxs("button",{onClick:()=>q("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[i.jsx(fn,{className:"w-4 h-4 inline mr-2"}),o("mainTabs.git")]}),i.jsxs("button",{onClick:()=>q("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[i.jsx(Lf,{className:"w-4 h-4 inline mr-2"}),o("mainTabs.apiTokens")]}),i.jsx("button",{onClick:()=>q("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${N==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("mainTabs.tasks")})]})}),i.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[N==="appearance"&&i.jsx("div",{className:"space-y-6 md:space-y-8",children:N==="appearance"&&i.jsxs("div",{className:"space-y-6 md:space-y-8",children:[i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.darkMode.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.darkMode.description")})]}),i.jsxs("button",{onClick:s,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":a,"aria-label":"Toggle dark mode",children:[i.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),i.jsx("span",{className:`${a?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:a?i.jsx(_h,{className:"w-3.5 h-3.5 text-gray-700"}):i.jsx(Oh,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),i.jsx("div",{className:"space-y-4",children:i.jsx(SS,{})}),i.jsx("div",{className:"space-y-4",children:i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.projectSorting.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.projectSorting.description")})]}),i.jsxs("select",{value:A,onChange:ae=>T(ae.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[i.jsx("option",{value:"name",children:o("appearanceSettings.projectSorting.alphabetical")}),i.jsx("option",{value:"date",children:o("appearanceSettings.projectSorting.recentActivity")})]})]})})}),i.jsxs("div",{className:"space-y-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o("appearanceSettings.codeEditor.title")}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.theme.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.theme.description")})]}),i.jsxs("button",{onClick:()=>Ae(pe==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":pe==="dark","aria-label":"Toggle editor theme",children:[i.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),i.jsx("span",{className:`${pe==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:pe==="dark"?i.jsx(_h,{className:"w-3.5 h-3.5 text-gray-700"}):i.jsx(Oh,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.wordWrap.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.wordWrap.description")})]}),i.jsxs("button",{onClick:()=>Ye(!Re),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Re,"aria-label":"Toggle word wrap",children:[i.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),i.jsx("span",{className:`${Re?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.showMinimap.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.showMinimap.description")})]}),i.jsxs("button",{onClick:()=>at(!Ze),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":Ze,"aria-label":"Toggle minimap",children:[i.jsx("span",{className:"sr-only",children:"Toggle minimap"}),i.jsx("span",{className:`${Ze?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.lineNumbers.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.lineNumbers.description")})]}),i.jsxs("button",{onClick:()=>Qe(!st),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":st,"aria-label":"Toggle line numbers",children:[i.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),i.jsx("span",{className:`${st?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),i.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-foreground",children:o("appearanceSettings.codeEditor.fontSize.label")}),i.jsx("div",{className:"text-sm text-muted-foreground",children:o("appearanceSettings.codeEditor.fontSize.description")})]}),i.jsxs("select",{value:Be,onChange:ae=>tt(ae.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[i.jsx("option",{value:"10",children:"10px"}),i.jsx("option",{value:"11",children:"11px"}),i.jsx("option",{value:"12",children:"12px"}),i.jsx("option",{value:"13",children:"13px"}),i.jsx("option",{value:"14",children:"14px"}),i.jsx("option",{value:"15",children:"15px"}),i.jsx("option",{value:"16",children:"16px"}),i.jsx("option",{value:"18",children:"18px"}),i.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),N==="git"&&i.jsx(y8,{}),N==="agents"&&i.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[i.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"flex",children:[i.jsx($a,{agentId:"claude",authStatus:De,isSelected:Q==="claude",onClick:()=>ne("claude"),isMobile:!0}),i.jsx($a,{agentId:"cursor",authStatus:fe,isSelected:Q==="cursor",onClick:()=>ne("cursor"),isMobile:!0}),i.jsx($a,{agentId:"codex",authStatus:St,isSelected:Q==="codex",onClick:()=>ne("codex"),isMobile:!0})]})}),i.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"p-2",children:[i.jsx($a,{agentId:"claude",authStatus:De,isSelected:Q==="claude",onClick:()=>ne("claude")}),i.jsx($a,{agentId:"cursor",authStatus:fe,isSelected:Q==="cursor",onClick:()=>ne("cursor")}),i.jsx($a,{agentId:"codex",authStatus:St,isSelected:Q==="codex",onClick:()=>ne("codex")})]})}),i.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[i.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:i.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[i.jsx("button",{onClick:()=>se("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.account")}),i.jsx("button",{onClick:()=>se("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.permissions")}),i.jsx("button",{onClick:()=>se("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:o("tabs.mcpServers")})]})}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[he==="account"&&i.jsx(S8,{agent:Q,authStatus:Q==="claude"?De:Q==="cursor"?fe:St,onLogin:Q==="claude"?_l:Q==="cursor"?Rl:Ts}),he==="permissions"&&Q==="claude"&&i.jsx(Gl,{agent:"claude",skipPermissions:g,setSkipPermissions:v,allowedTools:l,setAllowedTools:c,disallowedTools:u,setDisallowedTools:d,newAllowedTool:p,setNewAllowedTool:m,newDisallowedTool:h,setNewDisallowedTool:f}),he==="permissions"&&Q==="cursor"&&i.jsx(Gl,{agent:"cursor",skipPermissions:Te,setSkipPermissions:re,allowedCommands:xt,setAllowedCommands:ge,disallowedCommands:rt,setDisallowedCommands:de,newAllowedCommand:ue,setNewAllowedCommand:ve,newDisallowedCommand:Me,setNewDisallowedCommand:qe}),he==="permissions"&&Q==="codex"&&i.jsx(Gl,{agent:"codex",permissionMode:ze,setPermissionMode:Ke}),he==="mcp"&&Q==="claude"&&i.jsx(Wl,{agent:"claude",servers:I,onAdd:()=>Mi(),onEdit:ae=>Mi(ae),onDelete:(ae,be)=>Or(ae,be),onTest:(ae,be)=>Hn(ae,be),onDiscoverTools:(ae,be)=>Kg(ae,be),testResults:W,serverTools:le,toolsLoading:Z}),he==="mcp"&&Q==="cursor"&&i.jsx(Wl,{agent:"cursor",servers:kt,onAdd:()=>{},onEdit:ae=>{},onDelete:ae=>{}}),he==="mcp"&&Q==="codex"&&i.jsx(Wl,{agent:"codex",servers:Oe,onAdd:()=>Oi(),onEdit:ae=>Oi(ae),onDelete:ae=>Al(ae)})]})]})]}),L&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:i.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[i.jsx("h3",{className:"text-lg font-medium text-foreground",children:o(M?"mcpForm.title.edit":"mcpForm.title.add")}),i.jsx($e,{variant:"ghost",size:"sm",onClick:zn,children:i.jsx(_t,{className:"w-4 h-4"})})]}),i.jsxs("form",{onSubmit:Dl,className:"p-4 space-y-4",children:[!M&&i.jsxs("div",{className:"flex gap-2 mb-4",children:[i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${$.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:o("mcpForm.importMode.form")}),i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${$.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:o("mcpForm.importMode.json")})]}),$.importMode==="form"&&M&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[i.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:o("mcpForm.scope.label")}),i.jsxs("div",{className:"flex items-center gap-2",children:[$.scope==="user"?i.jsx(oi,{className:"w-4 h-4"}):i.jsx(na,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm",children:$.scope==="user"?o("mcpForm.scope.userGlobal"):o("mcpForm.scope.projectLocal")}),$.scope==="local"&&$.projectPath&&i.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",$.projectPath]})]}),i.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:o("mcpForm.scope.cannotChange")})]}),$.importMode==="form"&&!M&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.scope.label")," *"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${$.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(oi,{className:"w-4 h-4"}),i.jsx("span",{children:o("mcpForm.scope.userGlobal")})]})}),i.jsx("button",{type:"button",onClick:()=>F(ae=>({...ae,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${$.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(na,{className:"w-4 h-4"}),i.jsx("span",{children:o("mcpForm.scope.projectLocal")})]})})]}),i.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:$.scope==="user"?o("mcpForm.scope.userDescription"):o("mcpForm.scope.projectDescription")})]}),$.scope==="local"&&!M&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.selectProject")," *"]}),i.jsxs("select",{value:$.projectPath,onChange:ae=>F(be=>({...be,projectPath:ae.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:$.scope==="local",children:[i.jsxs("option",{value:"",children:[o("mcpForm.fields.selectProject"),"..."]}),r.map(ae=>i.jsx("option",{value:ae.path||ae.fullPath,children:ae.displayName||ae.name},ae.name))]}),$.projectPath&&i.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o("mcpForm.projectPath",{path:$.projectPath})})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:$.importMode==="json"?"md:col-span-2":"",children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.serverName")," *"]}),i.jsx(Ft,{value:$.name,onChange:ae=>{F(be=>({...be,name:ae.target.value}))},placeholder:o("mcpForm.placeholders.serverName"),required:!0})]}),$.importMode==="form"&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.transportType")," *"]}),i.jsxs("select",{value:$.type,onChange:ae=>{F(be=>({...be,type:ae.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[i.jsx("option",{value:"stdio",children:"stdio"}),i.jsx("option",{value:"sse",children:"SSE"}),i.jsx("option",{value:"http",children:"HTTP"})]})]})]}),M&&$.raw&&$.importMode==="form"&&i.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:o("mcpForm.configDetails",{configFile:M.scope==="global"?"~/.claude.json":"project config"})}),i.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify($.raw,null,2)})]}),$.importMode==="json"&&i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[o("mcpForm.fields.jsonConfig")," *"]}),i.jsx("textarea",{value:$.jsonInput,onChange:ae=>{F(be=>({...be,jsonInput:ae.target.value}));try{if(ae.target.value.trim()){const be=JSON.parse(ae.target.value);be.type?be.type==="stdio"&&!be.command?J(o("mcpForm.validation.stdioRequiresCommand")):(be.type==="http"||be.type==="sse")&&!be.url?J(o("mcpForm.validation.httpRequiresUrl",{type:be.type})):J(""):J(o("mcpForm.validation.missingType"))}}catch{ae.target.value.trim()?J(o("mcpForm.validation.invalidJson")):J("")}},className:`w-full px-3 py-2 border ${ie?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
|
|
585
585
|
"type": "stdio",
|
|
586
586
|
"command": "/path/to/server",
|
|
587
587
|
"args": ["--api-key", "abc123"],
|
|
@@ -937,7 +937,7 @@ ${e.prompt}`),e.resume&&r.push(`**Resuming from:** ${e.resume}`),{content:r.join
|
|
|
937
937
|
`))}}catch{}else if(Array.isArray(m)){const h=m.filter(f=>f.type==="text"&&f.text).map(f=>f.text);h.length>0&&(m=h.join(`
|
|
938
938
|
`))}return typeof m=="string"?i.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:m}):m?i.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(m,null,2)}):null})()})]})})},MG=({content:e,className:t="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>i.jsx(Hs,{className:t,children:e}),PG=({files:e,onFileClick:t,title:r})=>i.jsxs("div",{children:[r&&i.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:r}),i.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:e.map((n,a)=>{const s=typeof n=="string"?n:n.path,o=s.split("/").pop()||s,l=typeof n=="string"?()=>t?.(n):n.onClick;return i.jsxs("span",{className:"inline-flex items-center",children:[i.jsx("button",{onClick:l,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:s,children:o}),a<e.length-1&&i.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},a)})})]}),FG=({todos:e,isResult:t=!1})=>{if(!e||!Array.isArray(e))return null;const r=s=>{switch(s){case"completed":return i.jsx(GA,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return i.jsx(ii,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return i.jsx(Qa,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},n=s=>{switch(s){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},a=s=>{switch(s){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return i.jsxs("div",{className:"space-y-1.5",children:[t&&i.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",e.length," ",e.length===1?"item":"items",")"]}),e.map((s,o)=>i.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[i.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r(s.status)}),i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[i.jsx("p",{className:`text-xs font-medium ${s.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:s.content}),i.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[i.jsx(Zr,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(s.priority)}`,children:s.priority}),i.jsx(Zr,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(s.status)}`,children:s.status.replace("_"," ")})]})]})})]},s.id||`todo-${o}`))]})},BG=({todos:e,isResult:t=!1})=>i.jsx(FG,{todos:e,isResult:t});function UG(e){const t=[],r=e.split(`
|
|
939
939
|
`);for(const n of r){const a=n.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(a){const[,s,o,l]=a,c=n.match(/blockedBy:\s*\[([^\]]*)\]/);t.push({id:s,subject:l.trim(),status:o||"pending",blockedBy:c?c[1].split(",").map(u=>u.trim()).filter(Boolean):void 0})}}return t}const dE={completed:{icon:i.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:i.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:i.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},$G=({content:e})=>{const t=UG(e);if(t.length===0)return i.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:e});const r=t.filter(a=>a.status==="completed").length,n=t.length;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[i.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[r,"/",n," completed"]}),i.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${n>0?r/n*100:0}%`}})})]}),i.jsx("div",{className:"space-y-px",children:t.map(a=>{const s=dE[a.status]||dE.pending;return i.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[i.jsx("span",{className:"flex-shrink-0",children:s.icon}),i.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",a.id]}),i.jsx("span",{className:`text-xs truncate flex-1 ${s.textClass}`,children:a.subject}),i.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${s.badgeClass}`,children:a.status.replace("_"," ")})]},a.id)})})]})},zG=({content:e,format:t="plain",className:r=""})=>{if(t==="json"){let n=e;try{const a=JSON.parse(e);n=JSON.stringify(a,null,2)}catch{}return i.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${r}`,children:n})}return t==="code"?i.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${r}`,children:e}):i.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${r}`,children:e})},HG=({questions:e,answers:t,className:r=""})=>{const[n,a]=x.useState(null);if(!e||e.length===0)return null;const s=Object.keys(t||{}).length>0,o=e.length;return i.jsxs("div",{className:`space-y-2 ${r}`,children:[e.map((l,c)=>{const u=t?.[l.question],d=u?u.split(", "):[],p=!u,m=n===c;return i.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[i.jsxs("button",{type:"button",onClick:()=>a(m?null:c),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[i.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${d.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:d.length>0?i.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):i.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.header&&i.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:l.header}),o>1&&i.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[c+1,"/",o]})]}),i.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:l.question}),!m&&d.length>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:d.map(h=>{const f=!l.options.some(g=>g.label===h);return i.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[h,f&&i.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},h)})}),!m&&p&&s&&i.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),i.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${m?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),m&&i.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:i.jsxs("div",{className:"space-y-1 ml-6.5",children:[l.options.map(h=>{const f=d.includes(h.label);return i.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[i.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${l.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&i.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:h.label}),h.description&&i.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:h.description})]})]},h.label)}),d.filter(h=>!l.options.some(f=>f.label===h)).map(h=>i.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[i.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${l.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:i.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:h}),i.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},h)),p&&s&&i.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},c)}),!s&&o===1&&i.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},qG=({request:e,onDecision:t})=>{const r=e.input,n=r?.questions||[],[a,s]=x.useState(0),[o,l]=x.useState(()=>new Map),[c,u]=x.useState(()=>new Map),[d,p]=x.useState(()=>new Map),[m,h]=x.useState(!1),f=x.useRef(null),g=x.useRef(null);x.useEffect(()=>{requestAnimationFrame(()=>h(!0))},[]),x.useEffect(()=>{d.get(a)||f.current?.focus()},[a,d]),x.useEffect(()=>{d.get(a)&&g.current?.focus()},[d,a]);const v=x.useCallback((B,W,V)=>{l(le=>{const R=new Map(le),Z=new Set(R.get(B)||[]);return V?Z.has(W)?Z.delete(W):Z.add(W):(Z.clear(),Z.add(W),p(H=>{const N=new Map(H);return N.set(B,!1),N})),R.set(B,Z),R})},[]),E=x.useCallback((B,W)=>{p(V=>{const le=new Map(V),R=le.get(B)||!1;return le.set(B,!R),!W&&!R&&l(Z=>{const H=new Map(Z);return H.set(B,new Set),H}),le})},[]),w=x.useCallback((B,W)=>{u(V=>{const le=new Map(V);return le.set(B,W),le})},[]),k=x.useCallback(()=>{const B={};return n.forEach((W,V)=>{const le=Array.from(o.get(V)||[]),R=d.get(V)||!1,Z=(c.get(V)||"").trim();R&&Z&&le.push(Z),le.length>0&&(B[W.question]=le.join(", "))}),B},[n,o,d,c]),C=x.useCallback(()=>{t(e.requestId,{allow:!0,updatedInput:{...r,answers:k()}})},[t,e.requestId,r,k]),A=x.useCallback(()=>{t(e.requestId,{allow:!0,updatedInput:{...r,answers:{}}})},[t,e.requestId,r]),T=x.useCallback(B=>{if(B.target instanceof HTMLInputElement)return;const W=n[a];if(!W)return;const V=W.multiSelect||!1,le=W.options.length,R=parseInt(B.key);if(!isNaN(R)&&R>=1&&R<=le){B.preventDefault(),v(a,W.options[R-1].label,V);return}if(B.key==="0"){B.preventDefault(),E(a,V);return}if(B.key==="Enter"){B.preventDefault(),a===n.length-1?C():s(H=>H+1);return}if(B.key==="Escape"){B.preventDefault(),A();return}},[a,n,v,E,C,A]);if(n.length===0)return null;const I=n.length,j=I===1,L=n[a],_=L.multiSelect||!1,M=o.get(a)||new Set,P=d.get(a)||!1,$=a===I-1,F=a===0,X=M.size>0||P&&(c.get(a)||"").trim().length>0;return i.jsx("div",{ref:f,tabIndex:-1,onKeyDown:T,className:`w-full outline-none transition-all duration-500 ease-out ${m?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:i.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[i.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),i.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[i.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[i.jsxs("div",{className:"relative flex-shrink-0",children:[i.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:i.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),i.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),i.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[i.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),L.header&&i.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:L.header})]}),!j&&i.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[a+1,"/",I]})]}),!j&&i.jsx("div",{className:"flex items-center gap-1 mb-2",children:n.map((B,W)=>i.jsx("button",{type:"button",onClick:()=>s(W),className:`h-[3px] rounded-full transition-all duration-300 ${W===a?"w-5 bg-blue-500 dark:bg-blue-400":W<a?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},W))}),i.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:L.question}),_&&i.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),i.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:_?"group":"radiogroup","aria-label":L.question,children:i.jsxs("div",{className:"space-y-1",children:[L.options.map((B,W)=>{const V=M.has(B.label);return i.jsxs("button",{type:"button",onClick:()=>v(a,B.label,_),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${V?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[i.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${V?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:W+1}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${V?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:B.label}),B.description&&i.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${V?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:B.description})]}),V&&i.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},B.label)}),i.jsxs("button",{type:"button",onClick:()=>E(a,_),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${P?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[i.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${P?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),i.jsx("span",{className:`text-[13px] leading-tight transition-colors ${P?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),P&&i.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),P&&i.jsx("div",{className:"pl-[30px] pr-0.5",children:i.jsxs("div",{className:"relative",children:[i.jsx("input",{ref:g,type:"text",value:c.get(a)||"",onChange:B=>w(a,B.target.value),onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),$?C():s(W=>W+1)),B.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),i.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),i.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[i.jsxs("button",{type:"button",onClick:A,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[j?"Skip":"Skip all",i.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[!j&&!F&&i.jsxs("button",{type:"button",onClick:()=>s(B=>B-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),$?i.jsxs("button",{type:"button",onClick:C,disabled:!X&&!Object.keys(k()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",i.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):i.jsxs("button",{type:"button",onClick:()=>s(B=>B+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",i.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function GG(e){return["Edit","Write","ApplyPatch"].includes(e)?"edit":["Grep","Glob"].includes(e)?"search":e==="Bash"?"bash":["TodoWrite","TodoRead"].includes(e)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(e)?"task":e==="Task"?"agent":e==="exit_plan_mode"||e==="ExitPlanMode"?"plan":e==="AskUserQuestion"?"question":"default"}const uf=x.memo(({toolName:e,toolInput:t,toolResult:r,toolId:n,mode:a,onFileOpen:s,createDiff:o,selectedProject:l,autoExpandTools:c=!1,showRawParameters:u=!1,rawToolInput:d,isSubagentContainer:p,subagentState:m})=>{if(p&&m)return a==="result"?null:i.jsx(jG,{toolInput:t,toolResult:r,subagentState:m});const h=cN(e),f=a==="input"?h.input:h.result,g=x.useMemo(()=>{try{const E=a==="input"?t:r;return typeof E=="string"?JSON.parse(E):E}catch{return a==="input"?t:r}},[a,t,r]),v=x.useCallback(()=>{if(f?.action==="open-file"&&s){const E=f.getValue?.(g)||"";s(E)}},[f,g,s]);if(!f)return null;if(f.type==="one-line"){const E=f.getValue?.(g)||"",w=f.getSecondary?.(g);return i.jsx(LG,{toolName:e,toolResult:r,toolId:n,icon:f.icon,label:f.label,value:E,secondary:w,action:f.action,onAction:v,style:f.style,wrapText:f.wrapText,colorScheme:f.colorScheme,resultId:a==="input"?`tool-result-${n}`:void 0})}if(f.type==="collapsible"){const E=typeof f.title=="function"?f.title(g):f.title||"Details",w=f.defaultOpen!==void 0?f.defaultOpen:c,k=f.getContentProps?.(g,{selectedProject:l,createDiff:o,onFileOpen:s})||{};let C=null;switch(f.contentType){case"diff":o&&(C=i.jsx(_G,{...k,createDiff:o,onFileClick:()=>s?.(k.filePath)}));break;case"markdown":C=i.jsx(MG,{content:k.content||""});break;case"file-list":C=i.jsx(PG,{files:k.files||[],onFileClick:s,title:k.title});break;case"todo-list":k.todos?.length>0&&(C=i.jsx(BG,{todos:k.todos,isResult:k.isResult}));break;case"task":C=i.jsx($G,{content:k.content||""});break;case"question-answer":C=i.jsx(HG,{questions:k.questions||[],answers:k.answers||{}});break;case"text":C=i.jsx(zG,{content:k.content||"",format:k.format||"plain"});break;case"success-message":{const T=f.getMessage?.(g)||"Success";C=i.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),T]});break}}const A=(e==="Edit"||e==="Write"||e==="ApplyPatch")&&k.filePath&&s?()=>s(k.filePath,{old_string:k.oldContent,new_string:k.newContent}):void 0;return i.jsx(DG,{toolName:e,toolId:n,title:E,defaultOpen:w,onTitleClick:A,showRawParameters:a==="input"&&u,rawContent:d,toolCategory:GG(e),children:C})}return null});uf.displayName="ToolRenderer";const WG=x.memo(({message:e,index:t,prevMessage:r,createDiff:n,onFileOpen:a,onShowSettings:s,onGrantToolPermission:o,autoExpandTools:l,showRawParameters:c,showThinking:u,selectedProject:d,provider:p})=>{const{t:m}=Nt("chat"),h=r&&r.type===e.type&&(r.type==="assistant"||r.type==="user"||r.type==="tool"||r.type==="error"),f=Xt.useRef(null),[g,v]=Xt.useState(!1),E=CG(e,p),[w,k]=Xt.useState("idle");Xt.useEffect(()=>{k("idle")},[E?.entry,e.toolId]),Xt.useEffect(()=>{const T=f.current;if(!l||!T||!e.isToolUse)return;const I=new IntersectionObserver(j=>{j.forEach(L=>{L.isIntersecting&&!g&&(v(!0),T.querySelectorAll("details").forEach(M=>{M.open=!0}))})},{threshold:.1});return I.observe(T),()=>{I.unobserve(T)}},[l,g,e.isToolUse]);const C=x.useMemo(()=>new Date(e.timestamp).toLocaleTimeString(),[e.timestamp]);return e.isThinking&&!u?null:i.jsx("div",{ref:f,className:`chat-message ${e.type} ${h?"grouped":""} ${e.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:e.type==="user"?i.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[i.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[i.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content}),e.images&&e.images.length>0&&i.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:e.images.map((T,I)=>i.jsx("img",{src:T.data,alt:T.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(T.data,"_blank")},T.name||I))}),i.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:C})]}),!h&&i.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):e.isTaskNotification?i.jsx("div",{className:"w-full",children:i.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[i.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${e.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),i.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.content})]})}):i.jsxs("div",{className:"w-full",children:[!h&&i.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.type==="error"?i.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):e.type==="tool"?i.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):i.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:i.jsx(Kr,{provider:p,className:"w-full h-full"})}),i.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.type==="error"?m("messageTypes.error"):e.type==="tool"?m("messageTypes.tool"):m(p==="cursor"?"messageTypes.cursor":p==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),i.jsxs("div",{className:"w-full",children:[e.isToolUse?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-col",children:i.jsx("div",{className:"flex flex-col",children:i.jsx(Hs,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(e.displayText||"")})})}),e.toolInput&&i.jsx(uf,{toolName:e.toolName||"UnknownTool",toolInput:e.toolInput,toolResult:e.toolResult,toolId:e.toolId,mode:"input",onFileOpen:a,createDiff:n,selectedProject:d,autoExpandTools:l,showRawParameters:c,rawToolInput:typeof e.toolInput=="string"?e.toolInput:void 0,isSubagentContainer:e.isSubagentContainer,subagentState:e.subagentState}),e.toolResult&&!IG(e.toolName||"UnknownTool",e.toolResult)&&(e.toolResult.isError?i.jsxs("div",{id:`tool-result-${e.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[i.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[i.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),i.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:m("messageTypes.error")})]}),i.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[i.jsx(Hs,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(e.toolResult.content||"")}),E&&i.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>{if(!o)return;o(E)?.success?k("granted"):k("error")},disabled:E.isAllowed||w==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${E.isAllowed||w==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:E.isAllowed||w==="granted"?m("permissions.added"):m("permissions.grant",{tool:E.toolName})}),s&&i.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),s()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:m("permissions.openSettings")})]}),i.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:m("permissions.addTo",{entry:E.entry})}),w==="error"&&i.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:m("permissions.error")}),(E.isAllowed||w==="granted")&&i.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:m("permissions.retry")})]})]})]}):i.jsx("div",{id:`tool-result-${e.toolId}`,className:"scroll-mt-4",children:i.jsx(uf,{toolName:e.toolName||"UnknownTool",toolInput:e.toolInput,toolResult:e.toolResult,toolId:e.toolId,mode:"result",onFileOpen:a,createDiff:n,selectedProject:d,autoExpandTools:l})}))]}):e.isInteractivePrompt?i.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:m("interactive.title")}),(()=>{const T=(e.content||"").split(`
|
|
940
|
-
`).filter(L=>L.trim()),I=T.find(L=>L.includes("?"))||T[0]||"",j=[];return T.forEach(L=>{const _=L.match(/[❯\s]*(\d+)\.\s+(.+)/);if(_){const M=L.includes("❯");j.push({number:_[1],text:_[2].trim(),isSelected:M})}}),i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:I}),i.jsx("div",{className:"space-y-2 mb-4",children:j.map(L=>i.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${L.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${L.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:L.number}),i.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:L.text}),L.isSelected&&i.jsx("span",{className:"text-lg",children:"❯"})]})},L.number))}),i.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[i.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:m("interactive.waiting")}),i.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:m("interactive.instruction")})]})]})})()]})]})}):e.isThinking?i.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[i.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),i.jsx("span",{children:m("thinking.emoji")})]}),i.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:i.jsx(Hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):i.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&i.jsxs("details",{className:"mb-3",children:[i.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:m("thinking.emoji")}),i.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:i.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const T=lf(String(e.content||"")),I=T.trim();if((I.startsWith("{")||I.startsWith("["))&&(I.endsWith("}")||I.endsWith("]")))try{const j=JSON.parse(I),L=JSON.stringify(j,null,2);return i.jsxs("div",{className:"my-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),i.jsx("span",{className:"font-medium",children:m("json.response")})]}),i.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:i.jsx("pre",{className:"p-4 overflow-x-auto",children:i.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:L})})})]})}catch{}return e.type==="assistant"?i.jsx(Hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:T}):i.jsx("div",{className:"whitespace-pre-wrap",children:T})})()]}),!h&&i.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:C})]})]})})}),dN=({task:e,onClose:t,onEdit:r,onStatusChange:n,onTaskClick:a,isOpen:s=!0,className:o=""})=>{const[l,c]=x.useState(!1),[u,d]=x.useState(e||{}),[p,m]=x.useState(!1),[h,f]=x.useState(!1),[g,v]=x.useState(!1),{currentProject:E,refreshTasks:w}=ms();if(!s||!e)return null;const k=async()=>{if(E){m(!0);try{const _={};if(u.title!==e.title&&(_.title=u.title),u.description!==e.description&&(_.description=u.description),u.details!==e.details&&(_.details=u.details),Object.keys(_).length>0){const M=await bt.taskmaster.updateTask(E.name,e.id,_);if(M.ok)w?.(),r?.(u),c(!1);else{const P=await M.json();console.error("Failed to update task:",P),alert(`Failed to update task: ${P.message}`)}}else c(!1)}catch(_){console.error("Error updating task:",_),alert("Error updating task. Please try again.")}finally{m(!1)}}},C=()=>{navigator.clipboard.writeText(e.id.toString())},A=_=>{switch(_){case"done":return{icon:vi,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:ii,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:rl,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:nS,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:_t,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:Qa,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},T=A(e.status),I=T.icon,j=_=>{switch(_){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},L=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return i.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:i.jsxs("div",{className:Ve("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",o),children:[i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(I,{className:Ve("w-6 h-6",T.color)}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxs("button",{onClick:C,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[i.jsxs("span",{children:["Task ",e.id]}),i.jsx(X4,{className:"w-3 h-3"})]}),e.parentId&&i.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",e.parentId]})]}),l?i.jsx("input",{type:"text",value:u.title||"",onChange:_=>d({...u,title:_.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):i.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:e.title})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:k,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:i.jsx(_o,{className:Ve("w-5 h-5",p&&"animate-spin")})}),i.jsx("button",{onClick:()=>{c(!1),d(e)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:i.jsx(_t,{className:"w-5 h-5"})})]}):i.jsx("button",{onClick:()=>c(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:i.jsx(OI,{className:"w-5 h-5"})}),i.jsx("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:i.jsx(_t,{className:"w-5 h-5"})})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),i.jsx("div",{className:Ve("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",T.bg,T.color),children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(I,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium capitalize",children:L.find(_=>_.value===e.status)?.label||e.status})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),i.jsxs("div",{className:Ve("px-3 py-2 rounded-md text-sm font-medium capitalize",j(e.priority)),children:[i.jsx(J4,{className:"w-4 h-4 inline mr-2"}),e.priority||"Not set"]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),e.dependencies&&e.dependencies.length>0?i.jsx("div",{className:"flex flex-wrap gap-1",children:e.dependencies.map(_=>i.jsxs("button",{onClick:()=>a&&a({id:_}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!a,title:a?`Click to view Task ${_}`:`Task ${_}`,children:[i.jsx(Rf,{className:"w-3 h-3 inline mr-1"}),_]},_))}):i.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),l?i.jsx("textarea",{value:u.description||"",onChange:_=>d({...u,description:_.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.description||"No description provided"})]}),e.details&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[i.jsxs("button",{onClick:()=>f(!h),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),h?i.jsx(Mr,{className:"w-4 h-4 text-gray-500"}):i.jsx(Xr,{className:"w-4 h-4 text-gray-500"})]}),h&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:l?i.jsx("textarea",{value:u.details||"",onChange:_=>d({...u,details:_.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):i.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.details})})})]}),e.testStrategy&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[i.jsxs("button",{onClick:()=>v(!g),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),g?i.jsx(Mr,{className:"w-4 h-4 text-gray-500"}):i.jsx(Xr,{className:"w-4 h-4 text-gray-500"})]}),g&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:i.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.testStrategy})})})]}),e.subtasks&&e.subtasks.length>0&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",e.subtasks.length,")"]}),i.jsx("div",{className:"space-y-2",children:e.subtasks.map(_=>{const M=A(_.status),P=M.icon;return i.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[i.jsx(P,{className:Ve("w-4 h-4",M.color)}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:_.title}),_.description&&i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:_.description})]}),i.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:_.id})]},_.id)})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",e.id]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:t,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},pE=({onShowAllTasks:e,onStartTask:t,className:r=""})=>{const{nextTask:n,tasks:a,currentProject:s,isLoadingTasks:o,projectTaskMaster:l,refreshTasks:c,refreshProjects:u}=ms(),[d,p]=x.useState(!1),[m,h]=x.useState(!1),[f,g]=x.useState(!1),[v,E]=x.useState(!1),[w,k]=x.useState(!1),[C,A]=x.useState(!1),[T,I]=x.useState(!1),j=()=>{g(!0),h(!1)},L=()=>{E(!0),h(!1)};if(!s||o)return null;let _;if((!a||a.length===0)&&!l?.hasTaskmaster)_=i.jsxs("div",{className:Ve("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",r),children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Io,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),i.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsxs("button",{onClick:()=>h(!m),className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1",children:[i.jsx(Rt,{className:"w-3 h-3"}),"Initialize TaskMaster AI"]})})]}),m&&i.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!l?.hasTaskmaster&&i.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[i.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),i.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[i.jsxs("p",{children:["• ",i.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),i.jsx("div",{className:"flex flex-col gap-2",children:l?.hasTaskmaster?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[i.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),i.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:j,disabled:T,children:[i.jsx(er,{className:"w-3 h-3"}),"Create a new task manually"]}),i.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:L,disabled:T,children:[i.jsx(Jt,{className:"w-3 h-3"}),T?"Parsing...":"Generate tasks from PRD template"]})]}):i.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>k(!0),children:[i.jsx(ir,{className:"w-3 h-3"}),"Initialize TaskMaster"]})})]})]});else if(n)_=i.jsx("div",{className:Ve("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",r),children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:i.jsx(FI,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),i.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",n.id]}),n.priority==="high"&&i.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:i.jsx(jf,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),n.priority==="medium"&&i.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:i.jsx(J4,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),n.priority==="low"&&i.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:i.jsx(Qa,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),i.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:n.title})]}),i.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[i.jsxs("button",{onClick:()=>t?.(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[i.jsx(bI,{className:"w-3 h-3"}),"Start Task"]}),i.jsx("button",{onClick:()=>A(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:i.jsx(Aa,{className:"w-3 h-3"})}),e&&i.jsx("button",{onClick:e,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:i.jsx(Io,{className:"w-3 h-3"})})]})]})});else if(a&&a.length>0){const M=a.filter($=>$.status==="done").length,P=a.length;_=i.jsx("div",{className:Ve("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",r),children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(vi,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),i.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:M===P?"All done! 🎉":"No pending tasks"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[M,"/",P]}),i.jsx("button",{onClick:e,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else _=null;return i.jsxs(i.Fragment,{children:[_,f&&i.jsx(VG,{currentProject:s,onClose:()=>g(!1),onTaskCreated:()=>{c(),g(!1)}}),v&&i.jsx(YG,{currentProject:s,onClose:()=>E(!1),onTemplateApplied:()=>{c(),E(!1)}}),w&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:i.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(ir,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",s?.displayName]})]})]}),i.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"flex-1 p-4",children:i.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:i.jsx(Mf,{selectedProject:s,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),i.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),i.jsx("button",{onClick:()=>k(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),C&&n&&i.jsx(dN,{task:n,isOpen:C,onClose:()=>A(!1),onStatusChange:()=>c?.(),onTaskClick:null})]})},VG=({currentProject:e,onClose:t,onTaskCreated:r})=>{const[n,a]=x.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[s,o]=x.useState(!1),l=async c=>{if(c.preventDefault(),!!e){o(!0);try{const u=n.useAI?{prompt:n.prompt,priority:n.priority}:{title:n.title,description:n.description,priority:n.priority},d=await bt.taskmaster.addTask(e.name,u);if(d.ok)r();else{const p=await d.json();console.error("Failed to create task:",p),alert(`Failed to create task: ${p.message}`)}}catch(u){console.error("Error creating task:",u),alert("Error creating task. Please try again.")}finally{o(!1)}}};return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),i.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:i.jsx(_t,{className:"w-4 h-4"})})]}),i.jsxs("form",{onSubmit:l,className:"space-y-4",children:[i.jsx("div",{children:i.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[i.jsx("input",{type:"checkbox",checked:n.useAI,onChange:c=>a(u=>({...u,useAI:c.target.checked}))}),"Use AI to generate task details"]})}),n.useAI?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),i.jsx("textarea",{value:n.prompt,onChange:c=>a(u=>({...u,prompt:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),i.jsx("input",{type:"text",value:n.title,onChange:c=>a(u=>({...u,title:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),i.jsx("textarea",{value:n.description,onChange:c=>a(u=>({...u,description:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),i.jsxs("select",{value:n.priority,onChange:c=>a(u=>({...u,priority:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[i.jsx("option",{value:"low",children:"Low"}),i.jsx("option",{value:"medium",children:"Medium"}),i.jsx("option",{value:"high",children:"High"})]})]}),i.jsxs("div",{className:"flex gap-2 pt-4",children:[i.jsx("button",{type:"button",onClick:t,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:s,children:"Cancel"}),i.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:s||n.useAI&&!n.prompt.trim()||!n.useAI&&(!n.title.trim()||!n.description.trim()),children:s?"Creating...":"Create Task"})]})]})]})})},YG=({currentProject:e,onClose:t,onTemplateApplied:r})=>{const[n,a]=x.useState([]),[s,o]=x.useState(null),[l,c]=x.useState({}),[u,d]=x.useState("prd.txt"),[p,m]=x.useState(!0),[h,f]=x.useState(!1),[g,v]=x.useState("select");useEffect(()=>{(async()=>{try{const C=await bt.taskmaster.getTemplates();if(C.ok){const A=await C.json();a(A.templates)}}catch(C){console.error("Error loading templates:",C)}finally{m(!1)}})()},[]);const E=k=>{o(k);const C=k.content.match(/\[([^\]]+)\]/g)||[],A=[...new Set(C.map(I=>I.slice(1,-1)))],T={};A.forEach(I=>{T[I]=""}),c(T),v("customize")},w=async()=>{if(!(!s||!e)){f(!0);try{const k=await bt.taskmaster.applyTemplate(e.name,{templateId:s.id,fileName:u,customizations:l});if(!k.ok){const A=await k.json();throw new Error(A.message||"Failed to apply template")}const C=await bt.taskmaster.parsePRD(e.name,{fileName:u,numTasks:10});if(!C.ok){const A=await C.json();throw new Error(A.message||"Failed to generate tasks")}v("generate"),setTimeout(()=>{r()},2e3)}catch(k){console.error("Error applying template:",k),alert(`Error: ${k.message}`),f(!1)}}};return p?i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),i.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g==="select"?"Select PRD Template":g==="customize"?"Customize Template":"Generating Tasks"}),i.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:i.jsx(_t,{className:"w-4 h-4"})})]}),g==="select"&&i.jsx("div",{className:"space-y-3",children:n.map(k=>i.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>E(k),children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:k.name}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:k.description}),i.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:k.category})]}),i.jsx(Rf,{className:"w-4 h-4 text-gray-400 mt-1"})]})},k.id))}),g==="customize"&&s&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),i.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(l).length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),i.jsx("div",{className:"space-y-3",children:Object.entries(l).map(([k,C])=>i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:k.replace(/([A-Z])/g," $1").replace(/^./,A=>A.toUpperCase())}),i.jsx("input",{type:"text",value:C,onChange:A=>c(T=>({...T,[k]:A.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${k.toLowerCase()}`})]},k))})]}),i.jsxs("div",{className:"flex gap-2 pt-4",children:[i.jsx("button",{onClick:()=>v("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),i.jsx("button",{onClick:w,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:h,children:h?"Applying...":"Apply & Generate Tasks"})]})]}),g==="generate"&&i.jsxs("div",{className:"text-center py-8",children:[i.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(vi,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),i.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),i.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},pN={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},mN={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},hN={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},KG=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function XG(e){return e==="claude"?pN:e==="codex"?hN:mN}function ZG(e,t,r,n){return e==="claude"?t:e==="codex"?n:r}function QG({selectedSession:e,currentSessionId:t,provider:r,setProvider:n,textareaRef:a,claudeModel:s,setClaudeModel:o,cursorModel:l,setCursorModel:c,codexModel:u,setCodexModel:d,tasksEnabled:p,isTaskMasterInstalled:m,onShowAllTasks:h,setInput:f}){const{t:g}=Nt("chat"),v=g("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),E=A=>{n(A),localStorage.setItem("selected-provider",A),setTimeout(()=>a.current?.focus(),100)},w=A=>{r==="claude"?(o(A),localStorage.setItem("claude-model",A)):r==="codex"?(d(A),localStorage.setItem("codex-model",A)):(c(A),localStorage.setItem("cursor-model",A))},k=XG(r),C=ZG(r,s,l,u);return!e&&!t?i.jsx("div",{className:"flex items-center justify-center h-full px-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:g("providerSelection.title")}),i.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:g("providerSelection.description")})]}),i.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:KG.map(A=>{const T=r===A.id;return i.jsxs("button",{onClick:()=>E(A.id),className:`
|
|
940
|
+
`).filter(L=>L.trim()),I=T.find(L=>L.includes("?"))||T[0]||"",j=[];return T.forEach(L=>{const _=L.match(/[❯\s]*(\d+)\.\s+(.+)/);if(_){const M=L.includes("❯");j.push({number:_[1],text:_[2].trim(),isSelected:M})}}),i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:I}),i.jsx("div",{className:"space-y-2 mb-4",children:j.map(L=>i.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${L.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${L.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:L.number}),i.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:L.text}),L.isSelected&&i.jsx("span",{className:"text-lg",children:"❯"})]})},L.number))}),i.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[i.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:m("interactive.waiting")}),i.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:m("interactive.instruction")})]})]})})()]})]})}):e.isThinking?i.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:i.jsxs("details",{className:"group",children:[i.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[i.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),i.jsx("span",{children:m("thinking.emoji")})]}),i.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:i.jsx(Hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:e.content})})]})}):i.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&e.reasoning&&i.jsxs("details",{className:"mb-3",children:[i.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:m("thinking.emoji")}),i.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:i.jsx("div",{className:"whitespace-pre-wrap",children:e.reasoning})})]}),(()=>{const T=lf(String(e.content||"")),I=T.trim();if((I.startsWith("{")||I.startsWith("["))&&(I.endsWith("}")||I.endsWith("]")))try{const j=JSON.parse(I),L=JSON.stringify(j,null,2);return i.jsxs("div",{className:"my-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),i.jsx("span",{className:"font-medium",children:m("json.response")})]}),i.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:i.jsx("pre",{className:"p-4 overflow-x-auto",children:i.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:L})})})]})}catch{}return e.type==="assistant"?i.jsx(Hs,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:T}):i.jsx("div",{className:"whitespace-pre-wrap",children:T})})()]}),!h&&i.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:C})]})]})})}),dN=({task:e,onClose:t,onEdit:r,onStatusChange:n,onTaskClick:a,isOpen:s=!0,className:o=""})=>{const[l,c]=x.useState(!1),[u,d]=x.useState(e||{}),[p,m]=x.useState(!1),[h,f]=x.useState(!1),[g,v]=x.useState(!1),{currentProject:E,refreshTasks:w}=ms();if(!s||!e)return null;const k=async()=>{if(E){m(!0);try{const _={};if(u.title!==e.title&&(_.title=u.title),u.description!==e.description&&(_.description=u.description),u.details!==e.details&&(_.details=u.details),Object.keys(_).length>0){const M=await bt.taskmaster.updateTask(E.name,e.id,_);if(M.ok)w?.(),r?.(u),c(!1);else{const P=await M.json();console.error("Failed to update task:",P),alert(`Failed to update task: ${P.message}`)}}else c(!1)}catch(_){console.error("Error updating task:",_),alert("Error updating task. Please try again.")}finally{m(!1)}}},C=()=>{navigator.clipboard.writeText(e.id.toString())},A=_=>{switch(_){case"done":return{icon:vi,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:ii,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:rl,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:nS,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:_t,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:Qa,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},T=A(e.status),I=T.icon,j=_=>{switch(_){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},L=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return i.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:i.jsxs("div",{className:Ve("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",o),children:[i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[i.jsx(I,{className:Ve("w-6 h-6",T.color)}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsxs("button",{onClick:C,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[i.jsxs("span",{children:["Task ",e.id]}),i.jsx(X4,{className:"w-3 h-3"})]}),e.parentId&&i.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",e.parentId]})]}),l?i.jsx("input",{type:"text",value:u.title||"",onChange:_=>d({...u,title:_.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):i.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:e.title})]})]}),i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[l?i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:k,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:i.jsx(_o,{className:Ve("w-5 h-5",p&&"animate-spin")})}),i.jsx("button",{onClick:()=>{c(!1),d(e)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:i.jsx(_t,{className:"w-5 h-5"})})]}):i.jsx("button",{onClick:()=>c(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:i.jsx(OI,{className:"w-5 h-5"})}),i.jsx("button",{onClick:t,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:i.jsx(_t,{className:"w-5 h-5"})})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),i.jsx("div",{className:Ve("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",T.bg,T.color),children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(I,{className:"w-4 h-4"}),i.jsx("span",{className:"font-medium capitalize",children:L.find(_=>_.value===e.status)?.label||e.status})]})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),i.jsxs("div",{className:Ve("px-3 py-2 rounded-md text-sm font-medium capitalize",j(e.priority)),children:[i.jsx(J4,{className:"w-4 h-4 inline mr-2"}),e.priority||"Not set"]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),e.dependencies&&e.dependencies.length>0?i.jsx("div",{className:"flex flex-wrap gap-1",children:e.dependencies.map(_=>i.jsxs("button",{onClick:()=>a&&a({id:_}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!a,title:a?`Click to view Task ${_}`:`Task ${_}`,children:[i.jsx(Rf,{className:"w-3 h-3 inline mr-1"}),_]},_))}):i.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),l?i.jsx("textarea",{value:u.description||"",onChange:_=>d({...u,description:_.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.description||"No description provided"})]}),e.details&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[i.jsxs("button",{onClick:()=>f(!h),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),h?i.jsx(Mr,{className:"w-4 h-4 text-gray-500"}):i.jsx(Xr,{className:"w-4 h-4 text-gray-500"})]}),h&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:l?i.jsx("textarea",{value:u.details||"",onChange:_=>d({...u,details:_.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):i.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.details})})})]}),e.testStrategy&&i.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[i.jsxs("button",{onClick:()=>v(!g),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),g?i.jsx(Mr,{className:"w-4 h-4 text-gray-500"}):i.jsx(Xr,{className:"w-4 h-4 text-gray-500"})]}),g&&i.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:i.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:i.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:e.testStrategy})})})]}),e.subtasks&&e.subtasks.length>0&&i.jsxs("div",{className:"space-y-3",children:[i.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",e.subtasks.length,")"]}),i.jsx("div",{className:"space-y-2",children:e.subtasks.map(_=>{const M=A(_.status),P=M.icon;return i.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[i.jsx(P,{className:Ve("w-4 h-4",M.color)}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:_.title}),_.description&&i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:_.description})]}),i.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:_.id})]},_.id)})})]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",e.id]}),i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("button",{onClick:t,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},pE=({onShowAllTasks:e,onStartTask:t,className:r=""})=>{const{nextTask:n,tasks:a,currentProject:s,isLoadingTasks:o,projectTaskMaster:l,refreshTasks:c,refreshProjects:u}=ms(),[d,p]=x.useState(!1),[m,h]=x.useState(!1),[f,g]=x.useState(!1),[v,E]=x.useState(!1),[w,k]=x.useState(!1),[C,A]=x.useState(!1),[T,I]=x.useState(!1),j=()=>{g(!0),h(!1)},L=()=>{E(!0),h(!1)};if(!s||o)return null;let _;if((!a||a.length===0)&&!l?.hasTaskmaster)_=i.jsxs("div",{className:Ve("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",r),children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Io,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),i.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),i.jsx("div",{className:"flex items-center gap-1",children:i.jsxs("button",{onClick:()=>h(!m),className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1",children:[i.jsx(Rt,{className:"w-3 h-3"}),"Initialize TaskMaster AI"]})})]}),m&&i.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!l?.hasTaskmaster&&i.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[i.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),i.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[i.jsxs("p",{children:["• ",i.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),i.jsxs("p",{children:["• ",i.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),i.jsx("div",{className:"flex flex-col gap-2",children:l?.hasTaskmaster?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[i.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),i.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:j,disabled:T,children:[i.jsx(er,{className:"w-3 h-3"}),"Create a new task manually"]}),i.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:L,disabled:T,children:[i.jsx(Jt,{className:"w-3 h-3"}),T?"Parsing...":"Generate tasks from PRD template"]})]}):i.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>k(!0),children:[i.jsx(ir,{className:"w-3 h-3"}),"Initialize TaskMaster"]})})]})]});else if(n)_=i.jsx("div",{className:Ve("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",r),children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:i.jsx(FI,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),i.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",n.id]}),n.priority==="high"&&i.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:i.jsx(jf,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),n.priority==="medium"&&i.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:i.jsx(J4,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),n.priority==="low"&&i.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:i.jsx(Qa,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),i.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:n.title})]}),i.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[i.jsxs("button",{onClick:()=>t?.(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[i.jsx(bI,{className:"w-3 h-3"}),"Start Task"]}),i.jsx("button",{onClick:()=>A(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:i.jsx(Aa,{className:"w-3 h-3"})}),e&&i.jsx("button",{onClick:e,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:i.jsx(Io,{className:"w-3 h-3"})})]})]})});else if(a&&a.length>0){const M=a.filter($=>$.status==="done").length,P=a.length;_=i.jsx("div",{className:Ve("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",r),children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(vi,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),i.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:M===P?"All done! 🎉":"No pending tasks"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[M,"/",P]}),i.jsx("button",{onClick:e,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else _=null;return i.jsxs(i.Fragment,{children:[_,f&&i.jsx(VG,{currentProject:s,onClose:()=>g(!1),onTaskCreated:()=>{c(),g(!1)}}),v&&i.jsx(YG,{currentProject:s,onClose:()=>E(!1),onTemplateApplied:()=>{c(),E(!1)}}),w&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:i.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:i.jsx(ir,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",s?.displayName]})]})]}),i.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:i.jsx(_t,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"flex-1 p-4",children:i.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:i.jsx(Mf,{selectedProject:s,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),i.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),i.jsx("button",{onClick:()=>k(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),C&&n&&i.jsx(dN,{task:n,isOpen:C,onClose:()=>A(!1),onStatusChange:()=>c?.(),onTaskClick:null})]})},VG=({currentProject:e,onClose:t,onTaskCreated:r})=>{const[n,a]=x.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[s,o]=x.useState(!1),l=async c=>{if(c.preventDefault(),!!e){o(!0);try{const u=n.useAI?{prompt:n.prompt,priority:n.priority}:{title:n.title,description:n.description,priority:n.priority},d=await bt.taskmaster.addTask(e.name,u);if(d.ok)r();else{const p=await d.json();console.error("Failed to create task:",p),alert(`Failed to create task: ${p.message}`)}}catch(u){console.error("Error creating task:",u),alert("Error creating task. Please try again.")}finally{o(!1)}}};return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),i.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:i.jsx(_t,{className:"w-4 h-4"})})]}),i.jsxs("form",{onSubmit:l,className:"space-y-4",children:[i.jsx("div",{children:i.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[i.jsx("input",{type:"checkbox",checked:n.useAI,onChange:c=>a(u=>({...u,useAI:c.target.checked}))}),"Use AI to generate task details"]})}),n.useAI?i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),i.jsx("textarea",{value:n.prompt,onChange:c=>a(u=>({...u,prompt:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),i.jsx("input",{type:"text",value:n.title,onChange:c=>a(u=>({...u,title:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),i.jsx("textarea",{value:n.description,onChange:c=>a(u=>({...u,description:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),i.jsxs("select",{value:n.priority,onChange:c=>a(u=>({...u,priority:c.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[i.jsx("option",{value:"low",children:"Low"}),i.jsx("option",{value:"medium",children:"Medium"}),i.jsx("option",{value:"high",children:"High"})]})]}),i.jsxs("div",{className:"flex gap-2 pt-4",children:[i.jsx("button",{type:"button",onClick:t,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:s,children:"Cancel"}),i.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:s||n.useAI&&!n.prompt.trim()||!n.useAI&&(!n.title.trim()||!n.description.trim()),children:s?"Creating...":"Create Task"})]})]})]})})},YG=({currentProject:e,onClose:t,onTemplateApplied:r})=>{const[n,a]=x.useState([]),[s,o]=x.useState(null),[l,c]=x.useState({}),[u,d]=x.useState("prd.txt"),[p,m]=x.useState(!0),[h,f]=x.useState(!1),[g,v]=x.useState("select");useEffect(()=>{(async()=>{try{const C=await bt.taskmaster.getTemplates();if(C.ok){const A=await C.json();a(A.templates)}}catch(C){console.error("Error loading templates:",C)}finally{m(!1)}})()},[]);const E=k=>{o(k);const C=k.content.match(/\[([^\]]+)\]/g)||[],A=[...new Set(C.map(I=>I.slice(1,-1)))],T={};A.forEach(I=>{T[I]=""}),c(T),v("customize")},w=async()=>{if(!(!s||!e)){f(!0);try{const k=await bt.taskmaster.applyTemplate(e.name,{templateId:s.id,fileName:u,customizations:l});if(!k.ok){const A=await k.json();throw new Error(A.message||"Failed to apply template")}const C=await bt.taskmaster.parsePRD(e.name,{fileName:u,numTasks:10});if(!C.ok){const A=await C.json();throw new Error(A.message||"Failed to generate tasks")}v("generate"),setTimeout(()=>{r()},2e3)}catch(k){console.error("Error applying template:",k),alert(`Error: ${k.message}`),f(!1)}}};return p?i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),i.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:g==="select"?"Select PRD Template":g==="customize"?"Customize Template":"Generating Tasks"}),i.jsx("button",{onClick:t,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:i.jsx(_t,{className:"w-4 h-4"})})]}),g==="select"&&i.jsx("div",{className:"space-y-3",children:n.map(k=>i.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>E(k),children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:k.name}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:k.description}),i.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:k.category})]}),i.jsx(Rf,{className:"w-4 h-4 text-gray-400 mt-1"})]})},k.id))}),g==="customize"&&s&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),i.jsx("input",{type:"text",value:u,onChange:k=>d(k.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(l).length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),i.jsx("div",{className:"space-y-3",children:Object.entries(l).map(([k,C])=>i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:k.replace(/([A-Z])/g," $1").replace(/^./,A=>A.toUpperCase())}),i.jsx("input",{type:"text",value:C,onChange:A=>c(T=>({...T,[k]:A.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${k.toLowerCase()}`})]},k))})]}),i.jsxs("div",{className:"flex gap-2 pt-4",children:[i.jsx("button",{onClick:()=>v("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),i.jsx("button",{onClick:w,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:h,children:h?"Applying...":"Apply & Generate Tasks"})]})]}),g==="generate"&&i.jsxs("div",{className:"text-center py-8",children:[i.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:i.jsx(vi,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),i.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),i.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},pN={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},mN={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},hN={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.3-codex"},KG=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function XG(e){return e==="claude"?pN:e==="codex"?hN:mN}function ZG(e,t,r,n){return e==="claude"?t:e==="codex"?n:r}function QG({selectedSession:e,currentSessionId:t,provider:r,setProvider:n,textareaRef:a,claudeModel:s,setClaudeModel:o,cursorModel:l,setCursorModel:c,codexModel:u,setCodexModel:d,tasksEnabled:p,isTaskMasterInstalled:m,onShowAllTasks:h,setInput:f}){const{t:g}=Nt("chat"),v=g("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),E=A=>{n(A),localStorage.setItem("selected-provider",A),setTimeout(()=>a.current?.focus(),100)},w=A=>{r==="claude"?(o(A),localStorage.setItem("claude-model",A)):r==="codex"?(d(A),localStorage.setItem("codex-model",A)):(c(A),localStorage.setItem("cursor-model",A))},k=XG(r),C=ZG(r,s,l,u);return!e&&!t?i.jsx("div",{className:"flex items-center justify-center h-full px-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:g("providerSelection.title")}),i.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:g("providerSelection.description")})]}),i.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:KG.map(A=>{const T=r===A.id;return i.jsxs("button",{onClick:()=>E(A.id),className:`
|
|
941
941
|
relative flex flex-col items-center gap-2.5 pt-5 pb-4 px-2
|
|
942
942
|
rounded-xl border-[1.5px] transition-all duration-150
|
|
943
943
|
active:scale-[0.97]
|