@epiphytic/claudecodeui 1.0.0 → 1.0.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.
@@ -1195,7 +1195,7 @@ File: ${e?.name||"New PRD"}
1195
1195
  Path: ${e?.path||"Not saved yet"}
1196
1196
 
1197
1197
  ${re}`)}finally{d(!1)}})()},[e,r,s]),b.useEffect(()=>{(async()=>{if(!n?.name){console.log("No project name available:",n);return}try{console.log("Fetching PRDs for project:",n.name);const X=await ut.get(`/taskmaster/prd/${encodeURIComponent(n.name)}`);if(X.ok){const me=await X.json();console.log("Fetched existing PRDs:",me.prds),F(me.prds||[])}else console.log("Failed to fetch PRDs:",X.status,X.statusText)}catch(X){console.error("Error fetching existing PRDs:",X)}})()},[n?.name]);const le=async()=>{if(!l.trim()){alert("Please add content before saving.");return}if(!I.trim()){alert("Please provide a filename for the PRD.");return}const R=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,X=q.find(me=>me.name===R);if(console.log("Save check:",{fullFileName:R,existingPRDs:q,existingFile:X,isExisting:e?.isExisting,fileObject:e,shouldShowModal:X&&!e?.isExisting}),X&&!e?.isExisting){console.log("Showing overwrite confirmation modal"),L(!0);return}await ee()},ee=async()=>{m(!0);try{const R=I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,X=await Ie(`/api/taskmaster/prd/${encodeURIComponent(n?.name)}`,{method:"POST",body:JSON.stringify({fileName:R,content:l})});if(!X.ok){const ke=await X.json();throw new Error(ke.message||`Save failed: ${X.status}`)}k(!0),setTimeout(()=>k(!1),2e3);const me=await ut.get(`/taskmaster/prd/${encodeURIComponent(n.name)}`);if(me.ok){const ke=await me.json();F(ke.prds||[])}o&&await o()}catch(R){console.error("Error saving PRD:",R),alert(`Error saving PRD: ${R.message}`)}finally{m(!1)}},K=()=>{const R=new Blob([l],{type:"text/markdown"}),X=URL.createObjectURL(R),me=document.createElement("a");me.href=X;const ke=I?`${I}.txt`:"prd.txt";me.download=ke,document.body.appendChild(me),me.click(),document.body.removeChild(me),URL.revokeObjectURL(X)},C=async()=>{if(!l.trim()){alert("Please add content to the PRD before generating tasks.");return}_(!0)},V=()=>{g(!h)};b.useEffect(()=>{const R=X=>{(X.ctrlKey||X.metaKey)&&(X.key==="s"?(X.preventDefault(),le()):X.key==="Escape"&&(X.preventDefault(),t()))};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[l]);const ie=R=>R.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return u?a.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:a.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),a.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):a.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${h?"md:p-0":""}`,children:[a.jsxs("div",{className:Xe("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",h?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:a.jsx(xr,{className:"w-4 h-4 text-white"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[a.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[a.jsx("input",{type:"text",value:I,onChange:R=>{const X=R.target.value.replace(/[<>:"/\\|?*]/g,"");D(X)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),a.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),a.jsx("button",{onClick:()=>document.querySelector('input[placeholder="Enter PRD filename"]')?.focus(),className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),s&&a.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),a.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),a.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>N(!v),className:Xe("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",v?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:v?"Switch to edit mode":"Preview markdown",children:a.jsx(Xa,{className:"w-5 h-5 md:w-4 md:h-4"})}),a.jsx("button",{onClick:()=>w(!A),className:Xe("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",A?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:A?"Disable word wrap":"Enable word wrap",children:a.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),a.jsx("button",{onClick:()=>S(!x),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:a.jsx("span",{className:"text-lg md:text-base",children:x?"☀️":"🌙"})}),a.jsx("button",{onClick:K,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:a.jsx(Ls,{className:"w-5 h-5 md:w-4 md:h-4"})}),a.jsxs("button",{onClick:C,disabled:!l.trim(),className:Xe("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[a.jsx(Tn,{className:"w-4 h-4"}),a.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),a.jsx("button",{onClick:le,disabled:p,className:Xe("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",E?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:E?a.jsxs(a.Fragment,{children:[a.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ms,{className:"w-5 h-5 md:w-4 md:h-4"}),a.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),a.jsx("button",{onClick:V,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:h?"Exit fullscreen":"Fullscreen",children:h?a.jsx(pw,{className:"w-4 h-4"}):a.jsx(nh,{className:"w-4 h-4"})}),a.jsx("button",{onClick:t,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:a.jsx(Tt,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:v?a.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:a.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:ie(l)}})}):a.jsx(nw,{ref:$,value:l,onChange:c,extensions:[iw(),...A?[Ur.lineWrapping]:[]],theme:x?aw:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),a.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[a.jsxs("span",{children:["Lines: ",l.split(`
1198
- `).length]}),a.jsxs("span",{children:["Characters: ",l.length]}),a.jsxs("span",{children:["Words: ",l.split(/\s+/).filter(R=>R.length>0).length]}),a.jsx("span",{children:"Format: Markdown"})]}),a.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:a.jsx(Tn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),a.jsx("button",{onClick:()=>_(!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:a.jsx(Tt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:a.jsx(Tn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Claude Code Directly!"}),a.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask Claude Code in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[a.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),a.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),a.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[a.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),a.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),a.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),a.jsx("div",{className:"pt-4",children:a.jsx("button",{onClick:()=>_(!1),className:"w-full 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-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask Claude Code directly"})})]})]})}),z&&a.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>L(!1)}),a.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex items-center mb-4",children:[a.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:a.jsx(ga,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),a.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),a.jsxs("div",{className:"flex justify-end space-x-3",children:[a.jsx("button",{onClick:()=>L(!1),className:"px-4 py-2 text-sm 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:"Cancel"}),a.jsxs("button",{onClick:async()=>{L(!1),await ee()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{children:"Overwrite"})]})]})]})})]})]})};function E$({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:n,ws:i,sendMessage:s,messages:o,isMobile:l,isPWA:c,onMenuClick:u,isLoading:d,onInputFocusChange:p,onSessionActive:m,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:x,processingSessions:S,onReplaceTemporarySession:E,onNavigateToSession:k,onShowSettings:v,autoExpandTools:N,showRawParameters:A,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:D,externalMessageUpdate:O}){const[_,z]=b.useState(null),[L,q]=b.useState(null),[F,$]=b.useState(!1),[re,le]=b.useState(600),[ee,K]=b.useState(!1),[C,V]=b.useState(!1),ie=b.useRef(null),[R,X]=b.useState(!1),[me,ke]=b.useState(null),[ue,De]=b.useState([]),[de,ye]=b.useState(null),{tasks:Pe,currentProject:se,refreshTasks:je,setCurrentProject:$e}=Mi(),{tasksEnabled:gt,isTaskMasterInstalled:nt,isTaskMasterReady:dt}=Fi(),tt=gt&&nt;b.useEffect(()=>{e&&e!==se&&$e(e)},[e,se,$e]),b.useEffect(()=>{!tt&&r==="tasks"&&n("chat")},[tt,r,n]),b.useEffect(()=>{(async()=>{if(!se?.name){De([]);return}try{const W=await ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`);if(W.ok){const we=await W.json();De(we.prdFiles||[])}else De([])}catch(W){console.error("Failed to load existing PRDs:",W),De([])}})()},[se?.name]);const Ve=(H,W=null)=>{const we={name:H.split("/").pop(),path:H,projectName:e?.name,diffInfo:W};z(we)},ct=()=>{z(null),V(!1)},wt=()=>{V(!C)},Rt=H=>{if(typeof H=="object"&&H.id&&!H.title){const W=Pe?.find(we=>we.id===H.id);W&&(q(W),$(!0))}else q(H),$(!0)},Pt=()=>{$(!1),q(null)},Ee=(H,W)=>{console.log("Update task status:",H,W),je?.()},pe=H=>{l||(K(!0),H.preventDefault())};return b.useEffect(()=>{const H=we=>{if(!ee)return;const Me=ie.current?.parentElement;if(!Me)return;const Ze=Me.getBoundingClientRect(),ge=Ze.right-we.clientX,U=300,Z=Ze.width*.8;ge>=U&&ge<=Z&&le(ge)},W=()=>{K(!1)};return ee&&(document.addEventListener("mousemove",H),document.addEventListener("mouseup",W),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",W),document.body.style.cursor="",document.body.style.userSelect=""}},[ee]),d?a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:a.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),a.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Loading Claude Code UI"}),a.jsx("p",{children:"Setting up your workspace..."})]})})]}):e?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsxs("div",{className:"flex items-center justify-between relative",children:[a.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[l&&a.jsx("button",{onClick:u,onTouchStart:H=>{H.preventDefault(),u()},className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[r==="chat"&&t&&a.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:t.__provider==="cursor"?a.jsx(en,{className:"w-4 h-4"}):a.jsx($r,{className:"w-4 h-4"})}),a.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r==="chat"&&!t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:r==="files"?"Project Files":r==="git"?"Source Control":r==="tasks"&&tt?"TaskMaster":"Project"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),a.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:a.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[a.jsx(yr,{content:"Chat",position:"bottom",children:a.jsx("button",{onClick:()=>n("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${r==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),a.jsx(yr,{content:"Shell",position:"bottom",children:a.jsx("button",{onClick:()=>n("shell"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),a.jsx(yr,{content:"Files",position:"bottom",children:a.jsx("button",{onClick:()=>n("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),a.jsx(yr,{content:"Source Control",position:"bottom",children:a.jsx("button",{onClick:()=>n("git"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="git"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Source Control"})]})})}),tt&&a.jsx(yr,{content:"Tasks",position:"bottom",children:a.jsx("button",{onClick:()=>n("tasks"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="tasks"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Tasks"})]})})})]})})]})}),a.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[a.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${_?"mr-0":""} ${C?"hidden":""}`,children:[a.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:a.jsx(v$,{showDetails:!0,children:a.jsx(AU,{selectedProject:e,selectedSession:t,ws:i,sendMessage:s,messages:o,onFileOpen:Ve,onInputFocusChange:p,onSessionActive:m,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:x,processingSessions:S,onReplaceTemporarySession:E,onNavigateToSession:k,onShowSettings:v,autoExpandTools:N,showRawParameters:A,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:D,externalMessageUpdate:O,onShowAllTasks:gt?()=>n("tasks"):null})})}),r==="files"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(x$,{selectedProject:e})}),r==="shell"&&a.jsx("div",{className:"h-full w-full overflow-hidden",children:a.jsx(KE,{project:e,session:t,showHeader:!1})}),r==="git"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(y$,{selectedProject:e,isMobile:l,onFileOpen:Ve})}),tt&&a.jsx("div",{className:`h-full ${r==="tasks"?"block":"hidden"}`,children:a.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:a.jsx(w$,{tasks:Pe||[],onTaskClick:Rt,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:se,onTaskCreated:je,onShowPRDEditor:(H=null)=>{ke(H),X(!0)},existingPRDs:ue,onRefreshPRDs:(H=!1)=>{se?.name&&ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`).then(W=>W.ok?W.json():Promise.reject()).then(W=>{De(W.prdFiles||[]),H&&(ye("PRD saved successfully!"),setTimeout(()=>ye(null),3e3))}).catch(W=>console.error("Failed to refresh PRDs:",W))}})})}),a.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]}),_&&!l&&a.jsxs(a.Fragment,{children:[!C&&a.jsx("div",{ref:ie,onMouseDown:pe,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:a.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),a.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${C?"flex-1":""}`,style:C?{}:{width:`${re}px`},children:a.jsx(Km,{file:_,onClose:ct,projectPath:e?.path,isSidebar:!0,isExpanded:C,onToggleExpand:wt})})]})]}),_&&l&&a.jsx(Km,{file:_,onClose:ct,projectPath:e?.path,isSidebar:!1}),tt&&F&&L&&a.jsx(xE,{task:L,isOpen:F,onClose:Pt,onStatusChange:Ee,onTaskClick:Rt}),R&&a.jsx(S$,{project:se,projectPath:se?.fullPath||se?.path,onClose:()=>{X(!1),ke(null)},isNewFile:!me?.isExisting,file:{name:me?.name||"prd.txt",content:me?.content||""},onSave:async()=>{X(!1),ke(null);try{const H=await ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`);if(H.ok){const W=await H.json();De(W.prdFiles||[]),ye("PRD saved successfully!"),setTimeout(()=>ye(null),3e3)}}catch(H){console.error("Failed to refresh PRDs:",H)}je?.()}}),de&&a.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:a.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"font-medium",children:de})]})})]}):a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),a.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"Choose Your Project"}),a.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"Select a project from the sidebar to start coding with Claude. Each project contains your chat sessions and file history."}),a.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:a.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",a.jsx("strong",{children:"Tip:"})," ",l?"Tap the menu button above to access projects":"Create a new project by clicking the folder icon in the sidebar"]})})]})})]})}const N$=Wt.memo(E$);function C$({activeTab:e,setActiveTab:t,isInputFocused:r}){const{tasksEnabled:n}=Fi(),i=[{id:"chat",icon:Si,onClick:()=>t("chat")},{id:"shell",icon:Zn,onClick:()=>t("shell")},{id:"files",icon:Yn,onClick:()=>t("files")},{id:"git",icon:Cn,onClick:()=>t("git")},...n?[{id:"tasks",icon:N5,onClick:()=>t("tasks")}]:[]];return a.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${r?"translate-y-full":"translate-y-0"}`,children:a.jsx("div",{className:"flex items-center justify-around py-1",children:i.map(s=>{const o=s.icon,l=e===s.id;return a.jsxs("button",{onClick:s.onClick,onTouchStart:c=>{c.preventDefault(),s.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${l?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":s.id,children:[a.jsx(o,{className:"w-5 h-5"}),l&&a.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},s.id)})})})}const Xm="1.13.6",XE=(e,t)=>{const[r,n]=b.useState(!1),[i,s]=b.useState(null),[o,l]=b.useState(null);return b.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(Xm!==m),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:i,currentVersion:Xm,releaseInfo:o}};function T$(){const[e,t]=b.useState([]),[r,n]=b.useState([]),[i,s]=b.useState(!0),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(""),[S,E]=b.useState(""),[k,v]=b.useState({}),[N,A]=b.useState(null),[w,I]=b.useState(null),{updateAvailable:D,latestVersion:O,releaseInfo:_}=XE("siteboon","claudecodeui");b.useEffect(()=>{z()},[]);const z=async()=>{try{s(!0);const C=await(await Ie("/api/settings/api-keys")).json();t(C.apiKeys||[]);const ie=await(await Ie("/api/settings/credentials?type=github_token")).json();n(ie.credentials||[])}catch(K){console.error("Error fetching settings:",K)}finally{s(!1)}},L=async()=>{if(d.trim())try{const C=await(await Ie("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:d})})).json();C.success&&(I(C.apiKey),p(""),l(!1),z())}catch(K){console.error("Error creating API key:",K)}},q=async K=>{if(confirm("Are you sure you want to delete this API key?"))try{await Ie(`/api/settings/api-keys/${K}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting API key:",C)}},F=async(K,C)=>{try{await Ie(`/api/settings/api-keys/${K}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling API key:",V)}},$=async()=>{if(!(!m.trim()||!g.trim()))try{(await(await Ie("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:m,credentialType:"github_token",credentialValue:g,description:S})})).json()).success&&(h(""),x(""),E(""),u(!1),z())}catch(K){console.error("Error creating GitHub credential:",K)}},re=async K=>{if(confirm("Are you sure you want to delete this GitHub token?"))try{await Ie(`/api/settings/credentials/${K}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting GitHub credential:",C)}},le=async(K,C)=>{try{await Ie(`/api/settings/credentials/${K}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling GitHub credential:",V)}},ee=(K,C)=>{navigator.clipboard.writeText(K),A(C),setTimeout(()=>A(null),2e3)};return i?a.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):a.jsxs("div",{className:"space-y-8",children:[w&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[a.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:"⚠️ Save Your API Key"}),a.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"This is the only time you'll see this key. Store it securely."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:w.apiKey}),a.jsx(We,{size:"sm",variant:"outline",onClick:()=>ee(w.apiKey,"new"),children:N==="new"?a.jsx(cr,{className:"h-4 w-4"}):a.jsx(lw,{className:"h-4 w-4"})})]}),a.jsx(We,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>I(null),children:"I've saved it"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rh,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"API Keys"})]}),a.jsxs(We,{size:"sm",onClick:()=>l(!o),children:[a.jsx(ar,{className:"h-4 w-4 mr-1"}),"New API Key"]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Generate API keys to access the external API from other applications."}),a.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:["API Documentation",a.jsx(Eg,{className:"h-3 w-3"})]})]}),o&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[a.jsx(Ht,{placeholder:"API Key Name (e.g., Production Server)",value:d,onChange:K=>p(K.target.value),className:"mb-2"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:L,children:"Create"}),a.jsx(We,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]}),a.jsx("div",{className:"space-y-2",children:e.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No API keys created yet."}):e.map(K=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:K.key_name}),a.jsx("code",{className:"text-xs text-muted-foreground",children:K.api_key}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Created: ",new Date(K.created_at).toLocaleDateString(),K.last_used&&` • Last used: ${new Date(K.last_used).toLocaleDateString()}`]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:K.is_active?"outline":"secondary",onClick:()=>F(K.id,K.is_active),children:K.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>q(K.id),children:a.jsx(jr,{className:"h-4 w-4"})})]})]},K.id))})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(PN,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"GitHub Credentials"})]}),a.jsxs(We,{size:"sm",onClick:()=>u(!c),children:[a.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Token"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add GitHub Personal Access Tokens to clone private repositories. You can also pass tokens directly in API requests without storing them."}),c&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[a.jsx(Ht,{placeholder:"Token Name (e.g., Personal Repos)",value:m,onChange:K=>h(K.target.value)}),a.jsxs("div",{className:"relative",children:[a.jsx(Ht,{type:k.new?"text":"password",placeholder:"GitHub Personal Access Token (ghp_...)",value:g,onChange:K=>x(K.target.value),className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>v({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?a.jsx(cw,{className:"h-4 w-4"}):a.jsx(Xa,{className:"h-4 w-4"})})]}),a.jsx(Ht,{placeholder:"Description (optional)",value:S,onChange:K=>E(K.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:$,children:"Add Token"}),a.jsx(We,{variant:"outline",onClick:()=>{u(!1),h(""),x(""),E("")},children:"Cancel"})]}),a.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:"How to create a GitHub Personal Access Token →"})]}),a.jsx("div",{className:"space-y-2",children:r.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No GitHub tokens added yet."}):r.map(K=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:K.credential_name}),K.description&&a.jsx("div",{className:"text-xs text-muted-foreground",children:K.description}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Added: ",new Date(K.created_at).toLocaleDateString()]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:K.is_active?"outline":"secondary",onClick:()=>le(K.id,K.is_active),children:K.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>re(K.id),children:a.jsx(jr,{className:"h-4 w-4"})})]})]},K.id))})]}),a.jsx("div",{className:"pt-6 border-t border-border/50",children:a.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[a.jsxs("a",{href:_?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Xm]}),D&&O&&a.jsxs("a",{href:_?.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:[a.jsxs("span",{className:"text-[10px]",children:["Update available: v",O]}),a.jsx(Eg,{className:"h-2.5 w-2.5"})]})]})})]})}function A$(){const[e,t]=b.useState(""),[r,n]=b.useState(""),[i,s]=b.useState(!1),[o,l]=b.useState(!1),[c,u]=b.useState(null);b.useEffect(()=>{d()},[]);const d=async()=>{try{s(!0);const m=await Ie("/api/user/git-config");if(m.ok){const h=await m.json();t(h.gitName||""),n(h.gitEmail||"")}}catch(m){console.error("Error loading git config:",m)}finally{s(!1)}},p=async()=>{try{l(!0);const m=await Ie("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:e,gitEmail:r})});if(m.ok)u("success"),setTimeout(()=>u(null),3e3);else{const h=await m.json();u("error"),console.error("Failed to save git config:",h.error)}}catch(m){console.error("Error saving git config:",m),u("error")}finally{l(!1)}};return a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(Cn,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Git Configuration"})]}),a.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Configure your git identity for commits. These settings will be applied globally via ",a.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:"git config --global"})]}),a.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:"Git Name"}),a.jsx(Ht,{id:"settings-git-name",type:"text",value:e,onChange:m=>t(m.target.value),placeholder:"John Doe",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your name for git commits"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:"Git Email"}),a.jsx(Ht,{id:"settings-git-email",type:"email",value:r,onChange:m=>n(m.target.value),placeholder:"john@example.com",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your email for git commits"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{onClick:p,disabled:o||!e||!r,children:o?"Saving...":"Save Configuration"}),c==="success"&&a.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[a.jsx(cr,{className:"w-4 h-4"}),"Saved successfully"]})]})]})]})})}function I$(){const{tasksEnabled:e,setTasksEnabled:t,isTaskMasterInstalled:r,isCheckingInstallation:n}=Fi();return a.jsx("div",{className:"space-y-8",children:n?a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking TaskMaster installation..."})]})}):a.jsxs(a.Fragment,{children:[!r&&a.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:"TaskMaster AI CLI Not Installed"}),a.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[a.jsx("p",{children:"TaskMaster CLI is required to use task management features. Install it to get started:"}),a.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:a.jsx("code",{children:"npm install -g task-master-ai"})}),a.jsx("div",{children:a.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:[a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:a.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"})}),"View on GitHub",a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"font-medium",children:"After installation:"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[a.jsx("li",{children:"Restart this application"}),a.jsx("li",{children:"TaskMaster features will automatically become available"}),a.jsxs("li",{children:["Use ",a.jsx("code",{className:"bg-orange-100 dark:bg-orange-800 px-1 rounded",children:"task-master init"})," in your project directory"]})]})]})]})]})]})}),r&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Enable TaskMaster Integration"}),a.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:"Show TaskMaster tasks, banners, and sidebar indicators across the interface"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:i=>t(i.target.checked),className:"sr-only peer"}),a.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"})]})]})})})]})})}function ZE({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:i,customCommand:s}){if(!e)return null;const o=()=>{if(s)return s;const u=!1;switch(r){case"claude":return"claude setup-token --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return u?"codex login --device-auth":"codex login";default:return"claude setup-token --dangerously-skip-permissions"}},l=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=u=>{i&&i(u),u===0&&t()};return a.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:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l()}),a.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:a.jsx(Tt,{className:"w-6 h-6"})})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(KE,{project:n,command:o(),onComplete:c,minimal:!0})})]})})}const R$={claude:{name:"Claude",color:"blue",Logo:$r},cursor:{name:"Cursor",color:"purple",Logo:en},codex:{name:"Codex",color:"gray",Logo:un}},j$={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:i=!1}){const s=R$[e],o=j$[s.color],{Logo:l}=s;return i?a.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${o.borderBottom} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(l,{className:"w-5 h-5"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name}),t?.authenticated&&a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`})]})}):a.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${o.border} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(l,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:s.name})]}),a.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?a.jsx("span",{className:"text-gray-400",children:"Checking..."}):t?.authenticated?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`}),a.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||"Connected"})]}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),a.jsx("span",{children:"Not connected"})]})})]})}const _$={claude:{name:"Claude",description:"Anthropic Claude AI assistant",Logo:$r,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",Logo:en,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",Logo:un,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 O$({agent:e,authStatus:t,onLogin:r}){const n=_$[e],{Logo:i}=n;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx(i,{className:"w-6 h-6"}),a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-medium text-foreground",children:[n.name," Account"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]})]}),a.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:"Connection Status"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.loading?"Checking authentication status...":t?.authenticated?`Logged in as ${t.email||"authenticated user"}`:"Not connected"})]}),a.jsx("div",{children:t?.loading?a.jsx(tn,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:"Checking..."}):t?.authenticated?a.jsx(tn,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:"Connected"}):a.jsx(tn,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:"Disconnected"})})]}),a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:t?.authenticated?"Re-authenticate":"Login"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.authenticated?"Sign in with a different account or refresh credentials":`Sign in to your ${n.name} account to enable AI features`})]}),a.jsxs(We,{onClick:r,className:`${n.buttonClass} text-white`,size:"sm",children:[a.jsx(dw,{className:"w-4 h-4 mr-2"}),t?.authenticated?"Re-login":"Login"]})]})}),t?.error&&a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"text-sm text-red-600 dark:text-red-400",children:["Error: ",t.error]})})]})})]})}const L$=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],D$=["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 M$({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:i,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to --dangerously-skip-permissions flag"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically allowed without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common tools:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:L$.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed tools configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically blocked without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked tools configured"})]})]}),a.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"Tool Pattern Examples:"}),a.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - Allow all git log commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - Allow all git diff commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - Allow all Write tool usage"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - Block all rm commands (dangerous)"]})]})]})]})}function F$({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:i,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to -f flag in Cursor CLI"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically allowed without prompting"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common commands:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:D$.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed commands configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically blocked"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked commands configured"})]})]}),a.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell Command Examples:"}),a.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - Allow ls command"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - Allow git status"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - Allow npm install"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - Block recursive delete"]})]})]})]})}function P$({permissionMode:e,setPermissionMode:t}){return a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Mode"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how Codex handles file modifications and command execution"}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Only trusted commands (ls, cat, grep, git status, etc.) run automatically. Other commands are skipped. Can write to workspace."})]})]})}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"Accept Edits"}),a.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"All commands run automatically within the workspace. Full auto mode with sandboxed execution."})]})]})}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),a.jsxs("div",{children:[a.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["Bypass Permissions",a.jsx(ga,{className:"w-4 h-4"})]}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Full system access with no restrictions. All commands run automatically with full disk and network access. Use with caution."})]})]})}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Technical details"}),a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),a.jsx("p",{className:"text-xs opacity-75",children:"You can override this per-session using the mode button in the chat interface."})]})]})]})})}function rm({agent:e,...t}){return e==="claude"?a.jsx(M$,{...t}):e==="cursor"?a.jsx(F$,{...t}):e==="codex"?a.jsx(P$,{...t}):null}const B$=e=>{switch(e){case"stdio":return a.jsx(Zn,{className:"w-4 h-4"});case"sse":return a.jsx(ih,{className:"w-4 h-4"});case"http":return a.jsx(im,{className:"w-4 h-4"});default:return a.jsx(to,{className:"w-4 h-4"})}};function z$({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:i,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Claude"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(u=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[B$(u.type),a.jsx("span",{className:"font-medium text-foreground",children:u.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:u.type}),a.jsx(tn,{variant:"outline",className:"text-xs",children:u.scope==="local"?"local":u.scope==="user"?"user":u.scope})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&u.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.command})]}),(u.type==="sse"||u.type==="http")&&u.config?.url&&a.jsxs("div",{children:["URL: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.url})]}),u.config?.args&&u.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.args.join(" ")})]})]}),o?.[u.id]&&a.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[u.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:a.jsx("div",{className:"font-medium",children:o[u.id].message})}),l?.[u.id]&&l[u.id].tools?.length>0&&a.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:[a.jsxs("div",{className:"font-medium",children:["Tools (",l[u.id].tools.length,"):"]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((d,p)=>a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:d.name},p)),l[u.id].tools.length>5&&a.jsxs("span",{className:"text-xs opacity-75",children:["+",l[u.id].tools.length-5," more"]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},u.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function U$({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Cursor"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Zn,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsx("div",{className:"text-sm text-muted-foreground",children:i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]})})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},i.name||i.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function $$({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Codex"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Zn,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]}),i.config?.args&&i.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.args.join(" ")})]}),i.config?.env&&Object.keys(i.config.env).length>0&&a.jsxs("div",{children:["Environment: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(i.config.env).map(([s,o])=>`${s}=${o}`).join(", ")})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},i.name)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]}),a.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"About Codex MCP"}),a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex supports stdio-based MCP servers. You can add servers that extend Codex's capabilities with additional tools and resources."})]})]})}function nm({agent:e,...t}){return e==="claude"?a.jsx(z$,{...t}):e==="cursor"?a.jsx(U$,{...t}):e==="codex"?a.jsx($$,{...t}):null}function q$({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:i,toggleDarkMode:s}=Li(),[o,l]=b.useState([]),[c,u]=b.useState([]),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(!1),[S,E]=b.useState(!1),[k,v]=b.useState(null),[N,A]=b.useState("name"),[w,I]=b.useState([]),[D,O]=b.useState(!1),[_,z]=b.useState(null),[L,q]=b.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[F,$]=b.useState(!1),[re,le]=b.useState({}),[ee,K]=b.useState({}),[C,V]=b.useState({}),[ie,R]=b.useState(n),[X,me]=b.useState(""),[ke,ue]=b.useState("claude"),[De,de]=b.useState("account"),[ye,Pe]=b.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[se,je]=b.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[$e,gt]=b.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[nt,dt]=b.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[tt,Ve]=b.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[ct,wt]=b.useState([]),[Rt,Pt]=b.useState([]),[Ee,pe]=b.useState(!1),[H,W]=b.useState(""),[we,Me]=b.useState(""),[Ze,ge]=b.useState([]),[U,Z]=b.useState([]),[fe,Se]=b.useState("default"),[oe,Te]=b.useState(!1),[Ke,ft]=b.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,It]=b.useState(null),[Vr,Dr]=b.useState(!1),[Er,Nr]=b.useState(!1),[Jt,hr]=b.useState(""),[Lt,Pn]=b.useState(null),[nr,Mr]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[ae,xe]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Je,St]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),zt=async()=>{try{const Y=await Ie("/api/cursor/mcp");if(Y.ok){const he=await Y.json();ge(he.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(Y){console.error("Error fetching Cursor MCP servers:",Y)}},Qt=async()=>{try{const Y=await Ie("/api/codex/mcp/config/read");if(Y.ok){const _e=await Y.json();if(_e.success&&_e.servers){Z(_e.servers);return}}const he=await Ie("/api/codex/mcp/cli/list");if(he.ok){const _e=await he.json();if(_e.success&&_e.servers){const ot=_e.servers.map(er=>({id:er.name,name:er.name,type:er.type||"stdio",scope:"user",config:{command:er.command||"",args:er.args||[],env:er.env||{}}}));Z(ot)}}}catch(Y){console.error("Error fetching Codex MCP servers:",Y)}},Fr=async()=>{try{const Y=await Ie("/api/mcp/cli/list");if(Y.ok){const ot=await Y.json();if(ot.success&&ot.servers){const er=ot.servers.map(Cr=>({id:Cr.id||Cr.name,name:Cr.name,type:Cr.type,scope:"user",status:Cr.status,config:{command:Cr.command||"",args:Cr.args||[],env:Cr.env||{},url:Cr.url||"",headers:Cr.headers||{},timeout:3e4},description:Cr.description,created:new Date().toISOString(),updated:new Date().toISOString()}));I(er);return}}const he=await Ie("/api/mcp/config/read");if(he.ok){const ot=await he.json();if(ot.success&&ot.servers){I(ot.servers);return}}const _e=await Ie("/api/mcp/servers?scope=user");if(_e.ok){const ot=await _e.json();I(ot.servers||[])}else console.error("Failed to fetch MCP servers")}catch(Y){console.error("Error fetching MCP servers:",Y)}},Sa=async Y=>{try{_&&await aa(_.id,"user");const he=await Ie("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:Y.name,type:Y.type,scope:Y.scope,projectPath:Y.projectPath,command:Y.config?.command,args:Y.config?.args||[],url:Y.config?.url,headers:Y.config?.headers||{},env:Y.config?.env||{}})});if(he.ok){const _e=await he.json();if(_e.success)return await Fr(),!0;throw new Error(_e.error||"Failed to save server via Claude CLI")}else{const _e=await he.json();throw new Error(_e.error||"Failed to save server")}}catch(he){throw console.error("Error saving MCP server:",he),he}},aa=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/cli/remove/${Y}?scope=${he}`,{method:"DELETE"});if(_e.ok){const ot=await _e.json();if(ot.success)return await Fr(),!0;throw new Error(ot.error||"Failed to delete server via Claude CLI")}else{const ot=await _e.json();throw new Error(ot.error||"Failed to delete server")}}catch(_e){throw console.error("Error deleting MCP server:",_e),_e}},Yr=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/servers/${Y}/test?scope=${he}`,{method:"POST"});if(_e.ok)return(await _e.json()).testResult;{const ot=await _e.json();throw new Error(ot.error||"Failed to test server")}}catch(_e){throw console.error("Error testing MCP server:",_e),_e}},vo=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/servers/${Y}/tools?scope=${he}`,{method:"POST"});if(_e.ok)return(await _e.json()).toolsResult;{const ot=await _e.json();throw new Error(ot.error||"Failed to discover tools")}}catch(_e){throw console.error("Error discovering MCP tools:",_e),_e}},nn=async Y=>{try{lt&&await Bn(lt.id);const he=await Ie("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:Y.name,command:Y.config?.command,args:Y.config?.args||[],env:Y.config?.env||{}})});if(he.ok){const _e=await he.json();if(_e.success)return await Qt(),!0;throw new Error(_e.error||"Failed to save Codex MCP server")}else{const _e=await he.json();throw new Error(_e.error||"Failed to save server")}}catch(he){throw console.error("Error saving Codex MCP server:",he),he}},Bn=async Y=>{try{const he=await Ie(`/api/codex/mcp/cli/remove/${Y}`,{method:"DELETE"});if(he.ok){const _e=await he.json();if(_e.success)return await Qt(),!0;throw new Error(_e.error||"Failed to delete Codex MCP server")}else{const _e=await he.json();throw new Error(_e.error||"Failed to delete server")}}catch(he){throw console.error("Error deleting Codex MCP server:",he),he}},Kr=()=>{ft({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),It(null),Te(!1)},Ea=(Y=null)=>{Y?(It(Y),ft({name:Y.name,type:Y.type||"stdio",config:{command:Y.config?.command||"",args:Y.config?.args||[],env:Y.config?.env||{}}})):Kr(),Te(!0)},Xr=async Y=>{Y.preventDefault(),Dr(!0);try{lt&&await Bn(lt.name),await nn(Ke),Kr(),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}finally{Dr(!1)}},Wi=async Y=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Bn(Y),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}};b.useEffect(()=>{e&&(an(),zn(),Vi(),Yi(),R(n))},[e,n]),b.useEffect(()=>{localStorage.setItem("codeEditorTheme",ye),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ye]),b.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",se.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[se]),b.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",$e.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[$e]),b.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",nt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[nt]),b.useEffect(()=>{localStorage.setItem("codeEditorFontSize",tt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[tt]);const an=async()=>{try{const Y=localStorage.getItem("claude-settings");if(Y){const ot=JSON.parse(Y);l(ot.allowedTools||[]),u(ot.disallowedTools||[]),x(ot.skipPermissions||!1),A(ot.projectSortOrder||"name")}else l([]),u([]),x(!1),A("name");const he=localStorage.getItem("cursor-tools-settings");if(he){const ot=JSON.parse(he);wt(ot.allowedCommands||[]),Pt(ot.disallowedCommands||[]),pe(ot.skipPermissions||!1)}else wt([]),Pt([]),pe(!1);const _e=localStorage.getItem("codex-settings");if(_e){const ot=JSON.parse(_e);Se(ot.permissionMode||"default")}else Se("default");await Fr(),await zt(),await Qt()}catch(Y){console.error("Error loading tool settings:",Y),l([]),u([]),x(!1),A("name")}},zn=async()=>{try{const Y=await Ie("/api/cli/claude/status");if(Y.ok){const he=await Y.json();Mr({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else Mr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Claude auth status:",Y),Mr({authenticated:!1,email:null,loading:!1,error:Y.message})}},Vi=async()=>{try{const Y=await Ie("/api/cli/cursor/status");if(Y.ok){const he=await Y.json();xe({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else xe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Cursor auth status:",Y),xe({authenticated:!1,email:null,loading:!1,error:Y.message})}},Yi=async()=>{try{const Y=await Ie("/api/cli/codex/status");if(Y.ok){const he=await Y.json();St({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else St({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Codex auth status:",Y),St({authenticated:!1,email:null,loading:!1,error:Y.message})}},Zr=()=>{hr("claude"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},Ki=()=>{hr("cursor"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},Xi=()=>{hr("codex"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},pt=Y=>{Y===0&&(v("success"),Jt==="claude"?zn():Jt==="cursor"?Vi():Jt==="codex"&&Yi())},Na=()=>{E(!0),v(null);try{const Y={allowedTools:o,disallowedTools:c,skipPermissions:g,projectSortOrder:N,lastUpdated:new Date().toISOString()},he={allowedCommands:ct,disallowedCommands:Rt,skipPermissions:Ee,lastUpdated:new Date().toISOString()},_e={permissionMode:fe,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(Y)),localStorage.setItem("cursor-tools-settings",JSON.stringify(he)),localStorage.setItem("codex-settings",JSON.stringify(_e)),v("success"),setTimeout(()=>{t()},1e3)}catch(Y){console.error("Error saving tool settings:",Y),v("error")}finally{E(!1)}},Pr=()=>{q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),z(null),O(!1),me("")},ai=(Y=null)=>{Y?(z(Y),q({name:Y.name,type:Y.type,scope:Y.scope,projectPath:Y.projectPath||"",config:{...Y.config},raw:Y.raw,importMode:"form",jsonInput:""})):Pr(),O(!0)},ia=async Y=>{Y.preventDefault(),$(!0);try{if(L.importMode==="json"){const he=await Ie("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:L.name,jsonConfig:L.jsonInput,scope:L.scope,projectPath:L.projectPath})});if(he.ok){const _e=await he.json();if(_e.success)await Fr(),Pr(),v("success");else throw new Error(_e.error||"Failed to add server via JSON")}else{const _e=await he.json();throw new Error(_e.error||"Failed to add server")}}else await Sa(L),Pr(),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}finally{$(!1)}},ko=async(Y,he)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await aa(Y,he),v("success")}catch(_e){alert(`Error: ${_e.message}`),v("error")}},Ca=async(Y,he)=>{try{le({...re,[Y]:{loading:!0}});const _e=await Yr(Y,he);le({...re,[Y]:_e})}catch(_e){le({...re,[Y]:{success:!1,message:_e.message,details:[]}})}},wo=async(Y,he)=>{try{V({...C,[Y]:!0});const _e=await vo(Y,he);K({...ee,[Y]:_e})}catch{K({...ee,[Y]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{V({...C,[Y]:!1})}},Un=(Y,he)=>{q(_e=>({..._e,config:{..._e.config,[Y]:he}}))};return e?a.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ha,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),a.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"Settings"})]}),a.jsx(We,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:a.jsx(Tt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"border-b border-border",children:a.jsxs("div",{className:"flex px-4 md:px-6",children:[a.jsx("button",{onClick:()=>R("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agents"}),a.jsx("button",{onClick:()=>R("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Appearance"}),a.jsxs("button",{onClick:()=>R("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(Cn,{className:"w-4 h-4 inline mr-2"}),"Git"]}),a.jsxs("button",{onClick:()=>R("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(rh,{className:"w-4 h-4 inline mr-2"}),"API & Tokens"]}),a.jsx("button",{onClick:()=>R("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tasks"})]})}),a.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[ie==="appearance"&&a.jsx("div",{className:"space-y-6 md:space-y-8",children:ie==="appearance"&&a.jsxs("div",{className:"space-y-6 md:space-y-8",children:[a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Dark Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Toggle between light and dark themes"})]}),a.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":i,"aria-label":"Toggle dark mode",children:[a.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),a.jsx("span",{className:`${i?"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:i?a.jsx(sm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(om,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Project Sorting"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How projects are ordered in the sidebar"})]}),a.jsxs("select",{value:N,onChange:Y=>A(Y.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:[a.jsx("option",{value:"name",children:"Alphabetical"}),a.jsx("option",{value:"date",children:"Recent Activity"})]})]})})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Code Editor"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Editor Theme"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default theme for the code editor"})]}),a.jsxs("button",{onClick:()=>Pe(ye==="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":ye==="dark","aria-label":"Toggle editor theme",children:[a.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),a.jsx("span",{className:`${ye==="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:ye==="dark"?a.jsx(sm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(om,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Word Wrap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable word wrapping by default in the editor"})]}),a.jsxs("button",{onClick:()=>je(!se),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":se,"aria-label":"Toggle word wrap",children:[a.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),a.jsx("span",{className:`${se?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Minimap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display a minimap for easier navigation in diff view"})]}),a.jsxs("button",{onClick:()=>gt(!$e),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":$e,"aria-label":"Toggle minimap",children:[a.jsx("span",{className:"sr-only",children:"Toggle minimap"}),a.jsx("span",{className:`${$e?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Line Numbers"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display line numbers in the editor"})]}),a.jsxs("button",{onClick:()=>dt(!nt),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":nt,"aria-label":"Toggle line numbers",children:[a.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),a.jsx("span",{className:`${nt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Font Size"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Editor font size in pixels"})]}),a.jsxs("select",{value:tt,onChange:Y=>Ve(Y.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:[a.jsx("option",{value:"10",children:"10px"}),a.jsx("option",{value:"11",children:"11px"}),a.jsx("option",{value:"12",children:"12px"}),a.jsx("option",{value:"13",children:"13px"}),a.jsx("option",{value:"14",children:"14px"}),a.jsx("option",{value:"15",children:"15px"}),a.jsx("option",{value:"16",children:"16px"}),a.jsx("option",{value:"18",children:"18px"}),a.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),ie==="git"&&a.jsx(A$,{}),ie==="agents"&&a.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[a.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex",children:[a.jsx(_a,{agentId:"claude",authStatus:nr,isSelected:ke==="claude",onClick:()=>ue("claude"),isMobile:!0}),a.jsx(_a,{agentId:"cursor",authStatus:ae,isSelected:ke==="cursor",onClick:()=>ue("cursor"),isMobile:!0}),a.jsx(_a,{agentId:"codex",authStatus:Je,isSelected:ke==="codex",onClick:()=>ue("codex"),isMobile:!0})]})}),a.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"p-2",children:[a.jsx(_a,{agentId:"claude",authStatus:nr,isSelected:ke==="claude",onClick:()=>ue("claude")}),a.jsx(_a,{agentId:"cursor",authStatus:ae,isSelected:ke==="cursor",onClick:()=>ue("cursor")}),a.jsx(_a,{agentId:"codex",authStatus:Je,isSelected:ke==="codex",onClick:()=>ue("codex")})]})}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[a.jsx("button",{onClick:()=>de("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 ${De==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Account"}),a.jsx("button",{onClick:()=>de("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 ${De==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Permissions"}),a.jsx("button",{onClick:()=>de("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 ${De==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP Servers"})]})}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[De==="account"&&a.jsx(O$,{agent:ke,authStatus:ke==="claude"?nr:ke==="cursor"?ae:Je,onLogin:ke==="claude"?Zr:ke==="cursor"?Ki:Xi}),De==="permissions"&&ke==="claude"&&a.jsx(rm,{agent:"claude",skipPermissions:g,setSkipPermissions:x,allowedTools:o,setAllowedTools:l,disallowedTools:c,setDisallowedTools:u,newAllowedTool:d,setNewAllowedTool:p,newDisallowedTool:m,setNewDisallowedTool:h}),De==="permissions"&&ke==="cursor"&&a.jsx(rm,{agent:"cursor",skipPermissions:Ee,setSkipPermissions:pe,allowedCommands:ct,setAllowedCommands:wt,disallowedCommands:Rt,setDisallowedCommands:Pt,newAllowedCommand:H,setNewAllowedCommand:W,newDisallowedCommand:we,setNewDisallowedCommand:Me}),De==="permissions"&&ke==="codex"&&a.jsx(rm,{agent:"codex",permissionMode:fe,setPermissionMode:Se}),De==="mcp"&&ke==="claude"&&a.jsx(nm,{agent:"claude",servers:w,onAdd:()=>ai(),onEdit:Y=>ai(Y),onDelete:(Y,he)=>ko(Y,he),onTest:(Y,he)=>Ca(Y,he),onDiscoverTools:(Y,he)=>wo(Y,he),testResults:re,serverTools:ee,toolsLoading:C}),De==="mcp"&&ke==="cursor"&&a.jsx(nm,{agent:"cursor",servers:Ze,onAdd:()=>{},onEdit:Y=>{},onDelete:Y=>{}}),De==="mcp"&&ke==="codex"&&a.jsx(nm,{agent:"codex",servers:U,onAdd:()=>Ea(),onEdit:Y=>Ea(Y),onDelete:Y=>Wi(Y)})]})]})]}),D&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:a.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[a.jsx("h3",{className:"text-lg font-medium text-foreground",children:_?"Edit MCP Server":"Add MCP Server"}),a.jsx(We,{variant:"ghost",size:"sm",onClick:Pr,children:a.jsx(Tt,{className:"w-4 h-4"})})]}),a.jsxs("form",{onSubmit:ia,className:"p-4 space-y-4",children:[!_&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${L.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:"Form Input"}),a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${L.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:"JSON Import"})]}),L.importMode==="form"&&_&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope"}),a.jsxs("div",{className:"flex items-center gap-2",children:[L.scope==="user"?a.jsx(im,{className:"w-4 h-4"}):a.jsx(gn,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:L.scope==="user"?"User (Global)":"Project (Local)"}),L.scope==="local"&&L.projectPath&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",L.projectPath]})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Scope cannot be changed when editing an existing server"})]}),L.importMode==="form"&&!_&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${L.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(im,{className:"w-4 h-4"}),a.jsx("span",{children:"User (Global)"})]})}),a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${L.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(gn,{className:"w-4 h-4"}),a.jsx("span",{children:"Project (Local)"})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:L.scope==="user"?"User scope: Available across all projects on your machine":"Local scope: Only available in the selected project"})]}),L.scope==="local"&&!_&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Project *"}),a.jsxs("select",{value:L.projectPath,onChange:Y=>q(he=>({...he,projectPath:Y.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:L.scope==="local",children:[a.jsx("option",{value:"",children:"Select a project..."}),r.map(Y=>a.jsx("option",{value:Y.path||Y.fullPath,children:Y.displayName||Y.name},Y.name))]}),L.projectPath&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",L.projectPath]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:L.importMode==="json"?"md:col-span-2":"",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Server Name *"}),a.jsx(Ht,{value:L.name,onChange:Y=>{q(he=>({...he,name:Y.target.value}))},placeholder:"my-server",required:!0})]}),L.importMode==="form"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Transport Type *"}),a.jsxs("select",{value:L.type,onChange:Y=>{q(he=>({...he,type:Y.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:[a.jsx("option",{value:"stdio",children:"stdio"}),a.jsx("option",{value:"sse",children:"SSE"}),a.jsx("option",{value:"http",children:"HTTP"})]})]})]}),_&&L.raw&&L.importMode==="form"&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[a.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["Configuration Details (from"," ",_.scope==="global"?"~/.claude.json":"project config",")"]}),a.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(L.raw,null,2)})]}),L.importMode==="json"&&a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON Configuration *"}),a.jsx("textarea",{value:L.jsonInput,onChange:Y=>{q(he=>({...he,jsonInput:Y.target.value}));try{if(Y.target.value.trim()){const he=JSON.parse(Y.target.value);he.type?he.type==="stdio"&&!he.command?me("stdio type requires a command field"):(he.type==="http"||he.type==="sse")&&!he.url?me(`${he.type} type requires a url field`):me(""):me("Missing required field: type")}}catch{Y.target.value.trim()?me("Invalid JSON format"):me("")}},className:`w-full px-3 py-2 border ${X?"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:`{
1198
+ `).length]}),a.jsxs("span",{children:["Characters: ",l.length]}),a.jsxs("span",{children:["Words: ",l.split(/\s+/).filter(R=>R.length>0).length]}),a.jsx("span",{children:"Format: Markdown"})]}),a.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),O&&a.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:a.jsx(Tn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),a.jsx("button",{onClick:()=>_(!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:a.jsx(Tt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-6 space-y-4",children:[a.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:a.jsx(Tn,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Claude Code Directly!"}),a.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask Claude Code in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[a.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),a.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),a.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[a.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),a.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),a.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),a.jsx("div",{className:"pt-4",children:a.jsx("button",{onClick:()=>_(!1),className:"w-full 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-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask Claude Code directly"})})]})]})}),z&&a.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[a.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>L(!1)}),a.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex items-center mb-4",children:[a.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:a.jsx(ga,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),a.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',I.endsWith(".txt")||I.endsWith(".md")?I:`${I}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),a.jsxs("div",{className:"flex justify-end space-x-3",children:[a.jsx("button",{onClick:()=>L(!1),className:"px-4 py-2 text-sm 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:"Cancel"}),a.jsxs("button",{onClick:async()=>{L(!1),await ee()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[a.jsx(Ms,{className:"w-4 h-4"}),a.jsx("span",{children:"Overwrite"})]})]})]})})]})]})};function E$({selectedProject:e,selectedSession:t,activeTab:r,setActiveTab:n,ws:i,sendMessage:s,messages:o,isMobile:l,isPWA:c,onMenuClick:u,isLoading:d,onInputFocusChange:p,onSessionActive:m,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:x,processingSessions:S,onReplaceTemporarySession:E,onNavigateToSession:k,onShowSettings:v,autoExpandTools:N,showRawParameters:A,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:D,externalMessageUpdate:O}){const[_,z]=b.useState(null),[L,q]=b.useState(null),[F,$]=b.useState(!1),[re,le]=b.useState(600),[ee,K]=b.useState(!1),[C,V]=b.useState(!1),ie=b.useRef(null),[R,X]=b.useState(!1),[me,ke]=b.useState(null),[ue,De]=b.useState([]),[de,ye]=b.useState(null),{tasks:Pe,currentProject:se,refreshTasks:je,setCurrentProject:$e}=Mi(),{tasksEnabled:gt,isTaskMasterInstalled:nt,isTaskMasterReady:dt}=Fi(),tt=gt&&nt;b.useEffect(()=>{e&&e!==se&&$e(e)},[e,se,$e]),b.useEffect(()=>{!tt&&r==="tasks"&&n("chat")},[tt,r,n]),b.useEffect(()=>{(async()=>{if(!se?.name){De([]);return}try{const W=await ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`);if(W.ok){const we=await W.json();De(we.prdFiles||[])}else De([])}catch(W){console.error("Failed to load existing PRDs:",W),De([])}})()},[se?.name]);const Ve=(H,W=null)=>{const we={name:H.split("/").pop(),path:H,projectName:e?.name,diffInfo:W};z(we)},ct=()=>{z(null),V(!1)},wt=()=>{V(!C)},Rt=H=>{if(typeof H=="object"&&H.id&&!H.title){const W=Pe?.find(we=>we.id===H.id);W&&(q(W),$(!0))}else q(H),$(!0)},Pt=()=>{$(!1),q(null)},Ee=(H,W)=>{console.log("Update task status:",H,W),je?.()},pe=H=>{l||(K(!0),H.preventDefault())};return b.useEffect(()=>{const H=we=>{if(!ee)return;const Me=ie.current?.parentElement;if(!Me)return;const Ze=Me.getBoundingClientRect(),ge=Ze.right-we.clientX,U=300,Z=Ze.width*.8;ge>=U&&ge<=Z&&le(ge)},W=()=>{K(!1)};return ee&&(document.addEventListener("mousemove",H),document.addEventListener("mouseup",W),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",W),document.body.style.cursor="",document.body.style.userSelect=""}},[ee]),d?a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:a.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),a.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Loading Claude Code UI"}),a.jsx("p",{children:"Setting up your workspace..."})]})})]}):e?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsxs("div",{className:"flex items-center justify-between relative",children:[a.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[l&&a.jsx("button",{onClick:u,onTouchStart:H=>{H.preventDefault(),u()},className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),a.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[r==="chat"&&t&&a.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:t.__provider==="cursor"?a.jsx(en,{className:"w-4 h-4"}):a.jsx($r,{className:"w-4 h-4"})}),a.jsx("div",{className:"min-w-0 flex-1",children:r==="chat"&&t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):r==="chat"&&!t?a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"New Session"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]}):a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:r==="files"?"Project Files":r==="git"?"Source Control":r==="tasks"&&tt?"TaskMaster":"Project"}),a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:e.displayName})]})})]})]}),a.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:a.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[a.jsx(yr,{content:"Chat",position:"bottom",children:a.jsx("button",{onClick:()=>n("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${r==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),a.jsx(yr,{content:"Shell",position:"bottom",children:a.jsx("button",{onClick:()=>n("shell"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),a.jsx(yr,{content:"Files",position:"bottom",children:a.jsx("button",{onClick:()=>n("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),a.jsx(yr,{content:"Source Control",position:"bottom",children:a.jsx("button",{onClick:()=>n("git"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="git"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Source Control"})]})})}),tt&&a.jsx(yr,{content:"Tasks",position:"bottom",children:a.jsx("button",{onClick:()=>n("tasks"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${r==="tasks"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:a.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[a.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),a.jsx("span",{className:"hidden md:hidden lg:inline",children:"Tasks"})]})})})]})})]})}),a.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[a.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${_?"mr-0":""} ${C?"hidden":""}`,children:[a.jsx("div",{className:`h-full ${r==="chat"?"block":"hidden"}`,children:a.jsx(v$,{showDetails:!0,children:a.jsx(AU,{selectedProject:e,selectedSession:t,ws:i,sendMessage:s,messages:o,onFileOpen:Ve,onInputFocusChange:p,onSessionActive:m,onSessionInactive:h,onSessionProcessing:g,onSessionNotProcessing:x,processingSessions:S,onReplaceTemporarySession:E,onNavigateToSession:k,onShowSettings:v,autoExpandTools:N,showRawParameters:A,showThinking:w,autoScrollToBottom:I,sendByCtrlEnter:D,externalMessageUpdate:O,onShowAllTasks:gt?()=>n("tasks"):null})})}),r==="files"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(x$,{selectedProject:e})}),r==="shell"&&a.jsx("div",{className:"h-full w-full overflow-hidden",children:a.jsx(KE,{project:e,session:t,showHeader:!1})}),r==="git"&&a.jsx("div",{className:"h-full overflow-hidden",children:a.jsx(y$,{selectedProject:e,isMobile:l,onFileOpen:Ve})}),tt&&a.jsx("div",{className:`h-full ${r==="tasks"?"block":"hidden"}`,children:a.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:a.jsx(w$,{tasks:Pe||[],onTaskClick:Rt,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:se,onTaskCreated:je,onShowPRDEditor:(H=null)=>{ke(H),X(!0)},existingPRDs:ue,onRefreshPRDs:(H=!1)=>{se?.name&&ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`).then(W=>W.ok?W.json():Promise.reject()).then(W=>{De(W.prdFiles||[]),H&&(ye("PRD saved successfully!"),setTimeout(()=>ye(null),3e3))}).catch(W=>console.error("Failed to refresh PRDs:",W))}})})}),a.jsx("div",{className:`h-full overflow-hidden ${r==="preview"?"block":"hidden"}`})]}),_&&!l&&a.jsxs(a.Fragment,{children:[!C&&a.jsx("div",{ref:ie,onMouseDown:pe,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:a.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),a.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${C?"flex-1":""}`,style:C?{}:{width:`${re}px`},children:a.jsx(Km,{file:_,onClose:ct,projectPath:e?.path,isSidebar:!0,isExpanded:C,onToggleExpand:wt})})]})]}),_&&l&&a.jsx(Km,{file:_,onClose:ct,projectPath:e?.path,isSidebar:!1}),tt&&F&&L&&a.jsx(xE,{task:L,isOpen:F,onClose:Pt,onStatusChange:Ee,onTaskClick:Rt}),R&&a.jsx(S$,{project:se,projectPath:se?.fullPath||se?.path,onClose:()=>{X(!1),ke(null)},isNewFile:!me?.isExisting,file:{name:me?.name||"prd.txt",content:me?.content||""},onSave:async()=>{X(!1),ke(null);try{const H=await ut.get(`/taskmaster/prd/${encodeURIComponent(se.name)}`);if(H.ok){const W=await H.json();De(W.prdFiles||[]),ye("PRD saved successfully!"),setTimeout(()=>ye(null),3e3)}}catch(H){console.error("Failed to refresh PRDs:",H)}je?.()}}),de&&a.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:a.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),a.jsx("span",{className:"font-medium",children:de})]})})]}):a.jsxs("div",{className:"h-full flex flex-col",children:[l&&a.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:a.jsx("button",{onClick:u,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),a.jsx("div",{className:"flex-1 flex items-center justify-center",children:a.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[a.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:a.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),a.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"Choose Your Project"}),a.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"Select a project from the sidebar to start coding with Claude. Each project contains your chat sessions and file history."}),a.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:a.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",a.jsx("strong",{children:"Tip:"})," ",l?"Tap the menu button above to access projects":"Create a new project by clicking the folder icon in the sidebar"]})})]})})]})}const N$=Wt.memo(E$);function C$({activeTab:e,setActiveTab:t,isInputFocused:r}){const{tasksEnabled:n}=Fi(),i=[{id:"chat",icon:Si,onClick:()=>t("chat")},{id:"shell",icon:Zn,onClick:()=>t("shell")},{id:"files",icon:Yn,onClick:()=>t("files")},{id:"git",icon:Cn,onClick:()=>t("git")},...n?[{id:"tasks",icon:N5,onClick:()=>t("tasks")}]:[]];return a.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${r?"translate-y-full":"translate-y-0"}`,children:a.jsx("div",{className:"flex items-center justify-around py-1",children:i.map(s=>{const o=s.icon,l=e===s.id;return a.jsxs("button",{onClick:s.onClick,onTouchStart:c=>{c.preventDefault(),s.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${l?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":s.id,children:[a.jsx(o,{className:"w-5 h-5"}),l&&a.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},s.id)})})})}const Xm="1.0.0",XE=(e,t)=>{const[r,n]=b.useState(!1),[i,s]=b.useState(null),[o,l]=b.useState(null);return b.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(Xm!==m),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:i,currentVersion:Xm,releaseInfo:o}};function T$(){const[e,t]=b.useState([]),[r,n]=b.useState([]),[i,s]=b.useState(!0),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(""),[S,E]=b.useState(""),[k,v]=b.useState({}),[N,A]=b.useState(null),[w,I]=b.useState(null),{updateAvailable:D,latestVersion:O,releaseInfo:_}=XE("siteboon","claudecodeui");b.useEffect(()=>{z()},[]);const z=async()=>{try{s(!0);const C=await(await Ie("/api/settings/api-keys")).json();t(C.apiKeys||[]);const ie=await(await Ie("/api/settings/credentials?type=github_token")).json();n(ie.credentials||[])}catch(K){console.error("Error fetching settings:",K)}finally{s(!1)}},L=async()=>{if(d.trim())try{const C=await(await Ie("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:d})})).json();C.success&&(I(C.apiKey),p(""),l(!1),z())}catch(K){console.error("Error creating API key:",K)}},q=async K=>{if(confirm("Are you sure you want to delete this API key?"))try{await Ie(`/api/settings/api-keys/${K}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting API key:",C)}},F=async(K,C)=>{try{await Ie(`/api/settings/api-keys/${K}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling API key:",V)}},$=async()=>{if(!(!m.trim()||!g.trim()))try{(await(await Ie("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:m,credentialType:"github_token",credentialValue:g,description:S})})).json()).success&&(h(""),x(""),E(""),u(!1),z())}catch(K){console.error("Error creating GitHub credential:",K)}},re=async K=>{if(confirm("Are you sure you want to delete this GitHub token?"))try{await Ie(`/api/settings/credentials/${K}`,{method:"DELETE"}),z()}catch(C){console.error("Error deleting GitHub credential:",C)}},le=async(K,C)=>{try{await Ie(`/api/settings/credentials/${K}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!C})}),z()}catch(V){console.error("Error toggling GitHub credential:",V)}},ee=(K,C)=>{navigator.clipboard.writeText(K),A(C),setTimeout(()=>A(null),2e3)};return i?a.jsx("div",{className:"text-muted-foreground",children:"Loading..."}):a.jsxs("div",{className:"space-y-8",children:[w&&a.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[a.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:"⚠️ Save Your API Key"}),a.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"This is the only time you'll see this key. Store it securely."}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:w.apiKey}),a.jsx(We,{size:"sm",variant:"outline",onClick:()=>ee(w.apiKey,"new"),children:N==="new"?a.jsx(cr,{className:"h-4 w-4"}):a.jsx(lw,{className:"h-4 w-4"})})]}),a.jsx(We,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>I(null),children:"I've saved it"})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(rh,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"API Keys"})]}),a.jsxs(We,{size:"sm",onClick:()=>l(!o),children:[a.jsx(ar,{className:"h-4 w-4 mr-1"}),"New API Key"]})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Generate API keys to access the external API from other applications."}),a.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:["API Documentation",a.jsx(Eg,{className:"h-3 w-3"})]})]}),o&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[a.jsx(Ht,{placeholder:"API Key Name (e.g., Production Server)",value:d,onChange:K=>p(K.target.value),className:"mb-2"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:L,children:"Create"}),a.jsx(We,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]}),a.jsx("div",{className:"space-y-2",children:e.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No API keys created yet."}):e.map(K=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:K.key_name}),a.jsx("code",{className:"text-xs text-muted-foreground",children:K.api_key}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Created: ",new Date(K.created_at).toLocaleDateString(),K.last_used&&` • Last used: ${new Date(K.last_used).toLocaleDateString()}`]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:K.is_active?"outline":"secondary",onClick:()=>F(K.id,K.is_active),children:K.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>q(K.id),children:a.jsx(jr,{className:"h-4 w-4"})})]})]},K.id))})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(PN,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"GitHub Credentials"})]}),a.jsxs(We,{size:"sm",onClick:()=>u(!c),children:[a.jsx(ar,{className:"h-4 w-4 mr-1"}),"Add Token"]})]}),a.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add GitHub Personal Access Tokens to clone private repositories. You can also pass tokens directly in API requests without storing them."}),c&&a.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[a.jsx(Ht,{placeholder:"Token Name (e.g., Personal Repos)",value:m,onChange:K=>h(K.target.value)}),a.jsxs("div",{className:"relative",children:[a.jsx(Ht,{type:k.new?"text":"password",placeholder:"GitHub Personal Access Token (ghp_...)",value:g,onChange:K=>x(K.target.value),className:"pr-10"}),a.jsx("button",{type:"button",onClick:()=>v({...k,new:!k.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:k.new?a.jsx(cw,{className:"h-4 w-4"}):a.jsx(Xa,{className:"h-4 w-4"})})]}),a.jsx(Ht,{placeholder:"Description (optional)",value:S,onChange:K=>E(K.target.value)}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(We,{onClick:$,children:"Add Token"}),a.jsx(We,{variant:"outline",onClick:()=>{u(!1),h(""),x(""),E("")},children:"Cancel"})]}),a.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:"How to create a GitHub Personal Access Token →"})]}),a.jsx("div",{className:"space-y-2",children:r.length===0?a.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No GitHub tokens added yet."}):r.map(K=>a.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium",children:K.credential_name}),K.description&&a.jsx("div",{className:"text-xs text-muted-foreground",children:K.description}),a.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Added: ",new Date(K.created_at).toLocaleDateString()]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{size:"sm",variant:K.is_active?"outline":"secondary",onClick:()=>le(K.id,K.is_active),children:K.is_active?"Active":"Inactive"}),a.jsx(We,{size:"sm",variant:"ghost",onClick:()=>re(K.id),children:a.jsx(jr,{className:"h-4 w-4"})})]})]},K.id))})]}),a.jsx("div",{className:"pt-6 border-t border-border/50",children:a.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[a.jsxs("a",{href:_?.htmlUrl||"https://github.com/siteboon/claudecodeui/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Xm]}),D&&O&&a.jsxs("a",{href:_?.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:[a.jsxs("span",{className:"text-[10px]",children:["Update available: v",O]}),a.jsx(Eg,{className:"h-2.5 w-2.5"})]})]})})]})}function A$(){const[e,t]=b.useState(""),[r,n]=b.useState(""),[i,s]=b.useState(!1),[o,l]=b.useState(!1),[c,u]=b.useState(null);b.useEffect(()=>{d()},[]);const d=async()=>{try{s(!0);const m=await Ie("/api/user/git-config");if(m.ok){const h=await m.json();t(h.gitName||""),n(h.gitEmail||"")}}catch(m){console.error("Error loading git config:",m)}finally{s(!1)}},p=async()=>{try{l(!0);const m=await Ie("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:e,gitEmail:r})});if(m.ok)u("success"),setTimeout(()=>u(null),3e3);else{const h=await m.json();u("error"),console.error("Failed to save git config:",h.error)}}catch(m){console.error("Error saving git config:",m),u("error")}finally{l(!1)}};return a.jsx("div",{className:"space-y-8",children:a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[a.jsx(Cn,{className:"h-5 w-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:"Git Configuration"})]}),a.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Configure your git identity for commits. These settings will be applied globally via ",a.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs",children:"git config --global"})]}),a.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:"Git Name"}),a.jsx(Ht,{id:"settings-git-name",type:"text",value:e,onChange:m=>t(m.target.value),placeholder:"John Doe",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your name for git commits"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:"Git Email"}),a.jsx(Ht,{id:"settings-git-email",type:"email",value:r,onChange:m=>n(m.target.value),placeholder:"john@example.com",disabled:i,className:"w-full"}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your email for git commits"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(We,{onClick:p,disabled:o||!e||!r,children:o?"Saving...":"Save Configuration"}),c==="success"&&a.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[a.jsx(cr,{className:"w-4 h-4"}),"Saved successfully"]})]})]})]})})}function I$(){const{tasksEnabled:e,setTasksEnabled:t,isTaskMasterInstalled:r,isCheckingInstallation:n}=Fi();return a.jsx("div",{className:"space-y-8",children:n?a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),a.jsx("span",{className:"text-sm text-muted-foreground",children:"Checking TaskMaster installation..."})]})}):a.jsxs(a.Fragment,{children:[!r&&a.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.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:a.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:"TaskMaster AI CLI Not Installed"}),a.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[a.jsx("p",{children:"TaskMaster CLI is required to use task management features. Install it to get started:"}),a.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:a.jsx("code",{children:"npm install -g task-master-ai"})}),a.jsx("div",{children:a.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:[a.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:a.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"})}),"View on GitHub",a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.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"})})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"font-medium",children:"After installation:"}),a.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[a.jsx("li",{children:"Restart this application"}),a.jsx("li",{children:"TaskMaster features will automatically become available"}),a.jsxs("li",{children:["Use ",a.jsx("code",{className:"bg-orange-100 dark:bg-orange-800 px-1 rounded",children:"task-master init"})," in your project directory"]})]})]})]})]})]})}),r&&a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Enable TaskMaster Integration"}),a.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:"Show TaskMaster tasks, banners, and sidebar indicators across the interface"})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e,onChange:i=>t(i.target.checked),className:"sr-only peer"}),a.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"})]})]})})})]})})}function ZE({isOpen:e,onClose:t,provider:r="claude",project:n,onComplete:i,customCommand:s}){if(!e)return null;const o=()=>{if(s)return s;const u=!1;switch(r){case"claude":return"claude setup-token --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return u?"codex login --device-auth":"codex login";default:return"claude setup-token --dangerously-skip-permissions"}},l=()=>{switch(r){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=u=>{i&&i(u),u===0&&t()};return a.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:a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l()}),a.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:a.jsx(Tt,{className:"w-6 h-6"})})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(KE,{project:n,command:o(),onComplete:c,minimal:!0})})]})})}const R$={claude:{name:"Claude",color:"blue",Logo:$r},cursor:{name:"Cursor",color:"purple",Logo:en},codex:{name:"Codex",color:"gray",Logo:un}},j$={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:i=!1}){const s=R$[e],o=j$[s.color],{Logo:l}=s;return i?a.jsx("button",{onClick:n,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${r?`${o.borderBottom} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[a.jsx(l,{className:"w-5 h-5"}),a.jsx("span",{className:"text-xs font-medium text-foreground",children:s.name}),t?.authenticated&&a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`})]})}):a.jsxs("button",{onClick:n,className:`w-full text-left p-3 border-l-4 transition-colors ${r?`${o.border} ${o.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(l,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:s.name})]}),a.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:t?.loading?a.jsx("span",{className:"text-gray-400",children:"Checking..."}):t?.authenticated?a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.dot}`}),a.jsx("span",{className:"truncate max-w-[120px]",title:t.email,children:t.email||"Connected"})]}):a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),a.jsx("span",{children:"Not connected"})]})})]})}const _$={claude:{name:"Claude",description:"Anthropic Claude AI assistant",Logo:$r,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",Logo:en,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",Logo:un,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 O$({agent:e,authStatus:t,onLogin:r}){const n=_$[e],{Logo:i}=n;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[a.jsx(i,{className:"w-6 h-6"}),a.jsxs("div",{children:[a.jsxs("h3",{className:"text-lg font-medium text-foreground",children:[n.name," Account"]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]})]}),a.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:"Connection Status"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.loading?"Checking authentication status...":t?.authenticated?`Logged in as ${t.email||"authenticated user"}`:"Not connected"})]}),a.jsx("div",{children:t?.loading?a.jsx(tn,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:"Checking..."}):t?.authenticated?a.jsx(tn,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:"Connected"}):a.jsx(tn,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:"Disconnected"})})]}),a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:`font-medium ${n.textClass}`,children:t?.authenticated?"Re-authenticate":"Login"}),a.jsx("div",{className:`text-sm ${n.subtextClass}`,children:t?.authenticated?"Sign in with a different account or refresh credentials":`Sign in to your ${n.name} account to enable AI features`})]}),a.jsxs(We,{onClick:r,className:`${n.buttonClass} text-white`,size:"sm",children:[a.jsx(dw,{className:"w-4 h-4 mr-2"}),t?.authenticated?"Re-login":"Login"]})]})}),t?.error&&a.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:a.jsxs("div",{className:"text-sm text-red-600 dark:text-red-400",children:["Error: ",t.error]})})]})})]})}const L$=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],D$=["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 M$({skipPermissions:e,setSkipPermissions:t,allowedTools:r,setAllowedTools:n,disallowedTools:i,setDisallowedTools:s,newAllowedTool:o,setNewAllowedTool:l,newDisallowedTool:c,setNewDisallowedTool:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to --dangerously-skip-permissions flag"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically allowed without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common tools:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:L$.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed tools configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Tools"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools that are automatically blocked without prompting for permission"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked tools configured"})]})]}),a.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"Tool Pattern Examples:"}),a.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - Allow all git log commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - Allow all git diff commands"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - Allow all Write tool usage"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - Block all rm commands (dangerous)"]})]})]})]})}function F$({skipPermissions:e,setSkipPermissions:t,allowedCommands:r,setAllowedCommands:n,disallowedCommands:i,setDisallowedCommands:s,newAllowedCommand:o,setNewAllowedCommand:l,newDisallowedCommand:c,setNewDisallowedCommand:u}){const d=g=>{g&&!r.includes(g)&&(n([...r,g]),l(""))},p=g=>{n(r.filter(x=>x!==g))},m=g=>{g&&!i.includes(g)&&(s([...i,g]),u(""))},h=g=>{s(i.filter(x=>x!==g))};return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-orange-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Settings"})]}),a.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:a.jsxs("label",{className:"flex items-center gap-3",children:[a.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"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"Skip permission prompts (use with caution)"}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Equivalent to -f flag in Cursor CLI"})]})]})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Allowed Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically allowed without prompting"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:o,onChange:g=>l(g.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),d(o))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>d(o),disabled:!o,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Quick add common commands:"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:D$.map(g=>a.jsx(We,{variant:"outline",size:"sm",onClick:()=>d(g),disabled:r.includes(g),className:"text-xs h-8",children:g},g))})]}),a.jsxs("div",{className:"space-y-2",children:[r.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>p(g),className:"text-green-600 hover:text-green-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),r.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No allowed commands configured"})]})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ga,{className:"w-5 h-5 text-red-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Blocked Shell Commands"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Shell commands that are automatically blocked"}),a.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[a.jsx(Ht,{value:c,onChange:g=>u(g.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),m(c))},className:"flex-1 h-10"}),a.jsxs(We,{onClick:()=>m(c),disabled:!c,size:"sm",className:"h-10 px-4",children:[a.jsx(ar,{className:"w-4 h-4 mr-2 sm:mr-0"}),a.jsx("span",{className:"sm:hidden",children:"Add"})]})]}),a.jsxs("div",{className:"space-y-2",children:[i.map(g=>a.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:[a.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:g}),a.jsx(We,{variant:"ghost",size:"sm",onClick:()=>h(g),className:"text-red-600 hover:text-red-700",children:a.jsx(Tt,{className:"w-4 h-4"})})]},g)),i.length===0&&a.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"No blocked commands configured"})]})]}),a.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell Command Examples:"}),a.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - Allow ls command"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - Allow git status"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - Allow npm install"]}),a.jsxs("li",{children:[a.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - Block recursive delete"]})]})]})]})}function P$({permissionMode:e,setPermissionMode:t}){return a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ah,{className:"w-5 h-5 text-green-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Permission Mode"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Controls how Codex handles file modifications and command execution"}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="default",onChange:()=>t("default"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Default"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Only trusted commands (ls, cat, grep, git status, etc.) run automatically. Other commands are skipped. Can write to workspace."})]})]})}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="acceptEdits",onChange:()=>t("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"Accept Edits"}),a.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"All commands run automatically within the workspace. Full auto mode with sandboxed execution."})]})]})}),a.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:a.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[a.jsx("input",{type:"radio",name:"codexPermissionMode",checked:e==="bypassPermissions",onChange:()=>t("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),a.jsxs("div",{children:[a.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["Bypass Permissions",a.jsx(ga,{className:"w-4 h-4"})]}),a.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"Full system access with no restrictions. All commands run automatically with full disk and network access. Use with caution."})]})]})}),a.jsxs("details",{className:"text-sm",children:[a.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Technical details"}),a.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:[a.jsxs("p",{children:[a.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),a.jsxs("p",{children:[a.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),a.jsx("p",{className:"text-xs opacity-75",children:"You can override this per-session using the mode button in the chat interface."})]})]})]})})}function rm({agent:e,...t}){return e==="claude"?a.jsx(M$,{...t}):e==="cursor"?a.jsx(F$,{...t}):e==="codex"?a.jsx(P$,{...t}):null}const B$=e=>{switch(e){case"stdio":return a.jsx(Zn,{className:"w-4 h-4"});case"sse":return a.jsx(ih,{className:"w-4 h-4"});case"http":return a.jsx(im,{className:"w-4 h-4"});default:return a.jsx(to,{className:"w-4 h-4"})}};function z$({servers:e,onAdd:t,onEdit:r,onDelete:n,onTest:i,onDiscoverTools:s,testResults:o,serverTools:l,toolsLoading:c}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Claude"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(u=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[B$(u.type),a.jsx("span",{className:"font-medium text-foreground",children:u.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:u.type}),a.jsx(tn,{variant:"outline",className:"text-xs",children:u.scope==="local"?"local":u.scope==="user"?"user":u.scope})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&u.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.command})]}),(u.type==="sse"||u.type==="http")&&u.config?.url&&a.jsxs("div",{children:["URL: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.url})]}),u.config?.args&&u.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.args.join(" ")})]})]}),o?.[u.id]&&a.jsx("div",{className:`mt-2 p-2 rounded text-xs ${o[u.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:a.jsx("div",{className:"font-medium",children:o[u.id].message})}),l?.[u.id]&&l[u.id].tools?.length>0&&a.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:[a.jsxs("div",{className:"font-medium",children:["Tools (",l[u.id].tools.length,"):"]}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((d,p)=>a.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:d.name},p)),l[u.id].tools.length>5&&a.jsxs("span",{className:"text-xs opacity-75",children:["+",l[u.id].tools.length-5," more"]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},u.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function U$({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-purple-500"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Cursor"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Zn,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsx("div",{className:"text-sm text-muted-foreground",children:i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]})})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},i.name||i.id)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]})]})}function $$({servers:e,onAdd:t,onEdit:r,onDelete:n}){return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(to,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),a.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP Servers"})]}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol servers provide additional tools and data sources to Codex"}),a.jsx("div",{className:"flex justify-between items-center",children:a.jsxs(We,{onClick:t,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[a.jsx(ar,{className:"w-4 h-4 mr-2"}),"Add MCP Server"]})}),a.jsxs("div",{className:"space-y-2",children:[e.map(i=>a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Zn,{className:"w-4 h-4"}),a.jsx("span",{className:"font-medium text-foreground",children:i.name}),a.jsx(tn,{variant:"outline",className:"text-xs",children:"stdio"})]}),a.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[i.config?.command&&a.jsxs("div",{children:["Command: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.command})]}),i.config?.args&&i.config.args.length>0&&a.jsxs("div",{children:["Args: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:i.config.args.join(" ")})]}),i.config?.env&&Object.keys(i.config.env).length>0&&a.jsxs("div",{children:["Environment: ",a.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(i.config.env).map(([s,o])=>`${s}=${o}`).join(", ")})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[a.jsx(We,{onClick:()=>r(i),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"Edit server",children:a.jsx(Ei,{className:"w-4 h-4"})}),a.jsx(We,{onClick:()=>n(i.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"Delete server",children:a.jsx(jr,{className:"w-4 h-4"})})]})]})},i.name)),e.length===0&&a.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No MCP servers configured"})]}),a.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[a.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"About Codex MCP"}),a.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex supports stdio-based MCP servers. You can add servers that extend Codex's capabilities with additional tools and resources."})]})]})}function nm({agent:e,...t}){return e==="claude"?a.jsx(z$,{...t}):e==="cursor"?a.jsx(U$,{...t}):e==="codex"?a.jsx($$,{...t}):null}function q$({isOpen:e,onClose:t,projects:r=[],initialTab:n="agents"}){const{isDarkMode:i,toggleDarkMode:s}=Li(),[o,l]=b.useState([]),[c,u]=b.useState([]),[d,p]=b.useState(""),[m,h]=b.useState(""),[g,x]=b.useState(!1),[S,E]=b.useState(!1),[k,v]=b.useState(null),[N,A]=b.useState("name"),[w,I]=b.useState([]),[D,O]=b.useState(!1),[_,z]=b.useState(null),[L,q]=b.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[F,$]=b.useState(!1),[re,le]=b.useState({}),[ee,K]=b.useState({}),[C,V]=b.useState({}),[ie,R]=b.useState(n),[X,me]=b.useState(""),[ke,ue]=b.useState("claude"),[De,de]=b.useState("account"),[ye,Pe]=b.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[se,je]=b.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[$e,gt]=b.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[nt,dt]=b.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[tt,Ve]=b.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[ct,wt]=b.useState([]),[Rt,Pt]=b.useState([]),[Ee,pe]=b.useState(!1),[H,W]=b.useState(""),[we,Me]=b.useState(""),[Ze,ge]=b.useState([]),[U,Z]=b.useState([]),[fe,Se]=b.useState("default"),[oe,Te]=b.useState(!1),[Ke,ft]=b.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[lt,It]=b.useState(null),[Vr,Dr]=b.useState(!1),[Er,Nr]=b.useState(!1),[Jt,hr]=b.useState(""),[Lt,Pn]=b.useState(null),[nr,Mr]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[ae,xe]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),[Je,St]=b.useState({authenticated:!1,email:null,loading:!0,error:null}),zt=async()=>{try{const Y=await Ie("/api/cursor/mcp");if(Y.ok){const he=await Y.json();ge(he.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(Y){console.error("Error fetching Cursor MCP servers:",Y)}},Qt=async()=>{try{const Y=await Ie("/api/codex/mcp/config/read");if(Y.ok){const _e=await Y.json();if(_e.success&&_e.servers){Z(_e.servers);return}}const he=await Ie("/api/codex/mcp/cli/list");if(he.ok){const _e=await he.json();if(_e.success&&_e.servers){const ot=_e.servers.map(er=>({id:er.name,name:er.name,type:er.type||"stdio",scope:"user",config:{command:er.command||"",args:er.args||[],env:er.env||{}}}));Z(ot)}}}catch(Y){console.error("Error fetching Codex MCP servers:",Y)}},Fr=async()=>{try{const Y=await Ie("/api/mcp/cli/list");if(Y.ok){const ot=await Y.json();if(ot.success&&ot.servers){const er=ot.servers.map(Cr=>({id:Cr.id||Cr.name,name:Cr.name,type:Cr.type,scope:"user",status:Cr.status,config:{command:Cr.command||"",args:Cr.args||[],env:Cr.env||{},url:Cr.url||"",headers:Cr.headers||{},timeout:3e4},description:Cr.description,created:new Date().toISOString(),updated:new Date().toISOString()}));I(er);return}}const he=await Ie("/api/mcp/config/read");if(he.ok){const ot=await he.json();if(ot.success&&ot.servers){I(ot.servers);return}}const _e=await Ie("/api/mcp/servers?scope=user");if(_e.ok){const ot=await _e.json();I(ot.servers||[])}else console.error("Failed to fetch MCP servers")}catch(Y){console.error("Error fetching MCP servers:",Y)}},Sa=async Y=>{try{_&&await aa(_.id,"user");const he=await Ie("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:Y.name,type:Y.type,scope:Y.scope,projectPath:Y.projectPath,command:Y.config?.command,args:Y.config?.args||[],url:Y.config?.url,headers:Y.config?.headers||{},env:Y.config?.env||{}})});if(he.ok){const _e=await he.json();if(_e.success)return await Fr(),!0;throw new Error(_e.error||"Failed to save server via Claude CLI")}else{const _e=await he.json();throw new Error(_e.error||"Failed to save server")}}catch(he){throw console.error("Error saving MCP server:",he),he}},aa=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/cli/remove/${Y}?scope=${he}`,{method:"DELETE"});if(_e.ok){const ot=await _e.json();if(ot.success)return await Fr(),!0;throw new Error(ot.error||"Failed to delete server via Claude CLI")}else{const ot=await _e.json();throw new Error(ot.error||"Failed to delete server")}}catch(_e){throw console.error("Error deleting MCP server:",_e),_e}},Yr=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/servers/${Y}/test?scope=${he}`,{method:"POST"});if(_e.ok)return(await _e.json()).testResult;{const ot=await _e.json();throw new Error(ot.error||"Failed to test server")}}catch(_e){throw console.error("Error testing MCP server:",_e),_e}},vo=async(Y,he="user")=>{try{const _e=await Ie(`/api/mcp/servers/${Y}/tools?scope=${he}`,{method:"POST"});if(_e.ok)return(await _e.json()).toolsResult;{const ot=await _e.json();throw new Error(ot.error||"Failed to discover tools")}}catch(_e){throw console.error("Error discovering MCP tools:",_e),_e}},nn=async Y=>{try{lt&&await Bn(lt.id);const he=await Ie("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:Y.name,command:Y.config?.command,args:Y.config?.args||[],env:Y.config?.env||{}})});if(he.ok){const _e=await he.json();if(_e.success)return await Qt(),!0;throw new Error(_e.error||"Failed to save Codex MCP server")}else{const _e=await he.json();throw new Error(_e.error||"Failed to save server")}}catch(he){throw console.error("Error saving Codex MCP server:",he),he}},Bn=async Y=>{try{const he=await Ie(`/api/codex/mcp/cli/remove/${Y}`,{method:"DELETE"});if(he.ok){const _e=await he.json();if(_e.success)return await Qt(),!0;throw new Error(_e.error||"Failed to delete Codex MCP server")}else{const _e=await he.json();throw new Error(_e.error||"Failed to delete server")}}catch(he){throw console.error("Error deleting Codex MCP server:",he),he}},Kr=()=>{ft({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),It(null),Te(!1)},Ea=(Y=null)=>{Y?(It(Y),ft({name:Y.name,type:Y.type||"stdio",config:{command:Y.config?.command||"",args:Y.config?.args||[],env:Y.config?.env||{}}})):Kr(),Te(!0)},Xr=async Y=>{Y.preventDefault(),Dr(!0);try{lt&&await Bn(lt.name),await nn(Ke),Kr(),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}finally{Dr(!1)}},Wi=async Y=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Bn(Y),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}};b.useEffect(()=>{e&&(an(),zn(),Vi(),Yi(),R(n))},[e,n]),b.useEffect(()=>{localStorage.setItem("codeEditorTheme",ye),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ye]),b.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",se.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[se]),b.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",$e.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[$e]),b.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",nt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[nt]),b.useEffect(()=>{localStorage.setItem("codeEditorFontSize",tt),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[tt]);const an=async()=>{try{const Y=localStorage.getItem("claude-settings");if(Y){const ot=JSON.parse(Y);l(ot.allowedTools||[]),u(ot.disallowedTools||[]),x(ot.skipPermissions||!1),A(ot.projectSortOrder||"name")}else l([]),u([]),x(!1),A("name");const he=localStorage.getItem("cursor-tools-settings");if(he){const ot=JSON.parse(he);wt(ot.allowedCommands||[]),Pt(ot.disallowedCommands||[]),pe(ot.skipPermissions||!1)}else wt([]),Pt([]),pe(!1);const _e=localStorage.getItem("codex-settings");if(_e){const ot=JSON.parse(_e);Se(ot.permissionMode||"default")}else Se("default");await Fr(),await zt(),await Qt()}catch(Y){console.error("Error loading tool settings:",Y),l([]),u([]),x(!1),A("name")}},zn=async()=>{try{const Y=await Ie("/api/cli/claude/status");if(Y.ok){const he=await Y.json();Mr({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else Mr({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Claude auth status:",Y),Mr({authenticated:!1,email:null,loading:!1,error:Y.message})}},Vi=async()=>{try{const Y=await Ie("/api/cli/cursor/status");if(Y.ok){const he=await Y.json();xe({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else xe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Cursor auth status:",Y),xe({authenticated:!1,email:null,loading:!1,error:Y.message})}},Yi=async()=>{try{const Y=await Ie("/api/cli/codex/status");if(Y.ok){const he=await Y.json();St({authenticated:he.authenticated,email:he.email,loading:!1,error:he.error||null})}else St({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(Y){console.error("Error checking Codex auth status:",Y),St({authenticated:!1,email:null,loading:!1,error:Y.message})}},Zr=()=>{hr("claude"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},Ki=()=>{hr("cursor"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},Xi=()=>{hr("codex"),Pn(r?.[0]||{name:"default",fullPath:process.cwd()}),Nr(!0)},pt=Y=>{Y===0&&(v("success"),Jt==="claude"?zn():Jt==="cursor"?Vi():Jt==="codex"&&Yi())},Na=()=>{E(!0),v(null);try{const Y={allowedTools:o,disallowedTools:c,skipPermissions:g,projectSortOrder:N,lastUpdated:new Date().toISOString()},he={allowedCommands:ct,disallowedCommands:Rt,skipPermissions:Ee,lastUpdated:new Date().toISOString()},_e={permissionMode:fe,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(Y)),localStorage.setItem("cursor-tools-settings",JSON.stringify(he)),localStorage.setItem("codex-settings",JSON.stringify(_e)),v("success"),setTimeout(()=>{t()},1e3)}catch(Y){console.error("Error saving tool settings:",Y),v("error")}finally{E(!1)}},Pr=()=>{q({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),z(null),O(!1),me("")},ai=(Y=null)=>{Y?(z(Y),q({name:Y.name,type:Y.type,scope:Y.scope,projectPath:Y.projectPath||"",config:{...Y.config},raw:Y.raw,importMode:"form",jsonInput:""})):Pr(),O(!0)},ia=async Y=>{Y.preventDefault(),$(!0);try{if(L.importMode==="json"){const he=await Ie("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:L.name,jsonConfig:L.jsonInput,scope:L.scope,projectPath:L.projectPath})});if(he.ok){const _e=await he.json();if(_e.success)await Fr(),Pr(),v("success");else throw new Error(_e.error||"Failed to add server via JSON")}else{const _e=await he.json();throw new Error(_e.error||"Failed to add server")}}else await Sa(L),Pr(),v("success")}catch(he){alert(`Error: ${he.message}`),v("error")}finally{$(!1)}},ko=async(Y,he)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await aa(Y,he),v("success")}catch(_e){alert(`Error: ${_e.message}`),v("error")}},Ca=async(Y,he)=>{try{le({...re,[Y]:{loading:!0}});const _e=await Yr(Y,he);le({...re,[Y]:_e})}catch(_e){le({...re,[Y]:{success:!1,message:_e.message,details:[]}})}},wo=async(Y,he)=>{try{V({...C,[Y]:!0});const _e=await vo(Y,he);K({...ee,[Y]:_e})}catch{K({...ee,[Y]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{V({...C,[Y]:!1})}},Un=(Y,he)=>{q(_e=>({..._e,config:{..._e.config,[Y]:he}}))};return e?a.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[a.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:[a.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(ha,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),a.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"Settings"})]}),a.jsx(We,{variant:"ghost",size:"sm",onClick:t,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:a.jsx(Tt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a.jsx("div",{className:"border-b border-border",children:a.jsxs("div",{className:"flex px-4 md:px-6",children:[a.jsx("button",{onClick:()=>R("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agents"}),a.jsx("button",{onClick:()=>R("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Appearance"}),a.jsxs("button",{onClick:()=>R("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(Cn,{className:"w-4 h-4 inline mr-2"}),"Git"]}),a.jsxs("button",{onClick:()=>R("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[a.jsx(rh,{className:"w-4 h-4 inline mr-2"}),"API & Tokens"]}),a.jsx("button",{onClick:()=>R("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${ie==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Tasks"})]})}),a.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[ie==="appearance"&&a.jsx("div",{className:"space-y-6 md:space-y-8",children:ie==="appearance"&&a.jsxs("div",{className:"space-y-6 md:space-y-8",children:[a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Dark Mode"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Toggle between light and dark themes"})]}),a.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":i,"aria-label":"Toggle dark mode",children:[a.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),a.jsx("span",{className:`${i?"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:i?a.jsx(sm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(om,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),a.jsx("div",{className:"space-y-4",children:a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Project Sorting"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"How projects are ordered in the sidebar"})]}),a.jsxs("select",{value:N,onChange:Y=>A(Y.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:[a.jsx("option",{value:"name",children:"Alphabetical"}),a.jsx("option",{value:"date",children:"Recent Activity"})]})]})})}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Code Editor"}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Editor Theme"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Default theme for the code editor"})]}),a.jsxs("button",{onClick:()=>Pe(ye==="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":ye==="dark","aria-label":"Toggle editor theme",children:[a.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),a.jsx("span",{className:`${ye==="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:ye==="dark"?a.jsx(sm,{className:"w-3.5 h-3.5 text-gray-700"}):a.jsx(om,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Word Wrap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Enable word wrapping by default in the editor"})]}),a.jsxs("button",{onClick:()=>je(!se),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":se,"aria-label":"Toggle word wrap",children:[a.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),a.jsx("span",{className:`${se?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Minimap"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display a minimap for easier navigation in diff view"})]}),a.jsxs("button",{onClick:()=>gt(!$e),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":$e,"aria-label":"Toggle minimap",children:[a.jsx("span",{className:"sr-only",children:"Toggle minimap"}),a.jsx("span",{className:`${$e?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Show Line Numbers"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Display line numbers in the editor"})]}),a.jsxs("button",{onClick:()=>dt(!nt),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":nt,"aria-label":"Toggle line numbers",children:[a.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),a.jsx("span",{className:`${nt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),a.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("div",{className:"font-medium text-foreground",children:"Font Size"}),a.jsx("div",{className:"text-sm text-muted-foreground",children:"Editor font size in pixels"})]}),a.jsxs("select",{value:tt,onChange:Y=>Ve(Y.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:[a.jsx("option",{value:"10",children:"10px"}),a.jsx("option",{value:"11",children:"11px"}),a.jsx("option",{value:"12",children:"12px"}),a.jsx("option",{value:"13",children:"13px"}),a.jsx("option",{value:"14",children:"14px"}),a.jsx("option",{value:"15",children:"15px"}),a.jsx("option",{value:"16",children:"16px"}),a.jsx("option",{value:"18",children:"18px"}),a.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),ie==="git"&&a.jsx(A$,{}),ie==="agents"&&a.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[a.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex",children:[a.jsx(_a,{agentId:"claude",authStatus:nr,isSelected:ke==="claude",onClick:()=>ue("claude"),isMobile:!0}),a.jsx(_a,{agentId:"cursor",authStatus:ae,isSelected:ke==="cursor",onClick:()=>ue("cursor"),isMobile:!0}),a.jsx(_a,{agentId:"codex",authStatus:Je,isSelected:ke==="codex",onClick:()=>ue("codex"),isMobile:!0})]})}),a.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"p-2",children:[a.jsx(_a,{agentId:"claude",authStatus:nr,isSelected:ke==="claude",onClick:()=>ue("claude")}),a.jsx(_a,{agentId:"cursor",authStatus:ae,isSelected:ke==="cursor",onClick:()=>ue("cursor")}),a.jsx(_a,{agentId:"codex",authStatus:Je,isSelected:ke==="codex",onClick:()=>ue("codex")})]})}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:a.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[a.jsx("button",{onClick:()=>de("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 ${De==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Account"}),a.jsx("button",{onClick:()=>de("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 ${De==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Permissions"}),a.jsx("button",{onClick:()=>de("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 ${De==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP Servers"})]})}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[De==="account"&&a.jsx(O$,{agent:ke,authStatus:ke==="claude"?nr:ke==="cursor"?ae:Je,onLogin:ke==="claude"?Zr:ke==="cursor"?Ki:Xi}),De==="permissions"&&ke==="claude"&&a.jsx(rm,{agent:"claude",skipPermissions:g,setSkipPermissions:x,allowedTools:o,setAllowedTools:l,disallowedTools:c,setDisallowedTools:u,newAllowedTool:d,setNewAllowedTool:p,newDisallowedTool:m,setNewDisallowedTool:h}),De==="permissions"&&ke==="cursor"&&a.jsx(rm,{agent:"cursor",skipPermissions:Ee,setSkipPermissions:pe,allowedCommands:ct,setAllowedCommands:wt,disallowedCommands:Rt,setDisallowedCommands:Pt,newAllowedCommand:H,setNewAllowedCommand:W,newDisallowedCommand:we,setNewDisallowedCommand:Me}),De==="permissions"&&ke==="codex"&&a.jsx(rm,{agent:"codex",permissionMode:fe,setPermissionMode:Se}),De==="mcp"&&ke==="claude"&&a.jsx(nm,{agent:"claude",servers:w,onAdd:()=>ai(),onEdit:Y=>ai(Y),onDelete:(Y,he)=>ko(Y,he),onTest:(Y,he)=>Ca(Y,he),onDiscoverTools:(Y,he)=>wo(Y,he),testResults:re,serverTools:ee,toolsLoading:C}),De==="mcp"&&ke==="cursor"&&a.jsx(nm,{agent:"cursor",servers:Ze,onAdd:()=>{},onEdit:Y=>{},onDelete:Y=>{}}),De==="mcp"&&ke==="codex"&&a.jsx(nm,{agent:"codex",servers:U,onAdd:()=>Ea(),onEdit:Y=>Ea(Y),onDelete:Y=>Wi(Y)})]})]})]}),D&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:a.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[a.jsx("h3",{className:"text-lg font-medium text-foreground",children:_?"Edit MCP Server":"Add MCP Server"}),a.jsx(We,{variant:"ghost",size:"sm",onClick:Pr,children:a.jsx(Tt,{className:"w-4 h-4"})})]}),a.jsxs("form",{onSubmit:ia,className:"p-4 space-y-4",children:[!_&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${L.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:"Form Input"}),a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${L.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:"JSON Import"})]}),L.importMode==="form"&&_&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope"}),a.jsxs("div",{className:"flex items-center gap-2",children:[L.scope==="user"?a.jsx(im,{className:"w-4 h-4"}):a.jsx(gn,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:L.scope==="user"?"User (Global)":"Project (Local)"}),L.scope==="local"&&L.projectPath&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",L.projectPath]})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Scope cannot be changed when editing an existing server"})]}),L.importMode==="form"&&!_&&a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Scope *"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${L.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(im,{className:"w-4 h-4"}),a.jsx("span",{children:"User (Global)"})]})}),a.jsx("button",{type:"button",onClick:()=>q(Y=>({...Y,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${L.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:a.jsxs("div",{className:"flex items-center justify-center gap-2",children:[a.jsx(gn,{className:"w-4 h-4"}),a.jsx("span",{children:"Project (Local)"})]})})]}),a.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:L.scope==="user"?"User scope: Available across all projects on your machine":"Local scope: Only available in the selected project"})]}),L.scope==="local"&&!_&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Project *"}),a.jsxs("select",{value:L.projectPath,onChange:Y=>q(he=>({...he,projectPath:Y.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:L.scope==="local",children:[a.jsx("option",{value:"",children:"Select a project..."}),r.map(Y=>a.jsx("option",{value:Y.path||Y.fullPath,children:Y.displayName||Y.name},Y.name))]}),L.projectPath&&a.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",L.projectPath]})]})]}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[a.jsxs("div",{className:L.importMode==="json"?"md:col-span-2":"",children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Server Name *"}),a.jsx(Ht,{value:L.name,onChange:Y=>{q(he=>({...he,name:Y.target.value}))},placeholder:"my-server",required:!0})]}),L.importMode==="form"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Transport Type *"}),a.jsxs("select",{value:L.type,onChange:Y=>{q(he=>({...he,type:Y.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:[a.jsx("option",{value:"stdio",children:"stdio"}),a.jsx("option",{value:"sse",children:"SSE"}),a.jsx("option",{value:"http",children:"HTTP"})]})]})]}),_&&L.raw&&L.importMode==="form"&&a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[a.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["Configuration Details (from"," ",_.scope==="global"?"~/.claude.json":"project config",")"]}),a.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(L.raw,null,2)})]}),L.importMode==="json"&&a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON Configuration *"}),a.jsx("textarea",{value:L.jsonInput,onChange:Y=>{q(he=>({...he,jsonInput:Y.target.value}));try{if(Y.target.value.trim()){const he=JSON.parse(Y.target.value);he.type?he.type==="stdio"&&!he.command?me("stdio type requires a command field"):(he.type==="http"||he.type==="sse")&&!he.url?me(`${he.type} type requires a url field`):me(""):me("Missing required field: type")}}catch{Y.target.value.trim()?me("Invalid JSON format"):me("")}},className:`w-full px-3 py-2 border ${X?"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:`{
1199
1199
  "type": "stdio",
1200
1200
  "command": "/path/to/server",
1201
1201
  "args": ["--api-key", "abc123"],
package/dist/index.html CHANGED
@@ -25,7 +25,7 @@
25
25
 
26
26
  <!-- Prevent zoom on iOS -->
27
27
  <meta name="format-detection" content="telephone=no" />
28
- <script type="module" crossorigin src="/assets/index-DvlVn6Eb.js"></script>
28
+ <script type="module" crossorigin src="/assets/index-COkp1acE.js"></script>
29
29
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-DcyRfQm3.js">
30
30
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CJLzwpLB.js">
31
31
  <link rel="modulepreload" crossorigin href="/assets/vendor-xterm-DfaPXD3y.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epiphytic/claudecodeui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A web-based UI for Claude Code CLI",
5
5
  "type": "module",
6
6
  "main": "server/index.js",
@@ -277,7 +277,8 @@ export class OrchestratorClient extends EventEmitter {
277
277
  // Set timeout for pong response
278
278
  this.heartbeatTimeoutTimer = setTimeout(() => {
279
279
  console.warn("[ORCHESTRATOR] Heartbeat timeout, reconnecting...");
280
- this.ws?.terminate();
280
+ // Force close without waiting - terminate() can block if socket is dead
281
+ this.forceReconnect();
281
282
  }, DEFAULTS.heartbeatTimeout);
282
283
  }
283
284
 
@@ -879,6 +880,41 @@ export class OrchestratorClient extends EventEmitter {
879
880
  return result;
880
881
  }
881
882
 
883
+ /**
884
+ * Force reconnect without waiting for socket close
885
+ * This handles the case where the socket is dead (e.g., after macOS sleep)
886
+ * and terminate() would block indefinitely
887
+ */
888
+ forceReconnect() {
889
+ console.log("[ORCHESTRATOR] Force reconnecting...");
890
+
891
+ // Mark as disconnected immediately
892
+ this.isConnected = false;
893
+ this.isRegistered = false;
894
+ this.stopHeartbeat();
895
+
896
+ // Try to close the socket, but don't wait for it
897
+ if (this.ws) {
898
+ try {
899
+ // Destroy the underlying socket directly to avoid blocking
900
+ if (this.ws._socket) {
901
+ this.ws._socket.destroy();
902
+ }
903
+ this.ws.terminate();
904
+ } catch (e) {
905
+ // Ignore errors - socket may already be dead
906
+ }
907
+ this.ws = null;
908
+ }
909
+
910
+ this.emit("disconnected", { code: 1006, reason: "Force reconnect" });
911
+
912
+ // Schedule reconnect
913
+ if (this.shouldReconnect) {
914
+ this.scheduleReconnect();
915
+ }
916
+ }
917
+
882
918
  /**
883
919
  * Starts the heartbeat interval
884
920
  */