import{r as n,j as e}from"./vendor-react-96lCPsRK.js";import{i as ge,R as ye,j as be,k as we,f as ie,W as Ne,I as je}from"./index-C5ptjuTl.js";import{x as ve,a as Ce,b as ke,c as Se}from"./vendor-xterm-CZq1hqo1.js";import{O as Le}from"./vendor-canvas-D39yWul6.js";import{X as Te}from"./vendor-icons-BaD0x9SL.js";const Re=(t,r,a,p)=>{var s,w,C,d;const g=[a,{code:r,...p||{}}];if((w=(s=t==null?void 0:t.services)==null?void 0:s.logger)!=null&&w.forward)return t.services.logger.forward(g,"warn","react-i18next::",!0);F(g[0])&&(g[0]=`react-i18next:: ${g[0]}`),(d=(C=t==null?void 0:t.services)==null?void 0:C.logger)!=null&&d.warn?t.services.logger.warn(...g):console!=null&&console.warn&&console.warn(...g)},se={},ue=(t,r,a,p)=>{F(a)&&se[a]||(F(a)&&(se[a]=new Date),Re(t,r,a,p))},de=(t,r)=>()=>{if(t.isInitialized)r();else{const a=()=>{setTimeout(()=>{t.off("initialized",a)},0),r()};t.on("initialized",a)}},Z=(t,r,a)=>{t.loadNamespaces(r,de(t,a))},le=(t,r,a,p)=>{if(F(a)&&(a=[a]),t.options.preload&&t.options.preload.indexOf(r)>-1)return Z(t,a,p);a.forEach(g=>{t.options.ns.indexOf(g)<0&&t.options.ns.push(g)}),t.loadLanguages(r,de(t,p))},Ee=(t,r,a={})=>!r.languages||!r.languages.length?(ue(r,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:r.languages}),!0):r.hasLoadedNamespace(t,{lng:a.lng,precheck:(p,g)=>{if(a.bindI18n&&a.bindI18n.indexOf("languageChanging")>-1&&p.services.backendConnector.backend&&p.isLanguageChangingTo&&!g(p.isLanguageChangingTo,t))return!1}}),F=t=>typeof t=="string",Oe=t=>typeof t=="object"&&t!==null;var Ie=Le();const Ae=(t,r)=>F(r)?r:Oe(r)&&F(r.defaultValue)?r.defaultValue:Array.isArray(t)?t[t.length-1]:t,Me={t:Ae,ready:!1},_e=()=>()=>{},Pe=(t,r={})=>{var H,i,S;const{i18n:a}=r,{i18n:p,defaultNS:g}=n.useContext(ge)||{},s=a||p||we();s&&!s.reportNamespaces&&(s.reportNamespaces=new ye),s||ue(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const w=n.useMemo(()=>{var l;return{...be(),...(l=s==null?void 0:s.options)==null?void 0:l.react,...r}},[s,r]),{useSuspense:C,keyPrefix:d}=w,L=t||g||((H=s==null?void 0:s.options)==null?void 0:H.defaultNS),c=F(L)?[L]:L||["translation"],h=n.useMemo(()=>c,c);(S=(i=s==null?void 0:s.reportNamespaces)==null?void 0:i.addUsedNamespaces)==null||S.call(i,h);const u=n.useRef(0),k=n.useCallback(l=>{if(!s)return _e;const{bindI18n:f,bindI18nStore:x}=w,m=()=>{u.current+=1,l()};return f&&s.on(f,m),x&&s.store.on(x,m),()=>{f&&f.split(" ").forEach(_=>s.off(_,m)),x&&x.split(" ").forEach(_=>s.store.off(_,m))}},[s,w]),O=n.useRef(),y=n.useCallback(()=>{if(!s)return Me;const l=!!(s.isInitialized||s.initializedStoreOnce)&&h.every(P=>Ee(P,s,w)),f=r.lng||s.language,x=u.current,m=O.current;if(m&&m.ready===l&&m.lng===f&&m.keyPrefix===d&&m.revision===x)return m;const D={t:s.getFixedT(f,w.nsMode==="fallback"?h:h[0],d),ready:l,lng:f,keyPrefix:d,revision:x};return O.current=D,D},[s,h,d,w,r.lng]),[B,M]=n.useState(0),{t:I,ready:E}=Ie.useSyncExternalStore(k,y,y);n.useEffect(()=>{if(s&&!E&&!C){const l=()=>M(f=>f+1);r.lng?le(s,r.lng,h,l):Z(s,h,l)}},[s,r.lng,h,E,C,B]);const A=s||{},v=n.useRef(null),R=n.useRef(),U=l=>{const f=Object.getOwnPropertyDescriptors(l);f.__original&&delete f.__original;const x=Object.create(Object.getPrototypeOf(l),f);if(!Object.prototype.hasOwnProperty.call(x,"__original"))try{Object.defineProperty(x,"__original",{value:l,writable:!1,enumerable:!1,configurable:!1})}catch{}return x},T=n.useMemo(()=>{const l=A,f=l==null?void 0:l.language;let x=l;l&&(v.current&&v.current.__original===l?R.current!==f?(x=U(l),v.current=x,R.current=f):x=v.current:(x=U(l),v.current=x,R.current=f));const m=[I,x,E];return m.t=I,m.i18n=x,m.ready=E,m},[I,A,E,A.resolvedLanguage,A.language,A.languages]);if(s&&C&&!E)throw new Promise(l=>{const f=()=>l();r.lng?le(s,r.lng,h,f):Z(s,h,f)});return T},$e=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),Ke=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=ie();return e.jsx("img",{src:r?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:t})},Je=({className:t="w-5 h-5"})=>{const{isDarkMode:r}=ie();return e.jsx("img",{src:r?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:t})},We=`
  .xterm .xterm-screen {
    outline: none !important;
  }
  .xterm:focus .xterm-screen {
    outline: none !important;
  }
  .xterm-screen:focus {
    outline: none !important;
  }
`;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=We,document.head.appendChild(t)}function Ue(t){if(!t||typeof document>"u")return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",document.body.appendChild(r),r.focus(),r.select();let a=!1;try{a=document.execCommand("copy")}catch{a=!1}finally{document.body.removeChild(r)}return a}const ae="https://auth.openai.com/codex/device";function oe(t){return typeof t=="string"&&/\bcodex\s+login\b/i.test(t)}function ce({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:p=!1,onProcessComplete:g,minimal:s=!1,autoConnect:w=!1,shellType:C=null}){const{t:d}=Pe("chat"),L=n.useRef(null),c=n.useRef(null),h=n.useRef(null),u=n.useRef(null),[k,O]=n.useState(!1),[y,B]=n.useState(!1),[M,I]=n.useState(!1),[E,A]=n.useState(null),[v,R]=n.useState(!1),[U,T]=n.useState(null),[H,i]=n.useState(""),[S,l]=n.useState("idle"),[f,x]=n.useState(!1),m=n.useRef(t),_=n.useRef(r),D=n.useRef(a),P=n.useRef(p),ee=n.useRef(C),G=n.useRef(g),z=n.useRef("");n.useEffect(()=>{m.current=t,_.current=r,D.current=a,P.current=p,ee.current=C,G.current=g});const te=n.useCallback((b=z.current)=>{if(!b)return!1;const j=window.open(b,"_blank","noopener,noreferrer");if(j){try{j.opener=null}catch{}return!0}return!1},[]),X=n.useCallback(async(b=z.current)=>{var N;if(!b)return!1;let j=!1;try{typeof navigator<"u"&&((N=navigator.clipboard)!=null&&N.writeText)&&(await navigator.clipboard.writeText(b),j=!0)}catch{j=!1}return j||(j=Ue(b)),j},[]),re=n.useCallback(async()=>{if(!(v||k)){T(null);try{let b;Ne||(b=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell`),u.current=new WebSocket(b);const j=setTimeout(()=>{u.current&&u.current.readyState!==WebSocket.OPEN&&(u.current.close(),R(!1),T("Connection timed out. Check your relay connection (uc connect)."))},15e3);u.current.onopen=()=>{clearTimeout(j),O(!0),R(!1),T(null),z.current="",i(""),l("idle"),x(!1),setTimeout(()=>{var N,o;h.current&&c.current&&(h.current.fit(),u.current.send(JSON.stringify({type:"init",projectPath:m.current.fullPath||m.current.path,sessionId:P.current?null:(N=_.current)==null?void 0:N.id,hasSession:P.current?!1:!!_.current,provider:P.current?"plain-shell":((o=_.current)==null?void 0:o.__provider)||"claude",cols:c.current.cols,rows:c.current.rows,initialCommand:D.current,isPlainShell:P.current,shellType:ee.current})))},100)},u.current.onmessage=N=>{try{const o=JSON.parse(N.data);if(o.type==="output"){let W=o.data;if(P.current&&G.current){const K=W.replace(/\x1b\[[0-9;]*m/g,"");if(K.includes("Process exited with code 0"))G.current(0);else if(K.match(/Process exited with code (\d+)/)){const J=parseInt(K.match(/Process exited with code (\d+)/)[1]);J!==0&&G.current(J)}}c.current&&c.current.write(W)}else o.type==="error"?(T(o.message||"Connection error"),c.current&&c.current.write(`\r
\x1B[31m${o.message||"Connection error"}\x1B[0m\r
`)):(o.type==="auth_url"&&o.url||o.type==="url_open"&&o.url)&&(z.current=o.url,i(o.url),l("idle"),x(!1))}catch{}},u.current.onclose=N=>{clearTimeout(j);const o=k;O(!1),R(!1),l("idle"),x(!1),N.code===1006||N.code===4001?T("Connection lost. Your local machine may be offline."):(N.code===4003||N.code===1008)&&T("Authentication failed. Please log in again."),c.current&&(c.current.clear(),c.current.write("\x1B[2J\x1B[H"))},u.current.onerror=()=>{clearTimeout(j),O(!1),R(!1),T("Failed to connect. Check that your relay is running (uc connect).")}}catch{O(!1),R(!1),T("Failed to establish connection.")}}},[v,k,te]),q=n.useCallback(()=>{!y||k||v||(R(!0),T(null),re())},[y,k,v,re]),V=n.useCallback(()=>{u.current&&(u.current.close(),u.current=null),c.current&&(c.current.clear(),c.current.write("\x1B[2J\x1B[H")),O(!1),R(!1),T(null),z.current="",i(""),l("idle"),x(!1)},[]),$=n.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),xe=n.useMemo(()=>$?$.slice(0,30):null,[$]),he=n.useMemo(()=>$?$.slice(0,50):null,[$]),me=()=>{I(!0),u.current&&(u.current.close(),u.current=null),c.current&&(c.current.dispose(),c.current=null,h.current=null),O(!1),B(!1),z.current="",i(""),l("idle"),x(!1),setTimeout(()=>{I(!1)},200)};if(n.useEffect(()=>{const b=(r==null?void 0:r.id)||null;E!==null&&E!==b&&y&&V(),A(b)},[r==null?void 0:r.id,y,V]),n.useEffect(()=>{if(!L.current||!t||M||c.current)return;c.current=new ve.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!0,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),h.current=new Ce.FitAddon;const b=new ke.WebglAddon,j=new Se.WebLinksAddon;c.current.loadAddon(h.current),s||c.current.loadAddon(j);try{c.current.loadAddon(b)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}c.current.open(L.current),c.current.attachCustomKeyEventHandler(o=>{var K,J,ne;const W=oe(D.current)?ae:z.current;return o.type==="keydown"&&s&&P.current&&W&&!o.ctrlKey&&!o.metaKey&&!o.altKey&&((K=o.key)==null?void 0:K.toLowerCase())==="c"&&X(W).catch(()=>{}),o.type==="keydown"&&(o.ctrlKey||o.metaKey)&&((J=o.key)==null?void 0:J.toLowerCase())==="c"&&c.current.hasSelection()?(o.preventDefault(),o.stopPropagation(),document.execCommand("copy"),!1):o.type==="keydown"&&(o.ctrlKey||o.metaKey)&&((ne=o.key)==null?void 0:ne.toLowerCase())==="v"?(o.preventDefault(),o.stopPropagation(),navigator.clipboard.readText().then(pe=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"input",data:pe}))}).catch(()=>{}),!1):!0}),setTimeout(()=>{h.current&&(h.current.fit(),c.current&&u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"resize",cols:c.current.cols,rows:c.current.rows})))},100),B(!0),c.current.onData(o=>{u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"input",data:o}))});const N=new ResizeObserver(()=>{h.current&&c.current&&setTimeout(()=>{h.current.fit(),u.current&&u.current.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"resize",cols:c.current.cols,rows:c.current.rows}))},50)});return L.current&&N.observe(L.current),()=>{N.disconnect(),u.current&&(u.current.readyState===WebSocket.OPEN||u.current.readyState===WebSocket.CONNECTING)&&u.current.close(),u.current=null,c.current&&(c.current.dispose(),c.current=null)}},[(t==null?void 0:t.path)||(t==null?void 0:t.fullPath),M,s,X]),n.useEffect(()=>{!w||!y||v||k||q()},[w,y,v,k,q]),!t)return e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:d("shell.selectProject.title")}),e.jsx("p",{children:d("shell.selectProject.description")})]})});if(s){const b=oe(a)?ae:H,j=!!b,N=j&&!f,o=j&&f;return e.jsxs("div",{className:"h-full w-full bg-gray-900 relative",children:[e.jsx("div",{ref:L,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),N&&e.jsx("div",{className:"absolute inset-x-0 bottom-14 z-20 border-t border-gray-700/80 bg-gray-900/95 p-3 backdrop-blur-sm md:hidden",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),e.jsx("button",{type:"button",onClick:()=>x(!0),className:"rounded bg-gray-700 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-gray-100 hover:bg-gray-600",children:"Hide"})]}),e.jsx("input",{type:"text",value:b,readOnly:!0,onClick:W=>W.currentTarget.select(),className:"w-full rounded border border-gray-600 bg-gray-800 px-2 py-1 text-xs text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500","aria-label":"Authentication URL"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{te(b)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),e.jsx("button",{type:"button",onClick:async()=>{const W=await X(b);l(W?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:S==="copied"?"Copied":"Copy URL"})]})]})}),o&&e.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:e.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded bg-gray-800/95 px-3 py-2 text-xs font-medium text-gray-100 shadow-lg backdrop-blur-sm hover:bg-gray-700",children:"Show login URL"})})]})}return e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",xe,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:d("shell.status.newSession")}),!y&&e.jsx("span",{className:"text-xs text-yellow-400",children:d("shell.status.initializing")}),M&&e.jsx("span",{className:"text-xs text-blue-400",children:d("shell.status.restarting")})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[k&&e.jsxs("button",{onClick:V,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:d("shell.actions.disconnectTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:d("shell.actions.disconnect")})]}),e.jsxs("button",{onClick:me,disabled:M||k,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:d("shell.actions.restartTitle"),children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:d("shell.actions.restart")})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:L,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!y&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:d("shell.loading")})}),y&&!k&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[U&&e.jsx("div",{className:"mb-4 px-4 py-2 bg-red-900/40 border border-red-500/30 rounded-lg",children:e.jsx("p",{className:"text-red-400 text-xs",children:U})}),e.jsxs("button",{onClick:q,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:d("shell.actions.connectTitle"),children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:U?d("shell.actions.retry","Retry"):d("shell.actions.connect")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:p?d("shell.runCommand",{command:a||d("shell.defaultCommand"),projectName:t.displayName}):r?d("shell.resumeSession",{displayName:he}):d("shell.startSession")})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:d("shell.connecting")})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:p?d("shell.runCommand",{command:a||d("shell.defaultCommand"),projectName:t.displayName}):d("shell.startCli",{projectName:t.displayName})})]})})]})]})}let Q=0;const Y=[{value:"powershell",label:"PowerShell",icon:"PS"},{value:"cmd",label:"CMD",icon:">"},{value:"bash",label:"Bash",icon:"$"}];function fe({project:t,session:r=null,command:a=null,isPlainShell:p=null,autoConnect:g=!0,onComplete:s=null,onClose:w=null,title:C=null,className:d="",showHeader:L=!0,compact:c=!1,minimal:h=!1,multiTab:u=!1}){const[k,O]=n.useState(!1),[y,B]=n.useState(()=>[{id:++Q,shellType:"powershell",label:"PowerShell"}]),[M,I]=n.useState(()=>{var i;return(i=y[0])==null?void 0:i.id}),[E,A]=n.useState(!1),v=n.useRef(null),R=p!==null?p:a!==null,U=n.useCallback(i=>{O(!0),s&&s(i)},[s]),T=n.useCallback(i=>{const S=Y.find(f=>f.value===i)||Y[0],l=++Q;B(f=>[...f,{id:l,shellType:S.value,label:S.label}]),I(l),A(!1)},[]),H=n.useCallback(i=>{B(S=>{const l=S.filter(f=>f.id!==i);return l.length===0?[{id:++Q,shellType:"powershell",label:"PowerShell"}]:l}),I(S=>{if(S===i){const l=y.findIndex(m=>m.id===i),f=y.filter(m=>m.id!==i);if(f.length===0)return null;const x=Math.min(l,f.length-1);return f[x].id}return S})},[y]);return t?u&&!h&&!r&&!a?e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[e.jsxs("div",{className:"flex-shrink-0 flex items-center bg-[#1e1e1e] border-b border-gray-700 px-1 min-h-[36px]",children:[e.jsx("div",{className:"flex items-center gap-0.5 overflow-x-auto flex-1 min-w-0",children:y.map(i=>{var S;return e.jsxs("button",{onClick:()=>I(i.id),className:`group flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-t transition-colors shrink-0 ${M===i.id?"bg-gray-800 text-gray-100 border-t-2 border-t-blue-500":"text-gray-400 hover:text-gray-200 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] font-mono opacity-60",children:((S=Y.find(l=>l.value===i.shellType))==null?void 0:S.icon)||">"}),e.jsx("span",{children:i.label}),y.length>1&&e.jsx("span",{onClick:l=>{l.stopPropagation(),H(i.id)},className:"ml-1 opacity-0 group-hover:opacity-100 hover:text-red-400 transition-opacity cursor-pointer",title:"Close tab",children:"×"})]},i.id)})}),e.jsxs("div",{className:"relative ml-1 shrink-0",children:[e.jsx("button",{ref:v,onClick:()=>A(!E),className:"flex items-center justify-center w-7 h-7 text-gray-400 hover:text-gray-100 hover:bg-gray-700 rounded transition-colors text-lg",title:"New terminal",children:"+"}),E&&e.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 bg-gray-800 border border-gray-600 rounded-lg shadow-xl py-1 min-w-[140px]",children:Y.map(i=>e.jsxs("button",{onClick:()=>T(i.value),className:"w-full text-left px-3 py-1.5 text-xs text-gray-200 hover:bg-gray-700 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-[10px] opacity-60 w-4",children:i.icon}),i.label]},i.value))})]})]}),e.jsx("div",{className:"flex-1 w-full min-h-0 relative",children:y.map(i=>e.jsx("div",{className:"absolute inset-0",style:{display:M===i.id?"block":"none"},children:e.jsx(ce,{selectedProject:t,isPlainShell:!0,shellType:i.shellType,autoConnect:!0,minimal:!1})},i.id))})]}):e.jsxs("div",{className:`h-full w-full flex flex-col ${d}`,children:[!h&&L&&C&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:C}),k&&e.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),w&&e.jsx("button",{onClick:w,className:"text-gray-400 hover:text-white",title:"Close",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ce,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:R,onProcessComplete:U,minimal:h,autoConnect:h?!0:g})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${d}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Project Selected"}),e.jsx("p",{children:"A project is required to open a shell"})]})})}const Ge=Object.freeze(Object.defineProperty({__proto__:null,default:fe},Symbol.toStringTag,{value:"Module"}));function Ye({isOpen:t,onClose:r,provider:a="claude",project:p,onComplete:g,customCommand:s,isAuthenticated:w=!1,isOnboarding:C=!1}){if(!t)return null;const d=()=>{if(s)return s;switch(a){case"claude":return w?"claude setup-token --dangerously-skip-permissions":C?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions";case"cursor":return"cursor-agent login";case"codex":return je?"codex login --device-auth":"codex login";default:return w?"claude setup-token --dangerously-skip-permissions":C?"claude /exit --dangerously-skip-permissions":"claude /login --dangerously-skip-permissions"}},L=()=>{switch(a){case"claude":return"Claude CLI Login";case"cursor":return"Cursor CLI Login";case"codex":return"Codex CLI Login";default:return"CLI Login"}},c=h=>{g&&g(h)};return e.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:e.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:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:L()}),e.jsx("button",{onClick:r,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Close login modal",children:e.jsx(Te,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(fe,{project:p,command:d(),onComplete:c,minimal:!0})})]})})}export{Ke as C,Ye as L,ce as S,Je as a,$e as b,Ge as c,Pe as u};
