@pixelbyte-software/pixcode 1.31.3 → 1.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -226,7 +226,7 @@ import{j as s,a as ES,R as Km,o as Ym,_ as qT,b as VT,m as NS,E as mr,T as CS,P
226
226
  .xterm-screen:focus {
227
227
  outline: none !important;
228
228
  }
229
- `;function hR(){if(typeof document>"u"||document.getElementById(xy))return;const e=document.createElement("style");e.id=xy,e.type="text/css",e.innerText=mR,document.head.appendChild(e)}function fR({terminalContainerRef:e,terminalRef:t,fitAddonRef:n,wsRef:r,selectedProject:a,minimal:i,isRestarting:o,initialCommandRef:l,isPlainShellRef:c,authUrlRef:u,copyAuthUrlToClipboard:d,closeSocket:p}){const[h,m]=f.useState(!1),g=f.useRef(null),b=a?.fullPath||a?.path||"",x=!!a;f.useEffect(()=>{hR()},[]);const y=f.useCallback(()=>{t.current&&(t.current.clear(),t.current.write("\x1B[2J\x1B[H"))},[t]),v=f.useCallback(()=>{t.current&&(t.current.dispose(),t.current=null),n.current=null,m(!1)},[n,t]);return f.useEffect(()=>{if(!e.current||!x||o||t.current)return;const w=new uR.Terminal(Qj);t.current=w;const S=new sR.FitAddon;n.current=S,w.loadAddon(S),i||w.loadAddon(new lR.WebLinksAddon);try{w.loadAddon(new cR.WebglAddon)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}w.open(e.current);const E=async()=>{const N=w.getSelection();return N?hr(N):!1},k=N=>{if(!w.hasSelection())return;const _=w.getSelection();if(_){if(N.preventDefault(),N.clipboardData){N.clipboardData.setData("text/plain",_);return}hr(_)}};e.current.addEventListener("copy",k),w.attachCustomKeyEventHandler(N=>{const _=f5(l.current)?m5:u.current;return N.type==="keydown"&&i&&c.current&&_&&!N.ctrlKey&&!N.metaKey&&!N.altKey&&N.key?.toLowerCase()==="c"?(N.preventDefault(),N.stopPropagation(),d(_),!1):N.type==="keydown"&&(N.ctrlKey||N.metaKey)&&N.key?.toLowerCase()==="c"&&w.hasSelection()?(N.preventDefault(),N.stopPropagation(),E(),!1):N.type==="keydown"&&(N.ctrlKey||N.metaKey)&&N.key?.toLowerCase()==="v"?(N.preventDefault(),N.stopPropagation(),typeof navigator<"u"&&navigator.clipboard?.readText&&navigator.clipboard.readText().then(R=>{oi(r.current,{type:"input",data:R})}).catch(()=>{}),!1):!0}),window.setTimeout(()=>{const N=n.current,_=t.current;!N||!_||(N.fit(),oi(r.current,{type:"resize",cols:_.cols,rows:_.rows}))},h5),m(!0);const A=w.onData(N=>{oi(r.current,{type:"input",data:N})}),I=new ResizeObserver(()=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const N=n.current,_=t.current;!N||!_||(N.fit(),oi(r.current,{type:"resize",cols:_.cols,rows:_.rows}))},Wj)});return I.observe(e.current),()=>{e.current?.removeEventListener("copy",k),I.disconnect(),g.current!==null&&(window.clearTimeout(g.current),g.current=null),A.dispose(),p(),v()}},[u,p,d,v,n,l,c,o,i,x,b,e,t,r]),{isInitialized:h,clearTerminalScreen:y,disposeTerminal:v}}function gR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:a,autoConnect:i,isRestarting:o,onProcessComplete:l,onOutputRef:c}){const u=f.useRef(null),d=f.useRef(null),p=f.useRef(null),h=f.useRef(null),[m,g]=f.useState(""),[b,x]=f.useState(0),y=f.useRef(e),v=f.useRef(t),w=f.useRef(n),S=f.useRef(r),E=f.useRef(l),k=f.useRef(""),A=f.useRef(t?.id??null);f.useEffect(()=>{y.current=e,v.current=t,w.current=n,S.current=r,E.current=l},[e,t,n,r,l]);const I=f.useCallback(q=>{k.current=q,g(q),x(O=>O+1)},[]),N=f.useCallback(()=>{const q=h.current;q&&((q.readyState===WebSocket.OPEN||q.readyState===WebSocket.CONNECTING)&&q.close(),h.current=null)},[]),_=f.useCallback((q=k.current)=>{if(!q)return!1;const O=window.open(q,"_blank");if(O){try{O.opener=null}catch{}return!0}return!1},[]),R=f.useCallback(async(q=k.current)=>q?hr(q):!1,[]),{isInitialized:C,clearTerminalScreen:D,disposeTerminal:T}=fR({terminalContainerRef:u,terminalRef:d,fitAddonRef:p,wsRef:h,selectedProject:e,minimal:a,isRestarting:o,initialCommandRef:w,isPlainShellRef:S,authUrlRef:k,copyAuthUrlToClipboard:R,closeSocket:N}),{isConnected:z,isConnecting:H,connectToShell:B,disconnectFromShell:Y}=iR({wsRef:h,terminalRef:d,fitAddonRef:p,selectedProjectRef:y,selectedSessionRef:v,initialCommandRef:w,isPlainShellRef:S,onProcessCompleteRef:E,isInitialized:C,autoConnect:i,closeSocket:N,clearTerminalScreen:D,setAuthUrl:I,onOutputRef:c});return f.useEffect(()=>{o&&(Y(),T())},[Y,T,o]),f.useEffect(()=>{e||(Y(),T())},[Y,T,e]),f.useEffect(()=>{const q=t?.id??null;A.current!==q&&C&&Y(),A.current=q},[Y,C,t?.id]),{terminalContainerRef:u,terminalRef:d,wsRef:h,isConnected:z,isInitialized:C,isConnecting:H,authUrl:m,authUrlVersion:b,connectToShell:B,disconnectFromShell:Y,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:R}}function bR({mode:e,description:t,loadingLabel:n,connectLabel:r,connectTitle:a,connectingLabel:i,onConnect:o}){return e==="loading"?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:s.jsx("div",{className:"text-white",children:n})}):e==="connect"?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:s.jsxs("div",{className:"w-full max-w-sm text-center",children:[s.jsxs("button",{onClick:o,className:"flex w-full items-center justify-center space-x-2 rounded-lg bg-green-600 px-6 py-3 text-base font-medium text-white transition-colors hover:bg-green-700 sm:w-auto",title:a,children:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),s.jsx("span",{children:r})]}),s.jsx("p",{className:"mt-3 px-2 text-sm text-gray-400",children:t})]})}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:s.jsxs("div",{className:"w-full max-w-sm text-center",children:[s.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),s.jsx("span",{className:"text-base font-medium",children:i})]}),s.jsx("p",{className:"mt-3 px-2 text-sm text-gray-400",children:t})]})})}function xR({title:e,description:t}){return s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:e}),s.jsx("p",{children:t})]})})}function yR({isConnected:e,isInitialized:t,isRestarting:n,hasSession:r,sessionDisplayNameShort:a,onDisconnect:i,onRestart:o,statusNewSessionText:l,statusInitializingText:c,statusRestartingText:u,disconnectLabel:d,disconnectTitle:p,restartLabel:h,restartTitle:m,disableRestart:g}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-500":"bg-red-500"}`}),r&&a&&s.jsxs("span",{className:"text-xs text-blue-300",children:["(",a,"...)"]}),!r&&s.jsx("span",{className:"text-xs text-gray-400",children:l}),!t&&s.jsx("span",{className:"text-xs text-yellow-400",children:c}),n&&s.jsx("span",{className:"text-xs text-blue-400",children:u})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[e&&s.jsxs("button",{onClick:i,className:"flex items-center space-x-1 rounded bg-red-600 px-3 py-1 text-xs text-white hover:bg-red-700",title:p,children:[s.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),s.jsx("span",{children:d})]}),s.jsxs("button",{onClick:o,disabled:g,className:"flex items-center space-x-1 text-xs text-gray-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50",title:m,children:[s.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{children:h})]})]})]})})}function vR({terminalContainerRef:e,authUrl:t,authUrlVersion:n,initialCommand:r,isConnected:a,openAuthUrlInBrowser:i,copyAuthUrlToClipboard:o}){const[l,c]=f.useState("idle"),[u,d]=f.useState(!1),p=f.useMemo(()=>dR(r,t),[t,r]);f.useEffect(()=>{c("idle"),d(!1)},[n,p,a]);const h=!!p,m=h&&!u,g=h&&u;return s.jsxs("div",{className:"relative h-full w-full bg-gray-900",children:[s.jsx("div",{ref:e,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),m&&s.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:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),s.jsx("button",{type:"button",onClick:()=>d(!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"})]}),s.jsx("input",{type:"text",value:p,readOnly:!0,onClick:b=>b.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"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{i(p)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),s.jsx("button",{type:"button",onClick:async()=>{const b=await o(p);c(b?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:l==="copied"?"Copied":"Copy URL"})]})]})}),g&&s.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:s.jsx("button",{type:"button",onClick:()=>d(!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"})})]})}const wR=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],kR={up:XS,down:t0,left:qI,right:n0},Ks=e=>e.preventDefault(),yy="shrink-0 rounded-md border border-gray-600 bg-gray-700 px-2.5 py-1.5 text-xs font-medium text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40",SR="shrink-0 rounded-md border border-blue-500 bg-blue-600 px-2.5 py-1.5 text-xs font-medium text-white transition-colors select-none disabled:cursor-not-allowed disabled:opacity-40",Fu="shrink-0 rounded-md border border-gray-600 bg-gray-700 p-1.5 text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40";function vy({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=je("settings"),[i,o]=f.useState(!1),[l,c]=f.useState(!1),u=f.useCallback(m=>{oi(e.current,{type:"input",data:m})},[e]),d=f.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=f.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&u(m)}catch{}},[u]),h=f.useCallback(m=>{let g=m;if(i&&m.length===1){const b=m.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&m.length===1&&(g="\x1B"+g,c(!1)),u(g)},[i,l,u]);return s.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${r} z-20 px-2 md:hidden`,children:s.jsxs("div",{className:"pointer-events-auto flex items-center gap-1 overflow-x-auto rounded-lg border border-gray-700/80 bg-gray-900/95 px-1.5 py-1.5 shadow-lg backdrop-blur-sm [-webkit-overflow-scrolling:touch] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>{p()},disabled:!n,className:Fu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(i0,{className:"h-4 w-4"})}),wR.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?i:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:b,disabled:!n,className:g?SR:yy,children:m.label},m.id)}if(m.type==="arrow"){const g=kR[m.icon];return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>u(m.sequence),disabled:!n,className:Fu,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>h(m.sequence),disabled:!n,className:yy,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:Ks,onClick:d,disabled:!n,className:Fu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(VI,{className:"h-4 w-4"})})]})})}function g5({selectedProject:e=null,selectedSession:t=null,initialCommand:n=null,isPlainShell:r=!1,onProcessComplete:a=null,minimal:i=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=je("chat"),[u,d]=f.useState(!1),[p,h]=f.useState(null),m=f.useRef(null),g=f.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:S,authUrl:E,authUrlVersion:k,connectToShell:A,disconnectFromShell:I,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:_}=gR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:i,autoConnect:o,isRestarting:u,onProcessComplete:a,onOutputRef:g}),R=f.useCallback(()=>{const G=x.current;if(!G)return;const P=G.buffer.active,ee=P.baseY+P.cursorY,ne=Math.min(P.baseY+P.length-1,ee+10),pe=Math.max(0,ee-Yj),le=[];for(let De=pe;De<=ne;De++){const Ge=P.getLine(De);Ge&&le.push(Ge.translateToString().trimEnd())}let oe=-1;for(let De=le.length-1;De>=0;De--)if(/esc to cancel/i.test(le[De])||/enter to select/i.test(le[De])){oe=De;break}if(oe===-1){h(null);return}const he=new Map,Te=Math.max(0,oe-Zj);for(let De=oe-1;De>=Te;De--){const Ge=le[De].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ge){const M=Ge[1],me=Ge[2].trim();parseInt(M,10)<=Xj&&me.length>0&&!he.has(M)&&he.set(M,me)}}const _e=[];for(let De=1;De<=he.size&&he.has(String(De));De++)_e.push({number:String(De),label:he.get(String(De))});h(_e.length>=Jj?_e:null)},[x]),C=f.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(R,Kj)},[R]);f.useEffect(()=>{g.current=C},[C]),f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),f.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),h(null))},[v]),f.useEffect(()=>{if(!l||!w||!v)return;const G=()=>{x.current?.focus()},P=window.requestAnimationFrame(G),ee=window.setTimeout(G,0);return()=>{window.cancelAnimationFrame(P),window.clearTimeout(ee)}},[l,v,w,x]);const D=f.useCallback(G=>{oi(y.current,{type:"input",data:G})},[y]),T=f.useMemo(()=>pR(t),[t]),z=f.useMemo(()=>T?T.slice(0,30):null,[T]),H=f.useMemo(()=>T?T.slice(0,50):null,[T]),B=f.useCallback(()=>{d(!0),window.setTimeout(()=>{d(!1)},Vj)},[]);if(!e)return s.jsx(xR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(vR,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:n,isConnected:v,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:_}),s.jsx(vy,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const Y=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:H}):c("shell.startSession"),q=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?S?"connecting":v?null:"connect":"loading",$=O==="connecting"?q:Y;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(yR,{isConnected:v,isInitialized:w,isRestarting:u,hasSession:!!t,sessionDisplayNameShort:z,onDisconnect:I,onRestart:B,statusNewSessionText:c("shell.status.newSession"),statusInitializingText:c("shell.status.initializing"),statusRestartingText:c("shell.status.restarting"),disconnectLabel:c("shell.actions.disconnect"),disconnectTitle:c("shell.actions.disconnectTitle"),restartLabel:c("shell.actions.restart"),restartTitle:c("shell.actions.restartTitle"),disableRestart:u||v}),s.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[s.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),O&&s.jsx(bR,{mode:O,description:$,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:A}),p&&v&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:G=>G.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(G=>s.jsxs("button",{type:"button",onClick:()=>{D(G.number),h(null)},className:"max-w-36 truncate rounded bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",title:`${G.number}. ${G.label}`,children:[G.number,". ",G.label]},G.number)),s.jsx("button",{type:"button",onClick:()=>{D("\x1B"),h(null)},className:"rounded bg-gray-700 px-3 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:bg-gray-600",children:"Esc"})]})})]}),s.jsx(vy,{wsRef:y,terminalRef:x,isConnected:v})]})}function ER({className:e}){return s.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),s.jsx("p",{children:"A project is required to open a shell"})]})})}function NR({title:e,isCompleted:t,onClose:n=null}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&s.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),n&&s.jsx("button",{onClick:n,className:"text-gray-400 hover:text-white",title:"Close",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function b5({project:e=null,session:t=null,command:n=null,isPlainShell:r=null,isActive:a=!0,autoConnect:i=!0,onComplete:o=null,onClose:l=null,title:c=null,className:u="",showHeader:d=!0,compact:p=!1,minimal:h=!1}){const[m,g]=f.useState(!1),b=r!==null?r:n!==null,x=f.useCallback(y=>{g(!0),o?.(y)},[o]);return e?s.jsxs("div",{className:`flex h-full w-full flex-col ${u}`,children:[!h&&d&&c&&s.jsx(NR,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(g5,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:h,autoConnect:h?!0:i})})]}):s.jsx(ER,{className:u})}const CR=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":"gemini"),TR={claude:{keyLabel:"Anthropic API Key",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console"},codex:{keyLabel:"OpenAI API Key",keyExample:"sk-...",supportsBaseUrl:!0,baseUrlExample:"https://api.openai.com/v1",keyConsoleUrl:"https://platform.openai.com/api-keys",keyConsoleLabel:"OpenAI Platform"},gemini:{keyLabel:"Gemini API Key",keyExample:"AI...",supportsBaseUrl:!1,keyConsoleUrl:"https://aistudio.google.com/app/apikey",keyConsoleLabel:"Google AI Studio"},qwen:{keyLabel:"OpenAI-Compatible API Key",keyExample:"sk-... or sk-sp-...",supportsBaseUrl:!0,baseUrlExample:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",keyConsoleUrl:"https://github.com/QwenLM/qwen-code",keyConsoleLabel:"Qwen Code Docs",notes:"Accepts any OpenAI-compatible endpoint — Alibaba Cloud, ModelScope, OpenRouter, self-hosted, etc."}};function wy({active:e,children:t,onClick:n}){return s.jsx("button",{onClick:n,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function AR({provider:e}){const[t,n]=f.useState(""),[r,a]=f.useState(!1),[i,o]=f.useState("idle"),[l,c]=f.useState(null),u=async()=>{const d=t.trim();if(d){a(!0),c(null),o("idle");try{const p=await we(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:d})}),h=await p.json().catch(()=>({}));if(!p.ok||!h?.success)throw new Error(h?.error||`Request failed (${p.status})`);o("ok"),n("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return s.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[s.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",s.jsx("code",{className:"rounded bg-background px-1 font-mono text-[11px]",children:"http://127.0.0.1:PORT/…"})," and your browser can't reach it (VPS setups), copy the failing URL from your address bar and paste it below. Pixcode forwards the token exchange to the CLI process on this host."]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"url",value:t,onChange:d=>n(d.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:d=>{d.key==="Enter"&&u()}}),s.jsx("button",{onClick:()=>void u(),disabled:r||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:r?s.jsx(fn,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),i==="ok"&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx(Ut,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),i==="error"&&l&&s.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function _R({provider:e,onSaved:t}){const n=TR[e],[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[u,d]=f.useState("idle"),[p,h]=f.useState(null);f.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await we("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const m=async()=>{const g=r.trim();if(g){c(!0),h(null),d("idle");try{const b=await we(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:n.supportsBaseUrl&&i.trim()?i.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);d("ok"),a(""),t()}catch(b){h(b?.message||"Save failed"),d("error")}finally{c(!1)}}};return n?s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:s.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:s.jsx(Sj,{className:"h-5 w-5 text-foreground"})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.keyLabel}),s.jsxs("a",{href:n.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",n.keyConsoleLabel,s.jsx(Or,{className:"h-3 w-3"})]})]})]}),n.notes&&s.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:n.notes}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),s.jsx("input",{type:"password",value:r,onChange:g=>a(g.target.value),placeholder:n.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",s.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),n.supportsBaseUrl&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",s.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),s.jsx("input",{type:"url",value:i,onChange:g=>o(g.target.value),placeholder:n.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Point at any OpenAI-compatible proxy (OpenRouter, local LLM, self-hosted, budget provider) to cut costs or hit different models."})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[s.jsxs("button",{onClick:()=>void m(),disabled:l||!r.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?s.jsx(fn,{className:"h-4 w-4 animate-spin"}):s.jsx(Ut,{className:"h-4 w-4"}),"Save API Key"]}),u==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),u==="error"&&p&&s.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):s.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function x5({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:i=!1}){const{t:o}=je("common"),l=n!=="cursor",[c,u]=f.useState(l?"apiKey":"browser");f.useEffect(()=>{e&&u(l?"apiKey":"browser")},[e,n,l]);const d=f.useMemo(()=>`${fc[n]??n} Login`,[n]);if(!e)return null;const p=CR(n,a),h=m=>r?.(m);return s.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:s.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d}),s.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:s.jsx(ft,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(wy,{active:c==="browser",onClick:()=>u("browser"),children:"Browser / OAuth"}),l&&s.jsx(wy,{active:c==="apiKey",onClick:()=>u("apiKey"),children:"API Key"})]}),s.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(b5,{project:l6,command:p,onComplete:h,minimal:!0})}),(n==="claude"||n==="cursor"||n==="qwen")&&s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(AR,{provider:n})})]}):s.jsx(_R,{provider:n,onSaved:()=>h(0)})})]})})}const IR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),jR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Cs();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},RR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Cs();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},DR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),LR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-ai-icon.png",alt:"Qwen Code",className:e});function Dn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(RR,{className:t}):e==="codex"?s.jsx(jR,{className:t}):e==="gemini"?s.jsx(DR,{className:t}):e==="qwen"?s.jsx(LR,{className:t}):s.jsx(IR,{className:t})}function OR({provider:e,title:t,status:n,connectedClassName:r,iconContainerClassName:a,loginButtonClassName:i,onLogin:o}){const l=n.authenticated?r:"border-border bg-card",c=n.loading?"Checking...":n.authenticated?n.email||"Connected":n.error||"Not connected";return s.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:s.jsx(Dn,{provider:e,className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,n.authenticated&&s.jsx(Ut,{className:"h-4 w-4 text-green-500"})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!n.authenticated&&!n.loading&&s.jsx("button",{onClick:o,className:`${i} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const MR=[{provider:"claude",title:"Claude Code",connectedClassName:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",iconContainerClassName:"bg-blue-100 dark:bg-blue-900/30",loginButtonClassName:"bg-blue-600 hover:bg-blue-700"},{provider:"cursor",title:"Cursor",connectedClassName:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800",iconContainerClassName:"bg-purple-100 dark:bg-purple-900/30",loginButtonClassName:"bg-purple-600 hover:bg-purple-700"},{provider:"codex",title:"OpenAI Codex",connectedClassName:"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600",iconContainerClassName:"bg-gray-100 dark:bg-gray-800",loginButtonClassName:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"},{provider:"gemini",title:"Gemini",connectedClassName:"bg-teal-50 dark:bg-teal-900/20 border-teal-200 dark:border-teal-800",iconContainerClassName:"bg-teal-100 dark:bg-teal-900/30",loginButtonClassName:"bg-teal-600 hover:bg-teal-700"},{provider:"qwen",title:"Qwen Code",connectedClassName:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800",iconContainerClassName:"bg-orange-100 dark:bg-orange-900/30",loginButtonClassName:"bg-orange-600 hover:bg-orange-700"}];function PR({providerStatuses:e,onOpenProviderLogin:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),s.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),s.jsx("div",{className:"space-y-3",children:MR.map(n=>s.jsx(OR,{provider:n.provider,title:n.title,status:e[n.provider],connectedClassName:n.connectedClassName,iconContainerClassName:n.iconContainerClassName,loginButtonClassName:n.loginButtonClassName,onLogin:()=>t(n.provider)},n.provider))}),s.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:s.jsx("p",{children:"You can configure these later in Settings."})})]})}function FR({gitName:e,gitEmail:t,isSubmitting:n,onGitNameChange:r,onGitEmailChange:a}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30",children:s.jsx(rr,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),s.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(wj,{className:"h-4 w-4"}),"Git Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",id:"gitName",value:e,onChange:i=>r(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:n}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(yj,{className:"h-4 w-4"}),"Git Email ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:i=>a(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:n}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const ky=[{title:"Git Configuration",icon:rr,required:!0},{title:"Connect Agents",icon:JS,required:!1}];function zR({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:ky.map((t,n)=>{const r=n<e,a=n===e,i=t.icon;return s.jsxs("div",{className:"contents",children:[s.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[s.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${r?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:r?s.jsx(Ut,{className:"h-6 w-6"}):s.jsx(i,{className:"h-6 w-6"})}),s.jsxs("div",{className:"mt-2 text-center",children:[s.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&s.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),n<ky.length-1&&s.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${r?"bg-green-500":"bg-border"}`})]},t.title)})})})}const Sy=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ey=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function BR({onComplete:e}){const[t,n]=f.useState(0),[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[u,d]=f.useState(""),[p,h]=f.useState(null),{providerAuthStatus:m,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=p0(),x=f.useRef(void 0),y=f.useCallback(async()=>{try{const I=await we("/api/user/git-config");if(!I.ok)return;const N=await I.json();N.gitName&&a(N.gitName),N.gitEmail&&o(N.gitEmail)}catch(I){console.error("Error loading git config:",I)}},[]);f.useEffect(()=>{y(),b()},[y,b]),f.useEffect(()=>{const I=x.current;x.current=p,I!=null&&p===null&&b()},[p,b]);const v=I=>{h(I)},w=I=>{I===0&&p&&g(p)},S=async()=>{if(d(""),t!==0){n(I=>I+1);return}if(!r.trim()||!i.trim()){d("Both git name and email are required.");return}if(!Sy.test(i)){d("Please enter a valid email address.");return}c(!0);try{const I=await we("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:i})});if(!I.ok){const N=await Ey(I,"Failed to save git configuration");throw new Error(N)}n(N=>N+1)}catch(I){d(I instanceof Error?I.message:"Failed to save git configuration")}finally{c(!1)}},E=()=>{d(""),n(I=>I-1)},k=async()=>{c(!0),d("");try{const I=await we("/api/user/complete-onboarding",{method:"POST"});if(!I.ok){const N=await Ey(I,"Failed to complete onboarding");throw new Error(N)}await e?.()}catch(I){d(I instanceof Error?I.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&i.trim()&&Sy.test(i)):!0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"w-full max-w-2xl",children:[s.jsx(zR,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(FR,{gitName:r,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):s.jsx(PR,{providerStatuses:m,onOpenProviderLogin:v}),u&&s.jsx("div",{className:"mt-6 rounded-lg border border-red-300 bg-red-100 p-4 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),s.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[s.jsxs("button",{onClick:E,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(r0,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<1?s.jsx("button",{onClick:S,disabled:!A||l,className:"flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(fn,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(Sr,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:k,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(fn,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ut,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(x5,{isOpen:!!p,onClose:()=>h(null),provider:p,onComplete:w})]})}const $R=["0s","0.1s","0.2s"];function UR(){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(xi,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),s.jsx("div",{className:"flex items-center justify-center space-x-2",children:$R.map(e=>s.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function y5({errorMessage:e}){return e?s.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function vo({id:e,label:t,value:n,onChange:r,placeholder:a,isDisabled:i,type:o="text",name:l,autoComplete:c}){return s.jsxs("div",{children:[s.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),s.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:n,onChange:u=>r(u.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:i})]})}function v5({title:e,description:t,children:n,footerText:r,logo:a}){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsx("div",{className:"w-full max-w-md",children:s.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:a??s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(xi,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),n,s.jsx("div",{className:"text-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:r})}),s.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.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 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 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.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),s.jsx("a",{href:"https://github.com/alicomert/pixcode",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground/50 transition-colors hover:text-muted-foreground",children:"Pixcode is open source"})]})]})})})}const GR={username:"",password:""};function HR(){const{t:e}=je("auth"),{login:t}=Zo(),[n,r]=f.useState(GR),[a,i]=f.useState(""),[o,l]=f.useState(!1),c=f.useCallback((d,p)=>{r(h=>({...h,[d]:p}))},[]),u=f.useCallback(async d=>{if(d.preventDefault(),i(""),!n.username.trim()||!n.password){i(e("login.errors.requiredFields"));return}l(!0);const p=await t(n.username.trim(),n.password);p.success||i(p.error),l(!1)},[n.password,n.username,t,e]);return s.jsx(v5,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx(vo,{id:"username",label:e("login.username"),value:n.username,onChange:d=>c("username",d),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(vo,{id:"password",label:e("login.password"),value:n.password,onChange:d=>c("password",d),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(y5,{errorMessage:a}),s.jsx("button",{type:"submit",disabled:o,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:e(o?"login.loading":"login.submit")})]})})}const qR={username:"",password:"",confirmPassword:""};function VR(e){return!e.username.trim()||!e.password||!e.confirmPassword?"Please fill in all fields.":e.username.trim().length<3?"Username must be at least 3 characters long.":e.password.length<6?"Password must be at least 6 characters long.":e.password!==e.confirmPassword?"Passwords do not match.":null}function WR(){const{register:e}=Zo(),[t,n]=f.useState(qR),[r,a]=f.useState(""),[i,o]=f.useState(!1),l=f.useCallback((u,d)=>{n(p=>({...p,[u]:d}))},[]),c=f.useCallback(async u=>{u.preventDefault(),a("");const d=VR(t);if(d){a(d);return}o(!0);const p=await e(t.username.trim(),t.password);p.success||a(p.error),o(!1)},[t,e]);return s.jsx(v5,{title:"Welcome to Pixcode",description:"Set up your account to get started",footerText:"This is a single-user system. Only one account can be created.",logo:s.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(vo,{id:"username",name:"username",label:"Username",value:t.username,onChange:u=>l("username",u),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(vo,{id:"password",name:"password",label:"Password",value:t.password,onChange:u=>l("password",u),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(vo,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:u=>l("confirmPassword",u),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(y5,{errorMessage:r}),s.jsx("button",{type:"submit",disabled:i,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:i?"Setting up...":"Create Account"})]})})}function KR({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=Zo();return n?s.jsx(UR,{}):r?s.jsx(WR,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(BR,{onComplete:i}):s.jsx(HR,{})}const w5=f.createContext(null),k5=()=>{const e=f.useContext(w5);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},YR=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},ZR=()=>{const e=f.useRef(null),t=f.useRef(!1),n=f.useRef(!1),[r,a]=f.useState(null),[i,o]=f.useState(!1),l=f.useRef(null),{token:c}=Zo();f.useEffect(()=>(u(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[c]);const u=f.useCallback(()=>{if(!t.current)try{const h=YR(c);if(!h)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(h);m.onopen=()=>{o(!0),e.current=m,n.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),n.current=!0},m.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},m.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||u()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(h){console.error("Error creating WebSocket connection:",h)}},[c]),d=f.useCallback(h=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(h)):console.warn("WebSocket not connected")},[]);return f.useMemo(()=>({ws:e.current,sendMessage:d,latestMessage:r,isConnected:i}),[d,r,i])},XR=({children:e})=>{const t=ZR();return s.jsx(w5.Provider,{value:t,children:e})},S5=f.createContext(null);function JR(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Ny(e){return{...e,taskMasterConfigured:e.taskmaster?.hasTaskmaster??!1,taskMasterStatus:e.taskmaster?.status??"not-configured",taskCount:Number(e.taskmaster?.metadata?.taskCount??0),completedCount:Number(e.taskmaster?.metadata?.completed??0)}}function QR(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function e9(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Ts(){const e=f.useContext(S5);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function t9({children:e}){const{latestMessage:t}=k5(),{user:n,token:r,isLoading:a}=Zo(),[i,o]=f.useState([]),[l,c]=f.useState(null),[u,d]=f.useState(null),[p,h]=f.useState(null),[m,g]=f.useState([]),[b,x]=f.useState(null),[y,v]=f.useState(!1),[w,S]=f.useState(!1),[E,k]=f.useState(!1),[A,I]=f.useState(null),N=f.useRef(null);f.useEffect(()=>{N.current=l?.name??null},[l?.name]);const _=f.useCallback(()=>{I(null)},[]),R=f.useCallback((B,Y)=>{console.error(`TaskMaster ${B} error:`,Y),I(JR(B,Y))},[]),C=f.useCallback(B=>{const Y=B?Ny(B):null;c(Y),d(Y?.taskmaster??null),g([]),x(null)},[]),D=f.useCallback(async()=>{if(!n||!r){o([]),c(null),d(null),g([]),x(null);return}try{v(!0),_();const B=await et.get("/projects");if(!B.ok)throw new Error(`Failed to fetch projects: ${B.status}`);const Y=await B.json(),O=(Array.isArray(Y)?Y:[]).map(P=>Ny(P));o(O);const $=N.current;if(!$)return;const G=O.find(P=>P.name===$)??null;c(G),d(G?.taskmaster??null)}catch(B){R("load projects",B)}finally{v(!1)}},[_,R,r,n]),T=f.useCallback(async()=>{const B=l?.name;if(!B||!n||!r){g([]),x(null);return}try{S(!0),_();const Y=await et.get(`/taskmaster/tasks/${encodeURIComponent(B)}`);if(!Y.ok){const $=await Y.json();throw new Error($.message??"Failed to load tasks")}const q=await Y.json(),O=Array.isArray(q.tasks)?q.tasks:[];g(O),x(QR(O))}catch(Y){R("load tasks",Y),g([]),x(null)}finally{S(!1)}},[_,l?.name,R,r,n]),z=f.useCallback(async()=>{if(!n||!r){h(null);return}try{k(!0),_();const B=await et.get("/mcp-utils/taskmaster-server");if(!B.ok)throw new Error(`Failed to load MCP status: ${B.status}`);const Y=await B.json();h(Y)}catch(B){R("check MCP server status",B),h(null)}finally{k(!1)}},[_,R,r,n]);f.useEffect(()=>{!a&&n&&r&&(D(),z())},[a,z,D,r,n]),f.useEffect(()=>{l?.name&&n&&r&&T()},[l?.name,T,r,n]),f.useEffect(()=>{const B=t;if(e9(B)){if(B.type==="taskmaster-project-updated"&&B.projectName){D();return}if(B.type==="taskmaster-tasks-updated"&&B.projectName===l?.name){T();return}B.type==="taskmaster-mcp-status-changed"&&z()}},[l?.name,t,z,D,T]);const H=f.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:u,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:A,refreshProjects:D,setCurrentProject:C,refreshTasks:T,refreshMCPStatus:z,clearError:_}),[_,l,A,y,E,w,p,b,u,i,z,D,T,C,m]);return s.jsx(S5.Provider,{value:H,children:e})}const E5=f.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Zc=()=>{const e=f.useContext(E5);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},n9=({children:e})=>{const[t,n]=f.useState(()=>{const m=localStorage.getItem("tasks-enabled");return m!==null?JSON.parse(m):!0}),[r,a]=f.useState(null),[i,o]=f.useState(null),[l,c]=f.useState(null),[u,d]=f.useState(!0);f.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(t))},[t]),f.useEffect(()=>{setTimeout(async()=>{try{const g=await et.get("/taskmaster/installation-status");if(g.ok){const b=await g.json();c(b),a(b.installation?.isInstalled||!1),o(b.isReady||!1);const x=localStorage.getItem("tasks-enabled");!b.installation?.isInstalled&&!x&&n(!1)}else console.error("Failed to check TaskMaster installation status"),a(!1),o(!1)}catch(g){console.error("Error checking TaskMaster installation:",g),a(!1),o(!1)}finally{d(!1)}},0)},[]);const h={tasksEnabled:t,setTasksEnabled:n,toggleTasksEnabled:()=>{n(m=>!m)},isTaskMasterInstalled:r,isTaskMasterReady:i,installationStatus:l,isCheckingInstallation:u};return s.jsx(E5.Provider,{value:h,children:e})},N5=f.createContext(null);function Xc(){const e=f.useContext(N5);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function r9({children:e}){const[t,n]=f.useState([]),[r,a]=f.useState(!0),[i,o]=f.useState(null),l=f.useCallback(async()=>{try{const h=await we("/api/plugins");if(h.ok){const m=await h.json();n(m.plugins||[]),o(null)}else{let m=`Failed to fetch plugins (${h.status})`;try{const g=await h.json();m=g.details||g.error||m}catch{m=h.statusText||m}o(m)}}catch(h){const m=h instanceof Error?h.message:"Failed to fetch plugins";o(m),console.error("[Plugins] Failed to fetch plugins:",h)}finally{a(!1)}},[]);f.useEffect(()=>{l()},[l]);const c=f.useCallback(async h=>{try{const m=await we("/api/plugins/install",{method:"POST",body:JSON.stringify({url:h})}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Install failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Install failed"}}},[l]),u=f.useCallback(async h=>{try{const m=await we(`/api/plugins/${encodeURIComponent(h)}`,{method:"DELETE"}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Uninstall failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Uninstall failed"}}},[l]),d=f.useCallback(async h=>{try{const m=await we(`/api/plugins/${encodeURIComponent(h)}/update`,{method:"POST"}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Update failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Update failed"}}},[l]),p=f.useCallback(async(h,m)=>{try{const g=await we(`/api/plugins/${encodeURIComponent(h)}/enable`,{method:"PUT",body:JSON.stringify({enabled:m})});if(!g.ok){let b=`Toggle failed (${g.status})`;try{const x=await g.json();b=x.details||x.error||b}catch{b=g.statusText||b}return{success:!1,error:b}}return await l(),{success:!0,error:null}}catch(g){return{success:!1,error:g instanceof Error?g.message:"Toggle failed"}}},[l]);return s.jsx(N5.Provider,{value:{plugins:t,loading:r,pluginsError:i,refreshPlugins:l,installPlugin:c,uninstallPlugin:u,updatePlugin:d,togglePlugin:p},children:e})}const Cy=e=>typeof window>"u"?!1:window.innerWidth<e,Ty=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function m0(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,i]=f.useState(()=>n?Cy(t):!1),[o,l]=f.useState(()=>r?Ty():!1);return f.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{i(Cy(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,n]),f.useEffect(()=>{if(!r||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),u=()=>{l(Ty())};return u(),typeof c.addEventListener=="function"?(c.addEventListener("change",u),()=>{c.removeEventListener("change",u)}):(c.addListener(u),()=>{c.removeListener(u)})},[r]),{isMobile:a,isPWA:o}}const a9=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let a=0;a<Math.max(n.length,r.length);a++){const i=n[a]||0,o=r[a]||0;if(i!==o)return i-o}return 0},i9="1.31.3",C5=(e,t)=>{const[n,r]=f.useState(!1),[a,i]=f.useState(null),[o,l]=f.useState(null),[c,u]=f.useState("git"),[d,p]=f.useState(i9);return f.useEffect(()=>{let h=!1;const m=async()=>{try{const x=await(await fetch("/health",{cache:"no-store"})).json();if(h)return;(x.installMode==="npm"||x.installMode==="git")&&u(x.installMode),typeof x.version=="string"&&/^\d+\.\d+\.\d+/.test(x.version)&&p(x.version)}catch{}};m();const g=()=>{m()};return window.addEventListener("focus",g),()=>{h=!0,window.removeEventListener("focus",g)}},[]),f.useEffect(()=>{if(!d)return;const h=async()=>{try{const b=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`)).json();if(b.tag_name){const x=b.tag_name.replace(/^v/,"");i(x),r(a9(x,d)>0),l({title:b.name||b.tag_name,body:b.body||"",htmlUrl:b.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:b.published_at})}else r(!1),i(null),l(null)}catch(g){console.error("Version check failed:",g),r(!1),i(null),l(null)}};h();const m=setInterval(h,300*1e3);return()=>clearInterval(m)},[e,t,d]),{updateAvailable:n,latestVersion:a,currentVersion:d,releaseInfo:o,installMode:c}},ai={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0,historyView:"flat"},s9=["flat","grouped"],o9=e=>typeof e=="string"&&s9.includes(e),gc=Object.keys(ai),l9=new Set(gc),zu="ui-preferences:sync",c9=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},bc=(e,t,n)=>e==="historyView"?o9(t)?t:n:c9(t,n),u9=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return bc(e,r,t)}catch{return t}},d9=e=>{if(typeof window>"u")return ai;try{const t=localStorage.getItem(e);if(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;return gc.reduce((a,i)=>(a[i]=bc(i,r[i],ai[i]),a),{...ai})}}}catch{}return gc.reduce((t,n)=>(t[n]=u9(n,ai[n]),t),{...ai})};function p9(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!l9.has(n))return e;const a=bc(n,r,e[n]);return e[n]===a?e:{...e,[n]:a}}case"set_many":{const n=t.value||{};let r=!1;const a={...e};for(const i of gc){if(!(i in n))continue;const o=n[i],l=bc(i,o,e[i]);a[i]!==l&&(a[i]=l,r=!0)}return r?a:e}case"reset":return{...ai,...t.value||{}};default:return e}}function h0(e="uiPreferences"){const t=f.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=f.useReducer(p9,e,d9);return f.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(zu,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),f.useEffect(()=>{if(typeof window>"u")return;const l=d=>{!d||typeof d!="object"||Array.isArray(d)||r({type:"set_many",value:d})},c=d=>{if(!(d.key!==e||d.newValue===null))try{const p=JSON.parse(d.newValue);l(p)}catch{}},u=d=>{const h=d.detail;!h||h.storageKey!==e||h.sourceId===t.current||l(h.value)};return window.addEventListener("storage",c),window.addEventListener(zu,u),()=>{window.removeEventListener("storage",c),window.removeEventListener(zu,u)}},[e]),{preferences:n,setPreference:(l,c)=>{r({type:"set",key:l,value:c})},setPreferences:l=>{r({type:"set_many",value:l})},resetPreferences:l=>{r({type:"reset",value:l})},dispatch:r}}const m9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},h9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},f9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Ay=(e,t)=>`${e}::${t}`,g9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},b9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},x9=/(?:^|[\s/\\(\[`"'])([\w./-]+?\.(?:ts|tsx|js|jsx|mjs|cjs|py|rb|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|bash|zsh|json|ya?ml|toml|md|mdx|html?|css|scss|less|sql|prisma|graphql|gql|vue|svelte|astro|dart|lua|r|pl|ps1|tf|dockerfile|env))(?:$|[\s:,)\]`"'])/i,y9=e=>{if(!e)return[];const t=new Set,n=new RegExp(x9.source,"gi");let r;for(;(r=n.exec(e))!==null;){const a=r[1],i=a.lastIndexOf(".");if(i>-1){const o=a.slice(i+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},ui=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||e.createdAt||0),v9=(e,t)=>e.__provider==="cursor"?e.summary||e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.__provider==="gemini"||e.__provider==="qwen"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),w9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),k9=(e,t,n)=>{const r=ui(e),a=Math.floor((t.getTime()-r.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isActive:a<10,sessionName:v9(e,n),sessionTime:w9(e),messageCount:Number(e.messageCount||0)}},T5=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(p=>({...p,__provider:"claude"})),r=(e.cursorSessions||[]).map(p=>({...p,__provider:"cursor"})),a=(e.codexSessions||[]).map(p=>({...p,__provider:"codex"})),i=p=>typeof p.id=="string"&&p.id.startsWith("qwen_")||p.provider==="qwen",o=e.geminiSessions||[],l=o.filter(p=>!i(p)).map(p=>({...p,__provider:"gemini"})),c=o.filter(p=>i(p)).map(p=>({...p,__provider:"qwen"})),u=[...(e.qwenSessions||[]).map(p=>({...p,__provider:"qwen"})),...c],d=new Map;for(const p of[...n,...r,...a,...l,...u])d.has(p.id)||d.set(p.id,p);return[...d.values()].sort((p,h)=>ui(h).getTime()-ui(p).getTime())},_y=(e,t)=>{const n=T5(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const i=ui(a);return i>r?i:r},new Date(0))},S9=(e,t,n,r)=>{const a=[...e];return a.sort((i,o)=>{const l=n.has(i.name),c=n.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?_y(o,r).getTime()-_y(i,r).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},E9=(e,t)=>{const n=t.trim().toLowerCase();return n?e.filter(r=>{const a=(r.displayName||r.name).toLowerCase(),i=r.name.toLowerCase();return a.includes(n)||i.includes(n)}):e},N9=(e,t)=>{const n=!!e.taskmaster?.hasTaskmaster,r=!!(t?.hasMCPServer&&t?.isConfigured);return n&&r?"fully-configured":n?"taskmaster-only":r?"mcp-only":"not-configured"},C9=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function T9({projects:e,selectedProject:t,selectedSession:n,isLoading:r,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:u,onProjectDelete:d,setCurrentProject:p,setSidebarVisible:h,sidebarVisible:m}){const[g,b]=f.useState(new Set),[x,y]=f.useState(null),[v,w]=f.useState(!1),[S,E]=f.useState(""),[k,A]=f.useState({}),[I,N]=f.useState({}),[_,R]=f.useState(new Set),[C,D]=f.useState(new Date),[T,z]=f.useState("name"),[H,B]=f.useState(!1),[Y,q]=f.useState({}),[O,$]=f.useState(null),[G,P]=f.useState(""),[ee,ne]=f.useState(""),[pe,le]=f.useState(new Set),[oe,he]=f.useState(null),[Te,_e]=f.useState(null),[De,Ge]=f.useState(!1),[M,me]=f.useState(()=>h9()),[ie,K]=f.useState(()=>g9()),[W,re]=f.useState("projects"),[xe,ue]=f.useState(null),[se,ve]=f.useState(!1),[Q,te]=f.useState(null),Z=f.useRef(null),ce=f.useRef(0),ye=f.useRef(null),Oe=!a&&!m;f.useEffect(()=>{const ge=setInterval(()=>{D(new Date)},6e4);return()=>clearInterval(ge)},[]),f.useEffect(()=>{N({}),R(new Set),q({})},[e]),f.useEffect(()=>{t&&b(ge=>{if(ge.has(t.name))return ge;const be=new Set(ge);return be.add(t.name),be})},[n,t]),f.useEffect(()=>{if(e.length>0&&!r){const ge=new Set;e.forEach(be=>{be.sessions&&be.sessions.length>=0&&ge.add(be.name)}),R(ge)}},[e,r]),f.useEffect(()=>{const ge=()=>{z(m9())};ge();const be=Be=>{Be.key==="claude-settings"&&ge()};window.addEventListener("storage",be);const Le=setInterval(()=>{document.hasFocus()&&ge()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(Le)}},[]),f.useEffect(()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null);const ge=ee.trim();if(W!=="conversations"||ge.length<2){ce.current+=1,ue(null),te(null),ve(!1);return}ve(!0);const be=++ce.current;return Z.current=setTimeout(()=>{if(be!==ce.current)return;const Le=et.searchConversationsUrl(ge),Be=new EventSource(Le);ye.current=Be;const Je=[];let We=0;Be.addEventListener("result",Vt=>{if(be!==ce.current){Be.close();return}try{const tn=JSON.parse(Vt.data);Je.push(tn.projectResult),We=tn.totalMatches,ue({results:[...Je],totalMatches:We,query:ge}),te({scannedProjects:tn.scannedProjects,totalProjects:tn.totalProjects})}catch{}}),Be.addEventListener("progress",Vt=>{if(be!==ce.current){Be.close();return}try{const tn=JSON.parse(Vt.data);We=tn.totalMatches,te({scannedProjects:tn.scannedProjects,totalProjects:tn.totalProjects})}catch{}}),Be.addEventListener("done",()=>{if(be!==ce.current){Be.close();return}Be.close(),ye.current=null,ve(!1),te(null),Je.length===0&&ue({results:[],totalMatches:0,query:ge})}),Be.addEventListener("error",()=>{if(be!==ce.current){Be.close();return}Be.close(),ye.current=null,ve(!1),te(null),Je.length===0&&ue({results:[],totalMatches:0,query:ge})})},400),()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null)}},[ee,W]),f.useCallback(ge=>be=>{const Le=be.target;Le.closest(".overflow-y-auto")||Le.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ge())},[]);const $e=f.useCallback(ge=>{b(be=>{const Le=new Set;return be.has(ge)||Le.add(ge),Le})},[]),tt=f.useCallback((ge,be)=>{c({...ge,__projectName:be})},[c]),bt=f.useCallback(ge=>{me(be=>{const Le=new Set(be);return Le.has(ge)?Le.delete(ge):Le.add(ge),f9(Le),Le})},[]),Ve=f.useCallback(ge=>M.has(ge),[M]),ct=f.useCallback((ge,be)=>{K(Le=>{const Be=Ay(ge,be),Je=new Set(Le);return Je.has(Be)?Je.delete(Be):Je.add(Be),b9(Je),Je})},[]),Dt=f.useCallback((ge,be)=>ie.has(Ay(ge,be)),[ie]),Xe=f.useCallback(ge=>T5(ge,I),[I]),It=f.useMemo(()=>e.map(ge=>{const be=Y[ge.name];return be===void 0?ge:{...ge,sessionMeta:{...ge.sessionMeta,hasMore:be}}}),[Y,e]),gt=f.useMemo(()=>S9(It,T,M,I),[I,T,It,M]),Un=f.useMemo(()=>E9(gt,ee),[ee,gt]),en=f.useCallback(ge=>{y(ge.name),E(ge.displayName)},[]),vn=f.useCallback(()=>{y(null),E("")},[]),dn=f.useCallback(async ge=>{try{(await et.renameProject(ge,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{y(null),E("")}},[S]),Ie=f.useCallback((ge,be,Le,Be="claude")=>{_e({projectName:ge,sessionId:be,sessionTitle:Le,provider:Be})},[]),nt=f.useCallback(async()=>{if(!Te)return;const{projectName:ge,sessionId:be,provider:Le}=Te;_e(null);try{let Be;if(Le==="codex"?Be=await et.deleteCodexSession(be):Le==="gemini"?Be=await et.deleteGeminiSession(be):Le==="qwen"?Be=await et.deleteQwenSession(be):Be=await et.deleteSession(ge,be),Be.ok)u?.(be);else{const Je=await Be.text();console.error("[Sidebar] Failed to delete session:",{status:Be.status,error:Je}),alert(i("messages.deleteSessionFailed"))}}catch(Be){console.error("[Sidebar] Error deleting session:",Be),alert(i("messages.deleteSessionError"))}},[u,Te,i]),Qe=f.useCallback(ge=>{he({project:ge,sessionCount:Xe(ge).length})},[Xe]),pt=f.useCallback(async(ge=!1)=>{if(!oe)return;const{project:be,sessionCount:Le}=oe,Be=Le===0;he(null),le(Je=>new Set([...Je,be.name]));try{const Je=await et.deleteProject(be.name,!Be,ge);if(Je.ok)d?.(be.name);else{const We=await Je.json();alert(We.error||i("messages.deleteProjectFailed"))}}catch(Je){console.error("Error deleting project:",Je),alert(i("messages.deleteProjectError"))}finally{le(Je=>{const We=new Set(Je);return We.delete(be.name),We})}},[oe,d,i]),Nt=f.useCallback(async ge=>{const be=Y[ge.name];if(!(!(be!==void 0?be:ge.sessionMeta?.hasMore===!0)||k[ge.name])){A(Be=>({...Be,[ge.name]:!0}));try{const Be=(ge.sessions?.length||0)+(I[ge.name]?.length||0),Je=await et.sessions(ge.name,5,Be);if(!Je.ok)return;const We=await Je.json();N(Vt=>({...Vt,[ge.name]:[...Vt[ge.name]||[],...We.sessions||[]]})),We.hasMore===!1&&q(Vt=>({...Vt,[ge.name]:!1}))}catch(Be){console.error("Error loading more sessions:",Be)}finally{A(Be=>({...Be,[ge.name]:!1}))}}},[I,k,Y]),Ct=f.useCallback(ge=>{l(ge),p(ge)},[l,p]),xr=f.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),ir=f.useCallback(async(ge,be,Le,Be)=>{const Je=Le.trim();if(!Je){$(null),P("");return}try{const We=await et.renameSession(be,Je,Be);We.ok?await o():(console.error("[Sidebar] Failed to rename session:",We.status),alert(i("messages.renameSessionFailed")))}catch(We){console.error("[Sidebar] Error renaming session:",We),alert(i("messages.renameSessionError"))}finally{$(null),P("")}},[o,i]),sr=f.useCallback(()=>{h(!1)},[h]),Ee=f.useCallback(()=>{h(!0)},[h]);return{isSidebarCollapsed:Oe,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:I,initialSessionsLoaded:_,currentTime:C,projectSortOrder:T,isRefreshing:H,editingSession:O,editingSessionName:G,searchFilter:ee,deletingProjects:pe,deleteConfirmation:oe,sessionDeleteConfirmation:Te,showVersionModal:De,starredProjects:M,starredSessions:ie,filteredProjects:Un,toggleProject:$e,handleSessionClick:tt,toggleStarProject:bt,isProjectStarred:Ve,toggleStarSession:ct,isSessionStarred:Dt,getProjectSessions:Xe,startEditing:en,cancelEditing:vn,saveProjectName:dn,showDeleteSessionConfirmation:Ie,confirmDeleteSession:nt,requestProjectDelete:Qe,confirmDeleteProject:pt,loadMoreSessions:Nt,handleProjectSelect:Ct,refreshProjects:xr,updateSessionSummary:ir,collapseSidebar:sr,expandSidebar:Ee,setShowNewProject:w,setEditingName:E,setEditingSession:$,setEditingSessionName:P,searchMode:W,setSearchMode:re,conversationResults:xe,isSearching:se,searchProgress:Q,clearConversationResults:f.useCallback(()=>{ce.current+=1,ye.current&&(ye.current.close(),ye.current=null),ve(!1),te(null),ue(null)},[]),setSearchFilter:ne,setDeleteConfirmation:he,setSessionDeleteConfirmation:_e,setShowVersionModal:Ge}}const A9="https://discord.gg/buxwujPNRE",_9="https://github.com/alicomert/pixcode/issues/new";function I9({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function j9({onExpand:e,onShowSettings:t,updateAvailable:n,onShowVersionModal:r,t:a}){return s.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[s.jsx("button",{onClick:e,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(ZI,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),s.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.settings"),title:a("actions.settings"),children:s.jsx(wt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:_9,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.reportIssue"),title:a("actions.reportIssue"),children:s.jsx(Dp,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:A9,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.joinCommunity"),title:a("actions.joinCommunity"),children:s.jsx(I9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&s.jsxs("button",{onClick:r,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(ia,{className:"h-4 w-4 text-blue-500"}),s.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function A5(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=A5(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function _5(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=A5(e))&&(r&&(r+=" "),r+=t);return r}const Iy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jy=_5,f0=(e,t)=>n=>{var r;if(t?.variants==null)return jy(e,n?.class,n?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(u=>{const d=n?.[u],p=i?.[u];if(d===null)return null;const h=Iy(d)||Iy(p);return a[u][h]}),l=n&&Object.entries(n).reduce((u,d)=>{let[p,h]=d;return h===void 0||(u[p]=h),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:p,className:h,...m}=d;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...u,p,h]:u},[]);return jy(e,o,c,n?.class,n?.className)},g0="-",R9=e=>{const t=L9(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(g0);return l[0]===""&&l.length!==1&&l.shift(),I5(l,t)||D9(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},I5=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?I5(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(g0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Ry=/^\[(.+)\]$/,D9=e=>{if(Ry.test(e)){const t=Ry.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},L9=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)zp(n[a],r,a,t);return r},zp=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Dy(t,a);i.classGroupId=n;return}if(typeof a=="function"){if(O9(a)){zp(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{zp(o,Dy(t,i),n,r)})})},Dy=(e,t)=>{let n=e;return t.split(g0).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},O9=e=>e.isThemeGetter,M9=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const a=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return a(i,o),o},set(i,o){n.has(i)?n.set(i,o):a(i,o)}}},Bp="!",$p=":",P9=$p.length,F9=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const i=[];let o=0,l=0,c=0,u;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===$p){i.push(a.slice(c,g)),c=g+P9;continue}if(b==="/"){u=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const d=i.length===0?a:a.substring(c),p=z9(d),h=p!==d,m=u&&u>c?u-c:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+$p,i=r;r=o=>o.startsWith(a)?i(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},z9=e=>e.endsWith(Bp)?e.substring(0,e.length-1):e.startsWith(Bp)?e.substring(1):e,B9=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const a=[];let i=[];return r.forEach(o=>{o[0]==="["||t[o]?(a.push(...i.sort(),o),i=[]):i.push(o)}),a.push(...i.sort()),a}},$9=e=>({cache:M9(e.cacheSize),parseClassName:F9(e),sortModifiers:B9(e),...R9(e)}),U9=/\s+/,G9=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(U9);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(d);if(p){c=d+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=d+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=d+(c.length>0?" "+c:c);continue}x=!1}const v=i(h).join(":"),w=m?v+Bp:v,S=w+y;if(o.includes(S))continue;o.push(S);const E=a(y,x);for(let k=0;k<E.length;++k){const A=E[k];o.push(w+A)}c=d+(c.length>0?" "+c:c)}return c};function H9(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=j5(t))&&(r&&(r+=" "),r+=n);return r}const j5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=j5(e[r]))&&(n&&(n+=" "),n+=t);return n};function q9(e,...t){let n,r,a,i=o;function o(c){const u=t.reduce((d,p)=>p(d),e());return n=$9(u),r=n.cache.get,a=n.cache.set,i=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=G9(c,n);return a(c,d),d}return function(){return i(H9.apply(null,arguments))}}const Xt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},R5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,D5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,V9=/^\d+\/\d+$/,W9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,K9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Y9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Z9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,X9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zi=e=>V9.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),xa=e=>!!e&&Number.isInteger(Number(e)),Bu=e=>e.endsWith("%")&&it(e.slice(0,-1)),Kr=e=>W9.test(e),J9=()=>!0,Q9=e=>K9.test(e)&&!Y9.test(e),L5=()=>!1,eD=e=>Z9.test(e),tD=e=>X9.test(e),nD=e=>!Fe(e)&&!ze(e),rD=e=>As(e,P5,L5),Fe=e=>R5.test(e),Za=e=>As(e,F5,Q9),$u=e=>As(e,lD,it),Ly=e=>As(e,O5,L5),aD=e=>As(e,M5,tD),fl=e=>As(e,z5,eD),ze=e=>D5.test(e),Ys=e=>_s(e,F5),iD=e=>_s(e,cD),Oy=e=>_s(e,O5),sD=e=>_s(e,P5),oD=e=>_s(e,M5),gl=e=>_s(e,z5,!0),As=(e,t,n)=>{const r=R5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},_s=(e,t,n=!1)=>{const r=D5.exec(e);return r?r[1]?t(r[1]):n:!1},O5=e=>e==="position"||e==="percentage",M5=e=>e==="image"||e==="url",P5=e=>e==="length"||e==="size"||e==="bg-size",F5=e=>e==="length",lD=e=>e==="number",cD=e=>e==="family-name",z5=e=>e==="shadow",uD=()=>{const e=Xt("color"),t=Xt("font"),n=Xt("text"),r=Xt("font-weight"),a=Xt("tracking"),i=Xt("leading"),o=Xt("breakpoint"),l=Xt("container"),c=Xt("spacing"),u=Xt("radius"),d=Xt("shadow"),p=Xt("inset-shadow"),h=Xt("text-shadow"),m=Xt("drop-shadow"),g=Xt("blur"),b=Xt("perspective"),x=Xt("aspect"),y=Xt("ease"),v=Xt("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...S(),ze,Fe],k=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],I=()=>[ze,Fe,c],N=()=>[zi,"full","auto",...I()],_=()=>[xa,"none","subgrid",ze,Fe],R=()=>["auto",{span:["full",xa,ze,Fe]},xa,ze,Fe],C=()=>[xa,"auto",ze,Fe],D=()=>["auto","min","max","fr",ze,Fe],T=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...I()],B=()=>[zi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],Y=()=>[e,ze,Fe],q=()=>[...S(),Oy,Ly,{position:[ze,Fe]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",sD,rD,{size:[ze,Fe]}],G=()=>[Bu,Ys,Za],P=()=>["","none","full",u,ze,Fe],ee=()=>["",it,Ys,Za],ne=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[it,Bu,Oy,Ly],oe=()=>["","none",g,ze,Fe],he=()=>["none",it,ze,Fe],Te=()=>["none",it,ze,Fe],_e=()=>[it,ze,Fe],De=()=>[zi,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Kr],breakpoint:[Kr],color:[J9],container:[Kr],"drop-shadow":[Kr],ease:["in","out","in-out"],font:[nD],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Kr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Kr],shadow:[Kr],spacing:["px",it],text:[Kr],"text-shadow":[Kr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zi,Fe,ze,x]}],container:["container"],columns:[{columns:[it,Fe,ze,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{start:N()}],end:[{end:N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[xa,"auto",ze,Fe]}],basis:[{basis:[zi,"full","auto",l,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,zi,"auto","initial","none",Fe]}],grow:[{grow:["",it,ze,Fe]}],shrink:[{shrink:["",it,ze,Fe]}],order:[{order:[xa,"first","last","none",ze,Fe]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":C()}],"col-end":[{"col-end":C()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":C()}],"row-end":[{"row-end":C()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...T(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...T()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":T()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[l,"screen",...B()]}],"min-w":[{"min-w":[l,"screen","none",...B()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,Ys,Za]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ze,$u]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Bu,Fe]}],"font-family":[{font:[iD,Fe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,ze,Fe]}],"line-clamp":[{"line-clamp":[it,"none",ze,$u]}],leading:[{leading:[i,...I()]}],"list-image":[{"list-image":["none",ze,Fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ze,Fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Y()}],"text-color":[{text:Y()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ze,Za]}],"text-decoration-color":[{decoration:Y()}],"underline-offset":[{"underline-offset":[it,"auto",ze,Fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ze,Fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ze,Fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:q()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xa,ze,Fe],radial:["",ze,Fe],conic:[xa,ze,Fe]},oD,aD]}],"bg-color":[{bg:Y()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:Y()}],"gradient-via":[{via:Y()}],"gradient-to":[{to:Y()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:Y()}],"border-color-x":[{"border-x":Y()}],"border-color-y":[{"border-y":Y()}],"border-color-s":[{"border-s":Y()}],"border-color-e":[{"border-e":Y()}],"border-color-t":[{"border-t":Y()}],"border-color-r":[{"border-r":Y()}],"border-color-b":[{"border-b":Y()}],"border-color-l":[{"border-l":Y()}],"divide-color":[{divide:Y()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ze,Fe]}],"outline-w":[{outline:["",it,Ys,Za]}],"outline-color":[{outline:Y()}],shadow:[{shadow:["","none",d,gl,fl]}],"shadow-color":[{shadow:Y()}],"inset-shadow":[{"inset-shadow":["none",p,gl,fl]}],"inset-shadow-color":[{"inset-shadow":Y()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Y()}],"ring-offset-w":[{"ring-offset":[it,Za]}],"ring-offset-color":[{"ring-offset":Y()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":Y()}],"text-shadow":[{"text-shadow":["none",h,gl,fl]}],"text-shadow-color":[{"text-shadow":Y()}],opacity:[{opacity:[it,ze,Fe]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":Y()}],"mask-image-linear-to-color":[{"mask-linear-to":Y()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":Y()}],"mask-image-t-to-color":[{"mask-t-to":Y()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":Y()}],"mask-image-r-to-color":[{"mask-r-to":Y()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":Y()}],"mask-image-b-to-color":[{"mask-b-to":Y()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":Y()}],"mask-image-l-to-color":[{"mask-l-to":Y()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":Y()}],"mask-image-x-to-color":[{"mask-x-to":Y()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":Y()}],"mask-image-y-to-color":[{"mask-y-to":Y()}],"mask-image-radial":[{"mask-radial":[ze,Fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":Y()}],"mask-image-radial-to-color":[{"mask-radial-to":Y()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":Y()}],"mask-image-conic-to-color":[{"mask-conic-to":Y()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:q()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ze,Fe]}],filter:[{filter:["","none",ze,Fe]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ze,Fe]}],contrast:[{contrast:[it,ze,Fe]}],"drop-shadow":[{"drop-shadow":["","none",m,gl,fl]}],"drop-shadow-color":[{"drop-shadow":Y()}],grayscale:[{grayscale:["",it,ze,Fe]}],"hue-rotate":[{"hue-rotate":[it,ze,Fe]}],invert:[{invert:["",it,ze,Fe]}],saturate:[{saturate:[it,ze,Fe]}],sepia:[{sepia:["",it,ze,Fe]}],"backdrop-filter":[{"backdrop-filter":["","none",ze,Fe]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ze,Fe]}],"backdrop-contrast":[{"backdrop-contrast":[it,ze,Fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ze,Fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ze,Fe]}],"backdrop-invert":[{"backdrop-invert":["",it,ze,Fe]}],"backdrop-opacity":[{"backdrop-opacity":[it,ze,Fe]}],"backdrop-saturate":[{"backdrop-saturate":[it,ze,Fe]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ze,Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ze,Fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[it,"initial",ze,Fe]}],ease:[{ease:["linear","initial",y,ze,Fe]}],delay:[{delay:[it,ze,Fe]}],animate:[{animate:["none",v,ze,Fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ze,Fe]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:Te()}],"scale-x":[{"scale-x":Te()}],"scale-y":[{"scale-y":Te()}],"scale-z":[{"scale-z":Te()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[ze,Fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:De()}],"translate-x":[{"translate-x":De()}],"translate-y":[{"translate-y":De()}],"translate-z":[{"translate-z":De()}],"translate-none":["translate-none"],accent:[{accent:Y()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Y()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ze,Fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ze,Fe]}],fill:[{fill:["none",...Y()]}],"stroke-w":[{stroke:[it,Ys,Za,$u]}],stroke:[{stroke:["none",...Y()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},dD=q9(uD);function fe(...e){return dD(_5(e))}function pD(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const mD=f0("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}}),B5=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:fe(mD({variant:t}),e),...n}));B5.displayName="Alert";const hD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"alert-title",className:fe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));hD.displayName="AlertTitle";const fD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"alert-description",className:fe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));fD.displayName="AlertDescription";const gD=f0("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function is({className:e,variant:t,...n}){return s.jsx("div",{className:fe(gD({variant:t}),e),...n})}const bD=f0("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Pe=f.forwardRef(({className:e,variant:t,size:n,...r},a)=>s.jsx("button",{className:fe(bD({variant:t,size:n,className:e})),ref:a,...r}));Pe.displayName="Button";const $5=f.createContext(null),U5=()=>{const e=f.useContext($5);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},G5=({className:e,approval:t="pending",children:n,...r})=>{const a=f.useMemo(()=>({approval:t}),[t]);return s.jsx($5.Provider,{value:a,children:s.jsx(B5,{className:fe("flex flex-col gap-2",e),...r,children:n})})};G5.displayName="Confirmation";const H5=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:fe("text-muted-foreground inline text-sm",e),...t});H5.displayName="ConfirmationTitle";const q5=({children:e})=>{const{approval:t}=U5();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};q5.displayName="ConfirmationRequest";const V5=({className:e,...t})=>{const{approval:n}=U5();return n!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:fe("flex items-center justify-end gap-2 self-end",e),...t})};V5.displayName="ConfirmationActions";const Yl=({variant:e="default",...t})=>s.jsx(Pe,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Yl.displayName="ConfirmationAction";const W5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));W5.displayName="Card";const K5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-4",e),...t}));K5.displayName="CardHeader";const Y5=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:fe("font-semibold leading-none tracking-tight",e),...t}));Y5.displayName="CardTitle";const xD=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:fe("text-sm text-muted-foreground",e),...t}));xD.displayName="CardDescription";const Z5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("p-4 pt-0",e),...t}));Z5.displayName="CardContent";const X5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex items-center p-4 pt-0",e),...t}));X5.displayName="CardFooter";const yD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("ml-auto shrink-0",e),...t}));yD.displayName="CardAction";const J5=f.createContext(null);function Q5(){const e=f.useContext(J5);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const vi=f.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,children:a,...i},o)=>{const[l,c]=f.useState(e),u=t!==void 0,d=u?t:l,p=f.useCallback(m=>{u||c(m),n?.(m)},[u,n]),h=f.useMemo(()=>({open:d,onOpenChange:p}),[d,p]);return s.jsx(J5.Provider,{value:h,children:s.jsx("div",{ref:o,"data-state":d?"open":"closed",className:r,...i,children:a})})});vi.displayName="Collapsible";const Oa=f.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:i,onOpenChange:o}=Q5(),l=f.useCallback(c=>{o(!i),e?.(c)},[i,o,e]);return s.jsx("button",{ref:a,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:l,className:n,...r,children:t})});Oa.displayName="CollapsibleTrigger";const wi=f.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=Q5();return s.jsx("div",{ref:r,"data-state":a?"open":"closed",className:fe("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...n,children:s.jsx("div",{className:"overflow-hidden",children:t})})});wi.displayName="CollapsibleContent";const e4=f.createContext(null);function b0(){const e=f.useContext(e4);if(!e)throw new Error("Command components must be used within <Command>");return e}const t4=f.forwardRef(({className:e,children:t,...n},r)=>{const[a,i]=f.useState(""),o=f.useRef(new Map),[l,c]=f.useState(0),u=f.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),d=f.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=f.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),h=f.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[S,E]of o.current)(!v||E.value.includes(v))&&w.add(S);return w},[a,l]),m=f.useMemo(()=>{const v=[];for(const[,w]of o.current)h.has(w.id)&&v.push(w);return v},[h]),[g,b]=f.useState(null);f.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=f.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=m;if(w.length===0)return;if(v.key==="Enter"){w.find(N=>N.id===g)?.onSelect();return}const S=w.findIndex(I=>I.id===g);let E;v.key==="ArrowDown"?E=S<w.length-1?S+1:0:E=S>0?S-1:w.length-1;const k=w[E].id;b(k),w[E].element?.scrollIntoView({block:"nearest"})},[m,g]),y=f.useMemo(()=>({search:a,setSearch:i,visibleIds:h,activeId:g,setActiveId:b,register:u,unregister:d,updateEntry:p}),[a,h,g,u,d,p]);return s.jsx(e4.Provider,{value:y,children:s.jsx("div",{ref:r,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:fe("flex flex-col",e),onKeyDown:x,...n,children:t})})});t4.displayName="Command";const n4=f.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:i}=b0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(aa,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("input",{ref:r,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>i(o.target.value),placeholder:t,className:fe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})});n4.displayName="CommandInput";const r4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,role:"listbox",className:fe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));r4.displayName="CommandList";const a4=f.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=b0();return!r||a.size>0?null:s.jsx("div",{ref:n,className:fe("py-6 text-center text-sm text-muted-foreground",e),...t})});a4.displayName="CommandEmpty";const i4=f.forwardRef(({className:e,heading:t,children:n,...r},a)=>s.jsxs("div",{ref:a,className:fe("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...r,children:[t&&s.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),n]}));i4.displayName="CommandGroup";const s4=f.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:u,register:d,unregister:p,updateEntry:h}=b0(),m=f.useId(),g=f.useRef(null),b=t||(typeof a=="string"?a:"");f.useEffect(()=>(d({id:m,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(m)),[m,b,d,p]),f.useEffect(()=>{h(m,{onSelect:n||(()=>{})})},[m,n,h]);const x=f.useCallback(v=>{g.current=v,h(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,h,o]);if(!l.has(m))return null;const y=c===m;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":r||void 0,"data-active":y||void 0,className:fe("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",r&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!r&&c!==m&&u(m)},onClick:()=>!r&&n?.(),...i,children:a})});s4.displayName="CommandItem";const vD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("-mx-1 h-px bg-border",e),...t}));vD.displayName="CommandSeparator";function Up({checked:e,onToggle:t,ariaLabel:n="Toggle dark mode"}){const{isDarkMode:r,toggleDarkMode:a}=Cs(),i=typeof e=="boolean"&&typeof t=="function",o=i?e:r,l=()=>{if(i&&t){t(!o);return}a()};return s.jsxs("button",{onClick:l,className:fe("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":n,children:[s.jsx("span",{className:"sr-only",children:n}),s.jsx("span",{className:fe("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?s.jsx(l0,{className:"h-3 w-3 text-primary"}):s.jsx(c0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const o4=f.createContext(null);function l4(){const e=f.useContext(o4);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const c4=({open:e,onOpenChange:t,defaultOpen:n=!1,children:r})=>{const[a,i]=f.useState(n),o=f.useRef(null),l=e!==void 0,c=l?e:a,u=f.useCallback(p=>{l||i(p),t?.(p)},[l,t]),d=f.useMemo(()=>({open:c,onOpenChange:u,triggerRef:o}),[c,u]);return s.jsx(o4.Provider,{value:d,children:r})},wD=f.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:i,triggerRef:o}=l4(),l=f.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(n&&f.isValidElement(t)){const c=t;return f.cloneElement(c,{onClick:u=>{i(!0),c.props.onClick?.(u)},ref:u=>{o.current=u,typeof a=="function"?a(u):a&&(a.current=u)}})}return s.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...r,children:t})});wD.displayName="DialogTrigger";const My='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',x0=f.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=l4(),u=f.useRef(null),d=f.useRef(null);return f.useEffect(()=>{o?d.current=document.activeElement:d.current&&((c.current||d.current)?.focus(),d.current=null)},[o,c]),f.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),n?.(),l(!1);return}if(m.key==="Tab"&&u.current){const g=Array.from(u.current.querySelectorAll(My));if(g.length===0)return;const b=g[0],x=g[g.length-1];m.shiftKey&&document.activeElement===b?(m.preventDefault(),x.focus()):!m.shiftKey&&document.activeElement===x&&(m.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=h}},[o,l,n]),f.useEffect(()=>{o&&u.current&&requestAnimationFrame(()=>{u.current?.querySelector(My)?.focus()})},[o]),o?Wc.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50",children:[s.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{r?.(),l(!1)},"aria-hidden":!0}),s.jsx("div",{ref:p=>{u.current=p,typeof i=="function"?i(p):i&&(i.current=p)},role:"dialog","aria-modal":"true",className:fe("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});x0.displayName="DialogContent";const y0=f.forwardRef(({className:e,...t},n)=>s.jsx("h2",{ref:n,className:fe("sr-only",e),...t}));y0.displayName="DialogTitle";const At=f.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:fe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));At.displayName="Input";const v0=f.forwardRef(({className:e,contentClassName:t,children:n,...r},a)=>s.jsx("div",{className:fe("relative overflow-hidden",e),...r,children:s.jsx("div",{ref:a,className:fe("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:n})}));v0.displayName="ScrollArea";const xc=f.memo(({children:e,className:t,as:n="span"})=>s.jsx(n,{className:fe("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",t),children:e}));xc.displayName="Shimmer";const u4=f.createContext(null),kD=()=>{const e=f.useContext(u4);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},SD=1e3,ED=1e3,Gp=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:i,children:o,...l})=>{const c=r??t,u=r===!1,[d,p]=f.useState(c),h=n!==void 0,m=h?n:d,g=f.useCallback(k=>{h||p(k),a?.(k)},[h,a]),[b,x]=f.useState(i),y=f.useRef(t),[v,w]=f.useState(!1),S=f.useRef(null);f.useEffect(()=>{i!==void 0&&x(i)},[i]),f.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/ED)),S.current=null)},[t]),f.useEffect(()=>{t&&!m&&!u&&g(!0)},[t,m,g,u]),f.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},SD);return()=>clearTimeout(k)}},[t,m,g,v]);const E=f.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return s.jsx(u4.Provider,{value:E,children:s.jsx(vi,{open:m,onOpenChange:g,className:fe("not-prose",e),...l,children:o})})});Gp.displayName="Reasoning";const ND=(e,t)=>e||t===0?s.jsx(xc,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Hp=f.memo(({className:e,children:t,getThinkingMessage:n=ND,...r})=>{const{isStreaming:a,isOpen:i,duration:o}=kD();return s.jsx(Oa,{className:fe("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...r,children:t??s.jsxs(s.Fragment,{children:[s.jsx(_j,{className:"h-4 w-4"}),n(a,o),s.jsx(GS,{className:fe("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Hp.displayName="ReasoningTrigger";const qp=f.memo(({className:e,children:t,...n})=>s.jsx(wi,{className:fe("mt-4 text-sm text-muted-foreground",e),...n,children:t}));qp.displayName="ReasoningContent";function CD(e){switch(e){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function ea({children:e,content:t,position:n="top",className:r="",delay:a=350}){const[i,o]=f.useState(!1),l=f.useRef(null),c=f.useRef(!1),u=f.useRef(null),d=f.useRef(null),[p,h]=f.useState(null),m=f.useCallback(()=>{const w=u.current;if(!w)return;const S=w.getBoundingClientRect(),E=8,k={position:"fixed",zIndex:9999};switch(n){case"bottom":k.left=S.left+S.width/2,k.top=S.bottom+E,k.transform="translateX(-50%)";break;case"left":k.left=S.left-E,k.top=S.top+S.height/2,k.transform="translate(-100%, -50%)";break;case"right":k.left=S.right+E,k.top=S.top+S.height/2,k.transform="translateY(-50%)";break;case"top":default:k.left=S.left+S.width/2,k.top=S.top-E,k.transform="translate(-50%, -100%)";break}h(k)},[n]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return f.useEffect(()=>()=>{g()},[]),f.useEffect(()=>{if(!i||typeof document>"u")return;const w=S=>{const E=S.target;E instanceof Node&&u.current?.contains(E)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),f.useEffect(()=>{if(!i){h(null);return}const w=window.requestAnimationFrame(m),S=()=>m();return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,m]),t?s.jsxs("div",{ref:u,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&Wc.createPortal(s.jsxs("div",{ref:d,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:fe("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",r),children:[t,s.jsx("div",{className:fe("absolute w-0 h-0 border-4 border-transparent",CD(n))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const d4=f.createContext(null),p4=f.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const i=f.useMemo(()=>({status:t}),[t]);return s.jsx(d4.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:fe("relative overflow-hidden rounded-xl border border-border/50 bg-card/80 shadow-sm backdrop-blur-sm transition-all duration-200 focus-within:border-primary/30 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/15",e),...r,children:n})})});p4.displayName="PromptInput";const m4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:fe("px-3 pt-3",e),...t}));m4.displayName="PromptInputHeader";const h4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:fe("relative",e),...t}));h4.displayName="PromptInputBody";const f4=f.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{ref:n,"data-slot":"prompt-input-textarea",className:fe("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));f4.displayName="PromptInputTextarea";const g4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-footer",className:fe("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));g4.displayName="PromptInputFooter";const b4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-tools",className:fe("flex items-center gap-1",e),...t}));b4.displayName="PromptInputTools";const Zl=f.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const i=s.jsx(Pe,{ref:a,type:"button",variant:"ghost",size:"icon",className:fe("h-8 w-8 [&_svg]:size-4",e),...r,children:n});return t?s.jsx(ea,{content:t.shortcut?s.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,s.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:i}):i});Zl.displayName="PromptInputButton";const x4=f.forwardRef(({className:e,status:t,children:n,...r},a)=>{const i=f.useContext(d4),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Pe,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:fe("h-8 w-8 rounded-lg",e),...r,children:n??(l?s.jsx(gj,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(XI,{className:"h-4 w-4"}))})});x4.displayName="PromptInputSubmit";function w0({children:e,className:t}){return s.jsx("div",{className:fe("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function k0({isActive:e,onClick:t,children:n,className:r}){return s.jsx("button",{onClick:t,className:fe("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",r),children:n})}const y4=f.createContext(null);function v4(){const e=f.useContext(y4);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const w4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:fe("space-y-0.5",e),...t}));w4.displayName="Queue";const k4=f.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const i=f.useMemo(()=>({status:e}),[e]);return s.jsx(y4.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:fe("flex items-start gap-2 py-0.5",t),...r,children:n})})});k4.displayName="QueueItem";const S4=f.forwardRef(({className:e,...t},n)=>{const{status:r}=v4();return s.jsxs("div",{ref:n,"data-slot":"queue-item-indicator","aria-hidden":"true",className:fe("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[r==="completed"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),r==="in_progress"&&s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),r==="pending"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});S4.displayName="QueueItemIndicator";const E4=f.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=v4();return s.jsx("div",{ref:r,"data-slot":"queue-item-content",className:fe("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...n,children:t})});E4.displayName="QueueItemContent";const Py="https://github.com/alicomert/pixcode/issues/new",TD="https://github.com/alicomert/pixcode",Fy="https://discord.gg/buxwujPNRE";function zy({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function AD({updateAvailable:e,releaseInfo:t,latestVersion:n,currentVersion:r,onShowVersionModal:a,onShowSettings:i,t:o}){return s.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:a,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(py,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${n}`}),s.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),s.jsx("div",{className:"px-3 py-2 md:hidden",children:s.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:a,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(py,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${n}`}),s.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.jsxs("a",{href:Py,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[s.jsx(Dp,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:Fy,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[s.jsx(zy,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:i,children:[s.jsx(wt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:TD,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",r," – ",o("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:Py,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Dp,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:Fy,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(zy,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),s.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:s.jsxs("button",{className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:i,children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(wt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const By="PIXCODE_GITHUB_STARS",$y="PIXCODE_HIDE_GITHUB_STAR",_D=3600*1e3,ID=(e,t)=>{const[n,r]=f.useState(null),[a,i]=f.useState(()=>{try{return localStorage.getItem($y)==="true"}catch{return!1}});f.useEffect(()=>{if(a)return;try{const u=localStorage.getItem(By);if(u){const d=JSON.parse(u);if(Date.now()-d.timestamp<_D){r(d.count);return}}}catch{}(async()=>{try{const u=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!u.ok)return;const p=(await u.json()).stargazers_count;if(typeof p=="number"){r(p);try{localStorage.setItem(By,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=f.useCallback(()=>{i(!0);try{localStorage.setItem($y,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},jD="https://github.com/alicomert/pixcode";function RD({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.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 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 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.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function DD(){const{formattedCount:e,isDismissed:t,dismiss:n}=ID("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:jD,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[s.jsx(RD,{className:"h-3.5 w-3.5"}),s.jsx(rs,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium",children:"Star"}),e&&s.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),s.jsx("button",{onClick:r=>{r.preventDefault(),r.stopPropagation(),n()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:s.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Uy({value:e,onChange:t,t:n}){const r="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return s.jsxs("div",{role:"tablist","aria-label":n("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:fe(r,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[s.jsx(jo,{className:"h-3 w-3"}),n("historyView.flat",{defaultValue:"Recent"})]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:fe(r,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[s.jsx(aj,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function LD({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:u,isRefreshing:d,onCreateProject:p,onQuickStartSession:h,onCollapseSidebar:m,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:s.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:s.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[s.jsx("path",{d:"M2037 3800 c-104 -40 -191 -134 -231 -250 -23 -67 -20 -82 22 -109 31 -20 287 -177 1009 -618 40 -24 82 -56 93 -70 27 -34 27 -102 0 -136 -11 -13 -106 -78 -212 -143 -106 -64 -201 -124 -210 -132 -16 -14 -18 -41 -18 -302 0 -291 2 -310 38 -310 16 0 267 148 610 359 180 111 270 173 310 213 216 217 215 574 -3 793 -37 38 -107 89 -185 136 -69 42 -253 154 -410 249 -434 264 -509 307 -563 326 -57 20 -191 17 -250 -6z"}),s.jsx("path",{d:"M1803 2994 c-10 -5 -13 -156 -13 -709 0 -671 1 -706 20 -767 27 -89 93 -184 167 -240 89 -67 157 -90 281 -96 92 -4 105 -2 117 14 12 16 14 134 15 735 0 669 -1 718 -17 737 -20 23 -514 322 -541 327 -9 2 -23 2 -29 -1z"})]})})}),s.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return s.jsxs("div",{className:"flex-shrink-0",children:[s.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:u,disabled:d,title:x("tooltips.refresh"),children:s.jsx(xt,{className:`h-4 w-4 ${d?"animate-spin":""}`})}),s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:p,title:x("tooltips.createProject"),children:s.jsx(sn,{className:"h-4 w-4"})}),s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:m,title:x("tooltips.hideSidebar"),children:s.jsx(YI,{className:"h-4 w-4"})})]})]}),s.jsx(DD,{}),h&&s.jsxs("button",{type:"button",onClick:()=>{h()},className:"mt-2.5 flex w-full items-center justify-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[s.jsx(ia,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Uy,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Er,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(xi,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(aa,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(At,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:s.jsx(ft,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider hidden md:block"}),s.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:u,disabled:d,children:s.jsx(xt,{className:`h-4 w-4 text-muted-foreground ${d?"animate-spin":""}`})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:p,children:s.jsx(bi,{className:"h-4 w-4"})})]})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Uy,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Er,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(xi,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(aa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(At,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:s.jsx(ft,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const OD=160,Gy=180;function N4({actions:e,className:t,triggerLabel:n}){const[r,a]=f.useState(!1),[i,o]=f.useState(null),l=f.useRef(null),c=f.useRef(null);f.useLayoutEffect(()=>{if(!r||!l.current)return;const d=l.current.getBoundingClientRect();let p=d.right-OD;p<8&&(p=8);let h=d.bottom+4;h+Gy>window.innerHeight&&(h=Math.max(8,d.top-4-Gy)),o({top:h,left:p})},[r]),f.useEffect(()=>{if(!r)return;const d=m=>{const g=m.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=m=>{m.key==="Escape"&&a(!1)},h=()=>a(!1);return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[r]);const u=d=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),d.onClick()};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":r,"aria-label":n||"Actions",title:n||"Actions",onClick:d=>{d.stopPropagation(),d.preventDefault(),a(p=>!p)},className:fe("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",r&&"bg-accent text-foreground opacity-100",t),children:s.jsx(hj,{className:"h-3.5 w-3.5"})}),r&&i&&Wc.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:fe("w-40 rounded-xl border border-border/60 bg-popover p-1 shadow-lg","animate-in fade-in-0 zoom-in-95 duration-100"),onClick:d=>d.stopPropagation(),onMouseDown:d=>d.stopPropagation(),children:e.map((d,p)=>{const h=d.icon,m=e[p-1],g=p>0&&d.danger&&!m?.danger;return s.jsxs("div",{children:[g&&s.jsx("div",{className:"my-1 h-px bg-border/60"}),s.jsxs("button",{type:"button",role:"menuitem",onClick:u(d),className:fe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",d.danger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"text-foreground hover:bg-accent"),children:[s.jsx(h,{className:"h-3 w-3"}),d.label]})]},d.id)})}),document.body)]})}const Hy={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},MD={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},PD=e=>e==="fully-configured"?{icon:ms,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:e==="taskmaster-only"?{icon:wt,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:e==="mcp-only"?{icon:ta,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:ft,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function FD({status:e="not-configured",size:t="sm",className:n="",showLabel:r=!1}){const a=PD(e),i=a.icon;return r?s.jsxs("div",{className:fe("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,n),title:a.title,children:[s.jsx(i,{className:Hy[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:fe("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,MD[t],n),title:a.title,children:s.jsx(i,{className:fe(Hy[t],a.colorClassName)})})}const zD=(e,t,n)=>{const r=new Date(e),a=t;if(isNaN(r.getTime()))return n?n("status.unknown"):"Unknown";const i=a.getTime()-r.getTime(),o=Math.floor(i/1e3),l=Math.floor(i/(1e3*60)),c=Math.floor(i/(1e3*60*60)),u=Math.floor(i/(1e3*60*60*24));return o<60?n?n("time.justNow"):"Just now":l===1?n?n("time.oneMinuteAgo"):"1 min ago":l<60?n?n("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?n?n("time.oneHourAgo"):"1 hour ago":c<24?n?n("time.hoursAgo",{count:c}):`${c} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:r.toLocaleDateString()};function qy({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:i,className:o}){const l=u=>s.jsx(rs,{className:`${u.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:oj,onClick:n},{id:"star",label:e?i("actions.unstarSession",{defaultValue:"Remove star"}):i("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:r}];return t&&c.push({id:"delete",label:i("actions.delete"),icon:gn,onClick:a,danger:!0}),s.jsx(N4,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const BD={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code"},Vy={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15"};function C4({project:e,session:t,selectedSession:n,currentTime:r,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:u,onCancelEditingSession:d,onSaveEditingSession:p,onToggleStarSession:h,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=k9(t,r,x),v=n?.id===t.id,w=a===t.id,S=t.__provider,E=BD[S]??S,k=Vy[S]??Vy.claude,A=y9(y.sessionName),I=()=>{m(e),g(t,e.name)},N=()=>{p(e.name,t.id,i,S)},_=()=>{b(e.name,t.id,y.sessionName,S)},R=()=>u(t.id,y.sessionName),C=()=>h(e.name,t.id),D=s.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[s.jsxs("span",{className:fe("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",k),children:[s.jsx(Dn,{provider:S,className:"h-2.5 w-2.5"}),E]}),s.jsx("span",{className:"text-muted-foreground/80",children:zD(y.sessionTime,r,x)}),y.isActive&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[s.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),A.slice(0,3).map(B=>s.jsxs("span",{className:"rounded-md bg-muted/60 px-1 py-px font-mono text-[9px] uppercase tracking-wide text-muted-foreground ring-1 ring-border/40",children:[".",B]},B))]}),T=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:B=>c(B.target.value),onKeyDown:B=>{B.stopPropagation(),B.key==="Enter"?N():B.key==="Escape"&&d()},onClick:B=>B.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),s.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:B=>{B.stopPropagation(),N()},title:x("tooltips.save"),children:s.jsx(Ut,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),s.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:B=>{B.stopPropagation(),d()},title:x("tooltips.cancel"),children:s.jsx(ft,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),z=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:fe("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:I,children:w?s.jsx("div",{className:"flex items-center gap-1",children:T}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:fe("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(Dn,{provider:S,className:"h-3 w-3"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[o&&s.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),D]}),s.jsx("div",{className:"flex-shrink-0",onClick:B=>B.stopPropagation(),children:s.jsx(qy,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:C,onDelete:_,t:x,className:"!opacity-100"})})]})})}),H=s.jsxs("div",{className:fe("group/item relative hidden md:block"),children:[s.jsxs(Pe,{variant:"ghost",className:fe("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&s.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&s.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),s.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[s.jsx("div",{className:fe("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:s.jsx(Dn,{provider:S,className:"h-3 w-3"})}),s.jsx("div",{className:"min-w-0 flex-1",children:w?s.jsx("div",{className:"flex items-center gap-1",children:T}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&s.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),D]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:B=>B.stopPropagation(),children:s.jsx(qy,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:C,onDelete:_,t:x,className:"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[z,H]})}function $D(){return s.jsx(s.Fragment,{children:Array.from({length:3}).map((e,t)=>s.jsx("div",{className:"rounded-md p-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),s.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function UD({project:e,isExpanded:t,sessions:n,selectedSession:r,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:u,onEditingSessionNameChange:d,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,t:S}){if(!t)return null;const E=n.length>0,k=e.sessionMeta?.hasMore===!0;return s.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[s.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:s.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{b(e),w(e)},children:[s.jsx(sn,{className:"h-3 w-3"}),S("sessions.newSession")]})}),s.jsxs(Pe,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>w(e),children:[s.jsx(sn,{className:"h-3 w-3"}),S("sessions.newSession")]}),a?!E&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:S("sessions.noSessions")})}):n.map(A=>s.jsx(C4,{project:e,session:A,selectedSession:r,currentTime:o,editingSession:l,editingSessionName:c,isStarred:u(e.name,A.id),onEditingSessionNameChange:d,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:S},A.id)):s.jsx($D,{}),E&&k&&s.jsx(Pe,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:i,children:i?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),S("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Fn,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const GD=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function HD({project:e,selectedProject:t,selectedSession:n,isExpanded:r,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:S,onToggleStarSession:E,onStartEditingProject:k,onCancelEditingProject:A,onSaveProjectName:I,onDeleteProject:N,onSessionSelect:_,onDeleteSession:R,onLoadMoreSessions:C,onNewSession:D,onEditingSessionNameChange:T,onStartEditingSession:z,onCancelEditingSession:H,onSaveEditingSession:B,t:Y}){const q=t?.name===e.name,O=o===e.name,$=e.sessionMeta?.hasMore===!0,G=GD(c,$),P=`${G} session${c.length===1?"":"s"}`,ee=N9(e,b),ne=()=>v(e.name),pe=()=>S(e.name),le=()=>{I(e.name)},oe=()=>{t?.name!==e.name&&w(e),ne()};return s.jsxs("div",{className:fe("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[s.jsxs("div",{className:"md:group group",children:[s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:fe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",q&&"bg-primary/5 border-primary/20",i&&!q&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ne,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s.jsx("div",{className:fe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",r?"bg-primary/10":"bg-muted"),children:r?s.jsx(La,{className:"h-4 w-4 text-primary"}):s.jsx(Er,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:O?s.jsx("input",{type:"text",value:l,onChange:he=>y(he.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:Y("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:he=>he.stopPropagation(),onKeyDown:he=>{he.key==="Enter"&&le(),he.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[s.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&s.jsx(FD,{status:ee,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:P})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:O?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:he=>{he.stopPropagation(),le()},children:s.jsx(Ut,{className:"h-4 w-4 text-white"})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:he=>{he.stopPropagation(),A()},children:s.jsx(ft,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:fe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:he=>{he.stopPropagation(),pe()},title:Y(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(rs,{className:fe("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:he=>{he.stopPropagation(),N(e)},children:s.jsx(gn,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:he=>{he.stopPropagation(),k(e)},children:s.jsx(Rp,{className:"h-4 w-4 text-primary"})}),s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:r?s.jsx(Fn,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(Sr,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Pe,{variant:"ghost",className:fe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",q&&"bg-accent text-accent-foreground",i&&!q&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:oe,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?s.jsx(La,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Er,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:O?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:he=>y(he.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:Y("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:he=>{he.key==="Enter"&&le(),he.key==="Escape"&&A()}}),s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):s.jsxs("div",{children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[G,e.fullPath!==e.displayName&&s.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),s.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:O?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:he=>{he.stopPropagation(),le()},children:s.jsx(Ut,{className:"h-3 w-3"})}),s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:he=>{he.stopPropagation(),A()},children:s.jsx(ft,{className:"h-3 w-3"})})]}):s.jsxs(s.Fragment,{children:[i&&s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded hover:bg-yellow-50 dark:hover:bg-yellow-900/20",onClick:he=>{he.stopPropagation(),pe()},title:Y("tooltips.removeFromFavorites"),children:s.jsx(rs,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(N4,{triggerLabel:Y("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:Y("actions.rename"),icon:Rp,onClick:()=>k(e)},{id:"star",label:Y(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:rs,onClick:pe},{id:"delete",label:Y("actions.delete",{defaultValue:"Delete"}),icon:gn,onClick:()=>N(e),danger:!0}]}),r?s.jsx(Fn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(Sr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(UD,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:h,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:T,onStartEditingSession:z,onCancelEditingSession:H,onSaveEditingSession:B,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:_,onDeleteSession:R,onLoadMoreSessions:C,onNewSession:D,t:Y})]})}function T4({isLoading:e,loadingProgress:t,projectsCount:n,filteredProjectsCount:r,t:a}){return e?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&s.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):n===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(Er,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):r===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(aa,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function qD({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:u,initialSessionsLoaded:d,currentTime:p,editingSession:h,editingSessionName:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:I,onStartEditingProject:N,onCancelEditingProject:_,onSaveProjectName:R,onDeleteProject:C,onSessionSelect:D,onDeleteSession:T,onLoadMoreSessions:z,onNewSession:H,onEditingSessionNameChange:B,onStartEditingSession:Y,onCancelEditingSession:q,onSaveEditingSession:O,t:$}){const G=s.jsx(T4,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:$});f.useEffect(()=>{let oe="Pixcode";const he=n?.displayName?.trim();he&&(oe=`${he} - ${oe}`),document.title=oe},[n]);const P=!a&&e.length>0&&t.length>0,ee=oe=>oe.source==="history"||oe.autoDiscovered===!0&&oe.isManuallyAdded!==!0,ne=t.filter(oe=>!ee(oe)),pe=t.filter(oe=>ee(oe)),le=oe=>s.jsx(HD,{project:oe,selectedProject:n,selectedSession:r,isExpanded:o.has(oe.name),isDeleting:g.has(oe.name),isStarred:v(oe.name),editingProject:l,editingName:c,sessions:y(oe),initialSessionsLoaded:d.has(oe.name),isLoadingSessions:!!u[oe.name],currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:I,onStartEditingProject:N,onCancelEditingProject:_,onSaveProjectName:R,onDeleteProject:C,onSessionSelect:D,onDeleteSession:T,onLoadMoreSessions:z,onNewSession:H,onEditingSessionNameChange:B,onStartEditingSession:Y,onCancelEditingSession:q,onSaveEditingSession:O,t:$},oe.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:P?s.jsxs(s.Fragment,{children:[ne.map(oe=>le(oe)),pe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:$("projects.detectedFromHistory")}),pe.map(oe=>le(oe))]})]}):G})}function Zr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A4(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
229
+ `;function hR(){if(typeof document>"u"||document.getElementById(xy))return;const e=document.createElement("style");e.id=xy,e.type="text/css",e.innerText=mR,document.head.appendChild(e)}function fR({terminalContainerRef:e,terminalRef:t,fitAddonRef:n,wsRef:r,selectedProject:a,minimal:i,isRestarting:o,initialCommandRef:l,isPlainShellRef:c,authUrlRef:u,copyAuthUrlToClipboard:d,closeSocket:p}){const[h,m]=f.useState(!1),g=f.useRef(null),b=a?.fullPath||a?.path||"",x=!!a;f.useEffect(()=>{hR()},[]);const y=f.useCallback(()=>{t.current&&(t.current.clear(),t.current.write("\x1B[2J\x1B[H"))},[t]),v=f.useCallback(()=>{t.current&&(t.current.dispose(),t.current=null),n.current=null,m(!1)},[n,t]);return f.useEffect(()=>{if(!e.current||!x||o||t.current)return;const w=new uR.Terminal(Qj);t.current=w;const S=new sR.FitAddon;n.current=S,w.loadAddon(S),i||w.loadAddon(new lR.WebLinksAddon);try{w.loadAddon(new cR.WebglAddon)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}w.open(e.current);const E=async()=>{const N=w.getSelection();return N?hr(N):!1},k=N=>{if(!w.hasSelection())return;const _=w.getSelection();if(_){if(N.preventDefault(),N.clipboardData){N.clipboardData.setData("text/plain",_);return}hr(_)}};e.current.addEventListener("copy",k),w.attachCustomKeyEventHandler(N=>{const _=f5(l.current)?m5:u.current;return N.type==="keydown"&&i&&c.current&&_&&!N.ctrlKey&&!N.metaKey&&!N.altKey&&N.key?.toLowerCase()==="c"?(N.preventDefault(),N.stopPropagation(),d(_),!1):N.type==="keydown"&&(N.ctrlKey||N.metaKey)&&N.key?.toLowerCase()==="c"&&w.hasSelection()?(N.preventDefault(),N.stopPropagation(),E(),!1):N.type==="keydown"&&(N.ctrlKey||N.metaKey)&&N.key?.toLowerCase()==="v"?(N.preventDefault(),N.stopPropagation(),typeof navigator<"u"&&navigator.clipboard?.readText&&navigator.clipboard.readText().then(R=>{oi(r.current,{type:"input",data:R})}).catch(()=>{}),!1):!0}),window.setTimeout(()=>{const N=n.current,_=t.current;!N||!_||(N.fit(),oi(r.current,{type:"resize",cols:_.cols,rows:_.rows}))},h5),m(!0);const A=w.onData(N=>{oi(r.current,{type:"input",data:N})}),I=new ResizeObserver(()=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{const N=n.current,_=t.current;!N||!_||(N.fit(),oi(r.current,{type:"resize",cols:_.cols,rows:_.rows}))},Wj)});return I.observe(e.current),()=>{e.current?.removeEventListener("copy",k),I.disconnect(),g.current!==null&&(window.clearTimeout(g.current),g.current=null),A.dispose(),p(),v()}},[u,p,d,v,n,l,c,o,i,x,b,e,t,r]),{isInitialized:h,clearTerminalScreen:y,disposeTerminal:v}}function gR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:a,autoConnect:i,isRestarting:o,onProcessComplete:l,onOutputRef:c}){const u=f.useRef(null),d=f.useRef(null),p=f.useRef(null),h=f.useRef(null),[m,g]=f.useState(""),[b,x]=f.useState(0),y=f.useRef(e),v=f.useRef(t),w=f.useRef(n),S=f.useRef(r),E=f.useRef(l),k=f.useRef(""),A=f.useRef(t?.id??null);f.useEffect(()=>{y.current=e,v.current=t,w.current=n,S.current=r,E.current=l},[e,t,n,r,l]);const I=f.useCallback(q=>{k.current=q,g(q),x(O=>O+1)},[]),N=f.useCallback(()=>{const q=h.current;q&&((q.readyState===WebSocket.OPEN||q.readyState===WebSocket.CONNECTING)&&q.close(),h.current=null)},[]),_=f.useCallback((q=k.current)=>{if(!q)return!1;const O=window.open(q,"_blank");if(O){try{O.opener=null}catch{}return!0}return!1},[]),R=f.useCallback(async(q=k.current)=>q?hr(q):!1,[]),{isInitialized:C,clearTerminalScreen:D,disposeTerminal:T}=fR({terminalContainerRef:u,terminalRef:d,fitAddonRef:p,wsRef:h,selectedProject:e,minimal:a,isRestarting:o,initialCommandRef:w,isPlainShellRef:S,authUrlRef:k,copyAuthUrlToClipboard:R,closeSocket:N}),{isConnected:z,isConnecting:H,connectToShell:B,disconnectFromShell:Y}=iR({wsRef:h,terminalRef:d,fitAddonRef:p,selectedProjectRef:y,selectedSessionRef:v,initialCommandRef:w,isPlainShellRef:S,onProcessCompleteRef:E,isInitialized:C,autoConnect:i,closeSocket:N,clearTerminalScreen:D,setAuthUrl:I,onOutputRef:c});return f.useEffect(()=>{o&&(Y(),T())},[Y,T,o]),f.useEffect(()=>{e||(Y(),T())},[Y,T,e]),f.useEffect(()=>{const q=t?.id??null;A.current!==q&&C&&Y(),A.current=q},[Y,C,t?.id]),{terminalContainerRef:u,terminalRef:d,wsRef:h,isConnected:z,isInitialized:C,isConnecting:H,authUrl:m,authUrlVersion:b,connectToShell:B,disconnectFromShell:Y,openAuthUrlInBrowser:_,copyAuthUrlToClipboard:R}}function bR({mode:e,description:t,loadingLabel:n,connectLabel:r,connectTitle:a,connectingLabel:i,onConnect:o}){return e==="loading"?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:s.jsx("div",{className:"text-white",children:n})}):e==="connect"?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:s.jsxs("div",{className:"w-full max-w-sm text-center",children:[s.jsxs("button",{onClick:o,className:"flex w-full items-center justify-center space-x-2 rounded-lg bg-green-600 px-6 py-3 text-base font-medium text-white transition-colors hover:bg-green-700 sm:w-auto",title:a,children:[s.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),s.jsx("span",{children:r})]}),s.jsx("p",{className:"mt-3 px-2 text-sm text-gray-400",children:t})]})}):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:s.jsxs("div",{className:"w-full max-w-sm text-center",children:[s.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),s.jsx("span",{className:"text-base font-medium",children:i})]}),s.jsx("p",{className:"mt-3 px-2 text-sm text-gray-400",children:t})]})})}function xR({title:e,description:t}){return s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:e}),s.jsx("p",{children:t})]})})}function yR({isConnected:e,isInitialized:t,isRestarting:n,hasSession:r,sessionDisplayNameShort:a,onDisconnect:i,onRestart:o,statusNewSessionText:l,statusInitializingText:c,statusRestartingText:u,disconnectLabel:d,disconnectTitle:p,restartLabel:h,restartTitle:m,disableRestart:g}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-500":"bg-red-500"}`}),r&&a&&s.jsxs("span",{className:"text-xs text-blue-300",children:["(",a,"...)"]}),!r&&s.jsx("span",{className:"text-xs text-gray-400",children:l}),!t&&s.jsx("span",{className:"text-xs text-yellow-400",children:c}),n&&s.jsx("span",{className:"text-xs text-blue-400",children:u})]}),s.jsxs("div",{className:"flex items-center space-x-3",children:[e&&s.jsxs("button",{onClick:i,className:"flex items-center space-x-1 rounded bg-red-600 px-3 py-1 text-xs text-white hover:bg-red-700",title:p,children:[s.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),s.jsx("span",{children:d})]}),s.jsxs("button",{onClick:o,disabled:g,className:"flex items-center space-x-1 text-xs text-gray-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50",title:m,children:[s.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})}),s.jsx("span",{children:h})]})]})]})})}function vR({terminalContainerRef:e,authUrl:t,authUrlVersion:n,initialCommand:r,isConnected:a,openAuthUrlInBrowser:i,copyAuthUrlToClipboard:o}){const[l,c]=f.useState("idle"),[u,d]=f.useState(!1),p=f.useMemo(()=>dR(r,t),[t,r]);f.useEffect(()=>{c("idle"),d(!1)},[n,p,a]);const h=!!p,m=h&&!u,g=h&&u;return s.jsxs("div",{className:"relative h-full w-full bg-gray-900",children:[s.jsx("div",{ref:e,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),m&&s.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:s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-xs text-gray-300",children:"Open or copy the login URL:"}),s.jsx("button",{type:"button",onClick:()=>d(!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"})]}),s.jsx("input",{type:"text",value:p,readOnly:!0,onClick:b=>b.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"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{i(p)},className:"flex-1 rounded bg-blue-600 px-3 py-2 text-xs font-medium text-white hover:bg-blue-700",children:"Open URL"}),s.jsx("button",{type:"button",onClick:async()=>{const b=await o(p);c(b?"copied":"failed")},className:"flex-1 rounded bg-gray-700 px-3 py-2 text-xs font-medium text-white hover:bg-gray-600",children:l==="copied"?"Copied":"Copy URL"})]})]})}),g&&s.jsx("div",{className:"absolute bottom-14 right-3 z-20 md:hidden",children:s.jsx("button",{type:"button",onClick:()=>d(!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"})})]})}const wR=[{type:"key",id:"esc",label:"Esc",sequence:"\x1B"},{type:"key",id:"tab",label:"Tab",sequence:" "},{type:"key",id:"shift-tab",label:"⇧Tab",sequence:"\x1B[Z"},{type:"modifier",id:"ctrl",label:"CTRL",modifier:"ctrl"},{type:"modifier",id:"alt",label:"ALT",modifier:"alt"},{type:"arrow",id:"arrow-up",sequence:"\x1B[A",icon:"up"},{type:"arrow",id:"arrow-down",sequence:"\x1B[B",icon:"down"},{type:"arrow",id:"arrow-left",sequence:"\x1B[D",icon:"left"},{type:"arrow",id:"arrow-right",sequence:"\x1B[C",icon:"right"}],kR={up:XS,down:t0,left:qI,right:n0},Ks=e=>e.preventDefault(),yy="shrink-0 rounded-md border border-gray-600 bg-gray-700 px-2.5 py-1.5 text-xs font-medium text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40",SR="shrink-0 rounded-md border border-blue-500 bg-blue-600 px-2.5 py-1.5 text-xs font-medium text-white transition-colors select-none disabled:cursor-not-allowed disabled:opacity-40",Fu="shrink-0 rounded-md border border-gray-600 bg-gray-700 p-1.5 text-gray-100 transition-colors select-none active:bg-blue-600 active:text-white active:border-blue-600 disabled:cursor-not-allowed disabled:opacity-40";function vy({wsRef:e,terminalRef:t,isConnected:n,bottomOffset:r="bottom-0"}){const{t:a}=je("settings"),[i,o]=f.useState(!1),[l,c]=f.useState(!1),u=f.useCallback(m=>{oi(e.current,{type:"input",data:m})},[e]),d=f.useCallback(()=>{t.current?.scrollToBottom()},[t]),p=f.useCallback(async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.readText))try{const m=await navigator.clipboard.readText();m.length>0&&u(m)}catch{}},[u]),h=f.useCallback(m=>{let g=m;if(i&&m.length===1){const b=m.toLowerCase().charCodeAt(0);b>=97&&b<=122&&(g=String.fromCharCode(b-96)),o(!1)}l&&m.length===1&&(g="\x1B"+g,c(!1)),u(g)},[i,l,u]);return s.jsx("div",{className:`pointer-events-none fixed inset-x-0 ${r} z-20 px-2 md:hidden`,children:s.jsxs("div",{className:"pointer-events-auto flex items-center gap-1 overflow-x-auto rounded-lg border border-gray-700/80 bg-gray-900/95 px-1.5 py-1.5 shadow-lg backdrop-blur-sm [-webkit-overflow-scrolling:touch] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>{p()},disabled:!n,className:Fu,title:a("terminalShortcuts.paste",{defaultValue:"Paste"}),"aria-label":a("terminalShortcuts.paste",{defaultValue:"Paste"}),children:s.jsx(i0,{className:"h-4 w-4"})}),wR.map(m=>{if(m.type==="modifier"){const g=m.modifier==="ctrl"?i:l,b=m.modifier==="ctrl"?()=>o(x=>!x):()=>c(x=>!x);return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:b,disabled:!n,className:g?SR:yy,children:m.label},m.id)}if(m.type==="arrow"){const g=kR[m.icon];return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>u(m.sequence),disabled:!n,className:Fu,children:s.jsx(g,{className:"h-4 w-4"})},m.id)}return s.jsx("button",{type:"button",onPointerDown:Ks,onClick:()=>h(m.sequence),disabled:!n,className:yy,children:m.label},m.id)}),s.jsx("button",{type:"button",onPointerDown:Ks,onClick:d,disabled:!n,className:Fu,title:a("terminalShortcuts.scrollDown"),"aria-label":a("terminalShortcuts.scrollDown"),children:s.jsx(VI,{className:"h-4 w-4"})})]})})}function g5({selectedProject:e=null,selectedSession:t=null,initialCommand:n=null,isPlainShell:r=!1,onProcessComplete:a=null,minimal:i=!1,autoConnect:o=!1,isActive:l=!0}){const{t:c}=je("chat"),[u,d]=f.useState(!1),[p,h]=f.useState(null),m=f.useRef(null),g=f.useRef(null),{terminalContainerRef:b,terminalRef:x,wsRef:y,isConnected:v,isInitialized:w,isConnecting:S,authUrl:E,authUrlVersion:k,connectToShell:A,disconnectFromShell:I,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:_}=gR({selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:r,minimal:i,autoConnect:o,isRestarting:u,onProcessComplete:a,onOutputRef:g}),R=f.useCallback(()=>{const G=x.current;if(!G)return;const P=G.buffer.active,ee=P.baseY+P.cursorY,ne=Math.min(P.baseY+P.length-1,ee+10),pe=Math.max(0,ee-Yj),le=[];for(let De=pe;De<=ne;De++){const Ge=P.getLine(De);Ge&&le.push(Ge.translateToString().trimEnd())}let oe=-1;for(let De=le.length-1;De>=0;De--)if(/esc to cancel/i.test(le[De])||/enter to select/i.test(le[De])){oe=De;break}if(oe===-1){h(null);return}const he=new Map,Te=Math.max(0,oe-Zj);for(let De=oe-1;De>=Te;De--){const Ge=le[De].match(/^\s*[❯›>]?\s*(\d+)\.\s+(.+)/);if(Ge){const M=Ge[1],me=Ge[2].trim();parseInt(M,10)<=Xj&&me.length>0&&!he.has(M)&&he.set(M,me)}}const _e=[];for(let De=1;De<=he.size&&he.has(String(De));De++)_e.push({number:String(De),label:he.get(String(De))});h(_e.length>=Jj?_e:null)},[x]),C=f.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(R,Kj)},[R]);f.useEffect(()=>{g.current=C},[C]),f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),f.useEffect(()=>{v||(m.current&&(clearTimeout(m.current),m.current=null),h(null))},[v]),f.useEffect(()=>{if(!l||!w||!v)return;const G=()=>{x.current?.focus()},P=window.requestAnimationFrame(G),ee=window.setTimeout(G,0);return()=>{window.cancelAnimationFrame(P),window.clearTimeout(ee)}},[l,v,w,x]);const D=f.useCallback(G=>{oi(y.current,{type:"input",data:G})},[y]),T=f.useMemo(()=>pR(t),[t]),z=f.useMemo(()=>T?T.slice(0,30):null,[T]),H=f.useMemo(()=>T?T.slice(0,50):null,[T]),B=f.useCallback(()=>{d(!0),window.setTimeout(()=>{d(!1)},Vj)},[]);if(!e)return s.jsx(xR,{title:c("shell.selectProject.title"),description:c("shell.selectProject.description")});if(i)return s.jsxs(s.Fragment,{children:[s.jsx(vR,{terminalContainerRef:b,authUrl:E,authUrlVersion:k,initialCommand:n,isConnected:v,openAuthUrlInBrowser:N,copyAuthUrlToClipboard:_}),s.jsx(vy,{wsRef:y,terminalRef:x,isConnected:v,bottomOffset:"bottom-0"})]});const Y=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):t?c("shell.resumeSession",{displayName:H}):c("shell.startSession"),q=r?c("shell.runCommand",{command:n||c("shell.defaultCommand"),projectName:e.displayName}):c("shell.startCli",{projectName:e.displayName}),O=w?S?"connecting":v?null:"connect":"loading",$=O==="connecting"?q:Y;return s.jsxs("div",{className:"flex h-full w-full flex-col bg-gray-900",children:[s.jsx(yR,{isConnected:v,isInitialized:w,isRestarting:u,hasSession:!!t,sessionDisplayNameShort:z,onDisconnect:I,onRestart:B,statusNewSessionText:c("shell.status.newSession"),statusInitializingText:c("shell.status.initializing"),statusRestartingText:c("shell.status.restarting"),disconnectLabel:c("shell.actions.disconnect"),disconnectTitle:c("shell.actions.disconnectTitle"),restartLabel:c("shell.actions.restart"),restartTitle:c("shell.actions.restartTitle"),disableRestart:u||v}),s.jsxs("div",{className:"relative flex-1 overflow-hidden p-2",children:[s.jsx("div",{ref:b,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),O&&s.jsx(bR,{mode:O,description:$,loadingLabel:c("shell.loading"),connectLabel:c("shell.actions.connect"),connectTitle:c("shell.actions.connectTitle"),connectingLabel:c("shell.connecting"),onConnect:A}),p&&v&&s.jsx("div",{className:"absolute inset-x-0 bottom-0 z-10 border-t border-gray-700/80 bg-gray-800/95 px-3 py-2 backdrop-blur-sm",onMouseDown:G=>G.preventDefault(),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.map(G=>s.jsxs("button",{type:"button",onClick:()=>{D(G.number),h(null)},className:"max-w-36 truncate rounded bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-700",title:`${G.number}. ${G.label}`,children:[G.number,". ",G.label]},G.number)),s.jsx("button",{type:"button",onClick:()=>{D("\x1B"),h(null)},className:"rounded bg-gray-700 px-3 py-1.5 text-xs font-medium text-gray-200 transition-colors hover:bg-gray-600",children:"Esc"})]})})]}),s.jsx(vy,{wsRef:y,terminalRef:x,isConnected:v})]})}function ER({className:e}){return s.jsx("div",{className:`flex h-full items-center justify-center ${e}`,children:s.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800",children:s.jsx("svg",{className:"h-8 w-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.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"})})}),s.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No Project Selected"}),s.jsx("p",{children:"A project is required to open a shell"})]})})}function NR({title:e,isCompleted:t,onClose:n=null}){return s.jsx("div",{className:"flex-shrink-0 border-b border-gray-700 bg-gray-800 px-4 py-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-200",children:e}),t&&s.jsx("span",{className:"text-xs text-green-400",children:"(Completed)"})]}),n&&s.jsx("button",{onClick:n,className:"text-gray-400 hover:text-white",title:"Close",children:s.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})})}function b5({project:e=null,session:t=null,command:n=null,isPlainShell:r=null,isActive:a=!0,autoConnect:i=!0,onComplete:o=null,onClose:l=null,title:c=null,className:u="",showHeader:d=!0,compact:p=!1,minimal:h=!1}){const[m,g]=f.useState(!1),b=r!==null?r:n!==null,x=f.useCallback(y=>{g(!0),o?.(y)},[o]);return e?s.jsxs("div",{className:`flex h-full w-full flex-col ${u}`,children:[!h&&d&&c&&s.jsx(NR,{title:c,isCompleted:m,onClose:l}),s.jsx("div",{className:"min-h-0 w-full flex-1",children:s.jsx(g5,{selectedProject:e,selectedSession:t,initialCommand:n,isPlainShell:b,isActive:a,onProcessComplete:x,minimal:h,autoConnect:h?!0:i})})]}):s.jsx(ER,{className:u})}const CR=(e,t)=>t||(e==="claude"?"claude --dangerously-skip-permissions /login":e==="cursor"?"cursor-agent login":e==="codex"?"codex login":e==="qwen"?"qwen auth":"gemini"),TR={claude:{keyLabel:"Anthropic API Key",keyExample:"sk-ant-...",supportsBaseUrl:!0,baseUrlExample:"https://api.anthropic.com",keyConsoleUrl:"https://console.anthropic.com/settings/keys",keyConsoleLabel:"Anthropic Console"},codex:{keyLabel:"OpenAI API Key",keyExample:"sk-...",supportsBaseUrl:!0,baseUrlExample:"https://api.openai.com/v1",keyConsoleUrl:"https://platform.openai.com/api-keys",keyConsoleLabel:"OpenAI Platform"},gemini:{keyLabel:"Gemini API Key",keyExample:"AI...",supportsBaseUrl:!1,keyConsoleUrl:"https://aistudio.google.com/app/apikey",keyConsoleLabel:"Google AI Studio"},qwen:{keyLabel:"OpenAI-Compatible API Key",keyExample:"sk-... or sk-sp-...",supportsBaseUrl:!0,baseUrlExample:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1",keyConsoleUrl:"https://github.com/QwenLM/qwen-code",keyConsoleLabel:"Qwen Code Docs",notes:"Accepts any OpenAI-compatible endpoint — Alibaba Cloud, ModelScope, OpenRouter, self-hosted, etc."}};function wy({active:e,children:t,onClick:n}){return s.jsx("button",{onClick:n,className:`flex-1 border-b-2 px-4 py-2.5 text-sm font-medium transition-colors ${e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:t})}function AR({provider:e}){const[t,n]=f.useState(""),[r,a]=f.useState(!1),[i,o]=f.useState("idle"),[l,c]=f.useState(null),u=async()=>{const d=t.trim();if(d){a(!0),c(null),o("idle");try{const p=await we(`/api/providers/${e}/oauth-paste`,{method:"POST",body:JSON.stringify({callbackUrl:d})}),h=await p.json().catch(()=>({}));if(!p.ok||!h?.success)throw new Error(h?.error||`Request failed (${p.status})`);o("ok"),n("")}catch(p){c(p?.message||"Forward failed"),o("error")}finally{a(!1)}}};return s.jsxs("div",{className:"mt-3 rounded-lg border border-border/60 bg-muted/30 p-3 text-sm",children:[s.jsx("div",{className:"mb-2 font-medium text-foreground",children:"Remote login? Paste the callback URL here"}),s.jsxs("p",{className:"mb-3 text-xs text-muted-foreground",children:["When the CLI shows ",s.jsx("code",{className:"rounded bg-background px-1 font-mono text-[11px]",children:"http://127.0.0.1:PORT/…"})," and your browser can't reach it (VPS setups), copy the failing URL from your address bar and paste it below. Pixcode forwards the token exchange to the CLI process on this host."]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"url",value:t,onChange:d=>n(d.target.value),placeholder:"http://127.0.0.1:49312/callback?code=...",className:"flex-1 rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground focus:border-primary focus:outline-none",onKeyDown:d=>{d.key==="Enter"&&u()}}),s.jsx("button",{onClick:()=>void u(),disabled:r||!t.trim(),className:"flex items-center gap-1.5 rounded-md bg-foreground px-3 py-2 text-xs font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:r?s.jsx(fn,{className:"h-3.5 w-3.5 animate-spin"}):"Forward"})]}),i==="ok"&&s.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-emerald-600 dark:text-emerald-400",children:[s.jsx(Ut,{className:"h-3.5 w-3.5"})," Forwarded — check the terminal above for the completion message."]}),i==="error"&&l&&s.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:l})]})}function _R({provider:e,onSaved:t}){const n=TR[e],[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[u,d]=f.useState("idle"),[p,h]=f.useState(null);f.useEffect(()=>{let g=!1;return(async()=>{try{const x=await(await we("/api/providers/credentials")).json().catch(()=>({}));if(g||!x?.success)return;const y=x.data?.[e];y?.baseUrl&&o(y.baseUrl)}catch{}})(),()=>{g=!0}},[e]);const m=async()=>{const g=r.trim();if(g){c(!0),h(null),d("idle");try{const b=await we(`/api/providers/${e}/auth/api-key`,{method:"POST",body:JSON.stringify({apiKey:g,baseUrl:n.supportsBaseUrl&&i.trim()?i.trim():""})}),x=await b.json().catch(()=>({}));if(!b.ok||!x?.success)throw new Error(x?.error||`Request failed (${b.status})`);d("ok"),a(""),t()}catch(b){h(b?.message||"Save failed"),d("error")}finally{c(!1)}}};return n?s.jsx("div",{className:"flex h-full flex-col overflow-y-auto p-6",children:s.jsxs("div",{className:"mx-auto w-full max-w-lg space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-muted",children:s.jsx(Sj,{className:"h-5 w-5 text-foreground"})}),s.jsxs("div",{children:[s.jsx("h4",{className:"text-base font-semibold text-foreground",children:n.keyLabel}),s.jsxs("a",{href:n.keyConsoleUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:["Get a key from ",n.keyConsoleLabel,s.jsx(Or,{className:"h-3 w-3"})]})]})]}),n.notes&&s.jsx("div",{className:"rounded-md border border-border/60 bg-muted/40 p-3 text-xs text-muted-foreground",children:n.notes}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-xs font-medium text-foreground",children:"API Key"}),s.jsx("input",{type:"password",value:r,onChange:g=>a(g.target.value),placeholder:n.keyExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Stored locally at ",s.jsx("code",{className:"rounded bg-muted px-1 font-mono text-[10px]",children:"~/.pixcode/provider-credentials.json"})," with 0600 permissions."]})]}),n.supportsBaseUrl&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Base URL ",s.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional — use a custom endpoint)"})]}),s.jsx("input",{type:"url",value:i,onChange:g=>o(g.target.value),placeholder:n.baseUrlExample,className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-sm text-foreground focus:border-primary focus:outline-none",autoComplete:"off",spellCheck:!1}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Point at any OpenAI-compatible proxy (OpenRouter, local LLM, self-hosted, budget provider) to cut costs or hit different models."})]}),s.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[s.jsxs("button",{onClick:()=>void m(),disabled:l||!r.trim(),className:"inline-flex items-center gap-2 rounded-md bg-foreground px-4 py-2 text-sm font-medium text-background transition-opacity hover:opacity-90 disabled:opacity-40",children:[l?s.jsx(fn,{className:"h-4 w-4 animate-spin"}):s.jsx(Ut,{className:"h-4 w-4"}),"Save API Key"]}),u==="ok"&&s.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"Saved — reconnect to pick it up."}),u==="error"&&p&&s.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:p})]})]})}):s.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"This provider uses OAuth only — use the Browser tab to log in."})}function x5({isOpen:e,onClose:t,provider:n="claude",onComplete:r,customCommand:a,isAuthenticated:i=!1}){const{t:o}=je("common"),l=n!=="cursor",[c,u]=f.useState(l?"apiKey":"browser");f.useEffect(()=>{e&&u(l?"apiKey":"browser")},[e,n,l]);const d=f.useMemo(()=>`${fc[n]??n} Login`,[n]);if(!e)return null;const p=CR(n,a),h=m=>r?.(m);return s.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black bg-opacity-50 max-md:items-stretch max-md:justify-stretch",children:s.jsxs("div",{className:"flex h-3/4 w-full max-w-4xl flex-col rounded-lg bg-white shadow-xl dark:bg-gray-800 max-md:m-0 max-md:h-full max-md:max-w-none max-md:rounded-none md:m-4 md:h-3/4 md:max-w-4xl md:rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d}),s.jsx("button",{onClick:t,className:"text-gray-400 transition-colors hover:text-gray-600 dark:hover:text-gray-300","aria-label":"Close login modal",children:s.jsx(ft,{className:"h-6 w-6"})})]}),s.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[s.jsx(wy,{active:c==="browser",onClick:()=>u("browser"),children:"Browser / OAuth"}),l&&s.jsx(wy,{active:c==="apiKey",onClick:()=>u("apiKey"),children:"API Key"})]}),s.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:c==="browser"?s.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(b5,{project:l6,command:p,onComplete:h,minimal:!0})}),(n==="claude"||n==="cursor"||n==="qwen")&&s.jsx("div",{className:"border-t border-border/40 bg-background/50 px-4 py-3",children:s.jsx(AR,{provider:n})})]}):s.jsx(_R,{provider:n,onSaved:()=>h(0)})})]})})}const IR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:e}),jR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Cs();return s.jsx("img",{src:t?"/icons/codex-white.svg":"/icons/codex.svg",alt:"Codex",className:e})},RR=({className:e="w-5 h-5"})=>{const{isDarkMode:t}=Cs();return s.jsx("img",{src:t?"/icons/cursor-white.svg":"/icons/cursor.svg",alt:"Cursor",className:e})},DR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/gemini-ai-icon.svg",alt:"Gemini",className:e}),LR=({className:e="w-5 h-5"})=>s.jsx("img",{src:"/icons/qwen-ai-icon.png",alt:"Qwen Code",className:e});function Dn({provider:e="claude",className:t="w-5 h-5"}){return e==="cursor"?s.jsx(RR,{className:t}):e==="codex"?s.jsx(jR,{className:t}):e==="gemini"?s.jsx(DR,{className:t}):e==="qwen"?s.jsx(LR,{className:t}):s.jsx(IR,{className:t})}function OR({provider:e,title:t,status:n,connectedClassName:r,iconContainerClassName:a,loginButtonClassName:i,onLogin:o}){const l=n.authenticated?r:"border-border bg-card",c=n.loading?"Checking...":n.authenticated?n.email||"Connected":n.error||"Not connected";return s.jsx("div",{className:`rounded-lg border p-4 transition-colors ${l}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-full ${a}`,children:s.jsx(Dn,{provider:e,className:"h-5 w-5"})}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 font-medium text-foreground",children:[t,n.authenticated&&s.jsx(Ut,{className:"h-4 w-4 text-green-500"})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:c})]})]}),!n.authenticated&&!n.loading&&s.jsx("button",{onClick:o,className:`${i} rounded-lg px-4 py-2 text-sm font-medium text-white transition-colors`,children:"Login"})]})})}const MR=[{provider:"claude",title:"Claude Code",connectedClassName:"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800",iconContainerClassName:"bg-blue-100 dark:bg-blue-900/30",loginButtonClassName:"bg-blue-600 hover:bg-blue-700"},{provider:"cursor",title:"Cursor",connectedClassName:"bg-purple-50 dark:bg-purple-900/20 border-purple-200 dark:border-purple-800",iconContainerClassName:"bg-purple-100 dark:bg-purple-900/30",loginButtonClassName:"bg-purple-600 hover:bg-purple-700"},{provider:"codex",title:"OpenAI Codex",connectedClassName:"bg-gray-100 dark:bg-gray-800/50 border-gray-300 dark:border-gray-600",iconContainerClassName:"bg-gray-100 dark:bg-gray-800",loginButtonClassName:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"},{provider:"gemini",title:"Gemini",connectedClassName:"bg-teal-50 dark:bg-teal-900/20 border-teal-200 dark:border-teal-800",iconContainerClassName:"bg-teal-100 dark:bg-teal-900/30",loginButtonClassName:"bg-teal-600 hover:bg-teal-700"},{provider:"qwen",title:"Qwen Code",connectedClassName:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800",iconContainerClassName:"bg-orange-100 dark:bg-orange-900/30",loginButtonClassName:"bg-orange-600 hover:bg-orange-700"}];function PR({providerStatuses:e,onOpenProviderLogin:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-6 text-center",children:[s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Connect Your AI Agents"}),s.jsx("p",{className:"text-muted-foreground",children:"Login to one or more AI coding assistants. All are optional."})]}),s.jsx("div",{className:"space-y-3",children:MR.map(n=>s.jsx(OR,{provider:n.provider,title:n.title,status:e[n.provider],connectedClassName:n.connectedClassName,iconContainerClassName:n.iconContainerClassName,loginButtonClassName:n.loginButtonClassName,onLogin:()=>t(n.provider)},n.provider))}),s.jsx("div",{className:"pt-2 text-center text-sm text-muted-foreground",children:s.jsx("p",{children:"You can configure these later in Settings."})})]})}function FR({gitName:e,gitEmail:t,isSubmitting:n,onGitNameChange:r,onGitEmailChange:a}){return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"mb-8 text-center",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30",children:s.jsx(rr,{className:"h-8 w-8 text-blue-600 dark:text-blue-400"})}),s.jsx("h2",{className:"mb-2 text-2xl font-bold text-foreground",children:"Git Configuration"}),s.jsx("p",{className:"text-muted-foreground",children:"Configure your git identity to ensure proper attribution for commits."})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitName",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(wj,{className:"h-4 w-4"}),"Git Name ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",id:"gitName",value:e,onChange:i=>r(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"John Doe",required:!0,disabled:n}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.name`."})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"gitEmail",className:"mb-2 flex items-center gap-2 text-sm font-medium text-foreground",children:[s.jsx(yj,{className:"h-4 w-4"}),"Git Email ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",id:"gitEmail",value:t,onChange:i=>a(i.target.value),className:"w-full rounded-lg border border-border bg-background px-4 py-3 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"john@example.com",required:!0,disabled:n}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Saved as `git config --global user.email`."})]})]})]})}const ky=[{title:"Git Configuration",icon:rr,required:!0},{title:"Connect Agents",icon:JS,required:!1}];function zR({currentStep:e}){return s.jsx("div",{className:"mb-8",children:s.jsx("div",{className:"flex items-center justify-between",children:ky.map((t,n)=>{const r=n<e,a=n===e,i=t.icon;return s.jsxs("div",{className:"contents",children:[s.jsxs("div",{className:"flex flex-1 flex-col items-center",children:[s.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-full border-2 transition-colors duration-200 ${r?"border-green-500 bg-green-500 text-white":a?"border-blue-600 bg-blue-600 text-white":"border-border bg-background text-muted-foreground"}`,children:r?s.jsx(Ut,{className:"h-6 w-6"}):s.jsx(i,{className:"h-6 w-6"})}),s.jsxs("div",{className:"mt-2 text-center",children:[s.jsx("p",{className:`text-sm font-medium ${a?"text-foreground":"text-muted-foreground"}`,children:t.title}),t.required&&s.jsx("span",{className:"text-xs text-red-500",children:"Required"})]})]}),n<ky.length-1&&s.jsx("div",{className:`mx-2 h-0.5 flex-1 transition-colors duration-200 ${r?"bg-green-500":"bg-border"}`})]},t.title)})})})}const Sy=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ey=async(e,t)=>{try{return(await e.json()).error||t}catch{return t}};function BR({onComplete:e}){const[t,n]=f.useState(0),[r,a]=f.useState(""),[i,o]=f.useState(""),[l,c]=f.useState(!1),[u,d]=f.useState(""),[p,h]=f.useState(null),{providerAuthStatus:m,checkProviderAuthStatus:g,refreshProviderAuthStatuses:b}=p0(),x=f.useRef(void 0),y=f.useCallback(async()=>{try{const I=await we("/api/user/git-config");if(!I.ok)return;const N=await I.json();N.gitName&&a(N.gitName),N.gitEmail&&o(N.gitEmail)}catch(I){console.error("Error loading git config:",I)}},[]);f.useEffect(()=>{y(),b()},[y,b]),f.useEffect(()=>{const I=x.current;x.current=p,I!=null&&p===null&&b()},[p,b]);const v=I=>{h(I)},w=I=>{I===0&&p&&g(p)},S=async()=>{if(d(""),t!==0){n(I=>I+1);return}if(!r.trim()||!i.trim()){d("Both git name and email are required.");return}if(!Sy.test(i)){d("Please enter a valid email address.");return}c(!0);try{const I=await we("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:i})});if(!I.ok){const N=await Ey(I,"Failed to save git configuration");throw new Error(N)}n(N=>N+1)}catch(I){d(I instanceof Error?I.message:"Failed to save git configuration")}finally{c(!1)}},E=()=>{d(""),n(I=>I-1)},k=async()=>{c(!0),d("");try{const I=await we("/api/user/complete-onboarding",{method:"POST"});if(!I.ok){const N=await Ey(I,"Failed to complete onboarding");throw new Error(N)}await e?.()}catch(I){d(I instanceof Error?I.message:"Failed to complete onboarding")}finally{c(!1)}},A=t===0?!!(r.trim()&&i.trim()&&Sy.test(i)):!0;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"w-full max-w-2xl",children:[s.jsx(zR,{currentStep:t}),s.jsxs("div",{className:"rounded-lg border border-border bg-card p-8 shadow-lg",children:[t===0?s.jsx(FR,{gitName:r,gitEmail:i,isSubmitting:l,onGitNameChange:a,onGitEmailChange:o}):s.jsx(PR,{providerStatuses:m,onOpenProviderLogin:v}),u&&s.jsx("div",{className:"mt-6 rounded-lg border border-red-300 bg-red-100 p-4 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:u})}),s.jsxs("div",{className:"mt-8 flex items-center justify-between border-t border-border pt-6",children:[s.jsxs("button",{onClick:E,disabled:t===0||l,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-muted-foreground transition-colors duration-200 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(r0,{className:"h-4 w-4"}),"Previous"]}),s.jsx("div",{className:"flex items-center gap-3",children:t<1?s.jsx("button",{onClick:S,disabled:!A||l,className:"flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:cursor-not-allowed disabled:bg-blue-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(fn,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:["Next",s.jsx(Sr,{className:"h-4 w-4"})]})}):s.jsx("button",{onClick:k,disabled:l,className:"flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 font-medium text-white transition-colors duration-200 hover:bg-green-700 disabled:cursor-not-allowed disabled:bg-green-400",children:l?s.jsxs(s.Fragment,{children:[s.jsx(fn,{className:"h-4 w-4 animate-spin"}),"Completing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ut,{className:"h-4 w-4"}),"Complete Setup"]})})})]})]})]})}),p&&s.jsx(x5,{isOpen:!!p,onClose:()=>h(null),provider:p,onComplete:w})]})}const $R=["0s","0.1s","0.2s"];function UR(){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(xi,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"mb-2 text-2xl font-bold text-foreground",children:"Pixcode"}),s.jsx("div",{className:"flex items-center justify-center space-x-2",children:$R.map(e=>s.jsx("div",{className:"h-2 w-2 animate-bounce rounded-full bg-blue-500",style:{animationDelay:e}},e))}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:"Loading..."})]})})}function y5({errorMessage:e}){return e?s.jsx("div",{className:"rounded-md border border-red-300 bg-red-100 p-3 dark:border-red-800 dark:bg-red-900/20",children:s.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:e})}):null}function vo({id:e,label:t,value:n,onChange:r,placeholder:a,isDisabled:i,type:o="text",name:l,autoComplete:c}){return s.jsxs("div",{children:[s.jsx("label",{htmlFor:e,className:"mb-1 block text-sm font-medium text-foreground",children:t}),s.jsx("input",{id:e,type:o,name:l??e,autoComplete:c,value:n,onChange:u=>r(u.target.value),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-foreground focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:a,required:!0,disabled:i})]})}function v5({title:e,description:t,children:n,footerText:r,logo:a}){return s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:s.jsx("div",{className:"w-full max-w-md",children:s.jsxs("div",{className:"space-y-6 rounded-lg border border-border bg-card p-8 shadow-lg",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-4 flex justify-center",children:a??s.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-lg bg-primary shadow-sm",children:s.jsx(xi,{className:"h-8 w-8 text-primary-foreground"})})}),s.jsx("h1",{className:"text-2xl font-bold text-foreground",children:e}),s.jsx("p",{className:"mt-2 text-muted-foreground",children:t})]}),n,s.jsx("div",{className:"text-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:r})}),s.jsxs("div",{className:"flex items-center justify-center gap-1.5 pt-2",children:[s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.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 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 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.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),s.jsx("a",{href:"https://github.com/alicomert/pixcode",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground/50 transition-colors hover:text-muted-foreground",children:"Pixcode is open source"})]})]})})})}const GR={username:"",password:""};function HR(){const{t:e}=je("auth"),{login:t}=Zo(),[n,r]=f.useState(GR),[a,i]=f.useState(""),[o,l]=f.useState(!1),c=f.useCallback((d,p)=>{r(h=>({...h,[d]:p}))},[]),u=f.useCallback(async d=>{if(d.preventDefault(),i(""),!n.username.trim()||!n.password){i(e("login.errors.requiredFields"));return}l(!0);const p=await t(n.username.trim(),n.password);p.success||i(p.error),l(!1)},[n.password,n.username,t,e]);return s.jsx(v5,{title:e("login.title"),description:e("login.description"),footerText:"Enter your credentials to access Pixcode",children:s.jsxs("form",{onSubmit:u,className:"space-y-4",children:[s.jsx(vo,{id:"username",label:e("login.username"),value:n.username,onChange:d=>c("username",d),placeholder:e("login.placeholders.username"),isDisabled:o,autoComplete:"username"}),s.jsx(vo,{id:"password",label:e("login.password"),value:n.password,onChange:d=>c("password",d),placeholder:e("login.placeholders.password"),isDisabled:o,type:"password",autoComplete:"current-password"}),s.jsx(y5,{errorMessage:a}),s.jsx("button",{type:"submit",disabled:o,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:e(o?"login.loading":"login.submit")})]})})}const qR={username:"",password:"",confirmPassword:""};function VR(e){return!e.username.trim()||!e.password||!e.confirmPassword?"Please fill in all fields.":e.username.trim().length<3?"Username must be at least 3 characters long.":e.password.length<6?"Password must be at least 6 characters long.":e.password!==e.confirmPassword?"Passwords do not match.":null}function WR(){const{register:e}=Zo(),[t,n]=f.useState(qR),[r,a]=f.useState(""),[i,o]=f.useState(!1),l=f.useCallback((u,d)=>{n(p=>({...p,[u]:d}))},[]),c=f.useCallback(async u=>{u.preventDefault(),a("");const d=VR(t);if(d){a(d);return}o(!0);const p=await e(t.username.trim(),t.password);p.success||a(p.error),o(!1)},[t,e]);return s.jsx(v5,{title:"Welcome to Pixcode",description:"Set up your account to get started",footerText:"This is a single-user system. Only one account can be created.",logo:s.jsx("img",{src:"/logo.svg",alt:"Pixcode",className:"h-16 w-16"}),children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx(vo,{id:"username",name:"username",label:"Username",value:t.username,onChange:u=>l("username",u),placeholder:"Enter your username",isDisabled:i,autoComplete:"username"}),s.jsx(vo,{id:"password",name:"password",label:"Password",value:t.password,onChange:u=>l("password",u),placeholder:"Enter your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(vo,{id:"confirmPassword",name:"confirmPassword",label:"Confirm Password",value:t.confirmPassword,onChange:u=>l("confirmPassword",u),placeholder:"Confirm your password",isDisabled:i,type:"password",autoComplete:"new-password"}),s.jsx(y5,{errorMessage:r}),s.jsx("button",{type:"submit",disabled:i,className:"w-full rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors duration-200 hover:bg-blue-700 disabled:bg-blue-400",children:i?"Setting up...":"Create Account"})]})})}function KR({children:e}){const{user:t,isLoading:n,needsSetup:r,hasCompletedOnboarding:a,refreshOnboardingStatus:i}=Zo();return n?s.jsx(UR,{}):r?s.jsx(WR,{}):t?a?s.jsx(s.Fragment,{children:e}):s.jsx(BR,{onComplete:i}):s.jsx(HR,{})}const w5=f.createContext(null),k5=()=>{const e=f.useContext(w5);if(!e)throw new Error("useWebSocket must be used within a WebSocketProvider");return e},YR=e=>{const t=window.location.protocol==="https:"?"wss:":"ws:";return e?`${t}//${window.location.host}/ws?token=${encodeURIComponent(e)}`:null},ZR=()=>{const e=f.useRef(null),t=f.useRef(!1),n=f.useRef(!1),[r,a]=f.useState(null),[i,o]=f.useState(!1),l=f.useRef(null),{token:c}=Zo();f.useEffect(()=>(u(),()=>{t.current=!0,l.current&&clearTimeout(l.current),e.current&&e.current.close()}),[c]);const u=f.useCallback(()=>{if(!t.current)try{const h=YR(c);if(!h)return console.warn("No authentication token found for WebSocket connection");const m=new WebSocket(h);m.onopen=()=>{o(!0),e.current=m,n.current&&a({type:"websocket-reconnected",timestamp:Date.now()}),n.current=!0},m.onmessage=g=>{try{const b=JSON.parse(g.data);a(b)}catch(b){console.error("Error parsing WebSocket message:",b)}},m.onclose=()=>{o(!1),e.current=null,l.current=setTimeout(()=>{t.current||u()},3e3)},m.onerror=g=>{console.error("WebSocket error:",g)}}catch(h){console.error("Error creating WebSocket connection:",h)}},[c]),d=f.useCallback(h=>{const m=e.current;m&&m.readyState===WebSocket.OPEN?m.send(JSON.stringify(h)):console.warn("WebSocket not connected")},[]);return f.useMemo(()=>({ws:e.current,sendMessage:d,latestMessage:r,isConnected:i}),[d,r,i])},XR=({children:e})=>{const t=ZR();return s.jsx(w5.Provider,{value:t,children:e})},S5=f.createContext(null);function JR(e,t){return{message:t instanceof Error?t.message:`Failed to ${e}`,context:e,timestamp:new Date().toISOString()}}function Ny(e){return{...e,taskMasterConfigured:e.taskmaster?.hasTaskmaster??!1,taskMasterStatus:e.taskmaster?.status??"not-configured",taskCount:Number(e.taskmaster?.metadata?.taskCount??0),completedCount:Number(e.taskmaster?.metadata?.completed??0)}}function QR(e){return e.find(t=>t.status==="pending"||t.status==="in-progress")??null}function e9(e){return e?.type?e.type.startsWith("taskmaster-"):!1}function Ts(){const e=f.useContext(S5);if(!e)throw new Error("useTaskMaster must be used within a TaskMasterProvider");return e}function t9({children:e}){const{latestMessage:t}=k5(),{user:n,token:r,isLoading:a}=Zo(),[i,o]=f.useState([]),[l,c]=f.useState(null),[u,d]=f.useState(null),[p,h]=f.useState(null),[m,g]=f.useState([]),[b,x]=f.useState(null),[y,v]=f.useState(!1),[w,S]=f.useState(!1),[E,k]=f.useState(!1),[A,I]=f.useState(null),N=f.useRef(null);f.useEffect(()=>{N.current=l?.name??null},[l?.name]);const _=f.useCallback(()=>{I(null)},[]),R=f.useCallback((B,Y)=>{console.error(`TaskMaster ${B} error:`,Y),I(JR(B,Y))},[]),C=f.useCallback(B=>{const Y=B?Ny(B):null;c(Y),d(Y?.taskmaster??null),g([]),x(null)},[]),D=f.useCallback(async()=>{if(!n||!r){o([]),c(null),d(null),g([]),x(null);return}try{v(!0),_();const B=await et.get("/projects");if(!B.ok)throw new Error(`Failed to fetch projects: ${B.status}`);const Y=await B.json(),O=(Array.isArray(Y)?Y:[]).map(P=>Ny(P));o(O);const $=N.current;if(!$)return;const G=O.find(P=>P.name===$)??null;c(G),d(G?.taskmaster??null)}catch(B){R("load projects",B)}finally{v(!1)}},[_,R,r,n]),T=f.useCallback(async()=>{const B=l?.name;if(!B||!n||!r){g([]),x(null);return}try{S(!0),_();const Y=await et.get(`/taskmaster/tasks/${encodeURIComponent(B)}`);if(!Y.ok){const $=await Y.json();throw new Error($.message??"Failed to load tasks")}const q=await Y.json(),O=Array.isArray(q.tasks)?q.tasks:[];g(O),x(QR(O))}catch(Y){R("load tasks",Y),g([]),x(null)}finally{S(!1)}},[_,l?.name,R,r,n]),z=f.useCallback(async()=>{if(!n||!r){h(null);return}try{k(!0),_();const B=await et.get("/mcp-utils/taskmaster-server");if(!B.ok)throw new Error(`Failed to load MCP status: ${B.status}`);const Y=await B.json();h(Y)}catch(B){R("check MCP server status",B),h(null)}finally{k(!1)}},[_,R,r,n]);f.useEffect(()=>{!a&&n&&r&&(D(),z())},[a,z,D,r,n]),f.useEffect(()=>{l?.name&&n&&r&&T()},[l?.name,T,r,n]),f.useEffect(()=>{const B=t;if(e9(B)){if(B.type==="taskmaster-project-updated"&&B.projectName){D();return}if(B.type==="taskmaster-tasks-updated"&&B.projectName===l?.name){T();return}B.type==="taskmaster-mcp-status-changed"&&z()}},[l?.name,t,z,D,T]);const H=f.useMemo(()=>({projects:i,currentProject:l,projectTaskMaster:u,mcpServerStatus:p,tasks:m,nextTask:b,isLoading:y,isLoadingTasks:w,isLoadingMCP:E,error:A,refreshProjects:D,setCurrentProject:C,refreshTasks:T,refreshMCPStatus:z,clearError:_}),[_,l,A,y,E,w,p,b,u,i,z,D,T,C,m]);return s.jsx(S5.Provider,{value:H,children:e})}const E5=f.createContext({tasksEnabled:!0,setTasksEnabled:()=>{},toggleTasksEnabled:()=>{},isTaskMasterInstalled:null,isTaskMasterReady:null,installationStatus:null,isCheckingInstallation:!0}),Zc=()=>{const e=f.useContext(E5);if(!e)throw new Error("useTasksSettings must be used within a TasksSettingsProvider");return e},n9=({children:e})=>{const[t,n]=f.useState(()=>{const m=localStorage.getItem("tasks-enabled");return m!==null?JSON.parse(m):!0}),[r,a]=f.useState(null),[i,o]=f.useState(null),[l,c]=f.useState(null),[u,d]=f.useState(!0);f.useEffect(()=>{localStorage.setItem("tasks-enabled",JSON.stringify(t))},[t]),f.useEffect(()=>{setTimeout(async()=>{try{const g=await et.get("/taskmaster/installation-status");if(g.ok){const b=await g.json();c(b),a(b.installation?.isInstalled||!1),o(b.isReady||!1);const x=localStorage.getItem("tasks-enabled");!b.installation?.isInstalled&&!x&&n(!1)}else console.error("Failed to check TaskMaster installation status"),a(!1),o(!1)}catch(g){console.error("Error checking TaskMaster installation:",g),a(!1),o(!1)}finally{d(!1)}},0)},[]);const h={tasksEnabled:t,setTasksEnabled:n,toggleTasksEnabled:()=>{n(m=>!m)},isTaskMasterInstalled:r,isTaskMasterReady:i,installationStatus:l,isCheckingInstallation:u};return s.jsx(E5.Provider,{value:h,children:e})},N5=f.createContext(null);function Xc(){const e=f.useContext(N5);if(!e)throw new Error("usePlugins must be used within a PluginsProvider");return e}function r9({children:e}){const[t,n]=f.useState([]),[r,a]=f.useState(!0),[i,o]=f.useState(null),l=f.useCallback(async()=>{try{const h=await we("/api/plugins");if(h.ok){const m=await h.json();n(m.plugins||[]),o(null)}else{let m=`Failed to fetch plugins (${h.status})`;try{const g=await h.json();m=g.details||g.error||m}catch{m=h.statusText||m}o(m)}}catch(h){const m=h instanceof Error?h.message:"Failed to fetch plugins";o(m),console.error("[Plugins] Failed to fetch plugins:",h)}finally{a(!1)}},[]);f.useEffect(()=>{l()},[l]);const c=f.useCallback(async h=>{try{const m=await we("/api/plugins/install",{method:"POST",body:JSON.stringify({url:h})}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Install failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Install failed"}}},[l]),u=f.useCallback(async h=>{try{const m=await we(`/api/plugins/${encodeURIComponent(h)}`,{method:"DELETE"}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Uninstall failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Uninstall failed"}}},[l]),d=f.useCallback(async h=>{try{const m=await we(`/api/plugins/${encodeURIComponent(h)}/update`,{method:"POST"}),g=await m.json();return m.ok?(await l(),{success:!0}):{success:!1,error:g.details||g.error||"Update failed"}}catch(m){return{success:!1,error:m instanceof Error?m.message:"Update failed"}}},[l]),p=f.useCallback(async(h,m)=>{try{const g=await we(`/api/plugins/${encodeURIComponent(h)}/enable`,{method:"PUT",body:JSON.stringify({enabled:m})});if(!g.ok){let b=`Toggle failed (${g.status})`;try{const x=await g.json();b=x.details||x.error||b}catch{b=g.statusText||b}return{success:!1,error:b}}return await l(),{success:!0,error:null}}catch(g){return{success:!1,error:g instanceof Error?g.message:"Toggle failed"}}},[l]);return s.jsx(N5.Provider,{value:{plugins:t,loading:r,pluginsError:i,refreshPlugins:l,installPlugin:c,uninstallPlugin:u,updatePlugin:d,togglePlugin:p},children:e})}const Cy=e=>typeof window>"u"?!1:window.innerWidth<e,Ty=()=>{if(typeof window>"u")return!1;const e=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!e.standalone||document.referrer.includes("android-app://")};function m0(e={}){const{mobileBreakpoint:t=768,trackMobile:n=!0,trackPWA:r=!0}=e,[a,i]=f.useState(()=>n?Cy(t):!1),[o,l]=f.useState(()=>r?Ty():!1);return f.useEffect(()=>{if(!n||typeof window>"u")return;const c=()=>{i(Cy(t))};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},[t,n]),f.useEffect(()=>{if(!r||typeof window>"u")return;const c=window.matchMedia("(display-mode: standalone)"),u=()=>{l(Ty())};return u(),typeof c.addEventListener=="function"?(c.addEventListener("change",u),()=>{c.removeEventListener("change",u)}):(c.addListener(u),()=>{c.removeListener(u)})},[r]),{isMobile:a,isPWA:o}}const a9=(e,t)=>{const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let a=0;a<Math.max(n.length,r.length);a++){const i=n[a]||0,o=r[a]||0;if(i!==o)return i-o}return 0},i9="1.31.4",C5=(e,t)=>{const[n,r]=f.useState(!1),[a,i]=f.useState(null),[o,l]=f.useState(null),[c,u]=f.useState("git"),[d,p]=f.useState(i9);return f.useEffect(()=>{let h=!1;const m=async()=>{try{const x=await(await fetch("/health",{cache:"no-store"})).json();if(h)return;(x.installMode==="npm"||x.installMode==="git")&&u(x.installMode),typeof x.version=="string"&&/^\d+\.\d+\.\d+/.test(x.version)&&p(x.version)}catch{}};m();const g=()=>{m()};return window.addEventListener("focus",g),()=>{h=!0,window.removeEventListener("focus",g)}},[]),f.useEffect(()=>{if(!d)return;const h=async()=>{try{const b=await(await fetch(`https://api.github.com/repos/${e}/${t}/releases/latest`)).json();if(b.tag_name){const x=b.tag_name.replace(/^v/,"");i(x),r(a9(x,d)>0),l({title:b.name||b.tag_name,body:b.body||"",htmlUrl:b.html_url||`https://github.com/${e}/${t}/releases/latest`,publishedAt:b.published_at})}else r(!1),i(null),l(null)}catch(g){console.error("Version check failed:",g),r(!1),i(null),l(null)}};h();const m=setInterval(h,300*1e3);return()=>clearInterval(m)},[e,t,d]),{updateAvailable:n,latestVersion:a,currentVersion:d,releaseInfo:o,installMode:c}},ai={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0,historyView:"flat"},s9=["flat","grouped"],o9=e=>typeof e=="string"&&s9.includes(e),gc=Object.keys(ai),l9=new Set(gc),zu="ui-preferences:sync",c9=(e,t)=>{if(typeof e=="boolean")return e;if(typeof e=="string"){if(e==="true")return!0;if(e==="false")return!1}return t},bc=(e,t,n)=>e==="historyView"?o9(t)?t:n:c9(t,n),u9=(e,t)=>{try{const n=localStorage.getItem(e);if(n===null)return t;const r=JSON.parse(n);return bc(e,r,t)}catch{return t}},d9=e=>{if(typeof window>"u")return ai;try{const t=localStorage.getItem(e);if(t){const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n;return gc.reduce((a,i)=>(a[i]=bc(i,r[i],ai[i]),a),{...ai})}}}catch{}return gc.reduce((t,n)=>(t[n]=u9(n,ai[n]),t),{...ai})};function p9(e,t){switch(t.type){case"set":{const{key:n,value:r}=t;if(!l9.has(n))return e;const a=bc(n,r,e[n]);return e[n]===a?e:{...e,[n]:a}}case"set_many":{const n=t.value||{};let r=!1;const a={...e};for(const i of gc){if(!(i in n))continue;const o=n[i],l=bc(i,o,e[i]);a[i]!==l&&(a[i]=l,r=!0)}return r?a:e}case"reset":return{...ai,...t.value||{}};default:return e}}function h0(e="uiPreferences"){const t=f.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[n,r]=f.useReducer(p9,e,d9);return f.useEffect(()=>{typeof window>"u"||(localStorage.setItem(e,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(zu,{detail:{storageKey:e,sourceId:t.current,value:n}})))},[n,e]),f.useEffect(()=>{if(typeof window>"u")return;const l=d=>{!d||typeof d!="object"||Array.isArray(d)||r({type:"set_many",value:d})},c=d=>{if(!(d.key!==e||d.newValue===null))try{const p=JSON.parse(d.newValue);l(p)}catch{}},u=d=>{const h=d.detail;!h||h.storageKey!==e||h.sourceId===t.current||l(h.value)};return window.addEventListener("storage",c),window.addEventListener(zu,u),()=>{window.removeEventListener("storage",c),window.removeEventListener(zu,u)}},[e]),{preferences:n,setPreference:(l,c)=>{r({type:"set",key:l,value:c})},setPreferences:l=>{r({type:"set_many",value:l})},resetPreferences:l=>{r({type:"reset",value:l})},dispatch:r}}const m9=()=>{try{const e=localStorage.getItem("claude-settings");return e&&JSON.parse(e).projectSortOrder==="date"?"date":"name"}catch{return"name"}},h9=()=>{try{const e=localStorage.getItem("starredProjects");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},f9=e=>{try{localStorage.setItem("starredProjects",JSON.stringify([...e]))}catch{}},Ay=(e,t)=>`${e}::${t}`,g9=()=>{try{const e=localStorage.getItem("starredSessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},b9=e=>{try{localStorage.setItem("starredSessions",JSON.stringify([...e]))}catch{}},x9=/(?:^|[\s/\\(\[`"'])([\w./-]+?\.(?:ts|tsx|js|jsx|mjs|cjs|py|rb|go|rs|java|kt|swift|c|cc|cpp|h|hpp|cs|php|sh|bash|zsh|json|ya?ml|toml|md|mdx|html?|css|scss|less|sql|prisma|graphql|gql|vue|svelte|astro|dart|lua|r|pl|ps1|tf|dockerfile|env))(?:$|[\s:,)\]`"'])/i,y9=e=>{if(!e)return[];const t=new Set,n=new RegExp(x9.source,"gi");let r;for(;(r=n.exec(e))!==null;){const a=r[1],i=a.lastIndexOf(".");if(i>-1){const o=a.slice(i+1).toLowerCase();o&&o.length<=10&&t.add(o)}if(t.size>=3)break}return[...t]},ui=e=>e.__provider==="cursor"?new Date(e.createdAt||0):e.__provider==="codex"?new Date(e.createdAt||e.lastActivity||0):new Date(e.lastActivity||e.createdAt||0),v9=(e,t)=>e.__provider==="cursor"?e.summary||e.name||t("projects.untitledSession"):e.__provider==="codex"?e.summary||e.name||t("projects.codexSession"):e.__provider==="gemini"||e.__provider==="qwen"?e.summary||e.name||t("projects.newSession"):e.summary||t("projects.newSession"),w9=e=>e.__provider==="cursor"?String(e.createdAt||""):e.__provider==="codex"?String(e.createdAt||e.lastActivity||""):String(e.lastActivity||e.createdAt||""),k9=(e,t,n)=>{const r=ui(e),a=Math.floor((t.getTime()-r.getTime())/(1e3*60));return{isCursorSession:e.__provider==="cursor",isCodexSession:e.__provider==="codex",isGeminiSession:e.__provider==="gemini",isQwenSession:e.__provider==="qwen",isActive:a<10,sessionName:v9(e,n),sessionTime:w9(e),messageCount:Number(e.messageCount||0)}},T5=(e,t)=>{const n=[...e.sessions||[],...t[e.name]||[]].map(p=>({...p,__provider:"claude"})),r=(e.cursorSessions||[]).map(p=>({...p,__provider:"cursor"})),a=(e.codexSessions||[]).map(p=>({...p,__provider:"codex"})),i=p=>typeof p.id=="string"&&p.id.startsWith("qwen_")||p.provider==="qwen",o=e.geminiSessions||[],l=o.filter(p=>!i(p)).map(p=>({...p,__provider:"gemini"})),c=o.filter(p=>i(p)).map(p=>({...p,__provider:"qwen"})),u=[...(e.qwenSessions||[]).map(p=>({...p,__provider:"qwen"})),...c],d=new Map;for(const p of[...n,...r,...a,...l,...u])d.has(p.id)||d.set(p.id,p);return[...d.values()].sort((p,h)=>ui(h).getTime()-ui(p).getTime())},_y=(e,t)=>{const n=T5(e,t);return n.length===0?new Date(0):n.reduce((r,a)=>{const i=ui(a);return i>r?i:r},new Date(0))},S9=(e,t,n,r)=>{const a=[...e];return a.sort((i,o)=>{const l=n.has(i.name),c=n.has(o.name);return l&&!c?-1:!l&&c?1:t==="date"?_y(o,r).getTime()-_y(i,r).getTime():(i.displayName||i.name).localeCompare(o.displayName||o.name)}),a},E9=(e,t)=>{const n=t.trim().toLowerCase();return n?e.filter(r=>{const a=(r.displayName||r.name).toLowerCase(),i=r.name.toLowerCase();return a.includes(n)||i.includes(n)}):e},N9=(e,t)=>{const n=!!e.taskmaster?.hasTaskmaster,r=!!(t?.hasMCPServer&&t?.isConfigured);return n&&r?"fully-configured":n?"taskmaster-only":r?"mcp-only":"not-configured"},C9=e=>{const t=typeof e.fullPath=="string"&&e.fullPath.length>0?e.fullPath:typeof e.path=="string"?e.path:"";return{name:e.name,displayName:typeof e.displayName=="string"&&e.displayName.trim().length>0?e.displayName:e.name,fullPath:t,path:typeof e.path=="string"&&e.path.length>0?e.path:t}};function T9({projects:e,selectedProject:t,selectedSession:n,isLoading:r,isMobile:a,t:i,onRefresh:o,onProjectSelect:l,onSessionSelect:c,onSessionDelete:u,onProjectDelete:d,setCurrentProject:p,setSidebarVisible:h,sidebarVisible:m}){const[g,b]=f.useState(new Set),[x,y]=f.useState(null),[v,w]=f.useState(!1),[S,E]=f.useState(""),[k,A]=f.useState({}),[I,N]=f.useState({}),[_,R]=f.useState(new Set),[C,D]=f.useState(new Date),[T,z]=f.useState("name"),[H,B]=f.useState(!1),[Y,q]=f.useState({}),[O,$]=f.useState(null),[G,P]=f.useState(""),[ee,ne]=f.useState(""),[pe,le]=f.useState(new Set),[oe,he]=f.useState(null),[Te,_e]=f.useState(null),[De,Ge]=f.useState(!1),[M,me]=f.useState(()=>h9()),[ie,K]=f.useState(()=>g9()),[W,re]=f.useState("projects"),[xe,ue]=f.useState(null),[se,ve]=f.useState(!1),[Q,te]=f.useState(null),Z=f.useRef(null),ce=f.useRef(0),ye=f.useRef(null),Oe=!a&&!m;f.useEffect(()=>{const ge=setInterval(()=>{D(new Date)},6e4);return()=>clearInterval(ge)},[]),f.useEffect(()=>{N({}),R(new Set),q({})},[e]),f.useEffect(()=>{t&&b(ge=>{if(ge.has(t.name))return ge;const be=new Set(ge);return be.add(t.name),be})},[n,t]),f.useEffect(()=>{if(e.length>0&&!r){const ge=new Set;e.forEach(be=>{be.sessions&&be.sessions.length>=0&&ge.add(be.name)}),R(ge)}},[e,r]),f.useEffect(()=>{const ge=()=>{z(m9())};ge();const be=Be=>{Be.key==="claude-settings"&&ge()};window.addEventListener("storage",be);const Le=setInterval(()=>{document.hasFocus()&&ge()},1e3);return()=>{window.removeEventListener("storage",be),clearInterval(Le)}},[]),f.useEffect(()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null);const ge=ee.trim();if(W!=="conversations"||ge.length<2){ce.current+=1,ue(null),te(null),ve(!1);return}ve(!0);const be=++ce.current;return Z.current=setTimeout(()=>{if(be!==ce.current)return;const Le=et.searchConversationsUrl(ge),Be=new EventSource(Le);ye.current=Be;const Je=[];let We=0;Be.addEventListener("result",Vt=>{if(be!==ce.current){Be.close();return}try{const tn=JSON.parse(Vt.data);Je.push(tn.projectResult),We=tn.totalMatches,ue({results:[...Je],totalMatches:We,query:ge}),te({scannedProjects:tn.scannedProjects,totalProjects:tn.totalProjects})}catch{}}),Be.addEventListener("progress",Vt=>{if(be!==ce.current){Be.close();return}try{const tn=JSON.parse(Vt.data);We=tn.totalMatches,te({scannedProjects:tn.scannedProjects,totalProjects:tn.totalProjects})}catch{}}),Be.addEventListener("done",()=>{if(be!==ce.current){Be.close();return}Be.close(),ye.current=null,ve(!1),te(null),Je.length===0&&ue({results:[],totalMatches:0,query:ge})}),Be.addEventListener("error",()=>{if(be!==ce.current){Be.close();return}Be.close(),ye.current=null,ve(!1),te(null),Je.length===0&&ue({results:[],totalMatches:0,query:ge})})},400),()=>{Z.current&&clearTimeout(Z.current),ye.current&&(ye.current.close(),ye.current=null)}},[ee,W]),f.useCallback(ge=>be=>{const Le=be.target;Le.closest(".overflow-y-auto")||Le.closest("[data-scroll-container]")||(be.preventDefault(),be.stopPropagation(),ge())},[]);const $e=f.useCallback(ge=>{b(be=>{const Le=new Set;return be.has(ge)||Le.add(ge),Le})},[]),tt=f.useCallback((ge,be)=>{c({...ge,__projectName:be})},[c]),bt=f.useCallback(ge=>{me(be=>{const Le=new Set(be);return Le.has(ge)?Le.delete(ge):Le.add(ge),f9(Le),Le})},[]),Ve=f.useCallback(ge=>M.has(ge),[M]),ct=f.useCallback((ge,be)=>{K(Le=>{const Be=Ay(ge,be),Je=new Set(Le);return Je.has(Be)?Je.delete(Be):Je.add(Be),b9(Je),Je})},[]),Dt=f.useCallback((ge,be)=>ie.has(Ay(ge,be)),[ie]),Xe=f.useCallback(ge=>T5(ge,I),[I]),It=f.useMemo(()=>e.map(ge=>{const be=Y[ge.name];return be===void 0?ge:{...ge,sessionMeta:{...ge.sessionMeta,hasMore:be}}}),[Y,e]),gt=f.useMemo(()=>S9(It,T,M,I),[I,T,It,M]),Un=f.useMemo(()=>E9(gt,ee),[ee,gt]),en=f.useCallback(ge=>{y(ge.name),E(ge.displayName)},[]),vn=f.useCallback(()=>{y(null),E("")},[]),dn=f.useCallback(async ge=>{try{(await et.renameProject(ge,S)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(be){console.error("Error renaming project:",be)}finally{y(null),E("")}},[S]),Ie=f.useCallback((ge,be,Le,Be="claude")=>{_e({projectName:ge,sessionId:be,sessionTitle:Le,provider:Be})},[]),nt=f.useCallback(async()=>{if(!Te)return;const{projectName:ge,sessionId:be,provider:Le}=Te;_e(null);try{let Be;if(Le==="codex"?Be=await et.deleteCodexSession(be):Le==="gemini"?Be=await et.deleteGeminiSession(be):Le==="qwen"?Be=await et.deleteQwenSession(be):Be=await et.deleteSession(ge,be),Be.ok)u?.(be);else{const Je=await Be.text();console.error("[Sidebar] Failed to delete session:",{status:Be.status,error:Je}),alert(i("messages.deleteSessionFailed"))}}catch(Be){console.error("[Sidebar] Error deleting session:",Be),alert(i("messages.deleteSessionError"))}},[u,Te,i]),Qe=f.useCallback(ge=>{he({project:ge,sessionCount:Xe(ge).length})},[Xe]),pt=f.useCallback(async(ge=!1)=>{if(!oe)return;const{project:be,sessionCount:Le}=oe,Be=Le===0;he(null),le(Je=>new Set([...Je,be.name]));try{const Je=await et.deleteProject(be.name,!Be,ge);if(Je.ok)d?.(be.name);else{const We=await Je.json();alert(We.error||i("messages.deleteProjectFailed"))}}catch(Je){console.error("Error deleting project:",Je),alert(i("messages.deleteProjectError"))}finally{le(Je=>{const We=new Set(Je);return We.delete(be.name),We})}},[oe,d,i]),Nt=f.useCallback(async ge=>{const be=Y[ge.name];if(!(!(be!==void 0?be:ge.sessionMeta?.hasMore===!0)||k[ge.name])){A(Be=>({...Be,[ge.name]:!0}));try{const Be=(ge.sessions?.length||0)+(I[ge.name]?.length||0),Je=await et.sessions(ge.name,5,Be);if(!Je.ok)return;const We=await Je.json();N(Vt=>({...Vt,[ge.name]:[...Vt[ge.name]||[],...We.sessions||[]]})),We.hasMore===!1&&q(Vt=>({...Vt,[ge.name]:!1}))}catch(Be){console.error("Error loading more sessions:",Be)}finally{A(Be=>({...Be,[ge.name]:!1}))}}},[I,k,Y]),Ct=f.useCallback(ge=>{l(ge),p(ge)},[l,p]),xr=f.useCallback(async()=>{B(!0);try{await o()}finally{B(!1)}},[o]),ir=f.useCallback(async(ge,be,Le,Be)=>{const Je=Le.trim();if(!Je){$(null),P("");return}try{const We=await et.renameSession(be,Je,Be);We.ok?await o():(console.error("[Sidebar] Failed to rename session:",We.status),alert(i("messages.renameSessionFailed")))}catch(We){console.error("[Sidebar] Error renaming session:",We),alert(i("messages.renameSessionError"))}finally{$(null),P("")}},[o,i]),sr=f.useCallback(()=>{h(!1)},[h]),Ee=f.useCallback(()=>{h(!0)},[h]);return{isSidebarCollapsed:Oe,expandedProjects:g,editingProject:x,showNewProject:v,editingName:S,loadingSessions:k,additionalSessions:I,initialSessionsLoaded:_,currentTime:C,projectSortOrder:T,isRefreshing:H,editingSession:O,editingSessionName:G,searchFilter:ee,deletingProjects:pe,deleteConfirmation:oe,sessionDeleteConfirmation:Te,showVersionModal:De,starredProjects:M,starredSessions:ie,filteredProjects:Un,toggleProject:$e,handleSessionClick:tt,toggleStarProject:bt,isProjectStarred:Ve,toggleStarSession:ct,isSessionStarred:Dt,getProjectSessions:Xe,startEditing:en,cancelEditing:vn,saveProjectName:dn,showDeleteSessionConfirmation:Ie,confirmDeleteSession:nt,requestProjectDelete:Qe,confirmDeleteProject:pt,loadMoreSessions:Nt,handleProjectSelect:Ct,refreshProjects:xr,updateSessionSummary:ir,collapseSidebar:sr,expandSidebar:Ee,setShowNewProject:w,setEditingName:E,setEditingSession:$,setEditingSessionName:P,searchMode:W,setSearchMode:re,conversationResults:xe,isSearching:se,searchProgress:Q,clearConversationResults:f.useCallback(()=>{ce.current+=1,ye.current&&(ye.current.close(),ye.current=null),ve(!1),te(null),ue(null)},[]),setSearchFilter:ne,setDeleteConfirmation:he,setSessionDeleteConfirmation:_e,setShowVersionModal:Ge}}const A9="https://discord.gg/buxwujPNRE",_9="https://github.com/alicomert/pixcode/issues/new";function I9({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function j9({onExpand:e,onShowSettings:t,updateAvailable:n,onShowVersionModal:r,t:a}){return s.jsxs("div",{className:"flex h-full w-12 flex-col items-center gap-1 bg-background/80 py-3 backdrop-blur-sm",children:[s.jsx("button",{onClick:e,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.showSidebar"),title:a("common:versionUpdate.ariaLabels.showSidebar"),children:s.jsx(ZI,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("div",{className:"nav-divider my-1 w-6"}),s.jsx("button",{onClick:t,className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.settings"),title:a("actions.settings"),children:s.jsx(wt,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:_9,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.reportIssue"),title:a("actions.reportIssue"),children:s.jsx(Dp,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),s.jsx("a",{href:A9,target:"_blank",rel:"noopener noreferrer",className:"group flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("actions.joinCommunity"),title:a("actions.joinCommunity"),children:s.jsx(I9,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})}),n&&s.jsxs("button",{onClick:r,className:"relative flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-accent/80","aria-label":a("common:versionUpdate.ariaLabels.updateAvailable"),title:a("common:versionUpdate.ariaLabels.updateAvailable"),children:[s.jsx(ia,{className:"h-4 w-4 text-blue-500"}),s.jsx("span",{className:"absolute right-1.5 top-1.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]})]})}function A5(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=A5(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function _5(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=A5(e))&&(r&&(r+=" "),r+=t);return r}const Iy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jy=_5,f0=(e,t)=>n=>{var r;if(t?.variants==null)return jy(e,n?.class,n?.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(u=>{const d=n?.[u],p=i?.[u];if(d===null)return null;const h=Iy(d)||Iy(p);return a[u][h]}),l=n&&Object.entries(n).reduce((u,d)=>{let[p,h]=d;return h===void 0||(u[p]=h),u},{}),c=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,d)=>{let{class:p,className:h,...m}=d;return Object.entries(m).every(g=>{let[b,x]=g;return Array.isArray(x)?x.includes({...i,...l}[b]):{...i,...l}[b]===x})?[...u,p,h]:u},[]);return jy(e,o,c,n?.class,n?.className)},g0="-",R9=e=>{const t=L9(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{const l=o.split(g0);return l[0]===""&&l.length!==1&&l.shift(),I5(l,t)||D9(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&r[o]?[...c,...r[o]]:c}}},I5=(e,t)=>{if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),a=r?I5(e.slice(1),r):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(g0);return t.validators.find(({validator:o})=>o(i))?.classGroupId},Ry=/^\[(.+)\]$/,D9=e=>{if(Ry.test(e)){const t=Ry.exec(e)[1],n=t?.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},L9=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const a in n)zp(n[a],r,a,t);return r},zp=(e,t,n,r)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:Dy(t,a);i.classGroupId=n;return}if(typeof a=="function"){if(O9(a)){zp(a(r),t,n,r);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([i,o])=>{zp(o,Dy(t,i),n,r)})})},Dy=(e,t)=>{let n=e;return t.split(g0).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},O9=e=>e.isThemeGetter,M9=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const a=(i,o)=>{n.set(i,o),t++,t>e&&(t=0,r=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=r.get(i))!==void 0)return a(i,o),o},set(i,o){n.has(i)?n.set(i,o):a(i,o)}}},Bp="!",$p=":",P9=$p.length,F9=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const i=[];let o=0,l=0,c=0,u;for(let g=0;g<a.length;g++){let b=a[g];if(o===0&&l===0){if(b===$p){i.push(a.slice(c,g)),c=g+P9;continue}if(b==="/"){u=g;continue}}b==="["?o++:b==="]"?o--:b==="("?l++:b===")"&&l--}const d=i.length===0?a:a.substring(c),p=z9(d),h=p!==d,m=u&&u>c?u-c:void 0;return{modifiers:i,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};if(t){const a=t+$p,i=r;r=o=>o.startsWith(a)?i(o.substring(a.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(n){const a=r;r=i=>n({className:i,parseClassName:a})}return r},z9=e=>e.endsWith(Bp)?e.substring(0,e.length-1):e.startsWith(Bp)?e.substring(1):e,B9=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const a=[];let i=[];return r.forEach(o=>{o[0]==="["||t[o]?(a.push(...i.sort(),o),i=[]):i.push(o)}),a.push(...i.sort()),a}},$9=e=>({cache:M9(e.cacheSize),parseClassName:F9(e),sortModifiers:B9(e),...R9(e)}),U9=/\s+/,G9=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:i}=t,o=[],l=e.trim().split(U9);let c="";for(let u=l.length-1;u>=0;u-=1){const d=l[u],{isExternal:p,modifiers:h,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:b}=n(d);if(p){c=d+(c.length>0?" "+c:c);continue}let x=!!b,y=r(x?g.substring(0,b):g);if(!y){if(!x){c=d+(c.length>0?" "+c:c);continue}if(y=r(g),!y){c=d+(c.length>0?" "+c:c);continue}x=!1}const v=i(h).join(":"),w=m?v+Bp:v,S=w+y;if(o.includes(S))continue;o.push(S);const E=a(y,x);for(let k=0;k<E.length;++k){const A=E[k];o.push(w+A)}c=d+(c.length>0?" "+c:c)}return c};function H9(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=j5(t))&&(r&&(r+=" "),r+=n);return r}const j5=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=j5(e[r]))&&(n&&(n+=" "),n+=t);return n};function q9(e,...t){let n,r,a,i=o;function o(c){const u=t.reduce((d,p)=>p(d),e());return n=$9(u),r=n.cache.get,a=n.cache.set,i=l,l(c)}function l(c){const u=r(c);if(u)return u;const d=G9(c,n);return a(c,d),d}return function(){return i(H9.apply(null,arguments))}}const Xt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},R5=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,D5=/^\((?:(\w[\w-]*):)?(.+)\)$/i,V9=/^\d+\/\d+$/,W9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,K9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Y9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Z9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,X9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zi=e=>V9.test(e),it=e=>!!e&&!Number.isNaN(Number(e)),xa=e=>!!e&&Number.isInteger(Number(e)),Bu=e=>e.endsWith("%")&&it(e.slice(0,-1)),Kr=e=>W9.test(e),J9=()=>!0,Q9=e=>K9.test(e)&&!Y9.test(e),L5=()=>!1,eD=e=>Z9.test(e),tD=e=>X9.test(e),nD=e=>!Fe(e)&&!ze(e),rD=e=>As(e,P5,L5),Fe=e=>R5.test(e),Za=e=>As(e,F5,Q9),$u=e=>As(e,lD,it),Ly=e=>As(e,O5,L5),aD=e=>As(e,M5,tD),fl=e=>As(e,z5,eD),ze=e=>D5.test(e),Ys=e=>_s(e,F5),iD=e=>_s(e,cD),Oy=e=>_s(e,O5),sD=e=>_s(e,P5),oD=e=>_s(e,M5),gl=e=>_s(e,z5,!0),As=(e,t,n)=>{const r=R5.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},_s=(e,t,n=!1)=>{const r=D5.exec(e);return r?r[1]?t(r[1]):n:!1},O5=e=>e==="position"||e==="percentage",M5=e=>e==="image"||e==="url",P5=e=>e==="length"||e==="size"||e==="bg-size",F5=e=>e==="length",lD=e=>e==="number",cD=e=>e==="family-name",z5=e=>e==="shadow",uD=()=>{const e=Xt("color"),t=Xt("font"),n=Xt("text"),r=Xt("font-weight"),a=Xt("tracking"),i=Xt("leading"),o=Xt("breakpoint"),l=Xt("container"),c=Xt("spacing"),u=Xt("radius"),d=Xt("shadow"),p=Xt("inset-shadow"),h=Xt("text-shadow"),m=Xt("drop-shadow"),g=Xt("blur"),b=Xt("perspective"),x=Xt("aspect"),y=Xt("ease"),v=Xt("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...S(),ze,Fe],k=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],I=()=>[ze,Fe,c],N=()=>[zi,"full","auto",...I()],_=()=>[xa,"none","subgrid",ze,Fe],R=()=>["auto",{span:["full",xa,ze,Fe]},xa,ze,Fe],C=()=>[xa,"auto",ze,Fe],D=()=>["auto","min","max","fr",ze,Fe],T=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...I()],B=()=>[zi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],Y=()=>[e,ze,Fe],q=()=>[...S(),Oy,Ly,{position:[ze,Fe]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",sD,rD,{size:[ze,Fe]}],G=()=>[Bu,Ys,Za],P=()=>["","none","full",u,ze,Fe],ee=()=>["",it,Ys,Za],ne=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],le=()=>[it,Bu,Oy,Ly],oe=()=>["","none",g,ze,Fe],he=()=>["none",it,ze,Fe],Te=()=>["none",it,ze,Fe],_e=()=>[it,ze,Fe],De=()=>[zi,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Kr],breakpoint:[Kr],color:[J9],container:[Kr],"drop-shadow":[Kr],ease:["in","out","in-out"],font:[nD],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Kr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Kr],shadow:[Kr],spacing:["px",it],text:[Kr],"text-shadow":[Kr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zi,Fe,ze,x]}],container:["container"],columns:[{columns:[it,Fe,ze,l]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{start:N()}],end:[{end:N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[xa,"auto",ze,Fe]}],basis:[{basis:[zi,"full","auto",l,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[it,zi,"auto","initial","none",Fe]}],grow:[{grow:["",it,ze,Fe]}],shrink:[{shrink:["",it,ze,Fe]}],order:[{order:[xa,"first","last","none",ze,Fe]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":C()}],"col-end":[{"col-end":C()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":C()}],"row-end":[{"row-end":C()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...T(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...T()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":T()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[l,"screen",...B()]}],"min-w":[{"min-w":[l,"screen","none",...B()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,Ys,Za]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ze,$u]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Bu,Fe]}],"font-family":[{font:[iD,Fe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,ze,Fe]}],"line-clamp":[{"line-clamp":[it,"none",ze,$u]}],leading:[{leading:[i,...I()]}],"list-image":[{"list-image":["none",ze,Fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ze,Fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Y()}],"text-color":[{text:Y()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[it,"from-font","auto",ze,Za]}],"text-decoration-color":[{decoration:Y()}],"underline-offset":[{"underline-offset":[it,"auto",ze,Fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ze,Fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ze,Fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:q()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xa,ze,Fe],radial:["",ze,Fe],conic:[xa,ze,Fe]},oD,aD]}],"bg-color":[{bg:Y()}],"gradient-from-pos":[{from:G()}],"gradient-via-pos":[{via:G()}],"gradient-to-pos":[{to:G()}],"gradient-from":[{from:Y()}],"gradient-via":[{via:Y()}],"gradient-to":[{to:Y()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:ee()}],"border-w-x":[{"border-x":ee()}],"border-w-y":[{"border-y":ee()}],"border-w-s":[{"border-s":ee()}],"border-w-e":[{"border-e":ee()}],"border-w-t":[{"border-t":ee()}],"border-w-r":[{"border-r":ee()}],"border-w-b":[{"border-b":ee()}],"border-w-l":[{"border-l":ee()}],"divide-x":[{"divide-x":ee()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ee()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:Y()}],"border-color-x":[{"border-x":Y()}],"border-color-y":[{"border-y":Y()}],"border-color-s":[{"border-s":Y()}],"border-color-e":[{"border-e":Y()}],"border-color-t":[{"border-t":Y()}],"border-color-r":[{"border-r":Y()}],"border-color-b":[{"border-b":Y()}],"border-color-l":[{"border-l":Y()}],"divide-color":[{divide:Y()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[it,ze,Fe]}],"outline-w":[{outline:["",it,Ys,Za]}],"outline-color":[{outline:Y()}],shadow:[{shadow:["","none",d,gl,fl]}],"shadow-color":[{shadow:Y()}],"inset-shadow":[{"inset-shadow":["none",p,gl,fl]}],"inset-shadow-color":[{"inset-shadow":Y()}],"ring-w":[{ring:ee()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Y()}],"ring-offset-w":[{"ring-offset":[it,Za]}],"ring-offset-color":[{"ring-offset":Y()}],"inset-ring-w":[{"inset-ring":ee()}],"inset-ring-color":[{"inset-ring":Y()}],"text-shadow":[{"text-shadow":["none",h,gl,fl]}],"text-shadow-color":[{"text-shadow":Y()}],opacity:[{opacity:[it,ze,Fe]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[it]}],"mask-image-linear-from-pos":[{"mask-linear-from":le()}],"mask-image-linear-to-pos":[{"mask-linear-to":le()}],"mask-image-linear-from-color":[{"mask-linear-from":Y()}],"mask-image-linear-to-color":[{"mask-linear-to":Y()}],"mask-image-t-from-pos":[{"mask-t-from":le()}],"mask-image-t-to-pos":[{"mask-t-to":le()}],"mask-image-t-from-color":[{"mask-t-from":Y()}],"mask-image-t-to-color":[{"mask-t-to":Y()}],"mask-image-r-from-pos":[{"mask-r-from":le()}],"mask-image-r-to-pos":[{"mask-r-to":le()}],"mask-image-r-from-color":[{"mask-r-from":Y()}],"mask-image-r-to-color":[{"mask-r-to":Y()}],"mask-image-b-from-pos":[{"mask-b-from":le()}],"mask-image-b-to-pos":[{"mask-b-to":le()}],"mask-image-b-from-color":[{"mask-b-from":Y()}],"mask-image-b-to-color":[{"mask-b-to":Y()}],"mask-image-l-from-pos":[{"mask-l-from":le()}],"mask-image-l-to-pos":[{"mask-l-to":le()}],"mask-image-l-from-color":[{"mask-l-from":Y()}],"mask-image-l-to-color":[{"mask-l-to":Y()}],"mask-image-x-from-pos":[{"mask-x-from":le()}],"mask-image-x-to-pos":[{"mask-x-to":le()}],"mask-image-x-from-color":[{"mask-x-from":Y()}],"mask-image-x-to-color":[{"mask-x-to":Y()}],"mask-image-y-from-pos":[{"mask-y-from":le()}],"mask-image-y-to-pos":[{"mask-y-to":le()}],"mask-image-y-from-color":[{"mask-y-from":Y()}],"mask-image-y-to-color":[{"mask-y-to":Y()}],"mask-image-radial":[{"mask-radial":[ze,Fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":le()}],"mask-image-radial-to-pos":[{"mask-radial-to":le()}],"mask-image-radial-from-color":[{"mask-radial-from":Y()}],"mask-image-radial-to-color":[{"mask-radial-to":Y()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":S()}],"mask-image-conic-pos":[{"mask-conic":[it]}],"mask-image-conic-from-pos":[{"mask-conic-from":le()}],"mask-image-conic-to-pos":[{"mask-conic-to":le()}],"mask-image-conic-from-color":[{"mask-conic-from":Y()}],"mask-image-conic-to-color":[{"mask-conic-to":Y()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:q()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ze,Fe]}],filter:[{filter:["","none",ze,Fe]}],blur:[{blur:oe()}],brightness:[{brightness:[it,ze,Fe]}],contrast:[{contrast:[it,ze,Fe]}],"drop-shadow":[{"drop-shadow":["","none",m,gl,fl]}],"drop-shadow-color":[{"drop-shadow":Y()}],grayscale:[{grayscale:["",it,ze,Fe]}],"hue-rotate":[{"hue-rotate":[it,ze,Fe]}],invert:[{invert:["",it,ze,Fe]}],saturate:[{saturate:[it,ze,Fe]}],sepia:[{sepia:["",it,ze,Fe]}],"backdrop-filter":[{"backdrop-filter":["","none",ze,Fe]}],"backdrop-blur":[{"backdrop-blur":oe()}],"backdrop-brightness":[{"backdrop-brightness":[it,ze,Fe]}],"backdrop-contrast":[{"backdrop-contrast":[it,ze,Fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",it,ze,Fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[it,ze,Fe]}],"backdrop-invert":[{"backdrop-invert":["",it,ze,Fe]}],"backdrop-opacity":[{"backdrop-opacity":[it,ze,Fe]}],"backdrop-saturate":[{"backdrop-saturate":[it,ze,Fe]}],"backdrop-sepia":[{"backdrop-sepia":["",it,ze,Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ze,Fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[it,"initial",ze,Fe]}],ease:[{ease:["linear","initial",y,ze,Fe]}],delay:[{delay:[it,ze,Fe]}],animate:[{animate:["none",v,ze,Fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,ze,Fe]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:Te()}],"scale-x":[{"scale-x":Te()}],"scale-y":[{"scale-y":Te()}],"scale-z":[{"scale-z":Te()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[ze,Fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:De()}],"translate-x":[{"translate-x":De()}],"translate-y":[{"translate-y":De()}],"translate-z":[{"translate-z":De()}],"translate-none":["translate-none"],accent:[{accent:Y()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Y()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ze,Fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ze,Fe]}],fill:[{fill:["none",...Y()]}],"stroke-w":[{stroke:[it,Ys,Za,$u]}],stroke:[{stroke:["none",...Y()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},dD=q9(uD);function fe(...e){return dD(_5(e))}function pD(e){if(!e||typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}const mD=f0("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}}),B5=f.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert","data-slot":"alert",className:fe(mD({variant:t}),e),...n}));B5.displayName="Alert";const hD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"alert-title",className:fe("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t}));hD.displayName="AlertTitle";const fD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"alert-description",className:fe("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t}));fD.displayName="AlertDescription";const gD=f0("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function is({className:e,variant:t,...n}){return s.jsx("div",{className:fe(gD({variant:t}),e),...n})}const bD=f0("inline-flex touch-manipulation items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 active:bg-primary/80",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 active:bg-destructive/80",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent/80",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 active:bg-secondary/70",ghost:"hover:bg-accent hover:text-accent-foreground active:bg-accent/80",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3 text-sm",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Pe=f.forwardRef(({className:e,variant:t,size:n,...r},a)=>s.jsx("button",{className:fe(bD({variant:t,size:n,className:e})),ref:a,...r}));Pe.displayName="Button";const $5=f.createContext(null),U5=()=>{const e=f.useContext($5);if(!e)throw new Error("Confirmation components must be used within Confirmation");return e},G5=({className:e,approval:t="pending",children:n,...r})=>{const a=f.useMemo(()=>({approval:t}),[t]);return s.jsx($5.Provider,{value:a,children:s.jsx(B5,{className:fe("flex flex-col gap-2",e),...r,children:n})})};G5.displayName="Confirmation";const H5=({className:e,...t})=>s.jsx("div",{"data-slot":"confirmation-title",className:fe("text-muted-foreground inline text-sm",e),...t});H5.displayName="ConfirmationTitle";const q5=({children:e})=>{const{approval:t}=U5();return t!=="pending"?null:s.jsx(s.Fragment,{children:e})};q5.displayName="ConfirmationRequest";const V5=({className:e,...t})=>{const{approval:n}=U5();return n!=="pending"?null:s.jsx("div",{"data-slot":"confirmation-actions",className:fe("flex items-center justify-end gap-2 self-end",e),...t})};V5.displayName="ConfirmationActions";const Yl=({variant:e="default",...t})=>s.jsx(Pe,{className:"h-8 px-3 text-sm",variant:e,type:"button",...t});Yl.displayName="ConfirmationAction";const W5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("rounded-xl border bg-card text-card-foreground shadow-sm",e),...t}));W5.displayName="Card";const K5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex flex-col space-y-1.5 p-4",e),...t}));K5.displayName="CardHeader";const Y5=f.forwardRef(({className:e,...t},n)=>s.jsx("h3",{ref:n,className:fe("font-semibold leading-none tracking-tight",e),...t}));Y5.displayName="CardTitle";const xD=f.forwardRef(({className:e,...t},n)=>s.jsx("p",{ref:n,className:fe("text-sm text-muted-foreground",e),...t}));xD.displayName="CardDescription";const Z5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("p-4 pt-0",e),...t}));Z5.displayName="CardContent";const X5=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("flex items-center p-4 pt-0",e),...t}));X5.displayName="CardFooter";const yD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("ml-auto shrink-0",e),...t}));yD.displayName="CardAction";const J5=f.createContext(null);function Q5(){const e=f.useContext(J5);if(!e)throw new Error("Collapsible components must be used within <Collapsible>");return e}const vi=f.forwardRef(({defaultOpen:e=!1,open:t,onOpenChange:n,className:r,children:a,...i},o)=>{const[l,c]=f.useState(e),u=t!==void 0,d=u?t:l,p=f.useCallback(m=>{u||c(m),n?.(m)},[u,n]),h=f.useMemo(()=>({open:d,onOpenChange:p}),[d,p]);return s.jsx(J5.Provider,{value:h,children:s.jsx("div",{ref:o,"data-state":d?"open":"closed",className:r,...i,children:a})})});vi.displayName="Collapsible";const Oa=f.forwardRef(({onClick:e,children:t,className:n,...r},a)=>{const{open:i,onOpenChange:o}=Q5(),l=f.useCallback(c=>{o(!i),e?.(c)},[i,o,e]);return s.jsx("button",{ref:a,type:"button","aria-expanded":i,"data-state":i?"open":"closed",onClick:l,className:n,...r,children:t})});Oa.displayName="CollapsibleTrigger";const wi=f.forwardRef(({className:e,children:t,...n},r)=>{const{open:a}=Q5();return s.jsx("div",{ref:r,"data-state":a?"open":"closed",className:fe("grid transition-[grid-template-rows] duration-200 ease-out",a?"grid-rows-[1fr]":"grid-rows-[0fr]",e),...n,children:s.jsx("div",{className:"overflow-hidden",children:t})})});wi.displayName="CollapsibleContent";const e4=f.createContext(null);function b0(){const e=f.useContext(e4);if(!e)throw new Error("Command components must be used within <Command>");return e}const t4=f.forwardRef(({className:e,children:t,...n},r)=>{const[a,i]=f.useState(""),o=f.useRef(new Map),[l,c]=f.useState(0),u=f.useCallback(v=>{o.current.set(v.id,v),c(w=>w+1)},[]),d=f.useCallback(v=>{o.current.delete(v),c(w=>w+1)},[]),p=f.useCallback((v,w)=>{const S=o.current.get(v);S&&Object.assign(S,w)},[]),h=f.useMemo(()=>{const v=a.toLowerCase(),w=new Set;for(const[S,E]of o.current)(!v||E.value.includes(v))&&w.add(S);return w},[a,l]),m=f.useMemo(()=>{const v=[];for(const[,w]of o.current)h.has(w.id)&&v.push(w);return v},[h]),[g,b]=f.useState(null);f.useEffect(()=>{b(m.length>0?m[0].id:null)},[m]);const x=f.useCallback(v=>{if(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="Enter")v.preventDefault();else return;const w=m;if(w.length===0)return;if(v.key==="Enter"){w.find(N=>N.id===g)?.onSelect();return}const S=w.findIndex(I=>I.id===g);let E;v.key==="ArrowDown"?E=S<w.length-1?S+1:0:E=S>0?S-1:w.length-1;const k=w[E].id;b(k),w[E].element?.scrollIntoView({block:"nearest"})},[m,g]),y=f.useMemo(()=>({search:a,setSearch:i,visibleIds:h,activeId:g,setActiveId:b,register:u,unregister:d,updateEntry:p}),[a,h,g,u,d,p]);return s.jsx(e4.Provider,{value:y,children:s.jsx("div",{ref:r,role:"combobox","aria-expanded":"true","aria-haspopup":"listbox",className:fe("flex flex-col",e),onKeyDown:x,...n,children:t})})});t4.displayName="Command";const n4=f.forwardRef(({className:e,placeholder:t="Search...",...n},r)=>{const{search:a,setSearch:i}=b0();return s.jsxs("div",{className:"flex items-center border-b px-3",role:"presentation",children:[s.jsx(aa,{className:"mr-2 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("input",{ref:r,type:"text",role:"searchbox","aria-autocomplete":"list",autoComplete:"off",autoCorrect:"off",spellCheck:!1,value:a,onChange:o=>i(o.target.value),placeholder:t,className:fe("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...n})]})});n4.displayName="CommandInput";const r4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,role:"listbox",className:fe("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));r4.displayName="CommandList";const a4=f.forwardRef(({className:e,...t},n)=>{const{search:r,visibleIds:a}=b0();return!r||a.size>0?null:s.jsx("div",{ref:n,className:fe("py-6 text-center text-sm text-muted-foreground",e),...t})});a4.displayName="CommandEmpty";const i4=f.forwardRef(({className:e,heading:t,children:n,...r},a)=>s.jsxs("div",{ref:a,className:fe("overflow-hidden p-1",e),role:"group","aria-label":typeof t=="string"?t:void 0,...r,children:[t&&s.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground",role:"presentation",children:t}),n]}));i4.displayName="CommandGroup";const s4=f.forwardRef(({className:e,value:t,onSelect:n,disabled:r,children:a,...i},o)=>{const{visibleIds:l,activeId:c,setActiveId:u,register:d,unregister:p,updateEntry:h}=b0(),m=f.useId(),g=f.useRef(null),b=t||(typeof a=="string"?a:"");f.useEffect(()=>(d({id:m,value:b.toLowerCase(),onSelect:n||(()=>{}),element:g.current}),()=>p(m)),[m,b,d,p]),f.useEffect(()=>{h(m,{onSelect:n||(()=>{})})},[m,n,h]);const x=f.useCallback(v=>{g.current=v,h(m,{element:v}),typeof o=="function"?o(v):o&&(o.current=v)},[m,h,o]);if(!l.has(m))return null;const y=c===m;return s.jsx("div",{ref:x,role:"option","aria-selected":y,"aria-disabled":r||void 0,"data-active":y||void 0,className:fe("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",y&&"bg-accent text-accent-foreground",r&&"pointer-events-none opacity-50",e),onPointerMove:()=>{!r&&c!==m&&u(m)},onClick:()=>!r&&n?.(),...i,children:a})});s4.displayName="CommandItem";const vD=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:fe("-mx-1 h-px bg-border",e),...t}));vD.displayName="CommandSeparator";function Up({checked:e,onToggle:t,ariaLabel:n="Toggle dark mode"}){const{isDarkMode:r,toggleDarkMode:a}=Cs(),i=typeof e=="boolean"&&typeof t=="function",o=i?e:r,l=()=>{if(i&&t){t(!o);return}a()};return s.jsxs("button",{onClick:l,className:fe("relative inline-flex h-7 w-12 flex-shrink-0 touch-manipulation cursor-pointer items-center rounded-full border-2 transition-colors duration-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",o?"border-primary bg-primary":"border-border bg-muted"),role:"switch","aria-checked":o,"aria-label":n,children:[s.jsx("span",{className:"sr-only",children:n}),s.jsx("span",{className:fe("flex h-5 w-5 transform items-center justify-center rounded-full shadow-sm transition-transform duration-200",o?"translate-x-[22px] bg-white":"translate-x-[2px] bg-foreground/60 dark:bg-foreground/80"),children:o?s.jsx(l0,{className:"h-3 w-3 text-primary"}):s.jsx(c0,{className:"h-3 w-3 text-white dark:text-background"})})]})}const o4=f.createContext(null);function l4(){const e=f.useContext(o4);if(!e)throw new Error("Dialog components must be used within <Dialog>");return e}const c4=({open:e,onOpenChange:t,defaultOpen:n=!1,children:r})=>{const[a,i]=f.useState(n),o=f.useRef(null),l=e!==void 0,c=l?e:a,u=f.useCallback(p=>{l||i(p),t?.(p)},[l,t]),d=f.useMemo(()=>({open:c,onOpenChange:u,triggerRef:o}),[c,u]);return s.jsx(o4.Provider,{value:d,children:r})},wD=f.forwardRef(({onClick:e,children:t,asChild:n,...r},a)=>{const{onOpenChange:i,triggerRef:o}=l4(),l=f.useCallback(c=>{i(!0),e?.(c)},[i,e]);if(n&&f.isValidElement(t)){const c=t;return f.cloneElement(c,{onClick:u=>{i(!0),c.props.onClick?.(u)},ref:u=>{o.current=u,typeof a=="function"?a(u):a&&(a.current=u)}})}return s.jsx("button",{ref:c=>{o.current=c,typeof a=="function"?a(c):a&&(a.current=c)},type:"button",onClick:l,...r,children:t})});wD.displayName="DialogTrigger";const My='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])',x0=f.forwardRef(({className:e,children:t,onEscapeKeyDown:n,onPointerDownOutside:r,...a},i)=>{const{open:o,onOpenChange:l,triggerRef:c}=l4(),u=f.useRef(null),d=f.useRef(null);return f.useEffect(()=>{o?d.current=document.activeElement:d.current&&((c.current||d.current)?.focus(),d.current=null)},[o,c]),f.useEffect(()=>{if(!o)return;const p=m=>{if(m.key==="Escape"){m.stopPropagation(),n?.(),l(!1);return}if(m.key==="Tab"&&u.current){const g=Array.from(u.current.querySelectorAll(My));if(g.length===0)return;const b=g[0],x=g[g.length-1];m.shiftKey&&document.activeElement===b?(m.preventDefault(),x.focus()):!m.shiftKey&&document.activeElement===x&&(m.preventDefault(),b.focus())}};document.addEventListener("keydown",p,!0);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",p,!0),document.body.style.overflow=h}},[o,l,n]),f.useEffect(()=>{o&&u.current&&requestAnimationFrame(()=>{u.current?.querySelector(My)?.focus()})},[o]),o?Wc.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50",children:[s.jsx("div",{className:"fixed inset-0 animate-dialog-overlay-show bg-black/50 backdrop-blur-sm",onClick:()=>{r?.(),l(!1)},"aria-hidden":!0}),s.jsx("div",{ref:p=>{u.current=p,typeof i=="function"?i(p):i&&(i.current=p)},role:"dialog","aria-modal":"true",className:fe("fixed left-1/2 top-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2","rounded-xl border bg-popover text-popover-foreground shadow-lg","animate-dialog-content-show",e),...a,children:t})]}),document.body):null});x0.displayName="DialogContent";const y0=f.forwardRef(({className:e,...t},n)=>s.jsx("h2",{ref:n,className:fe("sr-only",e),...t}));y0.displayName="DialogTitle";const At=f.forwardRef(({className:e,type:t,...n},r)=>s.jsx("input",{type:t,className:fe("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));At.displayName="Input";const v0=f.forwardRef(({className:e,contentClassName:t,children:n,...r},a)=>s.jsx("div",{className:fe("relative overflow-hidden",e),...r,children:s.jsx("div",{ref:a,className:fe("h-full w-full overflow-auto rounded-[inherit]",t),style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:n})}));v0.displayName="ScrollArea";const xc=f.memo(({children:e,className:t,as:n="span"})=>s.jsx(n,{className:fe("animate-shimmer inline-block bg-[length:250%_100%] bg-clip-text text-transparent","bg-[linear-gradient(90deg,transparent_33%,hsl(var(--foreground))_50%,transparent_67%),linear-gradient(hsl(var(--muted-foreground)),hsl(var(--muted-foreground)))]",t),children:e}));xc.displayName="Shimmer";const u4=f.createContext(null),kD=()=>{const e=f.useContext(u4);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},SD=1e3,ED=1e3,Gp=f.memo(({className:e,isStreaming:t=!1,open:n,defaultOpen:r,onOpenChange:a,duration:i,children:o,...l})=>{const c=r??t,u=r===!1,[d,p]=f.useState(c),h=n!==void 0,m=h?n:d,g=f.useCallback(k=>{h||p(k),a?.(k)},[h,a]),[b,x]=f.useState(i),y=f.useRef(t),[v,w]=f.useState(!1),S=f.useRef(null);f.useEffect(()=>{i!==void 0&&x(i)},[i]),f.useEffect(()=>{t?(y.current=!0,S.current===null&&(S.current=Date.now())):S.current!==null&&(x(Math.ceil((Date.now()-S.current)/ED)),S.current=null)},[t]),f.useEffect(()=>{t&&!m&&!u&&g(!0)},[t,m,g,u]),f.useEffect(()=>{if(y.current&&!t&&m&&!v){const k=setTimeout(()=>{g(!1),w(!0)},SD);return()=>clearTimeout(k)}},[t,m,g,v]);const E=f.useMemo(()=>({duration:b,isOpen:m,isStreaming:t,setIsOpen:g}),[b,m,t,g]);return s.jsx(u4.Provider,{value:E,children:s.jsx(vi,{open:m,onOpenChange:g,className:fe("not-prose",e),...l,children:o})})});Gp.displayName="Reasoning";const ND=(e,t)=>e||t===0?s.jsx(xc,{children:"Thinking..."}):t===void 0?s.jsx("p",{children:"Thought for a few seconds"}):s.jsxs("p",{children:["Thought for ",t," seconds"]}),Hp=f.memo(({className:e,children:t,getThinkingMessage:n=ND,...r})=>{const{isStreaming:a,isOpen:i,duration:o}=kD();return s.jsx(Oa,{className:fe("flex w-full items-center gap-2 text-sm text-muted-foreground transition-colors hover:text-foreground",e),...r,children:t??s.jsxs(s.Fragment,{children:[s.jsx(_j,{className:"h-4 w-4"}),n(a,o),s.jsx(GS,{className:fe("h-4 w-4 transition-transform",i?"rotate-180":"rotate-0")})]})})});Hp.displayName="ReasoningTrigger";const qp=f.memo(({className:e,children:t,...n})=>s.jsx(wi,{className:fe("mt-4 text-sm text-muted-foreground",e),...n,children:t}));qp.displayName="ReasoningContent";function CD(e){switch(e){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}}function ea({children:e,content:t,position:n="top",className:r="",delay:a=350}){const[i,o]=f.useState(!1),l=f.useRef(null),c=f.useRef(!1),u=f.useRef(null),d=f.useRef(null),[p,h]=f.useState(null),m=f.useCallback(()=>{const w=u.current;if(!w)return;const S=w.getBoundingClientRect(),E=8,k={position:"fixed",zIndex:9999};switch(n){case"bottom":k.left=S.left+S.width/2,k.top=S.bottom+E,k.transform="translateX(-50%)";break;case"left":k.left=S.left-E,k.top=S.top+S.height/2,k.transform="translate(-100%, -50%)";break;case"right":k.left=S.right+E,k.top=S.top+S.height/2,k.transform="translateY(-50%)";break;case"top":default:k.left=S.left+S.width/2,k.top=S.top-E,k.transform="translate(-50%, -100%)";break}h(k)},[n]),g=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},b=()=>{g(),l.current=window.setTimeout(()=>{o(!0)},a)},x=()=>{g(),o(!1)},y=()=>{g(),c.current=!1,l.current=window.setTimeout(()=>{c.current=!0,o(!0)},a)},v=()=>{g(),!c.current&&o(!1)};return f.useEffect(()=>()=>{g()},[]),f.useEffect(()=>{if(!i||typeof document>"u")return;const w=S=>{const E=S.target;E instanceof Node&&u.current?.contains(E)||(o(!1),c.current=!1)};return document.addEventListener("pointerdown",w,!0),()=>document.removeEventListener("pointerdown",w,!0)},[i]),f.useEffect(()=>{if(!i){h(null);return}const w=window.requestAnimationFrame(m),S=()=>m();return window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.cancelAnimationFrame(w),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[i,m]),t?s.jsxs("div",{ref:u,className:"relative inline-block",onMouseEnter:b,onMouseLeave:x,onTouchStart:y,onTouchEnd:v,onTouchCancel:v,children:[e,i&&typeof document<"u"&&Wc.createPortal(s.jsxs("div",{ref:d,style:p||{position:"fixed",top:"-9999px",left:"-9999px",opacity:0},className:fe("px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",r),children:[t,s.jsx("div",{className:fe("absolute w-0 h-0 border-4 border-transparent",CD(n))})]}),document.body)]}):s.jsx(s.Fragment,{children:e})}const d4=f.createContext(null),p4=f.forwardRef(({className:e,status:t="ready",children:n,...r},a)=>{const i=f.useMemo(()=>({status:t}),[t]);return s.jsx(d4.Provider,{value:i,children:s.jsx("form",{ref:a,"data-slot":"prompt-input",className:fe("relative overflow-hidden rounded-xl border border-border/50 bg-card/80 shadow-sm backdrop-blur-sm transition-all duration-200 focus-within:border-primary/30 focus-within:shadow-md focus-within:ring-1 focus-within:ring-primary/15",e),...r,children:n})})});p4.displayName="PromptInput";const m4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-header",className:fe("px-3 pt-3",e),...t}));m4.displayName="PromptInputHeader";const h4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-body",className:fe("relative",e),...t}));h4.displayName="PromptInputBody";const f4=f.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{ref:n,"data-slot":"prompt-input-textarea",className:fe("chat-input-placeholder block max-h-[40vh] w-full resize-none overflow-y-auto bg-transparent px-4 py-2 text-sm leading-6 text-foreground placeholder-muted-foreground/50 focus:outline-none sm:max-h-[300px]",e),...t}));f4.displayName="PromptInputTextarea";const g4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-footer",className:fe("flex items-center justify-between border-t border-border/30 px-3 py-2",e),...t}));g4.displayName="PromptInputFooter";const b4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"prompt-input-tools",className:fe("flex items-center gap-1",e),...t}));b4.displayName="PromptInputTools";const Zl=f.forwardRef(({className:e,tooltip:t,children:n,...r},a)=>{const i=s.jsx(Pe,{ref:a,type:"button",variant:"ghost",size:"icon",className:fe("h-8 w-8 [&_svg]:size-4",e),...r,children:n});return t?s.jsx(ea,{content:t.shortcut?s.jsxs("span",{className:"flex items-center gap-1.5",children:[t.content,s.jsx("kbd",{className:"rounded bg-white/20 px-1 text-[10px]",children:t.shortcut})]}):t.content,position:t.side??"top",children:i}):i});Zl.displayName="PromptInputButton";const x4=f.forwardRef(({className:e,status:t,children:n,...r},a)=>{const i=f.useContext(d4),o=t??i?.status??"ready",l=o==="submitted"||o==="streaming";return s.jsx(Pe,{ref:a,type:l?"button":"submit",variant:"default",size:"icon",className:fe("h-8 w-8 rounded-lg",e),...r,children:n??(l?s.jsx(gj,{className:"h-3.5 w-3.5 fill-current"}):s.jsx(XI,{className:"h-4 w-4"}))})});x4.displayName="PromptInputSubmit";function w0({children:e,className:t}){return s.jsx("div",{className:fe("inline-flex items-center gap-[2px] rounded-lg bg-muted/60 p-[3px]",t),children:e})}function k0({isActive:e,onClick:t,children:n,className:r}){return s.jsx("button",{onClick:t,className:fe("flex touch-manipulation items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-all duration-150",e?"bg-background text-foreground shadow-sm":"text-muted-foreground active:bg-background/50",r),children:n})}const y4=f.createContext(null);function v4(){const e=f.useContext(y4);if(!e)throw new Error("QueueItem sub-components must be used within <QueueItem>");return e}const w4=f.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,"data-slot":"queue",role:"list",className:fe("space-y-0.5",e),...t}));w4.displayName="Queue";const k4=f.forwardRef(({status:e="pending",className:t,children:n,...r},a)=>{const i=f.useMemo(()=>({status:e}),[e]);return s.jsx(y4.Provider,{value:i,children:s.jsx("div",{ref:a,"data-slot":"queue-item","data-status":e,role:"listitem",className:fe("flex items-start gap-2 py-0.5",t),...r,children:n})})});k4.displayName="QueueItem";const S4=f.forwardRef(({className:e,...t},n)=>{const{status:r}=v4();return s.jsxs("div",{ref:n,"data-slot":"queue-item-indicator","aria-hidden":"true",className:fe("mt-0.5 flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center",e),...t,children:[r==="completed"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),r==="in_progress"&&s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400"}),r==="pending"&&s.jsx("svg",{className:"h-3.5 w-3.5 text-muted-foreground/50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})})]})});S4.displayName="QueueItemIndicator";const E4=f.forwardRef(({className:e,children:t,...n},r)=>{const{status:a}=v4();return s.jsx("div",{ref:r,"data-slot":"queue-item-content",className:fe("min-w-0 flex-1 text-xs",a==="completed"&&"text-muted-foreground line-through",a==="in_progress"&&"font-medium text-foreground",a==="pending"&&"text-foreground",e),...n,children:t})});E4.displayName="QueueItemContent";const Py="https://github.com/alicomert/pixcode/issues/new",TD="https://github.com/alicomert/pixcode",Fy="https://discord.gg/buxwujPNRE";function zy({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.095 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}function AD({updateAvailable:e,releaseInfo:t,latestVersion:n,currentVersion:r,onShowVersionModal:a,onShowSettings:i,t:o}){return s.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.jsxs("button",{className:"group flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-blue-50/80 dark:hover:bg-blue-900/15",onClick:a,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(py,{className:"h-4 w-4 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${n}`}),s.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),s.jsx("div",{className:"px-3 py-2 md:hidden",children:s.jsxs("button",{className:"flex h-11 w-full items-center gap-3 rounded-xl border border-blue-200/60 bg-blue-50/80 px-3.5 transition-all active:scale-[0.98] dark:border-blue-700/40 dark:bg-blue-900/15",onClick:a,children:[s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(py,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),s.jsx("span",{className:"absolute -right-0.5 -top-0.5 h-1.5 w-1.5 animate-pulse rounded-full bg-blue-500"})]}),s.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[s.jsx("span",{className:"block truncate text-sm font-medium text-blue-600 dark:text-blue-300",children:t?.title||`v${n}`}),s.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),s.jsx("div",{className:"nav-divider"}),s.jsx("div",{className:"hidden px-2 pt-1.5 md:block",children:s.jsxs("a",{href:Py,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[s.jsx(Dp,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"hidden px-2 md:block",children:s.jsxs("a",{href:Fy,target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[s.jsx(zy,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.joinCommunity")})]})}),s.jsx("div",{className:"hidden px-2 py-1.5 md:block",children:s.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",onClick:i,children:[s.jsx(wt,{className:"h-3.5 w-3.5"}),s.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),s.jsx("div",{className:"hidden px-3 py-2 text-center md:block",children:s.jsxs("a",{href:TD,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-muted-foreground/40 transition-colors hover:text-muted-foreground",children:["Pixcode v",r," – ",o("branding.openSource")]})}),s.jsx("div",{className:"px-3 pt-3 md:hidden",children:s.jsxs("a",{href:Py,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(Dp,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.reportIssue")})]})}),s.jsx("div",{className:"px-3 pt-2 md:hidden",children:s.jsxs("a",{href:Fy,target:"_blank",rel:"noopener noreferrer",className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(zy,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.joinCommunity")})]})}),s.jsx("div",{className:"px-3 pb-3 pt-2 md:hidden",children:s.jsxs("button",{className:"flex h-12 w-full items-center gap-3.5 rounded-xl bg-muted/40 px-4 transition-all hover:bg-muted/60 active:scale-[0.98]",onClick:i,children:[s.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-xl bg-background/80",children:s.jsx(wt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),s.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const By="PIXCODE_GITHUB_STARS",$y="PIXCODE_HIDE_GITHUB_STAR",_D=3600*1e3,ID=(e,t)=>{const[n,r]=f.useState(null),[a,i]=f.useState(()=>{try{return localStorage.getItem($y)==="true"}catch{return!1}});f.useEffect(()=>{if(a)return;try{const u=localStorage.getItem(By);if(u){const d=JSON.parse(u);if(Date.now()-d.timestamp<_D){r(d.count);return}}}catch{}(async()=>{try{const u=await fetch(`https://api.github.com/repos/${e}/${t}`);if(!u.ok)return;const p=(await u.json()).stargazers_count;if(typeof p=="number"){r(p);try{localStorage.setItem(By,JSON.stringify({count:p,timestamp:Date.now()}))}catch{}}}catch{}})()},[e,t,a]);const o=f.useCallback(()=>{i(!0);try{localStorage.setItem($y,"true")}catch{}},[]),l=n!==null?n>=1e3?`${(n/1e3).toFixed(1)}k`:`${n}`:null;return{starCount:n,formattedCount:l,isDismissed:a,dismiss:o}},jD="https://github.com/alicomert/pixcode";function RD({className:e}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("path",{d:"M12 2C6.477 2 2 6.484 2 12.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 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 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.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})})}function DD(){const{formattedCount:e,isDismissed:t,dismiss:n}=ID("alicomert","pixcode");return t?null:s.jsxs("div",{className:"group/star relative hidden md:block",children:[s.jsxs("a",{href:jD,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground",children:[s.jsx(RD,{className:"h-3.5 w-3.5"}),s.jsx(rs,{className:"h-3 w-3"}),s.jsx("span",{className:"font-medium",children:"Star"}),e&&s.jsx("span",{className:"border-l border-border/50 pl-1.5 tabular-nums",children:e})]}),s.jsx("button",{onClick:r=>{r.preventDefault(),r.stopPropagation(),n()},className:"absolute -right-1.5 -top-1.5 hidden h-4 w-4 items-center justify-center rounded-full border border-border/50 bg-muted text-muted-foreground transition-colors hover:text-foreground group-hover/star:flex","aria-label":"Dismiss",children:s.jsx(ft,{className:"h-2.5 w-2.5"})})]})}function Uy({value:e,onChange:t,t:n}){const r="flex flex-1 items-center justify-center gap-1 rounded-md px-2 py-1 text-[11px] font-medium transition-all";return s.jsxs("div",{role:"tablist","aria-label":n("tooltips.historyView",{defaultValue:"History view"}),className:"flex rounded-lg bg-muted/40 p-0.5",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="flat",onClick:()=>t("flat"),className:fe(r,e==="flat"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewFlat",{defaultValue:"Recent conversations"}),children:[s.jsx(jo,{className:"h-3 w-3"}),n("historyView.flat",{defaultValue:"Recent"})]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":e==="grouped",onClick:()=>t("grouped"),className:fe(r,e==="grouped"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:n("tooltips.historyViewGrouped",{defaultValue:"Grouped by project"}),children:[s.jsx(aj,{className:"h-3 w-3"}),n("historyView.grouped",{defaultValue:"By project"})]})]})}function LD({isPWA:e,isMobile:t,isLoading:n,projectsCount:r,searchFilter:a,onSearchFilterChange:i,onClearSearchFilter:o,searchMode:l,onSearchModeChange:c,onRefresh:u,isRefreshing:d,onCreateProject:p,onQuickStartSession:h,onCollapseSidebar:m,historyView:g,onHistoryViewChange:b,t:x}){const y=()=>s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("svg",{className:"h-6 w-6 flex-shrink-0",viewBox:"0 0 500 500","aria-hidden":"true",children:s.jsx("g",{transform:"translate(250 250) scale(1.25) translate(-250 -250)",children:s.jsxs("g",{transform:"translate(0 500) scale(0.1 -0.1)",fill:"#5C3FFC",children:[s.jsx("path",{d:"M2037 3800 c-104 -40 -191 -134 -231 -250 -23 -67 -20 -82 22 -109 31 -20 287 -177 1009 -618 40 -24 82 -56 93 -70 27 -34 27 -102 0 -136 -11 -13 -106 -78 -212 -143 -106 -64 -201 -124 -210 -132 -16 -14 -18 -41 -18 -302 0 -291 2 -310 38 -310 16 0 267 148 610 359 180 111 270 173 310 213 216 217 215 574 -3 793 -37 38 -107 89 -185 136 -69 42 -253 154 -410 249 -434 264 -509 307 -563 326 -57 20 -191 17 -250 -6z"}),s.jsx("path",{d:"M1803 2994 c-10 -5 -13 -156 -13 -709 0 -671 1 -706 20 -767 27 -89 93 -184 167 -240 89 -67 157 -90 281 -96 92 -4 105 -2 117 14 12 16 14 134 15 735 0 669 -1 718 -17 737 -20 23 -514 322 -541 327 -9 2 -23 2 -29 -1z"})]})})}),s.jsx("h1",{className:"truncate text-sm font-semibold tracking-tight text-foreground",children:x("app.title")})]});return s.jsxs("div",{className:"flex-shrink-0",children:[s.jsxs("div",{className:"hidden px-4 pb-3 pt-4 md:block",style:{},children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:u,disabled:d,title:x("tooltips.refresh"),children:s.jsx(xt,{className:`h-4 w-4 ${d?"animate-spin":""}`})}),s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:p,title:x("tooltips.createProject"),children:s.jsx(sn,{className:"h-4 w-4"})}),s.jsx(Pe,{variant:"ghost",size:"sm",className:"h-8 w-8 rounded-lg p-0 text-muted-foreground hover:bg-accent/80 hover:text-foreground",onClick:m,title:x("tooltips.hideSidebar"),children:s.jsx(YI,{className:"h-4 w-4"})})]})]}),s.jsx(DD,{}),h&&s.jsxs("button",{type:"button",onClick:()=>{h()},className:"mt-2.5 flex w-full items-center justify-center gap-2 rounded-lg border border-primary/20 bg-primary/5 px-3 py-2 text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[s.jsx(ia,{className:"h-4 w-4"}),x("sidebar.newChat",{defaultValue:"New chat"})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Uy,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Er,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(xi,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(aa,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(At,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-9 rounded-xl border-0 pl-9 pr-8 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-0.5 hover:bg-accent",children:s.jsx(ft,{className:"h-3 w-3 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider hidden md:block"}),s.jsxs("div",{className:"p-3 pb-2 md:hidden",style:e&&t?{paddingTop:"16px"}:{},children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(y,{}),s.jsxs("div",{className:"flex flex-shrink-0 gap-1.5",children:[s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted/50 transition-all active:scale-95",onClick:u,disabled:d,children:s.jsx(xt,{className:`h-4 w-4 text-muted-foreground ${d?"animate-spin":""}`})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/90 text-primary-foreground transition-all active:scale-95",onClick:p,children:s.jsx(bi,{className:"h-4 w-4"})})]})]}),r>0&&!n&&s.jsxs("div",{className:"mt-2.5 space-y-2",children:[l==="projects"&&s.jsx(Uy,{value:g,onChange:b,t:x}),s.jsxs("div",{className:"flex rounded-lg bg-muted/50 p-0.5",children:[s.jsxs("button",{onClick:()=>c("projects"),"aria-pressed":l==="projects",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="projects"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(Er,{className:"h-3 w-3"}),x("search.modeProjects")]}),s.jsxs("button",{onClick:()=>c("conversations"),"aria-pressed":l==="conversations",className:fe("flex-1 flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-all",l==="conversations"?"bg-background shadow-sm text-foreground":"text-muted-foreground hover:text-foreground"),children:[s.jsx(xi,{className:"h-3 w-3"}),x("search.modeConversations")]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(aa,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/50"}),s.jsx(At,{type:"text",placeholder:x(l==="conversations"?"search.conversationsPlaceholder":"projects.searchPlaceholder"),value:a,onChange:v=>i(v.target.value),className:"nav-search-input h-10 rounded-xl border-0 pl-10 pr-9 text-sm transition-all duration-200 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0"}),a&&s.jsx("button",{onClick:o,"aria-label":x("tooltips.clearSearch"),className:"absolute right-2.5 top-1/2 -translate-y-1/2 rounded-md p-1 hover:bg-accent",children:s.jsx(ft,{className:"h-3.5 w-3.5 text-muted-foreground"})})]})]})]}),s.jsx("div",{className:"nav-divider md:hidden"})]})}const OD=160,Gy=180;function N4({actions:e,className:t,triggerLabel:n}){const[r,a]=f.useState(!1),[i,o]=f.useState(null),l=f.useRef(null),c=f.useRef(null);f.useLayoutEffect(()=>{if(!r||!l.current)return;const d=l.current.getBoundingClientRect();let p=d.right-OD;p<8&&(p=8);let h=d.bottom+4;h+Gy>window.innerHeight&&(h=Math.max(8,d.top-4-Gy)),o({top:h,left:p})},[r]),f.useEffect(()=>{if(!r)return;const d=m=>{const g=m.target;l.current?.contains(g)||c.current?.contains(g)||a(!1)},p=m=>{m.key==="Escape"&&a(!1)},h=()=>a(!1);return document.addEventListener("mousedown",d),document.addEventListener("keydown",p),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("keydown",p),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[r]);const u=d=>p=>{p.stopPropagation(),p.preventDefault(),a(!1),d.onClick()};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:l,type:"button","aria-haspopup":"menu","aria-expanded":r,"aria-label":n||"Actions",title:n||"Actions",onClick:d=>{d.stopPropagation(),d.preventDefault(),a(p=>!p)},className:fe("flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground","opacity-0 transition-all duration-150 hover:bg-accent hover:text-foreground","group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary","touch:opacity-100",r&&"bg-accent text-foreground opacity-100",t),children:s.jsx(hj,{className:"h-3.5 w-3.5"})}),r&&i&&Wc.createPortal(s.jsx("div",{ref:c,role:"menu",style:{position:"fixed",top:i.top,left:i.left,zIndex:9999},className:fe("w-40 rounded-xl border border-border/60 bg-popover p-1 shadow-lg","animate-in fade-in-0 zoom-in-95 duration-100"),onClick:d=>d.stopPropagation(),onMouseDown:d=>d.stopPropagation(),children:e.map((d,p)=>{const h=d.icon,m=e[p-1],g=p>0&&d.danger&&!m?.danger;return s.jsxs("div",{children:[g&&s.jsx("div",{className:"my-1 h-px bg-border/60"}),s.jsxs("button",{type:"button",role:"menuitem",onClick:u(d),className:fe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs",d.danger?"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20":"text-foreground hover:bg-accent"),children:[s.jsx(h,{className:"h-3 w-3"}),d.label]})]},d.id)})}),document.body)]})}const Hy={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},MD={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"},PD=e=>e==="fully-configured"?{icon:ms,colorClassName:"text-green-500 dark:text-green-400",backgroundClassName:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"}:e==="taskmaster-only"?{icon:wt,colorClassName:"text-blue-500 dark:text-blue-400",backgroundClassName:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"}:e==="mcp-only"?{icon:ta,colorClassName:"text-amber-500 dark:text-amber-400",backgroundClassName:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"}:{icon:ft,colorClassName:"text-gray-400 dark:text-gray-500",backgroundClassName:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"};function FD({status:e="not-configured",size:t="sm",className:n="",showLabel:r=!1}){const a=PD(e),i=a.icon;return r?s.jsxs("div",{className:fe("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",a.backgroundClassName,a.colorClassName,n),title:a.title,children:[s.jsx(i,{className:Hy[t]}),s.jsx("span",{className:"font-medium",children:a.label})]}):s.jsx("div",{className:fe("inline-flex items-center justify-center rounded-full transition-colors",a.backgroundClassName,MD[t],n),title:a.title,children:s.jsx(i,{className:fe(Hy[t],a.colorClassName)})})}const zD=(e,t,n)=>{const r=new Date(e),a=t;if(isNaN(r.getTime()))return n?n("status.unknown"):"Unknown";const i=a.getTime()-r.getTime(),o=Math.floor(i/1e3),l=Math.floor(i/(1e3*60)),c=Math.floor(i/(1e3*60*60)),u=Math.floor(i/(1e3*60*60*24));return o<60?n?n("time.justNow"):"Just now":l===1?n?n("time.oneMinuteAgo"):"1 min ago":l<60?n?n("time.minutesAgo",{count:l}):`${l} mins ago`:c===1?n?n("time.oneHourAgo"):"1 hour ago":c<24?n?n("time.hoursAgo",{count:c}):`${c} hours ago`:u===1?n?n("time.oneDayAgo"):"1 day ago":u<7?n?n("time.daysAgo",{count:u}):`${u} days ago`:r.toLocaleDateString()};function qy({isStarred:e,canDelete:t,onRename:n,onToggleStar:r,onDelete:a,t:i,className:o}){const l=u=>s.jsx(rs,{className:`${u.className??""} ${e?"fill-yellow-400 text-yellow-500":""}`}),c=[{id:"rename",label:i("actions.rename"),icon:oj,onClick:n},{id:"star",label:e?i("actions.unstarSession",{defaultValue:"Remove star"}):i("actions.starSession",{defaultValue:"Star"}),icon:l,onClick:r}];return t&&c.push({id:"delete",label:i("actions.delete"),icon:gn,onClick:a,danger:!0}),s.jsx(N4,{actions:c,className:o,triggerLabel:i("tooltips.sessionActions",{defaultValue:"Session actions"})})}const BD={claude:"Claude",cursor:"Cursor",codex:"Codex",gemini:"Gemini",qwen:"Qwen Code"},Vy={claude:"bg-orange-500/10 text-orange-600 dark:bg-orange-400/10 dark:text-orange-300 ring-1 ring-orange-500/15",cursor:"bg-sky-500/10 text-sky-600 dark:bg-sky-400/10 dark:text-sky-300 ring-1 ring-sky-500/15",codex:"bg-violet-500/10 text-violet-600 dark:bg-violet-400/10 dark:text-violet-300 ring-1 ring-violet-500/15",gemini:"bg-emerald-500/10 text-emerald-600 dark:bg-emerald-400/10 dark:text-emerald-300 ring-1 ring-emerald-500/15",qwen:"bg-amber-500/10 text-amber-600 dark:bg-amber-400/10 dark:text-amber-300 ring-1 ring-amber-500/15"};function C4({project:e,session:t,selectedSession:n,currentTime:r,editingSession:a,editingSessionName:i,isStarred:o,compact:l=!1,onEditingSessionNameChange:c,onStartEditingSession:u,onCancelEditingSession:d,onSaveEditingSession:p,onToggleStarSession:h,onProjectSelect:m,onSessionSelect:g,onDeleteSession:b,t:x}){const y=k9(t,r,x),v=n?.id===t.id,w=a===t.id,S=t.__provider,E=BD[S]??S,k=Vy[S]??Vy.claude,A=y9(y.sessionName),I=()=>{m(e),g(t,e.name)},N=()=>{p(e.name,t.id,i,S)},_=()=>{b(e.name,t.id,y.sessionName,S)},R=()=>u(t.id,y.sessionName),C=()=>h(e.name,t.id),D=s.jsxs("div",{className:"mt-0.5 flex min-w-0 flex-wrap items-center gap-1 text-[10px] leading-tight",children:[s.jsxs("span",{className:fe("inline-flex items-center gap-1 rounded-full px-1.5 py-px font-medium",k),children:[s.jsx(Dn,{provider:S,className:"h-2.5 w-2.5"}),E]}),s.jsx("span",{className:"text-muted-foreground/80",children:zD(y.sessionTime,r,x)}),y.isActive&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[s.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-green-500"}),x("status.active",{defaultValue:"Active"})]}),A.slice(0,3).map(B=>s.jsxs("span",{className:"rounded-md bg-muted/60 px-1 py-px font-mono text-[9px] uppercase tracking-wide text-muted-foreground ring-1 ring-border/40",children:[".",B]},B))]}),T=s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:i,onChange:B=>c(B.target.value),onKeyDown:B=>{B.stopPropagation(),B.key==="Enter"?N():B.key==="Escape"&&d()},onClick:B=>B.stopPropagation(),className:"w-full rounded-md border border-primary/40 bg-background px-2 py-1 text-xs focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),s.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40",onClick:B=>{B.stopPropagation(),N()},title:x("tooltips.save"),children:s.jsx(Ut,{className:"h-3 w-3 text-green-600 dark:text-green-400"})}),s.jsx("button",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40",onClick:B=>{B.stopPropagation(),d()},title:x("tooltips.cancel"),children:s.jsx(ft,{className:"h-3 w-3 text-gray-600 dark:text-gray-400"})})]}),z=s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:fe("relative mx-3 my-0.5 rounded-lg border border-border/30 bg-card p-2 transition-all duration-150 active:scale-[0.98]",v&&"border-primary/30 bg-primary/5 shadow-sm",!v&&y.isActive&&"border-green-500/25 bg-green-50/5 dark:bg-green-900/5",o&&!v&&"ring-1 ring-yellow-300/50 dark:ring-yellow-500/30"),onClick:w?void 0:I,children:w?s.jsx("div",{className:"flex items-center gap-1",children:T}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:fe("flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/60"),children:s.jsx(Dn,{provider:S,className:"h-3 w-3"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[o&&s.jsx("span",{className:"text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),D]}),s.jsx("div",{className:"flex-shrink-0",onClick:B=>B.stopPropagation(),children:s.jsx(qy,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:C,onDelete:_,t:x,className:"!opacity-100"})})]})})}),H=s.jsxs("div",{className:fe("group/item relative hidden md:block"),children:[s.jsxs(Pe,{variant:"ghost",className:fe("relative h-auto w-full justify-start overflow-hidden p-0 text-left font-normal transition-colors duration-150","hover:bg-accent/60",v&&"bg-accent text-accent-foreground",o&&!v&&"bg-yellow-50/40 hover:bg-yellow-100/40 dark:bg-yellow-900/10 dark:hover:bg-yellow-900/20",l?"rounded-xl px-3 py-2.5":"rounded-lg px-3 py-2"),onClick:w?void 0:()=>g(t,e.name),children:[v&&s.jsx("span",{"aria-hidden":!0,className:"absolute left-0 top-1/2 h-5 w-0.5 -translate-y-1/2 rounded-r bg-primary"}),!v&&!w&&s.jsx("span",{"aria-hidden":!0,className:"session-item-accent"}),s.jsxs("div",{className:"flex w-full min-w-0 items-start gap-2 pr-6",children:[s.jsx("div",{className:fe("mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md",v?"bg-primary/10":"bg-muted/50 group-hover/item:bg-muted/80"),children:s.jsx(Dn,{provider:S,className:"h-3 w-3"})}),s.jsx("div",{className:"min-w-0 flex-1",children:w?s.jsx("div",{className:"flex items-center gap-1",children:T}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[o&&s.jsx("span",{className:"flex-shrink-0 text-yellow-500","aria-hidden":!0,children:"★"}),s.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:y.sessionName})]}),D]})})]})]}),!w&&s.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",onClick:B=>B.stopPropagation(),children:s.jsx(qy,{isStarred:o,canDelete:!y.isCursorSession,onRename:R,onToggleStar:C,onDelete:_,t:x,className:"opacity-0 group-hover/item:opacity-100 focus-visible:opacity-100"})})]});return s.jsxs("div",{className:"group relative",children:[z,H]})}function $D(){return s.jsx(s.Fragment,{children:Array.from({length:3}).map((e,t)=>s.jsx("div",{className:"rounded-md p-2",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 h-3 w-3 animate-pulse rounded-full bg-muted"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsx("div",{className:"h-3 animate-pulse rounded bg-muted",style:{width:`${60+t*15}%`}}),s.jsx("div",{className:"h-2 w-1/2 animate-pulse rounded bg-muted"})]})]})},t))})}function UD({project:e,isExpanded:t,sessions:n,selectedSession:r,initialSessionsLoaded:a,isLoadingSessions:i,currentTime:o,editingSession:l,editingSessionName:c,isSessionStarred:u,onEditingSessionNameChange:d,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,onLoadMoreSessions:v,onNewSession:w,t:S}){if(!t)return null;const E=n.length>0,k=e.sessionMeta?.hasMore===!0;return s.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[s.jsx("div",{className:"px-3 pb-1 pt-1 md:hidden",children:s.jsxs("button",{className:"flex h-8 w-full items-center justify-center gap-2 rounded-md bg-primary text-xs font-medium text-primary-foreground transition-all duration-150 hover:bg-primary/90 active:scale-[0.98]",onClick:()=>{b(e),w(e)},children:[s.jsx(sn,{className:"h-3 w-3"}),S("sessions.newSession")]})}),s.jsxs(Pe,{variant:"default",size:"sm",className:"hidden h-8 w-full justify-start gap-2 bg-primary text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 md:flex",onClick:()=>w(e),children:[s.jsx(sn,{className:"h-3 w-3"}),S("sessions.newSession")]}),a?!E&&!i?s.jsx("div",{className:"px-3 py-2 text-left",children:s.jsx("p",{className:"text-xs text-muted-foreground",children:S("sessions.noSessions")})}):n.map(A=>s.jsx(C4,{project:e,session:A,selectedSession:r,currentTime:o,editingSession:l,editingSessionName:c,isStarred:u(e.name,A.id),onEditingSessionNameChange:d,onStartEditingSession:p,onCancelEditingSession:h,onSaveEditingSession:m,onToggleStarSession:g,onProjectSelect:b,onSessionSelect:x,onDeleteSession:y,t:S},A.id)):s.jsx($D,{}),E&&k&&s.jsx(Pe,{variant:"ghost",size:"sm",className:"mt-2 w-full justify-center gap-2 text-muted-foreground",onClick:()=>v(e),disabled:i,children:i?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),S("sessions.loading")]}):s.jsxs(s.Fragment,{children:[s.jsx(Fn,{className:"h-3 w-3"}),S("sessions.showMore")]})})]})}const GD=(e,t)=>{const n=e.length;return t&&n>=5?`${n}+`:`${n}`};function HD({project:e,selectedProject:t,selectedSession:n,isExpanded:r,isDeleting:a,isStarred:i,editingProject:o,editingName:l,sessions:c,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:g,mcpServerStatus:b,isSessionStarred:x,onEditingNameChange:y,onToggleProject:v,onProjectSelect:w,onToggleStarProject:S,onToggleStarSession:E,onStartEditingProject:k,onCancelEditingProject:A,onSaveProjectName:I,onDeleteProject:N,onSessionSelect:_,onDeleteSession:R,onLoadMoreSessions:C,onNewSession:D,onEditingSessionNameChange:T,onStartEditingSession:z,onCancelEditingSession:H,onSaveEditingSession:B,t:Y}){const q=t?.name===e.name,O=o===e.name,$=e.sessionMeta?.hasMore===!0,G=GD(c,$),P=`${G} session${c.length===1?"":"s"}`,ee=N9(e,b),ne=()=>v(e.name),pe=()=>S(e.name),le=()=>{I(e.name)},oe=()=>{t?.name!==e.name&&w(e),ne()};return s.jsxs("div",{className:fe("md:space-y-1",a&&"opacity-50 pointer-events-none"),children:[s.jsxs("div",{className:"md:group group",children:[s.jsx("div",{className:"md:hidden",children:s.jsx("div",{className:fe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",q&&"bg-primary/5 border-primary/20",i&&!q&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:ne,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s.jsx("div",{className:fe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",r?"bg-primary/10":"bg-muted"),children:r?s.jsx(La,{className:"h-4 w-4 text-primary"}):s.jsx(Er,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1",children:O?s.jsx("input",{type:"text",value:l,onChange:he=>y(he.target.value),className:"w-full rounded-lg border-2 border-primary/40 bg-background px-3 py-2 text-sm text-foreground shadow-sm transition-all duration-200 focus:border-primary focus:shadow-md focus:outline-none",placeholder:Y("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:he=>he.stopPropagation(),onKeyDown:he=>{he.key==="Enter"&&le(),he.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-between",children:[s.jsx("h3",{className:"truncate text-sm font-medium text-foreground",children:e.displayName}),g&&s.jsx(FD,{status:ee,size:"xs",className:"ml-2 hidden flex-shrink-0 md:inline-flex"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:P})]})})]}),s.jsx("div",{className:"flex items-center gap-1",children:O?s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-green-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-green-600",onClick:he=>{he.stopPropagation(),le()},children:s.jsx(Ut,{className:"h-4 w-4 text-white"})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-gray-500 shadow-sm transition-all duration-150 active:scale-90 active:shadow-none dark:bg-gray-600",onClick:he=>{he.stopPropagation(),A()},children:s.jsx(ft,{className:"h-4 w-4 text-white"})})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:fe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",i?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:he=>{he.stopPropagation(),pe()},title:Y(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:s.jsx(rs,{className:fe("w-4 h-4 transition-colors",i?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-red-200 bg-red-500/10 active:scale-90 dark:border-red-800 dark:bg-red-900/30",onClick:he=>{he.stopPropagation(),N(e)},children:s.jsx(gn,{className:"h-4 w-4 text-red-600 dark:text-red-400"})}),s.jsx("button",{className:"flex h-8 w-8 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 active:scale-90 dark:border-primary/30 dark:bg-primary/20",onClick:he=>{he.stopPropagation(),k(e)},children:s.jsx(Rp,{className:"h-4 w-4 text-primary"})}),s.jsx("div",{className:"flex h-6 w-6 items-center justify-center rounded-md bg-muted/30",children:r?s.jsx(Fn,{className:"h-3 w-3 text-muted-foreground"}):s.jsx(Sr,{className:"h-3 w-3 text-muted-foreground"})})]})})]})})}),s.jsxs(Pe,{variant:"ghost",className:fe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",q&&"bg-accent text-accent-foreground",i&&!q&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:oe,children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r?s.jsx(La,{className:"h-4 w-4 flex-shrink-0 text-primary"}):s.jsx(Er,{className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}),s.jsx("div",{className:"min-w-0 flex-1 text-left",children:O?s.jsxs("div",{className:"space-y-1",children:[s.jsx("input",{type:"text",value:l,onChange:he=>y(he.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-sm text-foreground focus:ring-2 focus:ring-primary/20",placeholder:Y("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:he=>{he.key==="Enter"&&le(),he.key==="Escape"&&A()}}),s.jsx("div",{className:"truncate text-xs text-muted-foreground",title:e.fullPath,children:e.fullPath})]}):s.jsxs("div",{children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:e.displayName,children:e.displayName}),s.jsxs("div",{className:"text-xs text-muted-foreground",children:[G,e.fullPath!==e.displayName&&s.jsxs("span",{className:"ml-1 opacity-60",title:e.fullPath,children:[" - ",e.fullPath.length>25?`...${e.fullPath.slice(-22)}`:e.fullPath]})]})]})})]}),s.jsx("div",{className:"flex flex-shrink-0 items-center gap-1",children:O?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-green-600 transition-colors hover:bg-green-50 hover:text-green-700 dark:hover:bg-green-900/20",onClick:he=>{he.stopPropagation(),le()},children:s.jsx(Ut,{className:"h-3 w-3"})}),s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-700 dark:hover:bg-gray-800",onClick:he=>{he.stopPropagation(),A()},children:s.jsx(ft,{className:"h-3 w-3"})})]}):s.jsxs(s.Fragment,{children:[i&&s.jsx("div",{className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded hover:bg-yellow-50 dark:hover:bg-yellow-900/20",onClick:he=>{he.stopPropagation(),pe()},title:Y("tooltips.removeFromFavorites"),children:s.jsx(rs,{className:"h-3 w-3 fill-current text-yellow-600 dark:text-yellow-400"})}),s.jsx(N4,{triggerLabel:Y("tooltips.projectActions",{defaultValue:"Project actions"}),actions:[{id:"rename",label:Y("actions.rename"),icon:Rp,onClick:()=>k(e)},{id:"star",label:Y(i?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),icon:rs,onClick:pe},{id:"delete",label:Y("actions.delete",{defaultValue:"Delete"}),icon:gn,onClick:()=>N(e),danger:!0}]}),r?s.jsx(Fn,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"}):s.jsx(Sr,{className:"h-4 w-4 text-muted-foreground transition-colors group-hover:text-foreground"})]})})]})]}),s.jsx(UD,{project:e,isExpanded:r,sessions:c,selectedSession:n,initialSessionsLoaded:u,isLoadingSessions:d,currentTime:p,editingSession:h,editingSessionName:m,isSessionStarred:x,onEditingSessionNameChange:T,onStartEditingSession:z,onCancelEditingSession:H,onSaveEditingSession:B,onToggleStarSession:E,onProjectSelect:w,onSessionSelect:_,onDeleteSession:R,onLoadMoreSessions:C,onNewSession:D,t:Y})]})}function T4({isLoading:e,loadingProgress:t,projectsCount:n,filteredProjectsCount:r,t:a}){return e?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.loadingProjects")}),t&&t.total>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${t.current/t.total*100}%`}})}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.current,"/",t.total," ",a("projects.projects")]}),t.currentProject&&s.jsx("p",{className:"mx-auto max-w-[200px] truncate text-xs text-muted-foreground/70",title:t.currentProject,children:t.currentProject.split("-").slice(-2).join("/")})]}):s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.fetchingProjects")})]}):n===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(Er,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.runClaudeCli")})]}):r===0?s.jsxs("div",{className:"px-4 py-12 text-center md:py-8",children:[s.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-lg bg-muted md:mb-3",children:s.jsx(aa,{className:"h-6 w-6 text-muted-foreground"})}),s.jsx("h3",{className:"mb-2 text-base font-medium text-foreground md:mb-1",children:a("projects.noMatchingProjects")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:a("projects.tryDifferentSearch")})]}):null}function qD({projects:e,filteredProjects:t,selectedProject:n,selectedSession:r,isLoading:a,loadingProgress:i,expandedProjects:o,editingProject:l,editingName:c,loadingSessions:u,initialSessionsLoaded:d,currentTime:p,editingSession:h,editingSessionName:m,deletingProjects:g,tasksEnabled:b,mcpServerStatus:x,getProjectSessions:y,isProjectStarred:v,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:I,onStartEditingProject:N,onCancelEditingProject:_,onSaveProjectName:R,onDeleteProject:C,onSessionSelect:D,onDeleteSession:T,onLoadMoreSessions:z,onNewSession:H,onEditingSessionNameChange:B,onStartEditingSession:Y,onCancelEditingSession:q,onSaveEditingSession:O,t:$}){const G=s.jsx(T4,{isLoading:a,loadingProgress:i,projectsCount:e.length,filteredProjectsCount:t.length,t:$});f.useEffect(()=>{let oe="Pixcode";const he=n?.displayName?.trim();he&&(oe=`${he} - ${oe}`),document.title=oe},[n]);const P=!a&&e.length>0&&t.length>0,ee=oe=>oe.source==="history"||oe.autoDiscovered===!0&&oe.isManuallyAdded!==!0,ne=t.filter(oe=>!ee(oe)),pe=t.filter(oe=>ee(oe)),le=oe=>s.jsx(HD,{project:oe,selectedProject:n,selectedSession:r,isExpanded:o.has(oe.name),isDeleting:g.has(oe.name),isStarred:v(oe.name),editingProject:l,editingName:c,sessions:y(oe),initialSessionsLoaded:d.has(oe.name),isLoadingSessions:!!u[oe.name],currentTime:p,editingSession:h,editingSessionName:m,tasksEnabled:b,mcpServerStatus:x,isSessionStarred:w,onEditingNameChange:S,onToggleProject:E,onProjectSelect:k,onToggleStarProject:A,onToggleStarSession:I,onStartEditingProject:N,onCancelEditingProject:_,onSaveProjectName:R,onDeleteProject:C,onSessionSelect:D,onDeleteSession:T,onLoadMoreSessions:z,onNewSession:H,onEditingSessionNameChange:B,onStartEditingSession:Y,onCancelEditingSession:q,onSaveEditingSession:O,t:$},oe.name);return s.jsx("div",{className:"pb-safe-area-inset-bottom md:space-y-1",children:P?s.jsxs(s.Fragment,{children:[ne.map(oe=>le(oe)),pe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:$("projects.detectedFromHistory")}),pe.map(oe=>le(oe))]})]}):G})}function Zr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A4(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}/*!
230
230
  * GSAP 3.15.0
231
231
  * https://gsap.com
232
232
  *
package/dist/index.html CHANGED
@@ -35,7 +35,7 @@
35
35
 
36
36
  <!-- Prevent zoom on iOS -->
37
37
  <meta name="format-detection" content="telephone=no" />
38
- <script type="module" crossorigin src="/assets/index-G0lapd3q.js"></script>
38
+ <script type="module" crossorigin src="/assets/index-Vt0j2JbZ.js"></script>
39
39
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-D7WwDXvu.js">
40
40
  <link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CzYAOTxS.js">
41
41
  <link rel="modulepreload" crossorigin href="/assets/vendor-xterm-CJZjLICi.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixelbyte-software/pixcode",
3
- "version": "1.31.3",
3
+ "version": "1.31.4",
4
4
  "description": "Pixcode — a desktop and mobile web UI for Claude Code, Cursor CLI, Codex, and Gemini CLI.",
5
5
  "type": "module",
6
6
  "main": "dist-server/server/index.js",